GNU ARM匯編--(七)s3c2440的串口控制
UART的測試代碼用C寫的:本文引用地址:http://butianyuan.cn/article/201611/321724.htm
uart_test.c:
[cpp]view plaincopy
- #include"uart_test.h"
- charuart_GetByte(void)
- {
- while(!(rUTRSTAT0&0x1));//WaituntilTHRisempty.
- returnRdURXH0();
- }
- voiduart_GetString(char*pt)
- {
- while(*pt)
- uart_GetByte();
- }
- voiduart_SendByte(intdata)
- {
- if(data==)
- {
- while(!(rUTRSTAT0&0x2));
- WrUTXH0();
- }
- while(!(rUTRSTAT0&0x2));//WaituntilTHRisempty.
- WrUTXH0(data);
- }
- //====================================================================
- voiduart_SendString(char*pt)
- {
- while(*pt)
- uart_SendByte(*pt++);
- }
- voiduart_test(void)
- {
- charstr[20]="helloworld";
- inta=97;
- //while(1)
- //uart_SendByte(a);
- uart_SendString(str);
- chars=uart_GetByte();
- //if(s==a)
- if(s==97)
- rGPBDAT=0x1c0;
- //uart_SendByte(a);
- //uart_SendByte(97);
- //uart_SendByte(a);
- uart_SendByte((int)s);
- uart_SendByte((int)s);
- }
[cpp]view plaincopy
- //#defineWrUTXH0(ch)(*(volatileunsignedchar*)0x50000023)=(unsignedchar)(ch)
- #defineWrUTXH0(ch)(*(volatileunsignedchar*)0x50000020)=(unsignedchar)(ch)
- #defineRdURXH0()(*(volatileunsignedchar*)0x50000024)
- #definerUTRSTAT0(*(volatileunsigned*)0x50000010)//UART0Tx/Rxstatus
- #definerGPBDAT(*(volatileunsigned*)0x56000014)
到此,使用串口的輪循模式,可以實現(xiàn)串口的正常收發(fā)功能了~~
中斷模式還沒寫,這個等到后面全面研究uboot的時候再回頭看,uboot用哪種模式,應(yīng)該就說明那種方式好,到時侯再實現(xiàn)吧
評論