Use semaphore instead of HAL on write function
This commit is contained in:
+4
-1
@@ -83,7 +83,10 @@ static void MX_USART1_UART_Init(void);
|
|||||||
/* USER CODE BEGIN PF */
|
/* USER CODE BEGIN PF */
|
||||||
int _write(int file, char *ptr, int len)
|
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;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user