drivers: serial: uart_nrfx_uarte: Fix interrupt driven TX only mode
When interrupt driven instance is using only TX then low power mode is automatically enabled and then TXSTOPPED interrupt is disabled in idle so uarte_nrfx_irq_tx_ready_complete() was returning wrong value. Adding a dedicate flag which holds information is user enabled TX interrupt. Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
parent
e48053fdb5
commit
282bc783b1
1 changed files with 5 additions and 4 deletions
|
@ -143,6 +143,7 @@ struct uarte_nrfx_int_driven {
|
|||
uint8_t *tx_buffer;
|
||||
uint16_t tx_buff_size;
|
||||
volatile bool disable_tx_irq;
|
||||
bool tx_irq_enabled;
|
||||
#ifdef CONFIG_PM_DEVICE
|
||||
bool rx_irq_enabled;
|
||||
#endif
|
||||
|
@ -1593,6 +1594,7 @@ static void uarte_nrfx_irq_tx_enable(const struct device *dev)
|
|||
unsigned int key = irq_lock();
|
||||
|
||||
data->int_driven->disable_tx_irq = false;
|
||||
data->int_driven->tx_irq_enabled = true;
|
||||
nrf_uarte_int_enable(uarte, NRF_UARTE_INT_TXSTOPPED_MASK);
|
||||
|
||||
irq_unlock(key);
|
||||
|
@ -1604,6 +1606,7 @@ static void uarte_nrfx_irq_tx_disable(const struct device *dev)
|
|||
struct uarte_nrfx_data *data = dev->data;
|
||||
/* TX IRQ will be disabled after current transmission is finished */
|
||||
data->int_driven->disable_tx_irq = true;
|
||||
data->int_driven->tx_irq_enabled = false;
|
||||
}
|
||||
|
||||
/** Interrupt driven transfer ready function */
|
||||
|
@ -1617,10 +1620,8 @@ static int uarte_nrfx_irq_tx_ready_complete(const struct device *dev)
|
|||
* enabled, otherwise this function would always return true no matter
|
||||
* what would be the source of interrupt.
|
||||
*/
|
||||
bool ready = !data->int_driven->disable_tx_irq &&
|
||||
nrf_uarte_event_check(uarte, NRF_UARTE_EVENT_TXSTOPPED) &&
|
||||
nrf_uarte_int_enable_check(uarte,
|
||||
NRF_UARTE_INT_TXSTOPPED_MASK);
|
||||
bool ready = data->int_driven->tx_irq_enabled &&
|
||||
nrf_uarte_event_check(uarte, NRF_UARTE_EVENT_TXSTOPPED);
|
||||
|
||||
if (ready) {
|
||||
data->int_driven->fifo_fill_lock = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue