STM32L4xx_HAL_Driver  1.14.0
Extended Peripheral Peripheral Control functions

SMARTCARD control functions. More...

Functions

HAL_StatusTypeDef HAL_SMARTCARDEx_EnableFifoMode (SMARTCARD_HandleTypeDef *hsmartcard)
 Enable the FIFO mode. More...
 
HAL_StatusTypeDef HAL_SMARTCARDEx_DisableFifoMode (SMARTCARD_HandleTypeDef *hsmartcard)
 Disable the FIFO mode. More...
 
HAL_StatusTypeDef HAL_SMARTCARDEx_SetTxFifoThreshold (SMARTCARD_HandleTypeDef *hsmartcard, uint32_t Threshold)
 Set the TXFIFO threshold. More...
 
HAL_StatusTypeDef HAL_SMARTCARDEx_SetRxFifoThreshold (SMARTCARD_HandleTypeDef *hsmartcard, uint32_t Threshold)
 Set the RXFIFO threshold. More...
 

Detailed Description

SMARTCARD control functions.

 ===============================================================================
                      ##### Peripheral Control functions #####
 ===============================================================================
    [..]
    This subsection provides a set of functions allowing to control the SMARTCARD.
     (+) HAL_SMARTCARDEx_EnableFifoMode() API enables the FIFO mode
     (+) HAL_SMARTCARDEx_DisableFifoMode() API disables the FIFO mode
     (+) HAL_SMARTCARDEx_SetTxFifoThreshold() API sets the TX FIFO threshold
     (+) HAL_SMARTCARDEx_SetRxFifoThreshold() API sets the RX FIFO threshold

Function Documentation

◆ HAL_SMARTCARDEx_DisableFifoMode()

HAL_StatusTypeDef HAL_SMARTCARDEx_DisableFifoMode ( SMARTCARD_HandleTypeDef hsmartcard)

Disable the FIFO mode.

Parameters
hsmartcardSMARTCARD handle.
Return values
HALstatus

Definition at line 302 of file stm32l4xx_hal_smartcard_ex.c.

303 {
304  uint32_t tmpcr1;
305 
306  /* Check parameters */
307  assert_param(IS_UART_FIFO_INSTANCE(hsmartcard->Instance));
308 
309  /* Process Locked */
310  __HAL_LOCK(hsmartcard);
311 
312  hsmartcard->gState = HAL_SMARTCARD_STATE_BUSY;
313 
314  /* Save actual SMARTCARD configuration */
315  tmpcr1 = READ_REG(hsmartcard->Instance->CR1);
316 
317  /* Disable SMARTCARD */
318  __HAL_SMARTCARD_DISABLE(hsmartcard);
319 
320  /* Enable FIFO mode */
321  CLEAR_BIT(tmpcr1, USART_CR1_FIFOEN);
322  hsmartcard->FifoMode = SMARTCARD_FIFOMODE_DISABLE;
323 
324  /* Restore SMARTCARD configuration */
325  WRITE_REG(hsmartcard->Instance->CR1, tmpcr1);
326 
327  hsmartcard->gState = HAL_SMARTCARD_STATE_READY;
328 
329  /* Process Unlocked */
330  __HAL_UNLOCK(hsmartcard);
331 
332  return HAL_OK;
333 }
__IO HAL_SMARTCARD_StateTypeDef gState
__HAL_UNLOCK(hrtc)
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
__HAL_LOCK(hrtc)
return HAL_OK
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_SMARTCARDEx_EnableFifoMode()

HAL_StatusTypeDef HAL_SMARTCARDEx_EnableFifoMode ( SMARTCARD_HandleTypeDef hsmartcard)

Enable the FIFO mode.

Parameters
hsmartcardSMARTCARD handle.
Return values
HALstatus

Definition at line 261 of file stm32l4xx_hal_smartcard_ex.c.

262 {
263  uint32_t tmpcr1;
264 
265  /* Check parameters */
266  assert_param(IS_UART_FIFO_INSTANCE(hsmartcard->Instance));
267 
268  /* Process Locked */
269  __HAL_LOCK(hsmartcard);
270 
271  hsmartcard->gState = HAL_SMARTCARD_STATE_BUSY;
272 
273  /* Save actual SMARTCARD configuration */
274  tmpcr1 = READ_REG(hsmartcard->Instance->CR1);
275 
276  /* Disable SMARTCARD */
277  __HAL_SMARTCARD_DISABLE(hsmartcard);
278 
279  /* Enable FIFO mode */
280  SET_BIT(tmpcr1, USART_CR1_FIFOEN);
281  hsmartcard->FifoMode = SMARTCARD_FIFOMODE_ENABLE;
282 
283  /* Restore SMARTCARD configuration */
284  WRITE_REG(hsmartcard->Instance->CR1, tmpcr1);
285 
286  /* Determine the number of data to process during RX/TX ISR execution */
287  SMARTCARDEx_SetNbDataToProcess(hsmartcard);
288 
289  hsmartcard->gState = HAL_SMARTCARD_STATE_READY;
290 
291  /* Process Unlocked */
292  __HAL_UNLOCK(hsmartcard);
293 
294  return HAL_OK;
295 }
__IO HAL_SMARTCARD_StateTypeDef gState
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
static void SMARTCARDEx_SetNbDataToProcess(SMARTCARD_HandleTypeDef *hsmartcard)
Calculate the number of data to process in RX/TX ISR.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_SMARTCARDEx_SetRxFifoThreshold()

