Skip to content

Commit 7e2042f

Browse files
committed
Removed macro in common code and moved the logging code to uartLogWrite API.
1 parent b509597 commit 7e2042f

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

examples/platform/silabs/SiWx917/uart.cpp

+25
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ extern "C" {
3232

3333
#define USART_BAUDRATE 115200 // Baud rate <9600-7372800>
3434
#define UART_CONSOLE_ERR -1 // Negative value in case of UART Console action failed. Triggers a failure for PW_RPC
35+
#define UART_CONSOLE_SUCCESS 1 // Positive value if UART Console action is success.
3536

3637
sl_usart_handle_t usart_handle;
3738

@@ -118,6 +119,30 @@ int16_t uartConsoleWrite(const char * Buf, uint16_t BufLength)
118119
return BufLength;
119120
}
120121

122+
/**
123+
* @brief Write Logs to the Uart. Appends a return character
124+
*
125+
* @param log pointer to the logs
126+
* @param length number of bytes to write
127+
* @return int16_t Amount of bytes written or ERROR (-1)
128+
*/
129+
int16_t uartLogWrite(const char * log, uint16_t length)
130+
{
131+
if (log == NULL || length < 1)
132+
{
133+
return UART_CONSOLE_ERR;
134+
}
135+
for (/* Empty */; length != 0; --length)
136+
{
137+
Board_UARTPutChar(*log++);
138+
}
139+
// To print next log in new line with proper formatting
140+
Board_UARTPutChar('\r');
141+
Board_UARTPutChar('\n');
142+
143+
return UART_CONSOLE_SUCCESS;
144+
}
145+
121146
/*
122147
* @brief Read the data available from the console Uart
123148
* @param Buffer for the data to be read, number bytes to read.

src/platform/silabs/Logging.cpp

-13
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@
5555
#endif
5656

5757
#if SILABS_LOG_OUT_UART
58-
#if SIWX_917
59-
#include "rsi_debug.h"
60-
#endif // SIWX_917
6158
#include "uart.h"
6259
#endif
6360

@@ -138,17 +135,7 @@ static void PrintLog(const char * msg)
138135
sz = strlen(msg);
139136

140137
#if SILABS_LOG_OUT_UART
141-
#if SIWX_917
142-
for (/* Empty */; sz != 0; --sz)
143-
{
144-
Board_UARTPutChar(*msg++);
145-
}
146-
// To print next log in new line with proper formatting
147-
Board_UARTPutChar('\r');
148-
Board_UARTPutChar('\n');
149-
#else
150138
uartLogWrite(msg, sz);
151-
#endif // SIWX_917
152139
#elif PW_RPC_ENABLED
153140
PigweedLogger::putString(msg, sz);
154141
#else

0 commit comments

Comments
 (0)