drivers: serial: nrfx: Skip poll out when device is not active
Added early return from uart_poll_out when uart device is not in active state. Poll_out is used from many contexts by multiple users and currently here is no mechanism in power management to disable them (console, logger when going to inactive power state. Additionally, moved setting new state when disactivating the device to ensure that no poll_out will happen after disabling the UARTE. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
parent
f97b07bc3f
commit
751bdf483b
1 changed files with 9 additions and 1 deletions
|
@ -1122,6 +1122,11 @@ static void uarte_nrfx_poll_out(const struct device *dev, unsigned char c)
|
|||
NRF_UARTE_Type *uarte = get_uarte_instance(dev);
|
||||
int key;
|
||||
|
||||
#ifdef CONFIG_DEVICE_POWER_MANAGEMENT
|
||||
if (data->pm_state != DEVICE_PM_ACTIVE_STATE) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (isr_mode) {
|
||||
while (1) {
|
||||
key = irq_lock();
|
||||
|
@ -1534,6 +1539,8 @@ static void uarte_nrfx_set_power_state(const struct device *dev,
|
|||
NRF_UARTE_PSEL_DISCONNECTED) {
|
||||
nrf_uarte_task_trigger(uarte, NRF_UARTE_TASK_STARTRX);
|
||||
}
|
||||
|
||||
data->pm_state = new_state;
|
||||
} else {
|
||||
__ASSERT_NO_MSG(new_state == DEVICE_PM_LOW_POWER_STATE ||
|
||||
new_state == DEVICE_PM_SUSPEND_STATE ||
|
||||
|
@ -1546,6 +1553,8 @@ static void uarte_nrfx_set_power_state(const struct device *dev,
|
|||
return;
|
||||
}
|
||||
|
||||
data->pm_state = new_state;
|
||||
|
||||
/* Disabling UART requires stopping RX, but stop RX event is
|
||||
* only sent after each RX if async UART API is used.
|
||||
*/
|
||||
|
@ -1587,7 +1596,6 @@ static int uarte_nrfx_pm_control(const struct device *dev,
|
|||
|
||||
if (new_state != data->pm_state) {
|
||||
uarte_nrfx_set_power_state(dev, new_state);
|
||||
data->pm_state = new_state;
|
||||
}
|
||||
} else {
|
||||
__ASSERT_NO_MSG(ctrl_command == DEVICE_PM_GET_POWER_STATE);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue