2 ******************************************************************************
3 * @file stm32f0xx_hal_smartcard_ex.h
4 * @author MCD Application Team
6 * @date 11-December-2014
7 * @brief Header file of SMARTCARD HAL module.
8 ******************************************************************************
11 * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
13 * Redistribution and use in source and binary forms, with or without modification,
14 * are permitted provided that the following conditions are met:
15 * 1. Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 ******************************************************************************
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F0xx_HAL_SMARTCARD_EX_H
40 #define __STM32F0xx_HAL_SMARTCARD_EX_H
46 #if !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC)
48 /* Includes ------------------------------------------------------------------*/
49 #include "stm32f0xx_hal_def.h"
51 /** @addtogroup STM32F0xx_HAL_Driver
55 /** @addtogroup SMARTCARDEx
59 /* Exported types ------------------------------------------------------------*/
60 /* Exported constants --------------------------------------------------------*/
61 /* Exported macro ------------------------------------------------------------*/
63 /** @defgroup SMARTCARD_Extended_Exported_Macros SMARTCARDEx Exported Macros
67 /** @brief Reports the SMARTCARD clock source.
68 * @param __HANDLE__: specifies the SMARTCARD Handle
69 * @param __CLOCKSOURCE__ : output variable
70 * @retval the SMARTCARD clocking source, written in __CLOCKSOURCE__.
72 #if defined(STM32F031x6) || defined(STM32F038xx)
73 #define __HAL_SMARTCARD_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
75 switch(__HAL_RCC_GET_USART1_SOURCE()) \
77 case RCC_USART1CLKSOURCE_PCLK1: \
78 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
80 case RCC_USART1CLKSOURCE_HSI: \
81 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
83 case RCC_USART1CLKSOURCE_SYSCLK: \
84 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
86 case RCC_USART1CLKSOURCE_LSE: \
87 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
90 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
94 #elif defined (STM32F030x8) || \
95 defined (STM32F042x6) || defined (STM32F048xx) || \
96 defined (STM32F051x8) || defined (STM32F058xx)
97 #define __HAL_SMARTCARD_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
99 if((__HANDLE__)->Instance == USART1) \
101 switch(__HAL_RCC_GET_USART1_SOURCE()) \
103 case RCC_USART1CLKSOURCE_PCLK1: \
104 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
106 case RCC_USART1CLKSOURCE_HSI: \
107 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
109 case RCC_USART1CLKSOURCE_SYSCLK: \
110 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
112 case RCC_USART1CLKSOURCE_LSE: \
113 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
116 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
120 else if((__HANDLE__)->Instance == USART2) \
122 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
126 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
129 #elif defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx)
130 #define __HAL_SMARTCARD_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
132 if((__HANDLE__)->Instance == USART1) \
134 switch(__HAL_RCC_GET_USART1_SOURCE()) \
136 case RCC_USART1CLKSOURCE_PCLK1: \
137 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
139 case RCC_USART1CLKSOURCE_HSI: \
140 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
142 case RCC_USART1CLKSOURCE_SYSCLK: \
143 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
145 case RCC_USART1CLKSOURCE_LSE: \
146 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
149 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
153 else if((__HANDLE__)->Instance == USART2) \
155 switch(__HAL_RCC_GET_USART2_SOURCE()) \
157 case RCC_USART2CLKSOURCE_PCLK1: \
158 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
160 case RCC_USART2CLKSOURCE_HSI: \
161 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
163 case RCC_USART2CLKSOURCE_SYSCLK: \
164 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
166 case RCC_USART2CLKSOURCE_LSE: \
167 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
170 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
174 else if((__HANDLE__)->Instance == USART3) \
176 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
178 else if((__HANDLE__)->Instance == USART4) \
180 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
184 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
187 #elif defined(STM32F091xC) || defined(STM32F098xx)
188 #define __HAL_SMARTCARD_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
190 if((__HANDLE__)->Instance == USART1) \
192 switch(__HAL_RCC_GET_USART1_SOURCE()) \
194 case RCC_USART1CLKSOURCE_PCLK1: \
195 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
197 case RCC_USART1CLKSOURCE_HSI: \
198 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
200 case RCC_USART1CLKSOURCE_SYSCLK: \
201 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
203 case RCC_USART1CLKSOURCE_LSE: \
204 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
207 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
211 else if((__HANDLE__)->Instance == USART2) \
213 switch(__HAL_RCC_GET_USART2_SOURCE()) \
215 case RCC_USART2CLKSOURCE_PCLK1: \
216 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
218 case RCC_USART2CLKSOURCE_HSI: \
219 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
221 case RCC_USART2CLKSOURCE_SYSCLK: \
222 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
224 case RCC_USART2CLKSOURCE_LSE: \
225 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
228 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
232 else if((__HANDLE__)->Instance == USART3) \
234 switch(__HAL_RCC_GET_USART3_SOURCE()) \
236 case RCC_USART3CLKSOURCE_PCLK1: \
237 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
239 case RCC_USART3CLKSOURCE_HSI: \
240 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
242 case RCC_USART3CLKSOURCE_SYSCLK: \
243 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
245 case RCC_USART3CLKSOURCE_LSE: \
246 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
249 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
253 else if((__HANDLE__)->Instance == USART4) \
255 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
257 else if((__HANDLE__)->Instance == USART5) \
259 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
261 else if((__HANDLE__)->Instance == USART6) \
263 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
265 else if((__HANDLE__)->Instance == USART7) \
267 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
269 else if((__HANDLE__)->Instance == USART8) \
271 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
275 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
278 #endif /* defined(STM32F031x6) || defined(STM32F038xx) */
284 /* Exported functions --------------------------------------------------------*/
286 /* Initialization and de-initialization functions ****************************/
287 /* IO operation functions *****************************************************/
289 /** @addtogroup SMARTCARDEx_Exported_Functions
293 /** @addtogroup SMARTCARDEx_Exported_Functions_Group1
297 /* Peripheral Control functions ***********************************************/
298 void HAL_SMARTCARDEx_BlockLength_Config(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t BlockLength);
299 void HAL_SMARTCARDEx_TimeOut_Config(SMARTCARD_HandleTypeDef *hsmartcard, uint32_t TimeOutValue);
300 HAL_StatusTypeDef HAL_SMARTCARDEx_EnableReceiverTimeOut(SMARTCARD_HandleTypeDef *hsmartcard);
301 HAL_StatusTypeDef HAL_SMARTCARDEx_DisableReceiverTimeOut(SMARTCARD_HandleTypeDef *hsmartcard);
303 /* Peripheral State and Error functions ***************************************/
321 #endif /* !defined(STM32F030x6) && !defined(STM32F030x8)&& !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) */
327 #endif /* __STM32F0xx_HAL_SMARTCARD_EX_H */
329 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/