@@ -1008,7 +1008,7 @@ void serial_free(serial_t *obj)
10081008 if (nordic_nrf5_uart_state [instance ].usage_counter == 0 ) {
10091009
10101010 nrf_uarte_disable (nordic_nrf5_uart_register [instance ]);
1011-
1011+
10121012 /* Turn NRF_UARTE0_BASE or NRF_UARTE1_BASE power off and on to reset peripheral. */
10131013 if (instance == 0 ) {
10141014 * (volatile uint32_t * )0x40002FFC = 0 ;
@@ -1022,7 +1022,7 @@ void serial_free(serial_t *obj)
10221022 * (volatile uint32_t * )0x40028FFC = 1 ;
10231023 }
10241024#endif
1025-
1025+
10261026 }
10271027 }
10281028}
@@ -1273,6 +1273,8 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable)
12731273 struct serial_s * uart_object = obj ;
12741274#endif
12751275
1276+ int instance = uart_object -> instance ;
1277+
12761278 /* Convert Mbed type to Nordic IRQ mask. */
12771279 uint32_t type = (irq == TxIrq ) ? NORDIC_TX_IRQ : NORDIC_RX_IRQ ;
12781280
@@ -1282,10 +1284,20 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable)
12821284 uart_object -> mask |= type ;
12831285 nordic_nrf5_serial_configure (obj );
12841286
1287+ /* It is required by Mbed HAL API to generate TxIrq interrupt when TXD register is empty (also after enabling TxIrq interrupt).
1288+ Driver uses DMA to perform uart transfer and TxIrq is generated after the transfer is finished.
1289+ Trigger TxIrq interrupt manually on enabling the TxIrq. */
1290+ if (irq == TxIrq ) {
1291+ if (nrf_uarte_event_check (nordic_nrf5_uart_register [instance ], NRF_UARTE_EVENT_TXDRDY )) {
1292+ nordic_swi_tx_trigger (instance );
1293+ }
1294+ }
12851295 } else {
12861296
12871297 uart_object -> mask &= ~type ;
12881298 }
1299+
1300+
12891301}
12901302
12911303/** Get character. This is a blocking call, waiting for a character
0 commit comments