/** * TODO file description */ #include #include "uart_stdout.h" #include "FreeRTOS.h" #include "main.h" #define USE_CRITICAL 0 void stdout_putchar(char c) { #if USE_CRITICAL portENTER_CRITICAL(); #endif while (!LL_USART_IsActiveFlag_TXE(USART_DEBUG)) {} LL_USART_TransmitData8(USART_DEBUG, c); while (!LL_USART_IsActiveFlag_TC(USART_DEBUG)) {} #if USE_CRITICAL portEXIT_CRITICAL(); #endif } void stdout_write(const char *pcBuffer, const size_t iLength) { #if USE_CRITICAL portENTER_CRITICAL(); #endif while (!LL_USART_IsActiveFlag_TXE(USART_DEBUG)) {} int cnt = (int) iLength; while (cnt-- > 0) { char c = *pcBuffer++; LL_USART_TransmitData8(USART_DEBUG, c); while (!LL_USART_IsActiveFlag_TC(USART_DEBUG)) {} } #if USE_CRITICAL portEXIT_CRITICAL(); #endif } void stdout_puts(const char *pcBuffer) { stdout_write(pcBuffer, strlen(pcBuffer)); } /** * @brief Retargets the C library printf function to the USART. * @param None * @retval None */ int _write(int fd, const char *pcBuffer, const int iLength) { stdout_write(pcBuffer, iLength); return iLength; }