C语言串口测试程序代码
2018-07-20 来源:open-open
#include<stdio.h> unsigned int UART0_ADDR = 0x20080000; unsigned int retu=0; int i=0; void delay_x(unsigned short cycles) { unsigned short t; t = cycles; while ( --t != 0 ); } int main() { ///////////初始化部分//////////////////////////////////////////////////// retu = *(unsigned int *)(UART0_ADDR + 0X30);//uart_cr *(unsigned int *)(UART0_ADDR + 0X30) = 0x300; // retu = *(unsigned int *)(UART0_ADDR + 0X24);//ibrd // retu = *(unsigned int *)(UART0_ADDR + 0X28);//fbrd *(unsigned int *)(UART0_ADDR + 0X24) = 1; *(unsigned int *)(UART0_ADDR + 0X28) = 40; *(unsigned int *)(UART0_ADDR + 0X30) = 0x300; *(unsigned int *)(UART0_ADDR + 0X2c) = 0x60;//UART_LCR_H *(unsigned int *)(UART0_ADDR + 0X34) = 0x12; //UART_IFLS *(unsigned int *)(UART0_ADDR + 0X38) = 0x0;//UART_IMSC retu = *(unsigned int *)(UART0_ADDR + 0X30);//uart_cr *(unsigned int *)(UART0_ADDR + 0X30) = retu | 0x01;//使能串口 ////////////////////////////////////////////////////////// while(1) { // retu = *(unsigned int *)(UART0_ADDR + 0X18); // retu = retu&0x40; if(((*(unsigned int *)(UART0_ADDR + 0X18))&0x40)==0x40) { retu = *(unsigned int *)(UART0_ADDR + 0X00); retu = retu&0xff; *(unsigned int *)(UART0_ADDR + 0X00) = retu; } retu = 0; delay_x(0X7000); } return 0; }
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
上一篇:android文件下载代码
最新资讯
热门推荐