“uart.c”:
#include "s2351_uart.h"
#include "string.h"
#include "stdarg.h"
#include "stdio.h"
#include "s3c2451_vector.h"
UART_Memptr constUART_BASE_PTR[4]={UART0_BASE_PTR,UART1_BASE_PTR,UART2_BASE_PTR,UART3_BASE_PTR};
void UART_INIT(UART_typedef uartx,UART_init_typedef uart_init_typedef) //初始化函数数据位,停止位,校验位
{
UART_BASE_PTR[uartx]->ULCON &= ~(0x7f); //0~6位初始化为0,0x7f为0111 1111
UART_BASE_PTR[uartx]->ULCON |=uart_init_typedef.wordwith; //数据位
UART_BASE_PTR[uartx]->ULCON |=(uart_init_typedef.stop<<2); //停止位
UART_BASE_PTR[uartx]->ULCON |=(uart_init_typedef.parity<<3); //校验位
//波特率的选择
if(uart_init_typedef.bobit == 115200)
{
UART_BASE_PTR[uartx]->UBRDIV = 34;
UART_BASE_PTR[uartx]->UDIVSLOT = 0xDFDD;
}
if(uart_init_typedef.bobit == 9600)
{
UART_BASE_PTR[uartx]->UBRDIV = 428;
<