Use semaphore instead of HAL on write function

This commit is contained in:
2026-06-24 15:09:43 +02:00
parent 84c56ea83f
commit 88b3fd873c
+4 -1
View File
@@ -83,7 +83,10 @@ static void MX_USART1_UART_Init(void);
/* USER CODE BEGIN PF */
int _write(int file, char *ptr, int len)
{
for (int i = 0; i < len; i++) ITM_SendChar((*ptr++));
if (osKernelGetState() == osKernelRunning) osSemaphoreAcquire(xUARTDMASemaphore, osWaitForever);
HAL_UART_Transmit(&huart1, (uint8_t*)ptr, len, 100);
if (osKernelGetState() == osKernelRunning) osSemaphoreRelease(xUARTDMASemaphore);
return len;
}