深入浅出ARM7-LPC213X_214X

xycxym42 37 0 RAR 2018-12-26 09:12:10

AM7开发板的引脚介绍及相关程序 如:void UART0_Init (void) { uint16 Fdiv; PINSEL0 = (PINSEL0&(~0x0f))|0x00000005; // 设置I/O连接到UART0 U0IER = 0x01;// 允许RBR中断,即接收中断 U0LCR = 0x83; // DLAB=1,允许设置波特率 Fdiv = (Fosc / 16) / UART_BPS; // 设置波特率 U0DLM = Fdiv / 256; U0DLL = Fdiv % 256; U0LCR = 0x03; // IRQEnable(); } uint8 UART0_GetByte (void) { uint8 rcv_dat; while ((U0LSR & 0x01) == 0); rcv_dat = U0RBR; return (rcv_dat); } void UART0_GetStr (uint8 *s, uint32 n) { for ( ; n>0; n--) { *s++ = UART0_GetByte(); } } void UART0_SendByte (uint8 dat) { U0THR = dat; while ((U0LSR & 0x40) == 0); // 等待数据发送完毕 } void UART0_SendStr (uint8 const *str) { while (1) { if (*str == '\0') break; // 遇到结束符,退出 UART0_SendByte(*str++); // 发送数据 } } void UART0_SendByte (uint8 dat) { U0THR = dat; while ((U0LSR & 0x40) == 0); // 等待数据发送完毕 } void UART0_SendStr (uint8 const *str) { while (1) { if (*str == '\0') break; // 遇到结束符,退出 UART0_SendByte(*str++); // 发送数据 } }

用户评论
请输入评论内容
评分:
暂无评论