diff --git a/examples/platform/silabs/SiWx917/uart.cpp b/examples/platform/silabs/SiWx917/uart.cpp index ee6f9ab6235246..b2747a09c74898 100644 --- a/examples/platform/silabs/SiWx917/uart.cpp +++ b/examples/platform/silabs/SiWx917/uart.cpp @@ -32,6 +32,7 @@ extern "C" { #define USART_BAUDRATE 115200 // Baud rate <9600-7372800> #define UART_CONSOLE_ERR -1 // Negative value in case of UART Console action failed. Triggers a failure for PW_RPC +#define UART_CONSOLE_SUCCESS 1 // Positive value if UART Console action is success. sl_usart_handle_t usart_handle; @@ -118,6 +119,30 @@ int16_t uartConsoleWrite(const char * Buf, uint16_t BufLength) return BufLength; } +/** + * @brief Write Logs to the Uart. Appends a return character + * + * @param log pointer to the logs + * @param length number of bytes to write + * @return int16_t Amount of bytes written or ERROR (-1) + */ +int16_t uartLogWrite(const char * log, uint16_t length) +{ + if (log == NULL || length < 1) + { + return UART_CONSOLE_ERR; + } + for (/* Empty */; length != 0; --length) + { + Board_UARTPutChar(*log++); + } + // To print next log in new line with proper formatting + Board_UARTPutChar('\r'); + Board_UARTPutChar('\n'); + + return UART_CONSOLE_SUCCESS; +} + /* * @brief Read the data available from the console Uart * @param Buffer for the data to be read, number bytes to read. diff --git a/src/platform/silabs/Logging.cpp b/src/platform/silabs/Logging.cpp index 72e9e4faa86ff0..71f377f94e66e3 100644 --- a/src/platform/silabs/Logging.cpp +++ b/src/platform/silabs/Logging.cpp @@ -55,9 +55,6 @@ #endif #if SILABS_LOG_OUT_UART -#if SIWX_917 -#include "rsi_debug.h" -#endif // SIWX_917 #include "uart.h" #endif @@ -138,17 +135,7 @@ static void PrintLog(const char * msg) sz = strlen(msg); #if SILABS_LOG_OUT_UART -#if SIWX_917 - for (/* Empty */; sz != 0; --sz) - { - Board_UARTPutChar(*msg++); - } - // To print next log in new line with proper formatting - Board_UARTPutChar('\r'); - Board_UARTPutChar('\n'); -#else uartLogWrite(msg, sz); -#endif // SIWX_917 #elif PW_RPC_ENABLED PigweedLogger::putString(msg, sz); #else