From fe8fe41571e7c317602e7d28e096a418bcfd7aea Mon Sep 17 00:00:00 2001 From: Krzysztof Chruscinski Date: Thu, 15 Apr 2021 12:33:40 +0200 Subject: [PATCH] drivers: serial: nrf_uarte: Support for no multithreading Don use k_sleep when multithreading is disabled. Signed-off-by: Krzysztof Chruscinski --- drivers/serial/uart_nrfx_uart.c | 12 ++++++++---- drivers/serial/uart_nrfx_uarte.c | 4 +++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/serial/uart_nrfx_uart.c b/drivers/serial/uart_nrfx_uart.c index 172e8729976..c4b43df03f6 100644 --- a/drivers/serial/uart_nrfx_uart.c +++ b/drivers/serial/uart_nrfx_uart.c @@ -272,10 +272,14 @@ static void uart_nrfx_poll_out(const struct device *dev, unsigned char c) while (atomic_cas((atomic_t *) lock, (atomic_val_t) 0, (atomic_val_t) 1) == false) { - /* k_sleep allows other threads to execute and finish - * their transactions. - */ - k_msleep(1); + if (IS_ENABLED(CONFIG_MULTITHREADING)) { + /* k_sleep allows other threads to execute and finish + * their transactions. + */ + k_msleep(1); + } else { + k_busy_wait(1000); + } if (--safety_cnt == 0) { break; } diff --git a/drivers/serial/uart_nrfx_uarte.c b/drivers/serial/uart_nrfx_uarte.c index 3f438e5ba3b..14ac2a75e57 100644 --- a/drivers/serial/uart_nrfx_uarte.c +++ b/drivers/serial/uart_nrfx_uarte.c @@ -489,7 +489,9 @@ static int wait_tx_ready(const struct device *dev) irq_unlock(key); } - k_msleep(1); + if (IS_ENABLED(CONFIG_MULTITHREADING)) { + k_msleep(1); + } } while (1); return key;