File tree 2 files changed +25
-13
lines changed
examples/platform/silabs/SiWx917
2 files changed +25
-13
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ extern "C" {
32
32
33
33
#define USART_BAUDRATE 115200 // Baud rate <9600-7372800>
34
34
#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.
35
36
36
37
sl_usart_handle_t usart_handle;
37
38
@@ -118,6 +119,30 @@ int16_t uartConsoleWrite(const char * Buf, uint16_t BufLength)
118
119
return BufLength;
119
120
}
120
121
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
+
121
146
/*
122
147
* @brief Read the data available from the console Uart
123
148
* @param Buffer for the data to be read, number bytes to read.
Original file line number Diff line number Diff line change 55
55
#endif
56
56
57
57
#if SILABS_LOG_OUT_UART
58
- #if SIWX_917
59
- #include " rsi_debug.h"
60
- #endif // SIWX_917
61
58
#include " uart.h"
62
59
#endif
63
60
@@ -138,17 +135,7 @@ static void PrintLog(const char * msg)
138
135
sz = strlen (msg);
139
136
140
137
#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
150
138
uartLogWrite (msg, sz);
151
- #endif // SIWX_917
152
139
#elif PW_RPC_ENABLED
153
140
PigweedLogger::putString (msg, sz);
154
141
#else
You can’t perform that action at this time.
0 commit comments