diff --git a/Core/Src/canlog.c b/Core/Src/canlog.c index d7322d9..def6302 100644 --- a/Core/Src/canlog.c +++ b/Core/Src/canlog.c @@ -129,6 +129,7 @@ void vCANListener(void *argument) osMessageQueuePut(xUARTQueue, &message, 0U, 0U); } + else DEBUG_PRINT("LALALLALA CIAOOOOOO c:\r\n"); } } /* END vCANListener */ diff --git a/Core/Src/main.c b/Core/Src/main.c index cdd5bba..18b83a0 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -91,13 +91,18 @@ int _write(int file, char *ptr, int len) #include #include +extern osSemaphoreId_t xUARTDMASemaphore; extern osMutexId_t debugPrintMutex; void uart_debug_print(const char *fmt, ...) { 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]; va_list args; @@ -106,13 +111,13 @@ void uart_debug_print(const char *fmt, ...) int len = vsnprintf(buf, sizeof(buf), fmt, args); va_end(args); - if (len > 0) - { - while (huart1.gState != HAL_UART_STATE_READY); - HAL_UART_Transmit(&huart1, (uint8_t*)buf, len, 100); - } + if (len > 0) HAL_UART_Transmit(&huart1, (uint8_t*)buf, len, 100); - if (osKernelGetState() == osKernelRunning) osMutexRelease(debugPrintMutex); + if (osKernelGetState() == osKernelRunning) + { + osSemaphoreRelease(xUARTDMASemaphore); + osMutexRelease(debugPrintMutex); + } } #endif /* USER CODE END PF */