Initialization and Configuration functions.
More...
Initialization and Configuration functions.
==============================================================================
##### Initialization and Configuration functions #####
==============================================================================
[..]
This subsection provides a set of functions allowing to initialize the USARTx
associated to the SmartCard.
(+) These parameters can be configured:
(++) Baud Rate
(++) Parity: parity should be enabled, frame Length is fixed to 8 bits plus parity
(++) Receiver/transmitter modes
(++) Synchronous mode (and if enabled, phase, polarity and last bit parameters)
(++) Prescaler value
(++) Guard bit time
(++) NACK enabling or disabling on transmission error
(+) The following advanced features can be configured as well:
(++) TX and/or RX pin level inversion
(++) data logical level inversion
(++) RX and TX pins swap
(++) RX overrun detection disabling
(++) DMA disabling on RX error
(++) MSB first on communication line
(++) Time out enabling (and if activated, timeout value)
(++) Block length
(++) Auto-retry counter
[..]
The HAL_SMARTCARD_Init() API follows the USART synchronous configuration procedures
(details for the procedures are available in reference manual).The USART frame format is given in the following table:
Table 1. USART frame format. +------------------------------------------------------------—+ | M1M0 bits | PCE bit | USART frame | |--------------------—|------------------------------------—| | 01 | 1 | | SB | 8 bit data | PB | STB | | +------------------------------------------------------------—+
◆ HAL_SMARTCARD_DeInit()
DeInitialize the SMARTCARD peripheral.
- Parameters
-
| hsmartcard | Pointer to a SMARTCARD_HandleTypeDef structure that contains the configuration information for the specified SMARTCARD module. |
- Return values
-
Definition at line 402 of file stm32l4xx_hal_smartcard.c.
405 if (hsmartcard == NULL)
413 hsmartcard->
gState = HAL_SMARTCARD_STATE_BUSY;
418 WRITE_REG(hsmartcard->
Instance->CR1, 0x0U);
419 WRITE_REG(hsmartcard->
Instance->CR2, 0x0U);
420 WRITE_REG(hsmartcard->
Instance->CR3, 0x0U);
421 WRITE_REG(hsmartcard->
Instance->RTOR, 0x0U);
422 WRITE_REG(hsmartcard->
Instance->GTPR, 0x0U);
425 #if USE_HAL_SMARTCARD_REGISTER_CALLBACKS == 1 436 hsmartcard->
ErrorCode = HAL_SMARTCARD_ERROR_NONE;
437 hsmartcard->
gState = HAL_SMARTCARD_STATE_RESET;
438 hsmartcard->
RxState = HAL_SMARTCARD_STATE_RESET;
void HAL_SMARTCARD_MspDeInit(SMARTCARD_HandleTypeDef *hsmartcard)
DeInitialize the SMARTCARD MSP.
__IO HAL_SMARTCARD_StateTypeDef gState
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
void(* MspDeInitCallback)(struct __SMARTCARD_HandleTypeDef *hsmartcard)
__IO HAL_SMARTCARD_StateTypeDef RxState
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))
◆ HAL_SMARTCARD_Init()
Initialize the SMARTCARD mode according to the specified parameters in the SMARTCARD_HandleTypeDef and initialize the associated handle.
- Parameters
-
| hsmartcard | Pointer to a SMARTCARD_HandleTypeDef structure that contains the configuration information for the specified SMARTCARD module. |
- Return values
-
Definition at line 329 of file stm32l4xx_hal_smartcard.c.
332 if (hsmartcard == NULL)
340 if (hsmartcard->
gState == HAL_SMARTCARD_STATE_RESET)
345 #if USE_HAL_SMARTCARD_REGISTER_CALLBACKS == 1 361 hsmartcard->
gState = HAL_SMARTCARD_STATE_BUSY;
373 SET_BIT(hsmartcard->
Instance->CR3, USART_CR3_SCEN);
382 SMARTCARD_TRANSMISSION_COMPLETION_SETTING(hsmartcard);
390 SET_BIT(hsmartcard->
Instance->CR1, USART_CR1_UE);
static void SMARTCARD_AdvFeatureConfig(SMARTCARD_HandleTypeDef *hsmartcard)
Configure the SMARTCARD associated USART peripheral advanced features.
static HAL_StatusTypeDef SMARTCARD_SetConfig(SMARTCARD_HandleTypeDef *hsmartcard)
Configure the SMARTCARD associated USART peripheral.
__IO HAL_SMARTCARD_StateTypeDef gState
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
void HAL_SMARTCARD_MspInit(SMARTCARD_HandleTypeDef *hsmartcard)
Initialize the SMARTCARD MSP.
void SMARTCARD_InitCallbacksToDefault(SMARTCARD_HandleTypeDef *hsmartcard)
Initialize the callbacks to their default values.
SMARTCARD_AdvFeatureInitTypeDef AdvancedInit
void(* MspInitCallback)(struct __SMARTCARD_HandleTypeDef *hsmartcard)
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))
static HAL_StatusTypeDef SMARTCARD_CheckIdleState(SMARTCARD_HandleTypeDef *hsmartcard)
Check the SMARTCARD Idle State.
◆ HAL_SMARTCARD_MspDeInit()
DeInitialize the SMARTCARD MSP.
- Parameters
-
| hsmartcard | Pointer to a SMARTCARD_HandleTypeDef structure that contains the configuration information for the specified SMARTCARD module. |
- Return values
-
Definition at line 468 of file stm32l4xx_hal_smartcard.c.
◆ HAL_SMARTCARD_MspInit()
Initialize the SMARTCARD MSP.
- Parameters
-
| hsmartcard | Pointer to a SMARTCARD_HandleTypeDef structure that contains the configuration information for the specified SMARTCARD module. |
- Return values
-
Definition at line 452 of file stm32l4xx_hal_smartcard.c.
◆ HAL_SMARTCARD_RegisterCallback()
Register a User SMARTCARD Callback To be used instead of the weak predefined callback.
- Parameters
-
| hsmartcard | smartcard handle |
| CallbackID | ID of the callback to be registered This parameter can be one of the following values:
|
| pCallback | pointer to the Callback function |
- Return values
-
Definition at line 498 of file stm32l4xx_hal_smartcard.c.
501 HAL_StatusTypeDef status =
HAL_OK;
503 if (pCallback == NULL)
506 hsmartcard->
ErrorCode |= HAL_SMARTCARD_ERROR_INVALID_CALLBACK;
513 if (hsmartcard->
gState == HAL_SMARTCARD_STATE_READY)
542 #if defined(USART_CR1_FIFOEN) 562 hsmartcard->
ErrorCode |= HAL_SMARTCARD_ERROR_INVALID_CALLBACK;
569 else if (hsmartcard->
gState == HAL_SMARTCARD_STATE_RESET)
583 hsmartcard->
ErrorCode |= HAL_SMARTCARD_ERROR_INVALID_CALLBACK;
593 hsmartcard->
ErrorCode |= HAL_SMARTCARD_ERROR_INVALID_CALLBACK;
void(* TxCpltCallback)(struct __SMARTCARD_HandleTypeDef *hsmartcard)
void(* AbortTransmitCpltCallback)(struct __SMARTCARD_HandleTypeDef *hsmartcard)
__IO HAL_SMARTCARD_StateTypeDef gState
void(* TxFifoEmptyCallback)(struct __SMARTCARD_HandleTypeDef *hsmartcard)
void(* AbortReceiveCpltCallback)(struct __SMARTCARD_HandleTypeDef *hsmartcard)
void(* ErrorCallback)(struct __SMARTCARD_HandleTypeDef *hsmartcard)
void(* MspInitCallback)(struct __SMARTCARD_HandleTypeDef *hsmartcard)
void(* MspDeInitCallback)(struct __SMARTCARD_HandleTypeDef *hsmartcard)
void(* RxCpltCallback)(struct __SMARTCARD_HandleTypeDef *hsmartcard)
void(* RxFifoFullCallback)(struct __SMARTCARD_HandleTypeDef *hsmartcard)
void(* AbortCpltCallback)(struct __SMARTCARD_HandleTypeDef *hsmartcard)
◆ HAL_SMARTCARD_UnRegisterCallback()
Unregister an SMARTCARD callback SMARTCARD callback is redirected to the weak predefined callback.
- Parameters
-
| hsmartcard | smartcard handle |
| CallbackID | ID of the callback to be unregistered This parameter can be one of the following values:
|
- Return values
-
Definition at line 623 of file stm32l4xx_hal_smartcard.c.
626 HAL_StatusTypeDef status =
HAL_OK;
631 if (HAL_SMARTCARD_STATE_READY == hsmartcard->
gState)
659 #if defined(USART_CR1_FIFOEN) 679 hsmartcard->
ErrorCode |= HAL_SMARTCARD_ERROR_INVALID_CALLBACK;
686 else if (HAL_SMARTCARD_STATE_RESET == hsmartcard->
gState)
700 hsmartcard->
ErrorCode |= HAL_SMARTCARD_ERROR_INVALID_CALLBACK;
710 hsmartcard->
ErrorCode |= HAL_SMARTCARD_ERROR_INVALID_CALLBACK;
void(* TxCpltCallback)(struct __SMARTCARD_HandleTypeDef *hsmartcard)
void HAL_SMARTCARD_MspDeInit(SMARTCARD_HandleTypeDef *hsmartcard)
DeInitialize the SMARTCARD MSP.
void(* AbortTransmitCpltCallback)(struct __SMARTCARD_HandleTypeDef *hsmartcard)
__IO HAL_SMARTCARD_StateTypeDef gState
void(* TxFifoEmptyCallback)(struct __SMARTCARD_HandleTypeDef *hsmartcard)
void HAL_SMARTCARDEx_TxFifoEmptyCallback(SMARTCARD_HandleTypeDef *hsmartcard)
SMARTCARD TX Fifo empty callback.
void HAL_SMARTCARD_RxCpltCallback(SMARTCARD_HandleTypeDef *hsmartcard)
Rx Transfer completed callback.
void HAL_SMARTCARD_ErrorCallback(SMARTCARD_HandleTypeDef *hsmartcard)
SMARTCARD error callback.
void HAL_SMARTCARD_MspInit(SMARTCARD_HandleTypeDef *hsmartcard)
Initialize the SMARTCARD MSP.
void HAL_SMARTCARD_AbortCpltCallback(SMARTCARD_HandleTypeDef *hsmartcard)
SMARTCARD Abort Complete callback.
void(* AbortReceiveCpltCallback)(struct __SMARTCARD_HandleTypeDef *hsmartcard)
void(* ErrorCallback)(struct __SMARTCARD_HandleTypeDef *hsmartcard)
void HAL_SMARTCARD_AbortReceiveCpltCallback(SMARTCARD_HandleTypeDef *hsmartcard)
SMARTCARD Abort Receive Complete callback.
void(* MspInitCallback)(struct __SMARTCARD_HandleTypeDef *hsmartcard)
void HAL_SMARTCARDEx_RxFifoFullCallback(SMARTCARD_HandleTypeDef *hsmartcard)
SMARTCARD RX Fifo full callback.
void(* MspDeInitCallback)(struct __SMARTCARD_HandleTypeDef *hsmartcard)
void(* RxCpltCallback)(struct __SMARTCARD_HandleTypeDef *hsmartcard)
void HAL_SMARTCARD_AbortTransmitCpltCallback(SMARTCARD_HandleTypeDef *hsmartcard)
SMARTCARD Abort Complete callback.
void(* RxFifoFullCallback)(struct __SMARTCARD_HandleTypeDef *hsmartcard)
void HAL_SMARTCARD_TxCpltCallback(SMARTCARD_HandleTypeDef *hsmartcard)
Tx Transfer completed callback.
void(* AbortCpltCallback)(struct __SMARTCARD_HandleTypeDef *hsmartcard)