SYS_ResetModule(UART0_RST);
/* Configure UART0 and set UART0 Baudrate */
UART_Open(UART0, 115200);
AutoFlow_FunctionRxTest();
void AutoFlow_FunctionRxTest(void)
{
uint32_t u32i;
// GetChar();
/* Enable RTS and CTS autoflow control */
// UART_EnableFlowCtrl(UART0);
/* Set RTS Trigger Level as 8 bytes */
//UART0->FIFO = (UART0->FIFO & (~UART_FIFO_RTSTRGLV_Msk)) | UART_FIFO_RTSTRGLV_8BYTES;
/* Set RX Trigger Level as 8 bytes */ // 触发接收中断 阈值大小
UART0->FIFO = (UART0->FIFO & (~UART_FIFO_RFITL_Msk)) | UART_FIFO_RFITL_14BYTES;
/* Set Timeout time 0x3E bit-time and time-out counter enable */
UART_SetTimeoutCnt(UART0, 0x3e);
/* Enable RDA and RTO Interrupt */
UART_EnableInt(UART0, (UART_INTEN_RDAIEN_Msk | UART_INTEN_RXTOIEN_Msk));
}
void UART0_IRQHandler(void)
{
u8 ret = 0;
static u16 g_i32pointer = 0;
if(UART_GET_INT_FLAG(UART0, UART_INTSTS_RDAINT_Msk)) /* UART receive data available flag */
{
//while(UART_GET_RX_EMPTY(UART0) == 0)
{
//判断接收完成
g_u8RecData[g_i32pointer++] = UART_READ(UART0) ;
}
}
else if(UART_GET_INT_FLAG(UART0,UART_INTSTS_RXTOINT_Msk))
{
while(UART_GET_RX_EMPTY(UART0) == 0)
{
//判断接收完成
g_u8RecData[g_i32pointer++] = UART_READ(UART0) ;
}
//将数据拆包分别放入队列中
Uart_Rec_Over_Flag = 1;
Uart_Rec_Over_Len = g_i32pointer ;
g_i32pointer = 0 ;
// Uart_Rec_Over_Len = g_i32pointer ;
//判断数据有效性
// if(g_u8RecData[0] == 0xFF &&g_u8RecData[1] == 0xFA)
// {
// //查找有无空间
// ret =Find_Space() ;
// if(ret<MAX_SIZE)
// {
// Uart_Cmd_Data[ret][1] = g_i32pointer ;
// my_strncpy(&Uart_Cmd_Data[ret][2],g_u8RecData,g_i32pointer) ;
// }
// else
// {
// PAbortStat = 0x01 ;
// //缓冲区没有空间
// //usart0_sendstring("nospace",7) ;
// }
//
// g_i32pointer = 0 ;
// }
// else
// {
// //收到无效数据
// g_i32pointer = 0 ;
// //串口发送异常指令
// //mymemset(g_u8RecData,0,sizeof(g_u8RecData));
// }
}
}
|