Skip to content

Commit 56a514c

Browse files
committed
zephyr/uart_core: Access console UART directly instead of printk() hack.
This is required to avoid extra level of output "cooking" ("\r\r\n") and make test infrastructure work. On the other hand, this breaks somewhat Zephyr console abstraction.
1 parent 0c59c30 commit 56a514c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

zephyr/uart_core.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@
2626
#include <unistd.h>
2727
#include "py/mpconfig.h"
2828
#include "src/zephyr_getchar.h"
29-
30-
// Stopgap
31-
extern void printk(const char*, ...);
29+
// Zephyr headers
30+
#include <uart.h>
3231

3332
/*
3433
* Core UART functions to implement for a port
@@ -41,7 +40,12 @@ int mp_hal_stdin_rx_chr(void) {
4140

4241
// Send string of given length
4342
void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) {
43+
static struct device *uart_console_dev;
44+
if (uart_console_dev == NULL) {
45+
uart_console_dev = device_get_binding(CONFIG_UART_CONSOLE_ON_DEV_NAME);
46+
}
47+
4448
while (len--) {
45-
printk("%c", *str++);
49+
uart_poll_out(uart_console_dev, *str++);
4650
}
4751
}

0 commit comments

Comments
 (0)