]> git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F0/stm32f0xx_hal_irda_ex.h
remove experimental return, cleanup slash_question key
[tmk_keyboard.git] / tmk_core / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_STM / TARGET_STM32F0 / stm32f0xx_hal_irda_ex.h
1 /**
2 ******************************************************************************
3 * @file stm32f0xx_hal_irda_ex.h
4 * @author MCD Application Team
5 * @version V1.2.0
6 * @date 11-December-2014
7 * @brief Header file of IRDA HAL Extension module.
8 ******************************************************************************
9 * @attention
10 *
11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
12 *
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.
23 *
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.
34 *
35 ******************************************************************************
36 */
37
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F0xx_HAL_IRDA_EX_H
40 #define __STM32F0xx_HAL_IRDA_EX_H
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46 #if !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC)
47
48 /* Includes ------------------------------------------------------------------*/
49 #include "stm32f0xx_hal_def.h"
50
51 /** @addtogroup STM32F0xx_HAL_Driver
52 * @{
53 */
54
55 /** @addtogroup IRDAEx IRDAEx Extended HAL module driver
56 * @{
57 */
58
59 /* Exported types ------------------------------------------------------------*/
60 /* Exported constants --------------------------------------------------------*/
61 /** @defgroup IRDAEx_Exported_Constants IRDAEx Exported Constants
62 * @{
63 */
64
65 /** @defgroup IRDAEx_Word_Length IRDA Word Length
66 * @{
67 */
68 #if defined (STM32F042x6) || defined (STM32F048xx) || \
69 defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || \
70 defined (STM32F091xC) || defined (STM32F098xx)
71 #define IRDA_WORDLENGTH_7B ((uint32_t)USART_CR1_M1)
72 #define IRDA_WORDLENGTH_8B ((uint32_t)0x00000000)
73 #define IRDA_WORDLENGTH_9B ((uint32_t)USART_CR1_M0)
74 #define IS_IRDA_WORD_LENGTH(LENGTH) (((LENGTH) == IRDA_WORDLENGTH_7B) || \
75 ((LENGTH) == IRDA_WORDLENGTH_8B) || \
76 ((LENGTH) == IRDA_WORDLENGTH_9B))
77 #else
78 #define IRDA_WORDLENGTH_8B ((uint32_t)0x00000000)
79 #define IRDA_WORDLENGTH_9B ((uint32_t)USART_CR1_M)
80 #define IS_IRDA_WORD_LENGTH(LENGTH) (((LENGTH) == IRDA_WORDLENGTH_8B) || \
81 ((LENGTH) == IRDA_WORDLENGTH_9B))
82 #endif /* defined (STM32F042x6) || defined (STM32F048xx) || \
83 defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || \
84 defined (STM32F091xC) || defined (STM32F098xx)*/
85 /**
86 * @}
87 */
88
89
90 /**
91 * @}
92 */
93
94 /* Exported macros -----------------------------------------------------------*/
95
96 /** @defgroup IRDAEx_Exported_Macros IRDAEx Exported Macros
97 * @{
98 */
99
100 /** @brief Reports the IRDA clock source.
101 * @param __HANDLE__: specifies the IRDA Handle
102 * @param __CLOCKSOURCE__ : output variable
103 * @retval IRDA clocking source, written in __CLOCKSOURCE__.
104 */
105
106 #if defined(STM32F031x6) || defined(STM32F038xx)
107 #define __HAL_IRDA_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
108 do { \
109 switch(__HAL_RCC_GET_USART1_SOURCE()) \
110 { \
111 case RCC_USART1CLKSOURCE_PCLK1: \
112 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \
113 break; \
114 case RCC_USART1CLKSOURCE_HSI: \
115 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \
116 break; \
117 case RCC_USART1CLKSOURCE_SYSCLK: \
118 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK; \
119 break; \
120 case RCC_USART1CLKSOURCE_LSE: \
121 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \
122 break; \
123 default: \
124 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \
125 break; \
126 } \
127 } while(0)
128 #elif defined (STM32F042x6) || defined (STM32F048xx) || \
129 defined (STM32F051x8) || defined (STM32F058xx)
130 #define __HAL_IRDA_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
131 do { \
132 if((__HANDLE__)->Instance == USART1) \
133 { \
134 switch(__HAL_RCC_GET_USART1_SOURCE()) \
135 { \
136 case RCC_USART1CLKSOURCE_PCLK1: \
137 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \
138 break; \
139 case RCC_USART1CLKSOURCE_HSI: \
140 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \
141 break; \
142 case RCC_USART1CLKSOURCE_SYSCLK: \
143 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK; \
144 break; \
145 case RCC_USART1CLKSOURCE_LSE: \
146 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \
147 break; \
148 default: \
149 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \
150 break; \
151 } \
152 } \
153 else if((__HANDLE__)->Instance == USART2) \
154 { \
155 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \
156 } \
157 else \
158 { \
159 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \
160 } \
161 } while(0)
162 #elif defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx)
163 #define __HAL_IRDA_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
164 do { \
165 if((__HANDLE__)->Instance == USART1) \
166 { \
167 switch(__HAL_RCC_GET_USART1_SOURCE()) \
168 { \
169 case RCC_USART1CLKSOURCE_PCLK1: \
170 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \
171 break; \
172 case RCC_USART1CLKSOURCE_HSI: \
173 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \
174 break; \
175 case RCC_USART1CLKSOURCE_SYSCLK: \
176 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK; \
177 break; \
178 case RCC_USART1CLKSOURCE_LSE: \
179 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \
180 break; \
181 default: \
182 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \
183 break; \
184 } \
185 } \
186 else if((__HANDLE__)->Instance == USART2) \
187 { \
188 switch(__HAL_RCC_GET_USART2_SOURCE()) \
189 { \
190 case RCC_USART2CLKSOURCE_PCLK1: \
191 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \
192 break; \
193 case RCC_USART2CLKSOURCE_HSI: \
194 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \
195 break; \
196 case RCC_USART2CLKSOURCE_SYSCLK: \
197 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK; \
198 break; \
199 case RCC_USART2CLKSOURCE_LSE: \
200 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \
201 break; \
202 default: \
203 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \
204 break; \
205 } \
206 } \
207 else if((__HANDLE__)->Instance == USART3) \
208 { \
209 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \
210 } \
211 else if((__HANDLE__)->Instance == USART4) \
212 { \
213 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \
214 } \
215 else \
216 { \
217 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \
218 } \
219 } while(0)
220 #elif defined(STM32F091xC) || defined(STM32F098xx)
221 #define __HAL_IRDA_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
222 do { \
223 if((__HANDLE__)->Instance == USART1) \
224 { \
225 switch(__HAL_RCC_GET_USART1_SOURCE()) \
226 { \
227 case RCC_USART1CLKSOURCE_PCLK1: \
228 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \
229 break; \
230 case RCC_USART1CLKSOURCE_HSI: \
231 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \
232 break; \
233 case RCC_USART1CLKSOURCE_SYSCLK: \
234 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK; \
235 break; \
236 case RCC_USART1CLKSOURCE_LSE: \
237 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \
238 break; \
239 default: \
240 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \
241 break; \
242 } \
243 } \
244 else if((__HANDLE__)->Instance == USART2) \
245 { \
246 switch(__HAL_RCC_GET_USART2_SOURCE()) \
247 { \
248 case RCC_USART2CLKSOURCE_PCLK1: \
249 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \
250 break; \
251 case RCC_USART2CLKSOURCE_HSI: \
252 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \
253 break; \
254 case RCC_USART2CLKSOURCE_SYSCLK: \
255 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK; \
256 break; \
257 case RCC_USART2CLKSOURCE_LSE: \
258 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \
259 break; \
260 default: \
261 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \
262 break; \
263 } \
264 } \
265 else if((__HANDLE__)->Instance == USART3) \
266 { \
267 switch(__HAL_RCC_GET_USART3_SOURCE()) \
268 { \
269 case RCC_USART3CLKSOURCE_PCLK1: \
270 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \
271 break; \
272 case RCC_USART3CLKSOURCE_HSI: \
273 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \
274 break; \
275 case RCC_USART3CLKSOURCE_SYSCLK: \
276 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK; \
277 break; \
278 case RCC_USART3CLKSOURCE_LSE: \
279 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \
280 break; \
281 default: \
282 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \
283 break; \
284 } \
285 } \
286 else if((__HANDLE__)->Instance == USART4) \
287 { \
288 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \
289 } \
290 else if((__HANDLE__)->Instance == USART5) \
291 { \
292 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \
293 } \
294 else if((__HANDLE__)->Instance == USART6) \
295 { \
296 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \
297 } \
298 else if((__HANDLE__)->Instance == USART7) \
299 { \
300 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \
301 } \
302 else if((__HANDLE__)->Instance == USART8) \
303 { \
304 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \
305 } \
306 else \
307 { \
308 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \
309 } \
310 } while(0)
311
312 #endif /* defined(STM32F031x6) || defined(STM32F038xx) */
313
314
315 /** @brief Computes the mask to apply to retrieve the received data
316 * according to the word length and to the parity bits activation.
317 * @param __HANDLE__: specifies the IRDA Handle
318 * @retval none
319 */
320 #if defined (STM32F042x6) || defined (STM32F048xx) || \
321 defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || \
322 defined (STM32F091xC) || defined (STM32F098xx)
323 #define __HAL_IRDA_MASK_COMPUTATION(__HANDLE__) \
324 do { \
325 if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_9B) \
326 { \
327 if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE) \
328 { \
329 (__HANDLE__)->Mask = 0x01FF ; \
330 } \
331 else \
332 { \
333 (__HANDLE__)->Mask = 0x00FF ; \
334 } \
335 } \
336 else if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_8B) \
337 { \
338 if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE) \
339 { \
340 (__HANDLE__)->Mask = 0x00FF ; \
341 } \
342 else \
343 { \
344 (__HANDLE__)->Mask = 0x007F ; \
345 } \
346 } \
347 else if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_7B) \
348 { \
349 if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE) \
350 { \
351 (__HANDLE__)->Mask = 0x007F ; \
352 } \
353 else \
354 { \
355 (__HANDLE__)->Mask = 0x003F ; \
356 } \
357 } \
358 } while(0)
359 #else
360 #define __HAL_IRDA_MASK_COMPUTATION(__HANDLE__) \
361 do { \
362 if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_9B) \
363 { \
364 if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE) \
365 { \
366 (__HANDLE__)->Mask = 0x01FF ; \
367 } \
368 else \
369 { \
370 (__HANDLE__)->Mask = 0x00FF ; \
371 } \
372 } \
373 else if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_8B) \
374 { \
375 if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE) \
376 { \
377 (__HANDLE__)->Mask = 0x00FF ; \
378 } \
379 else \
380 { \
381 (__HANDLE__)->Mask = 0x007F ; \
382 } \
383 } \
384 } while(0)
385 #endif /* defined (STM32F042x6) || defined (STM32F048xx) || \
386 defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || \
387 defined (STM32F091xC) || defined(STM32F098xx) */
388 /**
389 * @}
390 */
391
392 /* Exported functions --------------------------------------------------------*/
393 /* Initialization and de-initialization functions ****************************/
394 /* IO operation functions *****************************************************/
395 /* Peripheral Control functions ***********************************************/
396 /* Peripheral State and Error functions ***************************************/
397
398 /**
399 * @}
400 */
401
402 /**
403 * @}
404 */
405
406 #endif /* !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) */
407
408 #ifdef __cplusplus
409 }
410 #endif
411
412 #endif /* __STM32F0xx_HAL_IRDA_EX_H */
413
414 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
415
Imprint / Impressum