mirror of https://github.com/ARMmbed/mbed-os.git
[M487] Refine serial PDMA code
parent
422871ab4d
commit
898a4bb4bd
|
@ -591,7 +591,9 @@ int serial_tx_asynch(serial_t *obj, const void *tx, size_t tx_length, uint8_t tx
|
|||
MBED_ASSERT(modinit != NULL);
|
||||
MBED_ASSERT(modinit->modname == obj->serial.uart);
|
||||
|
||||
PDMA->CHCTL |= 1 << obj->serial.dma_chn_id_tx; // Enable this DMA channel
|
||||
PDMA_T *pdma_base = dma_modbase();
|
||||
|
||||
pdma_base->CHCTL |= 1 << obj->serial.dma_chn_id_tx; // Enable this DMA channel
|
||||
PDMA_SetTransferMode(obj->serial.dma_chn_id_tx,
|
||||
((struct nu_uart_var *) modinit->var)->pdma_perp_tx, // Peripheral connected to this PDMA
|
||||
0, // Scatter-gather disabled
|
||||
|
@ -653,7 +655,9 @@ void serial_rx_asynch(serial_t *obj, void *rx, size_t rx_length, uint8_t rx_widt
|
|||
MBED_ASSERT(modinit != NULL);
|
||||
MBED_ASSERT(modinit->modname == obj->serial.uart);
|
||||
|
||||
PDMA->CHCTL |= 1 << obj->serial.dma_chn_id_rx; // Enable this DMA channel
|
||||
PDMA_T *pdma_base = dma_modbase();
|
||||
|
||||
pdma_base->CHCTL |= 1 << obj->serial.dma_chn_id_rx; // Enable this DMA channel
|
||||
PDMA_SetTransferMode(obj->serial.dma_chn_id_rx,
|
||||
((struct nu_uart_var *) modinit->var)->pdma_perp_rx, // Peripheral connected to this PDMA
|
||||
0, // Scatter-gather disabled
|
||||
|
@ -687,11 +691,13 @@ void serial_tx_abort_asynch(serial_t *obj)
|
|||
while (! UART_IS_TX_EMPTY((UART_T *) NU_MODBASE(obj->serial.uart)));
|
||||
|
||||
if (obj->serial.dma_usage_tx != DMA_USAGE_NEVER) {
|
||||
PDMA_T *pdma_base = dma_modbase();
|
||||
|
||||
if (obj->serial.dma_chn_id_tx != DMA_ERROR_OUT_OF_CHANNELS) {
|
||||
PDMA_DisableInt(obj->serial.dma_chn_id_tx, PDMA_INT_TRANS_DONE);
|
||||
// FIXME: On NUC472, next PDMA transfer will fail with PDMA_STOP() called. Cause is unknown.
|
||||
//PDMA_STOP(obj->serial.dma_chn_id_tx);
|
||||
PDMA->CHCTL &= ~(1 << obj->serial.dma_chn_id_tx);
|
||||
pdma_base->CHCTL &= ~(1 << obj->serial.dma_chn_id_tx);
|
||||
}
|
||||
UART_DISABLE_INT(((UART_T *) NU_MODBASE(obj->serial.uart)), UART_INTEN_TXPDMAEN_Msk);
|
||||
}
|
||||
|
@ -706,11 +712,13 @@ void serial_tx_abort_asynch(serial_t *obj)
|
|||
void serial_rx_abort_asynch(serial_t *obj)
|
||||
{
|
||||
if (obj->serial.dma_usage_rx != DMA_USAGE_NEVER) {
|
||||
PDMA_T *pdma_base = dma_modbase();
|
||||
|
||||
if (obj->serial.dma_chn_id_rx != DMA_ERROR_OUT_OF_CHANNELS) {
|
||||
PDMA_DisableInt(obj->serial.dma_chn_id_rx, PDMA_INT_TRANS_DONE);
|
||||
// FIXME: On NUC472, next PDMA transfer will fail with PDMA_STOP() called. Cause is unknown.
|
||||
//PDMA_STOP(obj->serial.dma_chn_id_rx);
|
||||
PDMA->CHCTL &= ~(1 << obj->serial.dma_chn_id_rx);
|
||||
pdma_base->CHCTL &= ~(1 << obj->serial.dma_chn_id_rx);
|
||||
}
|
||||
UART_DISABLE_INT(((UART_T *) NU_MODBASE(obj->serial.uart)), UART_INTEN_RXPDMAEN_Msk);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue