文档详情

ARM之间串口通信.doc

发布:2017-08-27约8.55千字共7页下载文档
文本预览下载声明
#include ..\config.h #define UART_BPS 38400 /* 串口通信波特率 */ INT8U const send[]=0xfd 0x0a 0x00 0x01 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09\r\n; /********************************************************************************************************* ** Function name: delayNS ** Descriptions: 延时函数 ** input parameters: ulDly: 延时值 ** output parameters: 无 ** Returned value: 无 *********************************************************************************************************/ void delayNS (INT32U ulDly) { INT32U i; for (; ulDly 0; ulDly--) { for (i = 0; i 5000; i++); } } /********************************************************************************************************* ** Function name: uartInit ** Descriptions: 串口初始化,设置为8位数据位,1位停止位,无奇偶校验,波特率为115200 ** input parameters: 无 ** output parameters: 无 ** Returned value: 无 *********************************************************************************************************/ void uart0Init (void) { INT16U usFdiv; U0LCR = 0x83; /* 允许设置波特率 */ usFdiv = (FPCLK / 16) / UART_BPS; /* 设置波特率 */ U0DLM = usFdiv / 256; U0DLL = usFdiv % 256; U0LCR = 0x03; /* 锁定波特率 */ U0FCR = 0x06; } /********************************************************************************************************* ** Function name: uart0GetByte ** Descriptions: 从串口接收1字节数据,使用查询方式接收 ** input parameters: 无 ** output parameters: 无 ** Returned value: ucRcvData: 接收到的数据 *********************************************************************************************************/ INT8U uart0GetByte (void) { INT8U ucRcvData; while ((U0LSR 0x01) == 0);
显示全部
相似文档