提交 | 用户 | age
|
bfc108
|
1 |
/**
|
Q |
2 |
******************************************************************************
|
|
3 |
* @file stm32f0xx_hal_smartcard_ex.h
|
|
4 |
* @author MCD Application Team
|
|
5 |
* @brief Header file of SMARTCARD HAL Extended module.
|
|
6 |
******************************************************************************
|
|
7 |
* @attention
|
|
8 |
*
|
|
9 |
* <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
|
|
10 |
*
|
|
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.
|
|
21 |
*
|
|
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.
|
|
32 |
*
|
|
33 |
******************************************************************************
|
|
34 |
*/
|
|
35 |
|
|
36 |
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
37 |
#ifndef __STM32F0xx_HAL_SMARTCARD_EX_H
|
|
38 |
#define __STM32F0xx_HAL_SMARTCARD_EX_H
|
|
39 |
|
|
40 |
#ifdef __cplusplus
|
|
41 |
extern "C" {
|
|
42 |
#endif
|
|
43 |
|
|
44 |
#if !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC)
|
|
45 |
|
|
46 |
/* Includes ------------------------------------------------------------------*/
|
|
47 |
#include "stm32f0xx_hal_def.h"
|
|
48 |
|
|
49 |
/** @addtogroup STM32F0xx_HAL_Driver
|
|
50 |
* @{
|
|
51 |
*/
|
|
52 |
|
|
53 |
/** @addtogroup SMARTCARDEx
|
|
54 |
* @{
|
|
55 |
*/
|
|
56 |
|
|
57 |
/* Exported types ------------------------------------------------------------*/
|
|
58 |
/* Exported constants --------------------------------------------------------*/
|
|
59 |
/* Exported macros -----------------------------------------------------------*/
|
|
60 |
/* Private macros ------------------------------------------------------------*/
|
|
61 |
/** @defgroup SMARTCARDEx_Private_Macros SMARTCARD Extended Private Macros
|
|
62 |
* @{
|
|
63 |
*/
|
|
64 |
|
|
65 |
/** @brief Report the SMARTCARD clock source.
|
|
66 |
* @param __HANDLE__ specifies the SMARTCARD Handle.
|
|
67 |
* @param __CLOCKSOURCE__ output variable.
|
|
68 |
* @retval the SMARTCARD clocking source, written in __CLOCKSOURCE__.
|
|
69 |
*/
|
|
70 |
#if defined(STM32F031x6) || defined(STM32F038xx)
|
|
71 |
#define SMARTCARD_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
|
|
72 |
do { \
|
|
73 |
switch(__HAL_RCC_GET_USART1_SOURCE()) \
|
|
74 |
{ \
|
|
75 |
case RCC_USART1CLKSOURCE_PCLK1: \
|
|
76 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
|
|
77 |
break; \
|
|
78 |
case RCC_USART1CLKSOURCE_HSI: \
|
|
79 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
|
|
80 |
break; \
|
|
81 |
case RCC_USART1CLKSOURCE_SYSCLK: \
|
|
82 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
|
|
83 |
break; \
|
|
84 |
case RCC_USART1CLKSOURCE_LSE: \
|
|
85 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
|
|
86 |
break; \
|
|
87 |
default: \
|
|
88 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
|
|
89 |
break; \
|
|
90 |
} \
|
|
91 |
} while(0)
|
|
92 |
#elif defined (STM32F030x8) || \
|
|
93 |
defined (STM32F042x6) || defined (STM32F048xx) || \
|
|
94 |
defined (STM32F051x8) || defined (STM32F058xx)
|
|
95 |
#define SMARTCARD_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
|
|
96 |
do { \
|
|
97 |
if((__HANDLE__)->Instance == USART1) \
|
|
98 |
{ \
|
|
99 |
switch(__HAL_RCC_GET_USART1_SOURCE()) \
|
|
100 |
{ \
|
|
101 |
case RCC_USART1CLKSOURCE_PCLK1: \
|
|
102 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
|
|
103 |
break; \
|
|
104 |
case RCC_USART1CLKSOURCE_HSI: \
|
|
105 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
|
|
106 |
break; \
|
|
107 |
case RCC_USART1CLKSOURCE_SYSCLK: \
|
|
108 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
|
|
109 |
break; \
|
|
110 |
case RCC_USART1CLKSOURCE_LSE: \
|
|
111 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
|
|
112 |
break; \
|
|
113 |
default: \
|
|
114 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
|
|
115 |
break; \
|
|
116 |
} \
|
|
117 |
} \
|
|
118 |
else if((__HANDLE__)->Instance == USART2) \
|
|
119 |
{ \
|
|
120 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
|
|
121 |
} \
|
|
122 |
else \
|
|
123 |
{ \
|
|
124 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
|
|
125 |
} \
|
|
126 |
} while(0)
|
|
127 |
#elif defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx)
|
|
128 |
#define SMARTCARD_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
|
|
129 |
do { \
|
|
130 |
if((__HANDLE__)->Instance == USART1) \
|
|
131 |
{ \
|
|
132 |
switch(__HAL_RCC_GET_USART1_SOURCE()) \
|
|
133 |
{ \
|
|
134 |
case RCC_USART1CLKSOURCE_PCLK1: \
|
|
135 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
|
|
136 |
break; \
|
|
137 |
case RCC_USART1CLKSOURCE_HSI: \
|
|
138 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
|
|
139 |
break; \
|
|
140 |
case RCC_USART1CLKSOURCE_SYSCLK: \
|
|
141 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
|
|
142 |
break; \
|
|
143 |
case RCC_USART1CLKSOURCE_LSE: \
|
|
144 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
|
|
145 |
break; \
|
|
146 |
default: \
|
|
147 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
|
|
148 |
break; \
|
|
149 |
} \
|
|
150 |
} \
|
|
151 |
else if((__HANDLE__)->Instance == USART2) \
|
|
152 |
{ \
|
|
153 |
switch(__HAL_RCC_GET_USART2_SOURCE()) \
|
|
154 |
{ \
|
|
155 |
case RCC_USART2CLKSOURCE_PCLK1: \
|
|
156 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
|
|
157 |
break; \
|
|
158 |
case RCC_USART2CLKSOURCE_HSI: \
|
|
159 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
|
|
160 |
break; \
|
|
161 |
case RCC_USART2CLKSOURCE_SYSCLK: \
|
|
162 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
|
|
163 |
break; \
|
|
164 |
case RCC_USART2CLKSOURCE_LSE: \
|
|
165 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
|
|
166 |
break; \
|
|
167 |
default: \
|
|
168 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
|
|
169 |
break; \
|
|
170 |
} \
|
|
171 |
} \
|
|
172 |
else if((__HANDLE__)->Instance == USART3) \
|
|
173 |
{ \
|
|
174 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
|
|
175 |
} \
|
|
176 |
else if((__HANDLE__)->Instance == USART4) \
|
|
177 |
{ \
|
|
178 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
|
|
179 |
} \
|
|
180 |
else \
|
|
181 |
{ \
|
|
182 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
|
|
183 |
} \
|
|
184 |
} while(0)
|
|
185 |
#elif defined(STM32F091xC) || defined(STM32F098xx)
|
|
186 |
#define SMARTCARD_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
|
|
187 |
do { \
|
|
188 |
if((__HANDLE__)->Instance == USART1) \
|
|
189 |
{ \
|
|
190 |
switch(__HAL_RCC_GET_USART1_SOURCE()) \
|
|
191 |
{ \
|
|
192 |
case RCC_USART1CLKSOURCE_PCLK1: \
|
|
193 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
|
|
194 |
break; \
|
|
195 |
case RCC_USART1CLKSOURCE_HSI: \
|
|
196 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
|
|
197 |
break; \
|
|
198 |
case RCC_USART1CLKSOURCE_SYSCLK: \
|
|
199 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
|
|
200 |
break; \
|
|
201 |
case RCC_USART1CLKSOURCE_LSE: \
|
|
202 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
|
|
203 |
break; \
|
|
204 |
default: \
|
|
205 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
|
|
206 |
break; \
|
|
207 |
} \
|
|
208 |
} \
|
|
209 |
else if((__HANDLE__)->Instance == USART2) \
|
|
210 |
{ \
|
|
211 |
switch(__HAL_RCC_GET_USART2_SOURCE()) \
|
|
212 |
{ \
|
|
213 |
case RCC_USART2CLKSOURCE_PCLK1: \
|
|
214 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
|
|
215 |
break; \
|
|
216 |
case RCC_USART2CLKSOURCE_HSI: \
|
|
217 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
|
|
218 |
break; \
|
|
219 |
case RCC_USART2CLKSOURCE_SYSCLK: \
|
|
220 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
|
|
221 |
break; \
|
|
222 |
case RCC_USART2CLKSOURCE_LSE: \
|
|
223 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
|
|
224 |
break; \
|
|
225 |
default: \
|
|
226 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
|
|
227 |
break; \
|
|
228 |
} \
|
|
229 |
} \
|
|
230 |
else if((__HANDLE__)->Instance == USART3) \
|
|
231 |
{ \
|
|
232 |
switch(__HAL_RCC_GET_USART3_SOURCE()) \
|
|
233 |
{ \
|
|
234 |
case RCC_USART3CLKSOURCE_PCLK1: \
|
|
235 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
|
|
236 |
break; \
|
|
237 |
case RCC_USART3CLKSOURCE_HSI: \
|
|
238 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
|
|
239 |
break; \
|
|
240 |
case RCC_USART3CLKSOURCE_SYSCLK: \
|
|
241 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
|
|
242 |
break; \
|
|
243 |
case RCC_USART3CLKSOURCE_LSE: \
|
|
244 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
|
|
245 |
break; \
|
|
246 |
default: \
|
|
247 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
|
|
248 |
break; \
|
|
249 |
} \
|
|
250 |
} \
|
|
251 |
else if((__HANDLE__)->Instance == USART4) \
|
|
252 |
{ \
|
|
253 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
|
|
254 |
} \
|
|
255 |
else if((__HANDLE__)->Instance == USART5) \
|
|
256 |
{ \
|
|
257 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
|
|
258 |
} \
|
|
259 |
else if((__HANDLE__)->Instance == USART6) \
|
|
260 |
{ \
|
|
261 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
|
|
262 |
} \
|
|
263 |
else if((__HANDLE__)->Instance == USART7) \
|
|
264 |
{ \
|
|
265 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
|
|
266 |
} \
|
|
267 |
else if((__HANDLE__)->Instance == USART8) \
|
|
268 |
{ \
|
|
269 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
|
|
270 |
} \
|
|
271 |
else \
|
|
272 |
{ \
|
|
273 |
(__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
|
|
274 |
} \
|
|
275 |
} while(0)
|
|
276 |
#endif /* defined(STM32F031x6) || defined(STM32F038xx) */
|
|
277 |
|
|
278 |
/**
|
|
279 |
* @}
|
|
280 |
*/
|
|
281 |
|
|
282 |
/* Exported functions --------------------------------------------------------*/
|
|
283 |
/** @addtogroup SMARTCARDEx_Exported_Functions
|
|
284 |
* @{
|
|
285 |
*/
|
|
286 |
|
|
287 |
/* Initialization and de-initialization functions ****************************/
|
|
288 |
/* IO operation methods *******************************************************/
|
|
289 |
|
|
290 |
/** @addtogroup SMARTCARDEx_Exported_Functions_Group1
|
|
291 |
* @{
|
|
292 |
*/
|
|
293 |
|
|
294 |
/* Peripheral Control functions ***********************************************/
|
|
295 |
void HAL_SMARTCARDEx_BlockLength_Config(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t BlockLength);
|
|
296 |
void HAL_SMARTCARDEx_TimeOut_Config(SMARTCARD_HandleTypeDef *hsmartcard, uint32_t TimeOutValue);
|
|
297 |
HAL_StatusTypeDef HAL_SMARTCARDEx_EnableReceiverTimeOut(SMARTCARD_HandleTypeDef *hsmartcard);
|
|
298 |
HAL_StatusTypeDef HAL_SMARTCARDEx_DisableReceiverTimeOut(SMARTCARD_HandleTypeDef *hsmartcard);
|
|
299 |
|
|
300 |
/**
|
|
301 |
* @}
|
|
302 |
*/
|
|
303 |
|
|
304 |
/**
|
|
305 |
* @}
|
|
306 |
*/
|
|
307 |
|
|
308 |
/**
|
|
309 |
* @}
|
|
310 |
*/
|
|
311 |
|
|
312 |
/**
|
|
313 |
* @}
|
|
314 |
*/
|
|
315 |
|
|
316 |
#endif /* !defined(STM32F030x6) && !defined(STM32F030x8)&& !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) */
|
|
317 |
|
|
318 |
#ifdef __cplusplus
|
|
319 |
}
|
|
320 |
#endif
|
|
321 |
|
|
322 |
#endif /* __STM32F0xx_HAL_SMARTCARD_EX_H */
|
|
323 |
|
|
324 |
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
325 |
|