Skip to content

Commit 5a41aa2

Browse files
nordic-krchaescolar
authored andcommitted
drivers: serial: uart_nrfx_uarte2: Prevent TX in suspend mode
Do not transmit if the device is in suspend mode. Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent d27842c commit 5a41aa2

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

drivers/serial/uart_nrfx_uarte2.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,15 @@ static int api_tx(const struct device *dev, const uint8_t *buf, size_t len, int3
385385
nrfx_err_t err;
386386
bool hwfc;
387387

388+
#if CONFIG_PM_DEVICE
389+
enum pm_device_state state;
390+
391+
(void)pm_device_state_get(dev, &state);
392+
if (state != PM_DEVICE_STATE_ACTIVE) {
393+
return -ECANCELED;
394+
}
395+
#endif
396+
388397
#if CONFIG_UART_USE_RUNTIME_CONFIGURE
389398
hwfc = data->uart_config.flow_ctrl == UART_CFG_FLOW_CTRL_RTS_CTS;
390399
#else
@@ -575,6 +584,15 @@ static void api_poll_out(const struct device *dev, unsigned char out_char)
575584
const nrfx_uarte_t *nrfx_dev = get_nrfx_dev(dev);
576585
nrfx_err_t err;
577586

587+
#if CONFIG_PM_DEVICE
588+
enum pm_device_state state;
589+
590+
(void)pm_device_state_get(dev, &state);
591+
if (state != PM_DEVICE_STATE_ACTIVE) {
592+
return;
593+
}
594+
#endif
595+
578596
do {
579597
/* When runtime PM is used we cannot use early return because then
580598
* we have no information when UART is actually done with the

0 commit comments

Comments
 (0)