2 ******************************************************************************
\r
3 * @file stm32f7xx_hal_smartcard_ex.c
\r
4 * @author MCD Application Team
\r
6 * @date 24-March-2015
\r
7 * @brief SMARTCARD HAL module driver.
\r
9 * This file provides extended firmware functions to manage the following
\r
10 * functionalities of the SmartCard.
\r
11 * + Initialization and de-initialization functions
\r
12 * + Peripheral Control functions
\r
14 ===============================================================================
\r
15 ##### How to use this driver #####
\r
16 ===============================================================================
\r
18 The Extended SMARTCARD HAL driver can be used as follow:
\r
20 (#) After having configured the SMARTCARD basic features with HAL_SMARTCARD_Init(),
\r
21 then if required, program SMARTCARD advanced features (TX/RX pins swap, TimeOut,
\r
22 auto-retry counter,...) in the hsc AdvancedInit structure.
\r
25 ******************************************************************************
\r
28 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
\r
30 * Redistribution and use in source and binary forms, with or without modification,
\r
31 * are permitted provided that the following conditions are met:
\r
32 * 1. Redistributions of source code must retain the above copyright notice,
\r
33 * this list of conditions and the following disclaimer.
\r
34 * 2. Redistributions in binary form must reproduce the above copyright notice,
\r
35 * this list of conditions and the following disclaimer in the documentation
\r
36 * and/or other materials provided with the distribution.
\r
37 * 3. Neither the name of STMicroelectronics nor the names of its contributors
\r
38 * may be used to endorse or promote products derived from this software
\r
39 * without specific prior written permission.
\r
41 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
\r
42 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\r
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
\r
44 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
\r
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
\r
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
\r
47 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
\r
48 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
\r
49 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
\r
50 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
52 ******************************************************************************
\r
55 /* Includes ------------------------------------------------------------------*/
\r
56 #include "stm32f7xx_hal.h"
\r
58 /** @addtogroup STM32F7xx_HAL_Driver
\r
62 /** @defgroup SMARTCARDEx SMARTCARDEx
\r
63 * @brief SMARTCARD Extended HAL module driver
\r
66 #ifdef HAL_SMARTCARD_MODULE_ENABLED
\r
68 /* Private typedef -----------------------------------------------------------*/
\r
69 /* Private define ------------------------------------------------------------*/
\r
70 /* Private macro -------------------------------------------------------------*/
\r
71 /* Private variables ---------------------------------------------------------*/
\r
72 /* Private function prototypes -----------------------------------------------*/
\r
73 /* Private functions ---------------------------------------------------------*/
\r
75 /** @defgroup SMARTCARDEx_Private_Functions
\r
79 /** @defgroup SMARTCARDEx_Group1 Extended Peripheral Control functions
\r
80 * @brief Extended control functions
\r
83 ===============================================================================
\r
84 ##### Peripheral Control functions #####
\r
85 ===============================================================================
\r
87 This subsection provides a set of functions allowing to initialize the SMARTCARD.
\r
88 (+) HAL_SMARTCARDEx_BlockLength_Config() API allows to configure the Block Length on the fly
\r
89 (+) HAL_SMARTCARDEx_TimeOut_Config() API allows to configure the receiver timeout value on the fly
\r
90 (+) HAL_SMARTCARDEx_EnableReceiverTimeOut() API enables the receiver timeout feature
\r
91 (+) HAL_SMARTCARDEx_DisableReceiverTimeOut() API disables the receiver timeout feature
\r
98 * @brief Update on the fly the SMARTCARD block length in RTOR register
\r
99 * @param hsc: SMARTCARD handle
\r
100 * @param BlockLength: SMARTCARD block length (8-bit long at most)
\r
103 void HAL_SMARTCARDEx_BlockLength_Config(SMARTCARD_HandleTypeDef *hsc, uint8_t BlockLength)
\r
105 MODIFY_REG(hsc->Instance->RTOR, USART_RTOR_BLEN, ((uint32_t)BlockLength << SMARTCARD_RTOR_BLEN_LSB_POS));
\r
109 * @brief Update on the fly the receiver timeout value in RTOR register
\r
110 * @param hsc: SMARTCARD handle
\r
111 * @param TimeOutValue: receiver timeout value in number of baud blocks. The timeout
\r
112 * value must be less or equal to 0x0FFFFFFFF.
\r
115 void HAL_SMARTCARDEx_TimeOut_Config(SMARTCARD_HandleTypeDef *hsc, uint32_t TimeOutValue)
\r
117 assert_param(IS_SMARTCARD_TIMEOUT_VALUE(hsc->Init.TimeOutValue));
\r
118 MODIFY_REG(hsc->Instance->RTOR, USART_RTOR_RTO, TimeOutValue);
\r
122 * @brief Enable the SMARTCARD receiver timeout feature
\r
123 * @param hsc: SMARTCARD handle
\r
124 * @retval HAL status
\r
126 HAL_StatusTypeDef HAL_SMARTCARDEx_EnableReceiverTimeOut(SMARTCARD_HandleTypeDef *hsc)
\r
128 /* Process Locked */
\r
131 hsc->State = HAL_SMARTCARD_STATE_BUSY;
\r
133 /* Set the USART RTOEN bit */
\r
134 hsc->Instance->CR2 |= USART_CR2_RTOEN;
\r
136 hsc->State = HAL_SMARTCARD_STATE_READY;
\r
138 /* Process Unlocked */
\r
145 * @brief Disable the SMARTCARD receiver timeout feature
\r
146 * @param hsc: SMARTCARD handle
\r
147 * @retval HAL status
\r
149 HAL_StatusTypeDef HAL_SMARTCARDEx_DisableReceiverTimeOut(SMARTCARD_HandleTypeDef *hsc)
\r
151 /* Process Locked */
\r
154 hsc->State = HAL_SMARTCARD_STATE_BUSY;
\r
156 /* Clear the USART RTOEN bit */
\r
157 hsc->Instance->CR2 &= ~(USART_CR2_RTOEN);
\r
159 hsc->State = HAL_SMARTCARD_STATE_READY;
\r
161 /* Process Unlocked */
\r
175 #endif /* HAL_SMARTCARD_MODULE_ENABLED */
\r
184 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\r