HAL_StatusTypeDef HAL_SMARTCARDEx_SetRxFifoThreshold ( SMARTCARD_HandleTypeDef hsmartcard,
uint32_t  Threshold 
)

Set the RXFIFO threshold.

Parameters
hsmartcardSMARTCARD handle.
ThresholdRX FIFO threshold value This parameter can be one of the following values:
  • SMARTCARD_RXFIFO_THRESHOLD_1_8
  • SMARTCARD_RXFIFO_THRESHOLD_1_4
  • SMARTCARD_RXFIFO_THRESHOLD_1_2
  • SMARTCARD_RXFIFO_THRESHOLD_3_4
  • SMARTCARD_RXFIFO_THRESHOLD_7_8
  • SMARTCARD_RXFIFO_THRESHOLD_8_8
Return values
HALstatus

Definition at line 397 of file stm32l4xx_hal_smartcard_ex.c.

398 {
399  uint32_t tmpcr1;
400 
401  /* Check parameters */
402  assert_param(IS_UART_FIFO_INSTANCE(hsmartcard->Instance));
403  assert_param(IS_SMARTCARD_RXFIFO_THRESHOLD(Threshold));
404 
405  /* Process Locked */
406  __HAL_LOCK(hsmartcard);
407 
408  hsmartcard->gState = HAL_SMARTCARD_STATE_BUSY;
409 
410  /* Save actual SMARTCARD configuration */
411  tmpcr1 = READ_REG(hsmartcard->Instance->CR1);
412 
413  /* Disable SMARTCARD */
414  __HAL_SMARTCARD_DISABLE(hsmartcard);
415 
416  /* Update RX threshold configuration */
417  MODIFY_REG(hsmartcard->Instance->CR3, USART_CR3_RXFTCFG, Threshold);
418 
419  /* Determine the number of data to process during RX/TX ISR execution */
420  SMARTCARDEx_SetNbDataToProcess(hsmartcard);
421 
422  /* Restore SMARTCARD configuration */
423  MODIFY_REG(hsmartcard->Instance->CR1, USART_CR1_UE, tmpcr1);
424 
425  hsmartcard->gState = HAL_SMARTCARD_STATE_READY;
426 
427  /* Process Unlocked */
428  __HAL_UNLOCK(hsmartcard);
429 
430  return HAL_OK;
431 }
__IO HAL_SMARTCARD_StateTypeDef gState
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
static void SMARTCARDEx_SetNbDataToProcess(SMARTCARD_HandleTypeDef *hsmartcard)
Calculate the number of data to process in RX/TX ISR.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_SMARTCARDEx_SetTxFifoThreshold()

HAL_StatusTypeDef HAL_SMARTCARDEx_SetTxFifoThreshold ( SMARTCARD_HandleTypeDef hsmartcard,
uint32_t  Threshold 
)

Set the TXFIFO threshold.

Parameters
hsmartcardSMARTCARD handle.
ThresholdTX FIFO threshold value This parameter can be one of the following values:
  • SMARTCARD_TXFIFO_THRESHOLD_1_8
  • SMARTCARD_TXFIFO_THRESHOLD_1_4
  • SMARTCARD_TXFIFO_THRESHOLD_1_2
  • SMARTCARD_TXFIFO_THRESHOLD_3_4
  • SMARTCARD_TXFIFO_THRESHOLD_7_8
  • SMARTCARD_TXFIFO_THRESHOLD_8_8
Return values
HALstatus

Definition at line 348 of file stm32l4xx_hal_smartcard_ex.c.

349 {
350  uint32_t tmpcr1;
351 
352  /* Check parameters */
353  assert_param(IS_UART_FIFO_INSTANCE(hsmartcard->Instance));
354  assert_param(IS_SMARTCARD_TXFIFO_THRESHOLD(Threshold));
355 
356  /* Process Locked */
357  __HAL_LOCK(hsmartcard);
358 
359  hsmartcard->gState = HAL_SMARTCARD_STATE_BUSY;
360 
361  /* Save actual SMARTCARD configuration */
362  tmpcr1 = READ_REG(hsmartcard->Instance->CR1);
363 
364  /* Disable SMARTCARD */
365  __HAL_SMARTCARD_DISABLE(hsmartcard);
366 
367  /* Update TX threshold configuration */
368  MODIFY_REG(hsmartcard->Instance->CR3, USART_CR3_TXFTCFG, Threshold);
369 
370  /* Determine the number of data to process during RX/TX ISR execution */
371  SMARTCARDEx_SetNbDataToProcess(hsmartcard);
372 
373  /* Restore SMARTCARD configuration */
374  MODIFY_REG(hsmartcard->Instance->CR1, USART_CR1_UE, tmpcr1);
375 
376  hsmartcard->gState = HAL_SMARTCARD_STATE_READY;
377 
378  /* Process Unlocked */
379  __HAL_UNLOCK(hsmartcard);
380 
381  return HAL_OK;
382 }
__IO HAL_SMARTCARD_StateTypeDef gState
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
static void SMARTCARDEx_SetNbDataToProcess(SMARTCARD_HandleTypeDef *hsmartcard)
Calculate the number of data to process in RX/TX ISR.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))