Пример #1
0
/**
 * @brief   UART common service routine.
 *
 * @param[in] uartp     pointer to the @p UARTDriver object
 */
static void uart_serve_interrupt(UARTDriver *uartp)
{
  uint32_t dmachis = HWREG(UDMA_CHIS);
  uint32_t mis = HWREG(uartp->uart + UART_O_MIS);

  if (mis & UART_MIS_TXMIS) {
    /* End of transfer */
    _uart_tx2_isr_code(uartp);
  }

  if (mis & (UART_MIS_OEMIS | UART_MIS_BEMIS | UART_MIS_PEMIS | UART_MIS_FEMIS)) {
    /* Error occurred */
    _uart_rx_error_isr_code(uartp, translate_errors(mis));
  }

  if (dmachis & (1 << uartp->dmarxnr)) {
    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);
      uart_enter_rx_idle_loop(uartp);
    }
    else {
      /* Receiver in active state, a callback is generated, if enabled, after
         a completed transfer.*/
      _uart_rx_complete_isr_code(uartp);
    }
  }

  if (dmachis & (1 << uartp->dmatxnr)) {
    /* A callback is generated, if enabled, after a completed transfer.*/
    _uart_tx1_isr_code(uartp);
  }
}
Пример #2
0
/**
 * @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);
}