This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

CMSIS USART DRIVER concerns

Hello,

In function Usart_Receive
RXNE Interrupt is disabled before receiver busy check.

I think you have to turn around.

Imagine a call of this function while receiving data.
Receiver remains busy with disabled Interrupt.

// code extract from USART_STM32F4xx.c Revision V2.3
static int32_t USART_Receive (      void            *data,
                                    uint32_t         num,
                              const USART_RESOURCES *usart) {

  int32_t stat;
#ifdef __USART_DMA_RX
  uint32_t cr1;
  uint32_t dest_inc = DMA_MINC_ENABLE;
#endif

  if ((data == NULL) || (num == 0U)) {
    // Invalid parameters
    return ARM_DRIVER_ERROR_PARAMETER;
  }

  if ((usart->info->flags & USART_FLAG_CONFIGURED) == 0U) {
    // USART is not configured (mode not selected)
    return ARM_DRIVER_ERROR;
  }

  // Disable RXNE Interrupt
  usart->reg->CR1 &= ~USART_CR1_RXNEIE;

  // Check if receiver is busy
  if (usart->info->status.rx_busy == 1U) {
    return ARM_DRIVER_ERROR_BUSY;
  }

0