GNU ARM匯編--(七)s3c2440的串口控制
UART的測(cè)試代碼用C寫(xiě)的:本文引用地址:http://m.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)
到此,使用串口的輪循模式,可以實(shí)現(xiàn)串口的正常收發(fā)功能了~~
中斷模式還沒(méi)寫(xiě),這個(gè)等到后面全面研究uboot的時(shí)候再回頭看,uboot用哪種模式,應(yīng)該就說(shuō)明那種方式好,到時(shí)侯再實(shí)現(xiàn)吧
評(píng)論