Non-blocking on CAN1 queue check
- Check queue instantly - Use DMA to move tx_buffer to UART peripheral - Use a semaphore to DMA is being done, to avoid moving to next loop iteration and overwriting tx_buffer - HAL_UART_TxCpltCallback will release semaphore when DMA done
This commit is contained in:
+16
-1
@@ -94,7 +94,7 @@ void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
|
|||||||
*/
|
*/
|
||||||
void vUARTLogger(void *argument)
|
void vUARTLogger(void *argument)
|
||||||
{
|
{
|
||||||
CanMessage_t msg;
|
CanMessage_t message;
|
||||||
char tx_buffer[45]; // converted extended frame
|
char tx_buffer[45]; // converted extended frame
|
||||||
bool queues_empty;
|
bool queues_empty;
|
||||||
|
|
||||||
@@ -102,6 +102,21 @@ void vUARTLogger(void *argument)
|
|||||||
{
|
{
|
||||||
osEventFlagsWait(xCanEventFlags, 0x03, osFlagsWaitAny, osWaitForever);
|
osEventFlagsWait(xCanEventFlags, 0x03, osFlagsWaitAny, osWaitForever);
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
queues_empty = true;
|
||||||
|
|
||||||
|
if (osMessageQueueGet(xCAN1RxQueue, &message, NULL, 0U) == osOK)
|
||||||
|
{
|
||||||
|
format_can_message(tx_buffer, 1, &message);
|
||||||
|
|
||||||
|
HAL_UART_Transmit_DMA(&huart1, (uint8_t*)tx_buffer, 44);
|
||||||
|
osSemaphoreAcquire(xUartDmaSem, osWaitForever);
|
||||||
|
|
||||||
|
quesues_empty = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (!queues_empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* END vUARTLoggerListen */
|
/* END vUARTLoggerListen */
|
||||||
|
|||||||
Reference in New Issue
Block a user