Skip to content

Commit 0d8874c

Browse files
ccli8adbridge
authored andcommitted
Remove unnecessary UART INT in UART DMA transfer
In UART DMA transfer, it is PDMA INT rather than UART INT to go INT path
1 parent 5db8a42 commit 0d8874c

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

targets/TARGET_NUVOTON/TARGET_M451/serial_api.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,10 @@ int serial_tx_asynch(serial_t *obj, const void *tx, size_t tx_length, uint8_t tx
503503
// Register DMA event handler
504504
dma_set_handler(obj->serial.dma_chn_id_tx, (uint32_t) uart_dma_handler_tx, (uint32_t) obj, DMA_EVENT_ALL);
505505
serial_tx_enable_interrupt(obj, handler, 1);
506+
/* We needn't actually enable UART INT to go UART ISR -> handler.
507+
* Instead, as PDMA INT is triggered, we will go PDMA ISR -> UART ISR -> handler
508+
* with serial_tx/rx_enable_interrupt having set up this call path. */
509+
UART_DISABLE_INT(((UART_T *) NU_MODBASE(obj->serial.uart)), UART_INTEN_THREIEN_Msk);
506510
((UART_T *) NU_MODBASE(obj->serial.uart))->INTEN |= UART_INTEN_TXPDMAEN_Msk; // Start DMA transfer
507511
}
508512

@@ -566,6 +570,10 @@ void serial_rx_asynch(serial_t *obj, void *rx, size_t rx_length, uint8_t rx_widt
566570
// Register DMA event handler
567571
dma_set_handler(obj->serial.dma_chn_id_rx, (uint32_t) uart_dma_handler_rx, (uint32_t) obj, DMA_EVENT_ALL);
568572
serial_rx_enable_interrupt(obj, handler, 1);
573+
/* We needn't actually enable UART INT to go UART ISR -> handler.
574+
* Instead, as PDMA INT is triggered, we will go PDMA ISR -> UART ISR -> handler
575+
* with serial_tx/rx_enable_interrupt having set up this call path. */
576+
UART_DISABLE_INT(((UART_T *) NU_MODBASE(obj->serial.uart)), (UART_INTEN_RDAIEN_Msk | UART_INTEN_RXTOIEN_Msk));
569577
((UART_T *) NU_MODBASE(obj->serial.uart))->INTEN |= UART_INTEN_RXPDMAEN_Msk; // Start DMA transfer
570578
}
571579
}

targets/TARGET_NUVOTON/TARGET_M480/serial_api.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,10 @@ int serial_tx_asynch(serial_t *obj, const void *tx, size_t tx_length, uint8_t tx
561561
// Register DMA event handler
562562
dma_set_handler(obj->serial.dma_chn_id_tx, (uint32_t) uart_dma_handler_tx, (uint32_t) obj, DMA_EVENT_ALL);
563563
serial_tx_enable_interrupt(obj, handler, 1);
564+
/* We needn't actually enable UART INT to go UART ISR -> handler.
565+
* Instead, as PDMA INT is triggered, we will go PDMA ISR -> UART ISR -> handler
566+
* with serial_tx/rx_enable_interrupt having set up this call path. */
567+
UART_DISABLE_INT(((UART_T *) NU_MODBASE(obj->serial.uart)), UART_INTEN_THREIEN_Msk);
564568
((UART_T *) NU_MODBASE(obj->serial.uart))->INTEN |= UART_INTEN_TXPDMAEN_Msk; // Start DMA transfer
565569
}
566570

@@ -622,6 +626,10 @@ void serial_rx_asynch(serial_t *obj, void *rx, size_t rx_length, uint8_t rx_widt
622626
// Register DMA event handler
623627
dma_set_handler(obj->serial.dma_chn_id_rx, (uint32_t) uart_dma_handler_rx, (uint32_t) obj, DMA_EVENT_ALL);
624628
serial_rx_enable_interrupt(obj, handler, 1);
629+
/* We needn't actually enable UART INT to go UART ISR -> handler.
630+
* Instead, as PDMA INT is triggered, we will go PDMA ISR -> UART ISR -> handler
631+
* with serial_tx/rx_enable_interrupt having set up this call path. */
632+
UART_DISABLE_INT(((UART_T *) NU_MODBASE(obj->serial.uart)), (UART_INTEN_RDAIEN_Msk | UART_INTEN_RXTOIEN_Msk));
625633
((UART_T *) NU_MODBASE(obj->serial.uart))->INTEN |= UART_INTEN_RXPDMAEN_Msk; // Start DMA transfer
626634
}
627635
}

