新手入门
- 积分
- 4
- 金钱
- 4
- 注册时间
- 2019-11-8
- 在线时间
- 1 小时
|
6金钱
串口中端代码如下:ll库void USART_IRQHandler(UART_STRUCT *uartStruct)
{
uint8_t data;
//用RXNE和TXNE来判断这个串口是否全部完成初始化
if ((LL_USART_IsEnabledIT_RXNE(uartStruct->uart)) || (LL_USART_IsEnabledIT_TXE(uartStruct->uart)))
{
if (LL_USART_IsActiveFlag_TXE(uartStruct->uart))
{
osStatus_t status;
uint8_t ch;
status = osMessageQueueGet(uartStruct->sendMesageId, &ch, NULL, 0);
if (status == osOK)
{
LL_USART_TransmitData8(uartStruct->uart, ch);
}
else
{
LL_USART_DisableIT_TXE(uartStruct->uart);
}
}
if (LL_USART_IsActiveFlag_TC(uartStruct->uart))
{
osStatus_t status;
uint8_t ch;
status = osMessageQueueGet(uartStruct->sendMesageId, &ch, NULL, 0);
if (status == osOK)
{
LL_USART_TransmitData8(uartStruct->uart, ch);
LL_USART_EnableIT_TXE(uartStruct->uart);
}
else
{
LL_USART_DisableIT_TXE(uartStruct->uart);
LL_USART_DisableIT_TC(uartStruct->uart);
if (uartStruct->rs485Dir)
{
delay(UART_RS485_DELAY);
uartStruct->rs485Dir(false);
}
if (uartStruct->stateChanged)
{
uartStruct->stateChanged(UART_STATE_NONE);
}
}
}
if (LL_USART_IsActiveFlag_RXNE(uartStruct->uart))
{ //收到数据
data = LL_USART_ReceiveData8(uartStruct->uart);
if (uartStruct->stateChanged)
{
uartStruct->stateChanged(UART_STATE_RECV);
}
if (uartStruct->recvFilter)
{
if (!uartStruct->recvFilter(uartStruct,data))
{
osMessageQueuePut(uartStruct->recvMesageId, &data, NULL, 0);
}
}
else
{
osMessageQueuePut(uartStruct->recvMesageId, &data, NULL, 0);
}
}
if (LL_USART_IsActiveFlag_ORE(uartStruct->uart))
{ //过载错误
LL_USART_ClearFlag_ORE(uartStruct->uart);//过载发生后,对数据进行处理
if(uartStruct == &uart3Struct)
globalVar.ore_time++;
}
if (LL_USART_IsActiveFlag_IDLE(uartStruct->uart))
{ //空闲
LL_USART_ClearFlag_IDLE(uartStruct->uart);
if (uartStruct->idleInterrupt)
{
uartStruct->idleInterrupt();
}
if (uartStruct->stateChanged)
{
uartStruct->stateChanged(UART_STATE_NONE);
}
}
}
}
问题:是否是因为串口的数据溢出导致的?
或者有啥排查方向,目前准备往232电平方向排查
|
|