/** * @brief RX DMA common service routine. * * @param[in] uartp pointer to the @p UARTDriver object * @param[in] flags pre-shifted content of the ISR register */ static void uart_lld_serve_rx_end_irq(UARTDriver *uartp, uint32_t flags) { /* DMA errors handling.*/ #if defined(STM32_UART_DMA_ERROR_HOOK) if ((flags & (STM32_DMA_ISR_TEIF | STM32_DMA_ISR_DMEIF)) != 0) { STM32_UART_DMA_ERROR_HOOK(uartp); } #else (void)flags; #endif if (uartp->rxstate == UART_RX_IDLE) { /* Receiver in idle state, a callback is generated, if enabled, for each received character and then the driver stays in the same state.*/ if (uartp->config->rxchar_cb != NULL) uartp->config->rxchar_cb(uartp, uartp->rxbuf); } else { /* Receiver in active state, a callback is generated, if enabled, after a completed transfer.*/ dmaStreamDisable(uartp->dmarx); uartp->rxstate = UART_RX_COMPLETE; if (uartp->config->rxend_cb != NULL) uartp->config->rxend_cb(uartp); /* If the callback didn't explicitly change state then the receiver automatically returns to the idle state.*/ if (uartp->rxstate == UART_RX_COMPLETE) { uartp->rxstate = UART_RX_IDLE; set_rx_idle_loop(uartp); } } }
/** * @brief TX DMA common service routine. * * @param[in] uartp pointer to the @p UARTDriver object * @param[in] flags pre-shifted content of the ISR register */ static void uart_lld_serve_tx_end_irq(UARTDriver *uartp, uint32_t flags) { /* DMA errors handling.*/ #if defined(STM32_UART_DMA_ERROR_HOOK) if ((flags & (STM32_DMA_ISR_TEIF | STM32_DMA_ISR_DMEIF)) != 0) { STM32_UART_DMA_ERROR_HOOK(uartp); } #else (void)flags; #endif dmaStreamDisable(uartp->dmatx); /* Only enable TC interrupt if there's a callback attached to it. We have to do it here, rather than earlier, because TC flag is set until transmission starts.*/ if (uartp->config->txend2_cb != NULL) uartp->usart->CR1 |= USART_CR1_TCIE; /* A callback is generated, if enabled, after a completed transfer.*/ uartp->txstate = UART_TX_COMPLETE; if (uartp->config->txend1_cb != NULL) uartp->config->txend1_cb(uartp); /* If the callback didn't explicitly change state then the transmitter automatically returns to the idle state.*/ if (uartp->txstate == UART_TX_COMPLETE) uartp->txstate = UART_TX_IDLE; }
/** * @brief TX DMA common service routine. * * @param[in] uartp pointer to the @p UARTDriver object * @param[in] flags pre-shifted content of the ISR register */ static void uart_lld_serve_tx_end_irq(UARTDriver *uartp, uint32_t flags) { /* DMA errors handling.*/ #if defined(STM32_UART_DMA_ERROR_HOOK) if ((flags & (STM32_DMA_ISR_TEIF | STM32_DMA_ISR_DMEIF)) != 0) { STM32_UART_DMA_ERROR_HOOK(uartp); } #else (void)flags; #endif dmaStreamDisable(uartp->dmatx); /* A callback is generated, if enabled, after a completed transfer.*/ _uart_tx1_isr_code(uartp); }
/** * @brief TX DMA common service routine. * * @param[in] uartp pointer to the @p UARTDriver object * @param[in] flags pre-shifted content of the ISR register */ static void uart_lld_serve_tx_end_irq(UARTDriver *uartp, uint32_t flags) { /* DMA errors handling.*/ #if defined(STM32_UART_DMA_ERROR_HOOK) if ((flags & (STM32_DMA_ISR_TEIF | STM32_DMA_ISR_DMEIF)) != 0) { STM32_UART_DMA_ERROR_HOOK(uartp); } #else (void)flags; #endif dmaStreamDisable(uartp->dmatx); /* A callback is generated, if enabled, after a completed transfer.*/ uartp->txstate = UART_TX_COMPLETE; if (uartp->config->txend1_cb != NULL) uartp->config->txend1_cb(uartp); /* If the callback didn't explicitly change state then the transmitter automatically returns to the idle state.*/ if (uartp->txstate == UART_TX_COMPLETE) uartp->txstate = UART_TX_IDLE; }
/** * @brief RX DMA common service routine. * * @param[in] uartp pointer to the @p UARTDriver object * @param[in] flags pre-shifted content of the ISR register */ static void uart_lld_serve_rx_end_irq(UARTDriver *uartp, uint32_t flags) { /* DMA errors handling.*/ #if defined(STM32_UART_DMA_ERROR_HOOK) if ((flags & (STM32_DMA_ISR_TEIF | STM32_DMA_ISR_DMEIF)) != 0) { STM32_UART_DMA_ERROR_HOOK(uartp); } #else (void)flags; #endif if (uartp->rxstate == UART_RX_IDLE) { /* Receiver in idle state, a callback is generated, if enabled, for each received character and then the driver stays in the same state.*/ _uart_rx_idle_code(uartp); } else { /* Receiver in active state, a callback is generated, if enabled, after a completed transfer.*/ dmaStreamDisable(uartp->dmarx); _uart_rx_complete_isr_code(uartp); } }