diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Posix/console.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Posix/console.c index ec6a047baef..d9bff9485e6 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Posix/console.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Posix/console.c @@ -34,12 +34,22 @@ #include #include -SemaphoreHandle_t xStdioMutex; -StaticSemaphore_t xStdioMutexBuffer; +#include "console.h" + +static SemaphoreHandle_t xStdioMutex; +static StaticSemaphore_t xStdioMutexBuffer; void console_init( void ) { - xStdioMutex = xSemaphoreCreateMutexStatic( &xStdioMutexBuffer ); + #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + { + xStdioMutex = xSemaphoreCreateMutexStatic( &xStdioMutexBuffer ); + } + #else /* if( configSUPPORT_STATIC_ALLOCATION == 1 ) */ + { + xStdioMutex = xSemaphoreCreateMutex(); + } + #endif /* if( configSUPPORT_STATIC_ALLOCATION == 1 ) */ } void console_print( const char * fmt, @@ -53,6 +63,7 @@ void console_print( const char * fmt, vprintf( fmt, vargs ); + xSemaphoreGive( xStdioMutex ); va_end( vargs ); }