串口是用的较多的,由于一直比较忙,抽空看了下串口。
参考的是官方例程。
- switch(g_Uart0RxBuf) /* check Reception data */
- {
- case 'T': /* reception data is 'T' */
- g_Uart0TxEnd = R_UART0_Send(messageOK, 4); /* transmit "OK" */
- break;
- case 0x64: /* reception data is 'T' */
- ///g_Uart0TxEnd = R_UART0_Send(messageOK, 4); /* transmit "OK" */
- g_Uart0TxEnd = R_UART0_Send(messageLEDOFF, 8);
- P0 |= 0x02U;
- break;
- case 0x63:
- g_Uart0TxEnd = R_UART0_Send(messageLEDON, 7);
- P0 &= 0xfcU;
- break;
-
- case 't': /* reception data is 't' */
- g_Uart0TxEnd = R_UART0_Send(messageok, 4); /* transmit "ok" */
- break;
- default: /* received another character */
- g_Uart0TxEnd = R_UART0_Send(messageUC, 4); /* transmit "UC" */
- break;
- }
- while (g_Uart0TxEnd == 0){}
复制代码
主要是实现发一个数字,然后对应的灯亮灭之类的功能。