Remove UART DMA and use only semaphore and blocking transmit
This commit is contained in:
+6
-21
@@ -92,11 +92,6 @@ static int format_can_message(char *buf, uint8_t source, const CanMessage_t *mes
|
||||
*/
|
||||
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
|
||||
{
|
||||
if (huart->Instance == USART1)
|
||||
{
|
||||
huart->gState = HAL_UART_STATE_READY;
|
||||
osSemaphoreRelease(xUARTDMASemaphore);
|
||||
}
|
||||
}
|
||||
/* END HAL_UART_TxCpltCallback */
|
||||
|
||||
@@ -142,22 +137,12 @@ void vUARTLogger(void *argument)
|
||||
HAL_UART_Init(&huart1);
|
||||
}
|
||||
|
||||
if (osSemaphoreAcquire(xUARTDMASemaphore, queue_timeout) == osOK)
|
||||
{
|
||||
int len = format_can_message(tx_buffer, message.source, &message);
|
||||
if (HAL_UART_Transmit_DMA(&huart1, (uint8_t*)tx_buffer, len) != HAL_OK)
|
||||
{
|
||||
osSemaphoreRelease(xUARTDMASemaphore);
|
||||
DEBUG_PRINT("HAL error, CAN frame NOT sent!\r\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_PRINT("ERROR: Semaphore timeout! UART might be stuck in BUSY state.\r\n");
|
||||
HAL_UART_Abort(&huart1);
|
||||
HAL_UART_Init(&huart1);
|
||||
osSemaphoreRelease(xUARTDMASemaphore);
|
||||
}
|
||||
osSemaphoreAcquire(xUARTDMASemaphore, osWaitForever);
|
||||
|
||||
int len = format_can_message(tx_buffer, message.source, &message);
|
||||
HAL_UART_Transmit(&huart1, (uint8_t*)tx_buffer, len, 100);
|
||||
|
||||
osSemaphoreRelease(xUARTDMASemaphore);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user