今天学习一下ARM9串口中断部分的内容:
1、对于串口发送函数的处理部分:
void Uart_SendByte(int data) { if(whichUart==0) { if(data=='\n') { while(!(rUTRSTAT0 & 0x2)); // Delay(1); //because the slow response of hyper_terminal //WrUTXH0('\r');也可以用这种方式进行发送 rUTXH0 = '\r'; } while(!(rUTRSTAT0 & 0x2)); //Wait until THR is empty. // Delay(1); // WrUTXH0(data);也可以用这种方式进行发送,但是用UTXH0和WrUTXH0区别???? rUTXH0 = data; } }
rWrUTXH0 和 UTXH0 两种发送方式的区别????找到他们定义在2440addr.h中,如下面:#else //Little Endian #define rUTXH0 (*(volatile unsigned char *)0x50000020) //UART 0 Transmission Hold #define rURXH0 (*(volatile unsigned char *)0x50000024) //UART 0 Receive buffer #define rUTXH1 (*(volatile unsigned char *)0x50004020) //UART 1 Transmission Hold #define rURXH1 (*(volatile unsigned char *)0x50004024) //UART 1 Receive buffer #define rUTXH2 (*(volatile unsigned char *)0x50008020) //UART 2 Transmission Hold #define rURXH2 (*(volatile unsigned char *)0x50008024) //UART 2 Receive buffer #define WrUTXH0(ch) (*(volatile unsigned char *)0x50000020)=(unsigned char)(ch) #define RdURXH0() (*(volatile unsigned char *)0x50000024) #define WrUTXH1(ch) (*(volatile unsigned char *)0x50004020)=(unsigned char)(ch) #define RdURXH1() (*(volatile unsigned char *)0x50004024) #define WrUTXH2(ch) (*(volatile unsigned char *)0x50008020)=(unsigned char)(ch) #define RdURXH2() (*(volatile unsigned char *)0x50008024) #define UTXH0 (0x50000020) //Byte_access address by DMA #define URXH0 (0x50000024) #define UTXH1 (0x50004020) #define URXH1 (0x50004024) #define UTXH2 (0x50008020) #define URXH2 (0x50008024) #endif
其中还真的不明白这两种定义有什么区别呢?????对于串口发送函数其他的部分
//If you don't use vsprintf(), the code size is reduced very much.
void Uart_Printf(char *fmt,...)
{
va_list ap;
char string[256];
va_start(ap,fmt);
vsprintf(string,fmt,ap);
Uart_SendString(string);
va_end(ap);
}
上面这两个哈是哪壶有什么作用呢?????是不是向串口中断发送时,必须得设置的??
void Uart_SendString(char *pt)
{
while(*pt)
Uart_SendByte(*pt++);
}