Skip to content

Commit a5e4d60

Browse files
committed
[board][ports][kservice] add log function support and select the transmission method based on configuration.
1 parent d99aa8e commit a5e4d60

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

board/ports/kservice/kservice-ports.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <stdint.h>
1010
#include "board.h"
11+
#include "sdkconfig.h"
1112

1213
static USART_HandleTypeDef uart_handle;
1314

@@ -18,7 +19,18 @@ static USART_HandleTypeDef uart_handle;
1819
*/
1920
void _kputs(const char *str, long len)
2021
{
22+
#ifdef CONFIG_COMPONENTS_ENABLE_LOG
23+
for (long i = 0; i < len; i++)
24+
{
25+
if (str[i] == '\n')
26+
{
27+
HAL_USART_Transmit(&uart_handle, (uint8_t *)"\r", 1, 10);
28+
}
29+
HAL_USART_Transmit(&uart_handle, (uint8_t *)&str[i], 1, 10);
30+
}
31+
#else
2132
HAL_USART_Transmit(&uart_handle, (uint8_t *)str, len, 10);
33+
#endif
2234
}
2335

2436
void ports_kservice_init(void)

0 commit comments

Comments
 (0)