Fixed bug related to spurious interrupt

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11533 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
edolomb 2018-02-21 20:57:29 +00:00
parent b75eda3185
commit 86c2338782
1 changed files with 11 additions and 11 deletions

View File

@ -1343,6 +1343,13 @@ void uart_lld_stop(UARTDriver *uartp) {
*/ */
void uart_lld_start_send(UARTDriver *uartp, size_t n, const void *txbuf) { void uart_lld_start_send(UARTDriver *uartp, size_t n, const void *txbuf) {
/* TX DMA channel preparation.*/
dmaChannelSetSource(uartp->dmatx, txbuf);
dmaChannelSetTransactionSize(uartp->dmatx, n);
/* Starting transfer.*/
dmaChannelEnable(uartp->dmatx);
/* Only enable TC interrupt if there's a callback attached to it. /* Only enable TC interrupt if there's a callback attached to it.
Also we need to clear TC flag which could be set before. */ Also we need to clear TC flag which could be set before. */
if (uartp->config->txend2_cb != NULL) { if (uartp->config->txend2_cb != NULL) {
@ -1355,13 +1362,6 @@ void uart_lld_start_send(UARTDriver *uartp, size_t n, const void *txbuf) {
uartp->usart->US_IER = US_IER_TXEMPTY; uartp->usart->US_IER = US_IER_TXEMPTY;
#endif #endif
} }
/* TX DMA channel preparation.*/
dmaChannelSetSource(uartp->dmatx, txbuf);
dmaChannelSetTransactionSize(uartp->dmatx, n);
/* Starting transfer.*/
dmaChannelEnable(uartp->dmatx);
} }
/** /**
@ -1378,8 +1378,8 @@ void uart_lld_start_send(UARTDriver *uartp, size_t n, const void *txbuf) {
size_t uart_lld_stop_send(UARTDriver *uartp) { size_t uart_lld_stop_send(UARTDriver *uartp) {
dmaChannelDisable(uartp->dmatx); dmaChannelDisable(uartp->dmatx);
/* number of data frames not transmitted is always zero */
return 0; return dmaChannelGetTransactionSize(uartp->dmatx);
} }
/** /**
@ -1400,7 +1400,7 @@ void uart_lld_start_receive(UARTDriver *uartp, size_t n, void *rxbuf) {
/* Enabling BIE interrupt if disabled */ /* Enabling BIE interrupt if disabled */
if ((uartp->dmarx->xdmac->XDMAC_CHID[uartp->dmarx->chid].XDMAC_CIM & XDMAC_CIM_BIM) == 0) { if ((uartp->dmarx->xdmac->XDMAC_CHID[uartp->dmarx->chid].XDMAC_CIM & XDMAC_CIM_BIM) == 0) {
uartp->dmarx->xdmac->XDMAC_CHID[uartp->dmarx->chid].XDMAC_CIE = XDMAC_CIE_BIE; uartp->dmarx->xdmac->XDMAC_CHID[uartp->dmarx->chid].XDMAC_CIE = XDMAC_CIE_BIE;
} }
/* Resetting the XDMAC_CNCDAx */ /* Resetting the XDMAC_CNCDAx */
@ -1440,7 +1440,7 @@ size_t uart_lld_stop_receive(UARTDriver *uartp) {
size_t n; size_t n;
dmaChannelDisable(uartp->dmarx); dmaChannelDisable(uartp->dmarx);
n = 0; n = dmaChannelGetTransactionSize(uartp->dmarx);
uart_enter_rx_idle_loop(uartp); uart_enter_rx_idle_loop(uartp);
return n; return n;