Acquire DMA semaphore before transmitting UART
This commit is contained in:
@@ -129,6 +129,7 @@ void vCANListener(void *argument)
|
|||||||
|
|
||||||
osMessageQueuePut(xUARTQueue, &message, 0U, 0U);
|
osMessageQueuePut(xUARTQueue, &message, 0U, 0U);
|
||||||
}
|
}
|
||||||
|
else DEBUG_PRINT("LALALLALA CIAOOOOOO c:\r\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* END vCANListener */
|
/* END vCANListener */
|
||||||
|
|||||||
+12
-7
@@ -91,13 +91,18 @@ int _write(int file, char *ptr, int len)
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
extern osSemaphoreId_t xUARTDMASemaphore;
|
||||||
extern osMutexId_t debugPrintMutex;
|
extern osMutexId_t debugPrintMutex;
|
||||||
|
|
||||||
void uart_debug_print(const char *fmt, ...)
|
void uart_debug_print(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
if (huart1.gState == HAL_UART_STATE_RESET) return;
|
if (huart1.gState == HAL_UART_STATE_RESET) return;
|
||||||
|
|
||||||
if (osKernelGetState() == osKernelRunning) osMutexAcquire(debugPrintMutex, osWaitForever);
|
if (osKernelGetState() == osKernelRunning)
|
||||||
|
{
|
||||||
|
osMutexAcquire(debugPrintMutex, osWaitForever);
|
||||||
|
osSemaphoreAcquire(xUARTDMASemaphore, osWaitForever);
|
||||||
|
}
|
||||||
|
|
||||||
char buf[128];
|
char buf[128];
|
||||||
va_list args;
|
va_list args;
|
||||||
@@ -106,13 +111,13 @@ void uart_debug_print(const char *fmt, ...)
|
|||||||
int len = vsnprintf(buf, sizeof(buf), fmt, args);
|
int len = vsnprintf(buf, sizeof(buf), fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
if (len > 0)
|
if (len > 0) HAL_UART_Transmit(&huart1, (uint8_t*)buf, len, 100);
|
||||||
{
|
|
||||||
while (huart1.gState != HAL_UART_STATE_READY);
|
|
||||||
HAL_UART_Transmit(&huart1, (uint8_t*)buf, len, 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (osKernelGetState() == osKernelRunning) osMutexRelease(debugPrintMutex);
|
if (osKernelGetState() == osKernelRunning)
|
||||||
|
{
|
||||||
|
osSemaphoreRelease(xUARTDMASemaphore);
|
||||||
|
osMutexRelease(debugPrintMutex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* USER CODE END PF */
|
/* USER CODE END PF */
|
||||||
|
|||||||
Reference in New Issue
Block a user