这个例子里还实现了串口中断接收,并移植了lettle-shell
void UART1_Config(void)
{
UART_ConfigRunMode(UART1, 115200, UART_WLS_8, UART_PARITY_NONE, UART_STOP_BIT_1);
UART_EnableRBRInt(UART1);
UART_EnableFIFO(UART1, FIFO_L0_1BYTE, FIFO_L3_14BYTE, 0, 0);
SYS_EnablePeripheralClk(SYS_CLK_UART1_MSK);
SYS_SET_IOCFG(IOP22CFG, SYS_IOCFG_P22_TXD1);
SYS_SET_IOCFG(IOP23CFG, SYS_IOCFG_P23_RXD1);
/*
(2)设置Uart1 中断
*/
NVIC_SetPriority(UART1_IRQn, 4);
NVIC_EnableIRQ(UART1_IRQn);
}
void Uart1SendByte(uint8_t dat)
{
while (!(UART1->LSR & UART_LSR_THRE_Msk));
UART1->THR = dat;
}
void UartReceive(uint16_t c);
void UART1_IRQHandler(void)
{
while (UART1->LSR & (UART_LSR_OE_Msk | UART_LSR_RDR_Msk))
UartReceive(UART1->RBR);
}
root:/$ help
Command List:
logSetLevel CMD -------- set log level
setVar CMD -------- set var
help CMD -------- show command info
users CMD -------- list all user
cmds CMD -------- list all cmd
vars CMD -------- list all var
keys CMD -------- list all key
clear CMD -------- clear console
hexdump CMD -------- hex dump
方便自定义串口命令
|