targets/TARGET_NUVOTON/TARGET_NANO100/serial_api.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,10 @@ int serial_tx_asynch(serial_t *obj, const void *tx, size_t tx_length, uint8_t tx
458458
// Register DMA event handler
459459
dma_set_handler(obj->serial.dma_chn_id_tx, (uint32_t) uart_dma_handler_tx, (uint32_t) obj, DMA_EVENT_ALL);
460460
serial_tx_enable_interrupt(obj, handler, 1);
461+
/* We needn't actually enable UART INT to go UART ISR -> handler.
462+
* Instead, as PDMA INT is triggered, we will go PDMA ISR -> UART ISR -> handler
463+
* with serial_tx/rx_enable_interrupt having set up this call path. */
464+
UART_DISABLE_INT(((UART_T *) NU_MODBASE(obj->serial.uart)), UART_IER_THRE_IE_Msk);
461465
PDMA_Trigger(obj->serial.dma_chn_id_tx);
462466
((UART_T *) NU_MODBASE(obj->serial.uart))->CTL |= UART_CTL_DMA_TX_EN_Msk; // Start DMA transfer
463467
}
@@ -514,6 +518,10 @@ void serial_rx_asynch(serial_t *obj, void *rx, size_t rx_length, uint8_t rx_widt
514518
// Register DMA event handler
515519
dma_set_handler(obj->serial.dma_chn_id_rx, (uint32_t) uart_dma_handler_rx, (uint32_t) obj, DMA_EVENT_ALL);
516520
serial_rx_enable_interrupt(obj, handler, 1);
521+
/* We needn't actually enable UART INT to go UART ISR -> handler.
522+
* Instead, as PDMA INT is triggered, we will go PDMA ISR -> UART ISR -> handler
523+
* with serial_tx/rx_enable_interrupt having set up this call path. */
524+
UART_DISABLE_INT(((UART_T *) NU_MODBASE(obj->serial.uart)), (UART_IER_RDA_IE_Msk | UART_IER_RTO_IE_Msk));
517525
PDMA_Trigger(obj->serial.dma_chn_id_rx);
518526
((UART_T *) NU_MODBASE(obj->serial.uart))->CTL |= UART_CTL_DMA_RX_EN_Msk; // Start DMA transfer
519527
}

targets/TARGET_NUVOTON/TARGET_NUC472/serial_api.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,10 @@ int serial_tx_asynch(serial_t *obj, const void *tx, size_t tx_length, uint8_t tx
543543
// Register DMA event handler
544544
dma_set_handler(obj->serial.dma_chn_id_tx, (uint32_t) uart_dma_handler_tx, (uint32_t) obj, DMA_EVENT_ALL);
545545
serial_tx_enable_interrupt(obj, handler, 1);
546+
/* We needn't actually enable UART INT to go UART ISR -> handler.
547+
* Instead, as PDMA INT is triggered, we will go PDMA ISR -> UART ISR -> handler
548+
* with serial_tx/rx_enable_interrupt having set up this call path. */
549+
UART_DISABLE_INT(((UART_T *) NU_MODBASE(obj->serial.uart)), UART_INTEN_THREIEN_Msk);
546550
((UART_T *) NU_MODBASE(obj->serial.uart))->INTEN |= UART_INTEN_TXPDMAEN_Msk; // Start DMA transfer
547551
}
548552

@@ -604,6 +608,10 @@ void serial_rx_asynch(serial_t *obj, void *rx, size_t rx_length, uint8_t rx_widt
604608
// Register DMA event handler
605609
dma_set_handler(obj->serial.dma_chn_id_rx, (uint32_t) uart_dma_handler_rx, (uint32_t) obj, DMA_EVENT_ALL);
606610
serial_rx_enable_interrupt(obj, handler, 1);
611+
/* We needn't actually enable UART INT to go UART ISR -> handler.
612+
* Instead, as PDMA INT is triggered, we will go PDMA ISR -> UART ISR -> handler
613+
* with serial_tx/rx_enable_interrupt having set up this call path. */
614+
UART_DISABLE_INT(((UART_T *) NU_MODBASE(obj->serial.uart)), (UART_INTEN_RDAIEN_Msk | UART_INTEN_RXTOIEN_Msk));
607615
((UART_T *) NU_MODBASE(obj->serial.uart))->INTEN |= UART_INTEN_RXPDMAEN_Msk; // Start DMA transfer
608616
}
609617
}

0 commit comments

Comments
 (0)