STM32L4xx_HAL_Driver  1.14.0
SMARTCARD Extended private Functions

Functions

static void SMARTCARDEx_SetNbDataToProcess (SMARTCARD_HandleTypeDef *hsmartcard)
 Calculate the number of data to process in RX/TX ISR. More...
 

Detailed Description

Function Documentation

◆ SMARTCARDEx_SetNbDataToProcess()

static void SMARTCARDEx_SetNbDataToProcess ( SMARTCARD_HandleTypeDef hsmartcard)
static

Calculate the number of data to process in RX/TX ISR.

Note
The RX FIFO depth and the TX FIFO depth is extracted from the USART configuration registers.
Parameters
hsmartcardSMARTCARD handle.
Return values
None

Definition at line 454 of file stm32l4xx_hal_smartcard_ex.c.

455 {
456  uint8_t rx_fifo_depth;
457  uint8_t tx_fifo_depth;
458  uint8_t rx_fifo_threshold;
459  uint8_t tx_fifo_threshold;
460  /* 2 0U/1U added for MISRAC2012-Rule-18.1_b and MISRAC2012-Rule-18.1_d */
461  uint8_t numerator[] = {1U, 1U, 1U, 3U, 7U, 1U, 0U, 0U};
462  uint8_t denominator[] = {8U, 4U, 2U, 4U, 8U, 1U, 1U, 1U};
463 
464  if (hsmartcard->FifoMode == SMARTCARD_FIFOMODE_DISABLE)
465  {
466  hsmartcard->NbTxDataToProcess = 1U;
467  hsmartcard->NbRxDataToProcess = 1U;
468  }
469  else
470  {
471  rx_fifo_depth = RX_FIFO_DEPTH;
472  tx_fifo_depth = TX_FIFO_DEPTH;
473  rx_fifo_threshold = (uint8_t)(READ_BIT(hsmartcard->Instance->CR3, USART_CR3_RXFTCFG) >> USART_CR3_RXFTCFG_Pos);
474  tx_fifo_threshold = (uint8_t)(READ_BIT(hsmartcard->Instance->CR3, USART_CR3_TXFTCFG) >> USART_CR3_TXFTCFG_Pos);
475  hsmartcard->NbTxDataToProcess = ((uint16_t)tx_fifo_depth * numerator[tx_fifo_threshold]) / (uint16_t)denominator[tx_fifo_threshold];
476  hsmartcard->NbRxDataToProcess = ((uint16_t)rx_fifo_depth * numerator[rx_fifo_threshold]) / (uint16_t)denominator[rx_fifo_threshold];
477  }
478 }