2 ******************************************************************************
3 * @file stm32f3xx_hal_smartcard_ex.h
4 * @author MCD Application Team
5 * @brief Header file of SMARTCARD HAL Extended module.
6 ******************************************************************************
9 * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
11 * Redistribution and use in source and binary forms, with or without modification,
12 * are permitted provided that the following conditions are met:
13 * 1. Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 * 3. Neither the name of STMicroelectronics nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 ******************************************************************************
36 /* Define to prevent recursive inclusion -------------------------------------*/
37 #ifndef __STM32F3xx_HAL_SMARTCARD_EX_H
38 #define __STM32F3xx_HAL_SMARTCARD_EX_H
44 /* Includes ------------------------------------------------------------------*/
45 #include "stm32f3xx_hal_def.h"
47 /** @addtogroup STM32F3xx_HAL_Driver
51 /** @addtogroup SMARTCARDEx
55 /* Exported types ------------------------------------------------------------*/
56 /* Exported constants --------------------------------------------------------*/
57 /* Exported macros -----------------------------------------------------------*/
58 /* Private macros ------------------------------------------------------------*/
59 /** @defgroup SMARTCARDEx_Private_Macros SMARTCARD Extended Private Macros
63 /** @brief Report the SMARTCARD clock source.
64 * @param __HANDLE__ specifies the SMARTCARD Handle.
65 * @param __CLOCKSOURCE__ output variable.
66 * @retval the SMARTCARD clocking source, written in __CLOCKSOURCE__.
68 #if defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx) || \
69 defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
70 #define SMARTCARD_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
72 if((__HANDLE__)->Instance == USART1) \
74 switch(__HAL_RCC_GET_USART1_SOURCE()) \
76 case RCC_USART1CLKSOURCE_PCLK1: \
77 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
79 case RCC_USART1CLKSOURCE_HSI: \
80 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
82 case RCC_USART1CLKSOURCE_SYSCLK: \
83 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
85 case RCC_USART1CLKSOURCE_LSE: \
86 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
89 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
93 else if((__HANDLE__)->Instance == USART2) \
95 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
97 else if((__HANDLE__)->Instance == USART3) \
99 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
103 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
107 #define SMARTCARD_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
109 if((__HANDLE__)->Instance == USART1) \
111 switch(__HAL_RCC_GET_USART1_SOURCE()) \
113 case RCC_USART1CLKSOURCE_PCLK2: \
114 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK2; \
116 case RCC_USART1CLKSOURCE_HSI: \
117 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
119 case RCC_USART1CLKSOURCE_SYSCLK: \
120 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
122 case RCC_USART1CLKSOURCE_LSE: \
123 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
126 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
130 else if((__HANDLE__)->Instance == USART2) \
132 switch(__HAL_RCC_GET_USART2_SOURCE()) \
134 case RCC_USART2CLKSOURCE_PCLK1: \
135 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
137 case RCC_USART2CLKSOURCE_HSI: \
138 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
140 case RCC_USART2CLKSOURCE_SYSCLK: \
141 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
143 case RCC_USART2CLKSOURCE_LSE: \
144 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
147 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
151 else if((__HANDLE__)->Instance == USART3) \
153 switch(__HAL_RCC_GET_USART3_SOURCE()) \
155 case RCC_USART3CLKSOURCE_PCLK1: \
156 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
158 case RCC_USART3CLKSOURCE_HSI: \
159 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
161 case RCC_USART3CLKSOURCE_SYSCLK: \
162 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
164 case RCC_USART3CLKSOURCE_LSE: \
165 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
168 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
174 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
183 /* Exported functions --------------------------------------------------------*/
184 /** @addtogroup SMARTCARDEx_Exported_Functions
188 /* Initialization and de-initialization functions ****************************/
189 /* IO operation methods *******************************************************/
191 /** @addtogroup SMARTCARDEx_Exported_Functions_Group1
195 /* Peripheral Control functions ***********************************************/
196 void HAL_SMARTCARDEx_BlockLength_Config(SMARTCARD_HandleTypeDef
*hsmartcard
, uint8_t BlockLength
);
197 void HAL_SMARTCARDEx_TimeOut_Config(SMARTCARD_HandleTypeDef
*hsmartcard
, uint32_t TimeOutValue
);
198 HAL_StatusTypeDef
HAL_SMARTCARDEx_EnableReceiverTimeOut(SMARTCARD_HandleTypeDef
*hsmartcard
);
199 HAL_StatusTypeDef
HAL_SMARTCARDEx_DisableReceiverTimeOut(SMARTCARD_HandleTypeDef
*hsmartcard
);
221 #endif /* __STM32F3xx_HAL_SMARTCARD_EX_H */
223 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/