1 /**
2   ******************************************************************************
3   * @file    stm32h5xx_hal_irda_ex.h
4   * @author  MCD Application Team
5   * @brief   Header file of IRDA HAL Extended module.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2022 STMicroelectronics.
10   * All rights reserved.
11   *
12   * This software is licensed under terms that can be found in the LICENSE file
13   * in the root directory of this software component.
14   * If no LICENSE file comes with this software, it is provided AS-IS.
15   *
16   ******************************************************************************
17   */
18 
19 /* Define to prevent recursive inclusion -------------------------------------*/
20 #ifndef STM32H5xx_HAL_IRDA_EX_H
21 #define STM32H5xx_HAL_IRDA_EX_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32h5xx_hal_def.h"
29 
30 /** @addtogroup STM32H5xx_HAL_Driver
31   * @{
32   */
33 
34 /** @defgroup IRDAEx IRDAEx
35   * @brief IRDA Extended HAL module driver
36   * @{
37   */
38 
39 /* Exported types ------------------------------------------------------------*/
40 /* Exported constants --------------------------------------------------------*/
41 /** @defgroup IRDAEx_Extended_Exported_Constants IRDAEx Extended Exported Constants
42   * @{
43   */
44 
45 /** @defgroup IRDAEx_Word_Length IRDAEx Word Length
46   * @{
47   */
48 #define IRDA_WORDLENGTH_7B                  USART_CR1_M1   /*!< 7-bit long frame */
49 #define IRDA_WORDLENGTH_8B                  0x00000000U    /*!< 8-bit long frame */
50 #define IRDA_WORDLENGTH_9B                  USART_CR1_M0   /*!< 9-bit long frame */
51 /**
52   * @}
53   */
54 
55 /**
56   * @}
57   */
58 
59 /* Exported macros -----------------------------------------------------------*/
60 
61 /* Private macros ------------------------------------------------------------*/
62 
63 /** @defgroup IRDAEx_Private_Macros IRDAEx Private Macros
64   * @{
65   */
66 
67 /** @brief  Report the IRDA clock source.
68   * @param  __HANDLE__ specifies the IRDA Handle.
69   * @param  __CLOCKSOURCE__ output variable.
70   * @retval IRDA clocking source, written in __CLOCKSOURCE__.
71   */
72 #if (defined(STM32H573xx) || defined(STM32H563xx) || defined(STM32H562xx))
73 #define IRDA_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__)        \
74   do {                                                         \
75     if((__HANDLE__)->Instance == USART1)                       \
76     {                                                          \
77       switch(__HAL_RCC_GET_USART1_SOURCE())                    \
78       {                                                        \
79         case RCC_USART1CLKSOURCE_PCLK2:                        \
80           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK2;          \
81           break;                                               \
82         case RCC_USART1CLKSOURCE_HSI:                          \
83           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI;            \
84           break;                                               \
85         case RCC_USART1CLKSOURCE_CSI:                          \
86           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_CSI;            \
87           break;                                               \
88         case RCC_USART1CLKSOURCE_LSE:                          \
89           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE;            \
90           break;                                               \
91         case RCC_USART1CLKSOURCE_PLL2Q:                        \
92           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL2Q;          \
93           break;                                               \
94         case RCC_USART1CLKSOURCE_PLL3Q:                        \
95           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL3Q;          \
96           break;                                               \
97         default:                                               \
98           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED;      \
99           break;                                               \
100       }                                                        \
101     }                                                          \
102     else if((__HANDLE__)->Instance == USART2)                  \
103     {                                                          \
104       switch(__HAL_RCC_GET_USART2_SOURCE())                    \
105       {                                                        \
106         case RCC_USART2CLKSOURCE_PCLK1:                        \
107           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1;          \
108           break;                                               \
109         case RCC_USART2CLKSOURCE_HSI:                          \
110           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI;            \
111           break;                                               \
112         case RCC_USART2CLKSOURCE_CSI:                          \
113           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_CSI;            \
114           break;                                               \
115         case RCC_USART2CLKSOURCE_LSE:                          \
116           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE;            \
117           break;                                               \
118         case RCC_USART2CLKSOURCE_PLL2Q:                        \
119           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL2Q;          \
120           break;                                               \
121         case RCC_USART2CLKSOURCE_PLL3Q:                        \
122           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL3Q;          \
123           break;                                               \
124         default:                                               \
125           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED;      \
126           break;                                               \
127       }                                                        \
128     }                                                          \
129     else if((__HANDLE__)->Instance == USART3)                  \
130     {                                                          \
131       switch(__HAL_RCC_GET_USART3_SOURCE())                    \
132       {                                                        \
133         case RCC_USART3CLKSOURCE_PCLK1:                        \
134           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1;          \
135           break;                                               \
136         case RCC_USART3CLKSOURCE_HSI:                          \
137           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI;            \
138           break;                                               \
139         case RCC_USART3CLKSOURCE_CSI:                          \
140           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_CSI;            \
141           break;                                               \
142         case RCC_USART3CLKSOURCE_LSE:                          \
143           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE;            \
144           break;                                               \
145         case RCC_USART3CLKSOURCE_PLL2Q:                        \
146           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL2Q;          \
147           break;                                               \
148         case RCC_USART3CLKSOURCE_PLL3Q:                        \
149           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL3Q;          \
150           break;                                               \
151         default:                                               \
152           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED;      \
153           break;                                               \
154       }                                                        \
155     }                                                          \
156     else if((__HANDLE__)->Instance == UART4)                   \
157     {                                                          \
158       switch(__HAL_RCC_GET_UART4_SOURCE())                     \
159       {                                                        \
160         case RCC_UART4CLKSOURCE_PCLK1:                         \
161           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1;          \
162           break;                                               \
163         case RCC_UART4CLKSOURCE_HSI:                           \
164           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI;            \
165           break;                                               \
166         case RCC_UART4CLKSOURCE_CSI:                           \
167           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_CSI;            \
168           break;                                               \
169         case RCC_UART4CLKSOURCE_LSE:                           \
170           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE;            \
171           break;                                               \
172         case RCC_UART4CLKSOURCE_PLL2Q:                         \
173           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL2Q;          \
174           break;                                               \
175         case RCC_UART4CLKSOURCE_PLL3Q:                         \
176           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL3Q;          \
177           break;                                               \
178         default:                                               \
179           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED;      \
180           break;                                               \
181       }                                                        \
182     }                                                          \
183     else if((__HANDLE__)->Instance == UART5)                   \
184     {                                                          \
185       switch(__HAL_RCC_GET_UART5_SOURCE())                     \
186       {                                                        \
187         case RCC_UART5CLKSOURCE_PCLK1:                         \
188           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1;          \
189           break;                                               \
190         case RCC_UART5CLKSOURCE_HSI:                           \
191           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI;            \
192           break;                                               \
193         case RCC_UART5CLKSOURCE_CSI:                           \
194           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_CSI;            \
195           break;                                               \
196         case RCC_UART5CLKSOURCE_LSE:                           \
197           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE;            \
198           break;                                               \
199         case RCC_UART5CLKSOURCE_PLL2Q:                         \
200           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL2Q;          \
201           break;                                               \
202         case RCC_UART5CLKSOURCE_PLL3Q:                         \
203           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL3Q;          \
204           break;                                               \
205         default:                                               \
206           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED;      \
207           break;                                               \
208       }                                                        \
209     }                                                          \
210     else if((__HANDLE__)->Instance == USART6)                  \
211     {                                                          \
212       switch(__HAL_RCC_GET_USART6_SOURCE())                    \
213       {                                                        \
214         case RCC_USART6CLKSOURCE_PCLK1:                        \
215           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1;          \
216           break;                                               \
217         case RCC_USART6CLKSOURCE_HSI:                          \
218           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI;            \
219           break;                                               \
220         case RCC_USART6CLKSOURCE_CSI:                          \
221           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_CSI;            \
222           break;                                               \
223         case RCC_USART6CLKSOURCE_LSE:                          \
224           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE;            \
225           break;                                               \
226         case RCC_USART6CLKSOURCE_PLL2Q:                        \
227           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL2Q;          \
228           break;                                               \
229         case RCC_USART6CLKSOURCE_PLL3Q:                        \
230           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL3Q;          \
231           break;                                               \
232         default:                                               \
233           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED;      \
234           break;                                               \
235       }                                                        \
236     }                                                          \
237     else if((__HANDLE__)->Instance == UART7)                   \
238     {                                                          \
239       switch(__HAL_RCC_GET_UART7_SOURCE())                     \
240       {                                                        \
241         case RCC_UART7CLKSOURCE_PCLK1:                         \
242           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1;          \
243           break;                                               \
244         case RCC_UART7CLKSOURCE_HSI:                           \
245           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI;            \
246           break;                                               \
247         case RCC_UART7CLKSOURCE_CSI:                           \
248           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_CSI;            \
249           break;                                               \
250         case RCC_UART7CLKSOURCE_LSE:                           \
251           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE;            \
252           break;                                               \
253         case RCC_UART7CLKSOURCE_PLL2Q:                         \
254           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL2Q;          \
255           break;                                               \
256         case RCC_UART7CLKSOURCE_PLL3Q:                         \
257           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL3Q;          \
258           break;                                               \
259         default:                                               \
260           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED;      \
261           break;                                               \
262       }                                                        \
263     }                                                          \
264     else if((__HANDLE__)->Instance == UART8)                   \
265     {                                                          \
266       switch(__HAL_RCC_GET_UART8_SOURCE())                     \
267       {                                                        \
268         case RCC_UART8CLKSOURCE_PCLK1:                         \
269           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1;          \
270           break;                                               \
271         case RCC_UART8CLKSOURCE_HSI:                           \
272           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI;            \
273           break;                                               \
274         case RCC_UART8CLKSOURCE_CSI:                           \
275           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_CSI;            \
276           break;                                               \
277         case RCC_UART8CLKSOURCE_LSE:                           \
278           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE;            \
279           break;                                               \
280         case RCC_UART8CLKSOURCE_PLL2Q:                         \
281           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL2Q;          \
282           break;                                               \
283         case RCC_UART8CLKSOURCE_PLL3Q:                         \
284           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL3Q;          \
285           break;                                               \
286         default:                                               \
287           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED;      \
288           break;                                               \
289       }                                                        \
290     }                                                          \
291     else if((__HANDLE__)->Instance == UART9)                   \
292     {                                                          \
293       switch(__HAL_RCC_GET_UART9_SOURCE())                     \
294       {                                                        \
295         case RCC_UART9CLKSOURCE_PCLK1:                         \
296           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1;          \
297           break;                                               \
298         case RCC_UART9CLKSOURCE_HSI:                           \
299           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI;            \
300           break;                                               \
301         case RCC_UART9CLKSOURCE_CSI:                           \
302           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_CSI;            \
303           break;                                               \
304         case RCC_UART9CLKSOURCE_LSE:                           \
305           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE;            \
306           break;                                               \
307         case RCC_UART9CLKSOURCE_PLL2Q:                         \
308           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL2Q;          \
309           break;                                               \
310         case RCC_UART9CLKSOURCE_PLL3Q:                         \
311           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL3Q;          \
312           break;                                               \
313         default:                                               \
314           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED;      \
315           break;                                               \
316       }                                                        \
317     }                                                          \
318     else if((__HANDLE__)->Instance == USART10)                 \
319     {                                                          \
320       switch(__HAL_RCC_GET_USART10_SOURCE())                   \
321       {                                                        \
322         case RCC_USART10CLKSOURCE_PCLK1:                       \
323           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1;          \
324           break;                                               \
325         case RCC_USART10CLKSOURCE_HSI:                         \
326           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI;            \
327           break;                                               \
328         case RCC_USART10CLKSOURCE_CSI:                         \
329           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_CSI;            \
330           break;                                               \
331         case RCC_USART10CLKSOURCE_LSE:                         \
332           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE;            \
333           break;                                               \
334         case RCC_USART10CLKSOURCE_PLL2Q:                       \
335           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL2Q;          \
336           break;                                               \
337         case RCC_USART10CLKSOURCE_PLL3Q:                       \
338           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL3Q;          \
339           break;                                               \
340         default:                                               \
341           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED;      \
342           break;                                               \
343       }                                                        \
344     }                                                          \
345     else if((__HANDLE__)->Instance == USART11)                 \
346     {                                                          \
347       switch(__HAL_RCC_GET_USART11_SOURCE())                   \
348       {                                                        \
349         case RCC_USART11CLKSOURCE_PCLK1:                       \
350           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1;          \
351           break;                                               \
352         case RCC_USART11CLKSOURCE_HSI:                         \
353           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI;            \
354           break;                                               \
355         case RCC_USART11CLKSOURCE_CSI:                         \
356           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_CSI;            \
357           break;                                               \
358         case RCC_USART11CLKSOURCE_LSE:                         \
359           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE;            \
360           break;                                               \
361         case RCC_USART11CLKSOURCE_PLL2Q:                       \
362           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL2Q;          \
363           break;                                               \
364         case RCC_USART11CLKSOURCE_PLL3Q:                       \
365           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL3Q;          \
366           break;                                               \
367         default:                                               \
368           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED;      \
369           break;                                               \
370       }                                                        \
371     }                                                          \
372     else if((__HANDLE__)->Instance == UART12)                  \
373     {                                                          \
374       switch(__HAL_RCC_GET_UART12_SOURCE())                    \
375       {                                                        \
376         case RCC_UART12CLKSOURCE_PCLK1:                        \
377           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1;          \
378           break;                                               \
379         case RCC_UART12CLKSOURCE_HSI:                          \
380           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI;            \
381           break;                                               \
382         case RCC_UART12CLKSOURCE_CSI:                          \
383           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_CSI;            \
384           break;                                               \
385         case RCC_UART12CLKSOURCE_LSE:                          \
386           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE;            \
387           break;                                               \
388         case RCC_UART12CLKSOURCE_PLL2Q:                        \
389           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL2Q;          \
390           break;                                               \
391         case RCC_UART12CLKSOURCE_PLL3Q:                        \
392           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL3Q;          \
393           break;                                               \
394         default:                                               \
395           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED;      \
396           break;                                               \
397       }                                                        \
398     }                                                          \
399     else                                                       \
400     {                                                          \
401       (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED;          \
402     }                                                          \
403   } while(0U)
404 #else
405 #define IRDA_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__)        \
406   do {                                                         \
407     if((__HANDLE__)->Instance == USART1)                       \
408     {                                                          \
409       switch(__HAL_RCC_GET_USART1_SOURCE())                    \
410       {                                                        \
411         case RCC_USART1CLKSOURCE_PCLK2:                        \
412           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK2;          \
413           break;                                               \
414         case RCC_USART1CLKSOURCE_HSI:                          \
415           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI;            \
416           break;                                               \
417         case RCC_USART1CLKSOURCE_CSI:                          \
418           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_CSI;            \
419           break;                                               \
420         case RCC_USART1CLKSOURCE_LSE:                          \
421           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE;            \
422           break;                                               \
423         case RCC_USART1CLKSOURCE_PLL2Q:                        \
424           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL2Q;          \
425           break;                                               \
426         default:                                               \
427           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED;      \
428           break;                                               \
429       }                                                        \
430     }                                                          \
431     else if((__HANDLE__)->Instance == USART2)                  \
432     {                                                          \
433       switch(__HAL_RCC_GET_USART2_SOURCE())                    \
434       {                                                        \
435         case RCC_USART2CLKSOURCE_PCLK1:                        \
436           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1;          \
437           break;                                               \
438         case RCC_USART2CLKSOURCE_HSI:                          \
439           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI;            \
440           break;                                               \
441         case RCC_USART2CLKSOURCE_CSI:                          \
442           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_CSI;            \
443           break;                                               \
444         case RCC_USART2CLKSOURCE_LSE:                          \
445           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE;            \
446           break;                                               \
447         case RCC_USART2CLKSOURCE_PLL2Q:                        \
448           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL2Q;          \
449           break;                                               \
450         default:                                               \
451           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED;      \
452           break;                                               \
453       }                                                        \
454     }                                                          \
455     else if((__HANDLE__)->Instance == USART3)                  \
456     {                                                          \
457       switch(__HAL_RCC_GET_USART3_SOURCE())                    \
458       {                                                        \
459         case RCC_USART3CLKSOURCE_PCLK1:                        \
460           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1;          \
461           break;                                               \
462         case RCC_USART3CLKSOURCE_HSI:                          \
463           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI;            \
464           break;                                               \
465         case RCC_USART3CLKSOURCE_CSI:                          \
466           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_CSI;            \
467           break;                                               \
468         case RCC_USART3CLKSOURCE_LSE:                          \
469           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE;            \
470           break;                                               \
471         case RCC_USART3CLKSOURCE_PLL2Q:                        \
472           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL2Q;          \
473           break;                                               \
474         default:                                               \
475           (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED;      \
476           break;                                               \
477       }                                                        \
478     }                                                          \
479     else                                                       \
480     {                                                          \
481       (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED;          \
482     }                                                          \
483   } while(0U)
484 
485 #endif /* (defined(STM32H573xx) || defined(STM32H563xx) || defined(STM32H562xx) */
486 
487 /** @brief  Compute the mask to apply to retrieve the received data
488   *         according to the word length and to the parity bits activation.
489   * @param  __HANDLE__ specifies the IRDA Handle.
490   * @retval None, the mask to apply to the associated UART RDR register is stored in (__HANDLE__)->Mask field.
491   */
492 #define IRDA_MASK_COMPUTATION(__HANDLE__)                             \
493   do {                                                                \
494     if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_9B)          \
495     {                                                                 \
496       if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE)              \
497       {                                                               \
498         (__HANDLE__)->Mask = 0x01FFU ;                                \
499       }                                                               \
500       else                                                            \
501       {                                                               \
502         (__HANDLE__)->Mask = 0x00FFU ;                                \
503       }                                                               \
504     }                                                                 \
505     else if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_8B)     \
506     {                                                                 \
507       if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE)              \
508       {                                                               \
509         (__HANDLE__)->Mask = 0x00FFU ;                                \
510       }                                                               \
511       else                                                            \
512       {                                                               \
513         (__HANDLE__)->Mask = 0x007FU ;                                \
514       }                                                               \
515     }                                                                 \
516     else if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_7B)     \
517     {                                                                 \
518       if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE)              \
519       {                                                               \
520         (__HANDLE__)->Mask = 0x007FU ;                                \
521       }                                                               \
522       else                                                            \
523       {                                                               \
524         (__HANDLE__)->Mask = 0x003FU ;                                \
525       }                                                               \
526     }                                                                 \
527     else                                                              \
528     {                                                                 \
529       (__HANDLE__)->Mask = 0x0000U;                                   \
530     }                                                                 \
531   } while(0U)
532 
533 /** @brief Ensure that IRDA frame length is valid.
534   * @param __LENGTH__ IRDA frame length.
535   * @retval SET (__LENGTH__ is valid) or RESET (__LENGTH__ is invalid)
536   */
537 #define IS_IRDA_WORD_LENGTH(__LENGTH__) (((__LENGTH__) == IRDA_WORDLENGTH_7B) || \
538                                          ((__LENGTH__) == IRDA_WORDLENGTH_8B) || \
539                                          ((__LENGTH__) == IRDA_WORDLENGTH_9B))
540 /**
541   * @}
542   */
543 
544 /* Exported functions --------------------------------------------------------*/
545 
546 /**
547   * @}
548   */
549 
550 /**
551   * @}
552   */
553 
554 #ifdef __cplusplus
555 }
556 #endif
557 
558 #endif /* STM32H5xx_HAL_IRDA_EX_H */
559