]> git.gir.st - tmk_keyboard.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32L0/stm32l0xx_hal_irda_ex.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[tmk_keyboard.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_STM / TARGET_STM32L0 / stm32l0xx_hal_irda_ex.h
1 /**
2 ******************************************************************************
3 * @file stm32l0xx_hal_irda_ex.h
4 * @author MCD Application Team
5 * @version V1.2.0
6 * @date 06-February-2015
7 * @brief Header file of IRDA HAL Extension module.
8 ******************************************************************************
9 * @attention
10 *
11 * <h2><center>&copy; COPYRIGHT(c) 2013 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 __STM32L0xx_HAL_IRDA_EX_H
40 #define __STM32L0xx_HAL_IRDA_EX_H
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32l0xx_hal_def.h"
48
49 /** @addtogroup STM32L0xx_HAL_Driver
50 * @{
51 */
52
53 /** @addtogroup IRDAEx
54 * @{
55 */
56
57 /* Exported types ------------------------------------------------------------*/
58 /* Exported constants --------------------------------------------------------*/
59 /** @defgroup IRDAEx_Extended_Exported_Constants IRDA Extended Exported Constants
60 * @{
61 */
62
63 /** @defgroup IRDAEx_Word_Length IRDAEx Word length
64 * @{
65 */
66 #define IRDA_WORDLENGTH_7B ((uint32_t)USART_CR1_M_1)
67 #define IRDA_WORDLENGTH_8B ((uint32_t)0x00000000)
68 #define IRDA_WORDLENGTH_9B ((uint32_t)USART_CR1_M_0)
69 #define IS_IRDA_WORD_LENGTH(LENGTH) (((LENGTH) == IRDA_WORDLENGTH_7B) || \
70 ((LENGTH) == IRDA_WORDLENGTH_8B) || \
71 ((LENGTH) == IRDA_WORDLENGTH_9B))
72 /**
73 * @}
74 */
75
76
77 /**
78 * @}
79 */
80
81 /* Exported macro ------------------------------------------------------------*/
82
83 /** @defgroup IRDAEx_Extended_Exported_Macros IRDA Extended Exported Macros
84 * @{
85 */
86 /** @brief Reports the IRDA clock source.
87 * @param __HANDLE__: specifies the UART Handle
88 * @param __CLOCKSOURCE__ : output variable
89 * @retval IRDA clocking source, written in __CLOCKSOURCE__.
90 */
91 #if defined (STM32L031xx) || defined (STM32L041xx)
92 #define IRDA_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
93 do { \
94 if((__HANDLE__)->Instance == USART2) \
95 { \
96 switch(__HAL_RCC_GET_USART2_SOURCE()) \
97 { \
98 case RCC_USART2CLKSOURCE_PCLK1: \
99 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \
100 break; \
101 case RCC_USART2CLKSOURCE_HSI: \
102 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \
103 break; \
104 case RCC_USART2CLKSOURCE_SYSCLK: \
105 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK; \
106 break; \
107 case RCC_USART2CLKSOURCE_LSE: \
108 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \
109 break; \
110 default: \
111 break; \
112 } \
113 } \
114 else if((__HANDLE__)->Instance == LPUART1) \
115 { \
116 switch(__HAL_RCC_GET_LPUART1_SOURCE()) \
117 { \
118 case RCC_LPUART1CLKSOURCE_PCLK1: \
119 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \
120 break; \
121 case RCC_LPUART1CLKSOURCE_HSI: \
122 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \
123 break; \
124 case RCC_LPUART1CLKSOURCE_SYSCLK: \
125 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK; \
126 break; \
127 case RCC_LPUART1CLKSOURCE_LSE: \
128 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \
129 break; \
130 default: \
131 break; \
132 } \
133 } \
134 } while(0)
135
136 #else /* (STM32L031xx) || defined (STM32L041xx) */
137
138 #define IRDA_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
139 do { \
140 if((__HANDLE__)->Instance == USART1) \
141 { \
142 switch(__HAL_RCC_GET_USART1_SOURCE()) \
143 { \
144 case RCC_USART1CLKSOURCE_PCLK2: \
145 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK2; \
146 break; \
147 case RCC_USART1CLKSOURCE_HSI: \
148 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \
149 break; \
150 case RCC_USART1CLKSOURCE_SYSCLK: \
151 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK; \
152 break; \
153 case RCC_USART1CLKSOURCE_LSE: \
154 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \
155 break; \
156 default: \
157 break; \
158 } \
159 } \
160 else if((__HANDLE__)->Instance == USART2) \
161 { \
162 switch(__HAL_RCC_GET_USART2_SOURCE()) \
163 { \
164 case RCC_USART2CLKSOURCE_PCLK1: \
165 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \
166 break; \
167 case RCC_USART2CLKSOURCE_HSI: \
168 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \
169 break; \
170 case RCC_USART2CLKSOURCE_SYSCLK: \
171 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK; \
172 break; \
173 case RCC_USART2CLKSOURCE_LSE: \
174 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \
175 break; \
176 default: \
177 break; \
178 } \
179 } \
180 else if((__HANDLE__)->Instance == LPUART1) \
181 { \
182 switch(__HAL_RCC_GET_LPUART1_SOURCE()) \
183 { \
184 case RCC_LPUART1CLKSOURCE_PCLK1: \
185 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \
186 break; \
187 case RCC_LPUART1CLKSOURCE_HSI: \
188 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \
189 break; \
190 case RCC_LPUART1CLKSOURCE_SYSCLK: \
191 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK; \
192 break; \
193 case RCC_LPUART1CLKSOURCE_LSE: \
194 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \
195 break; \
196 default: \
197 break; \
198 } \
199 } \
200 } while(0)
201 #endif /* (STM32L031xx) || (STM32L041xx) */
202
203 /** @brief Reports the mask to apply to retrieve the received data
204 * according to the word length and to the parity bits activation.
205 * @param __HANDLE__: specifies the IRDA Handle
206 * @retval mask to apply to USART RDR register value.
207 */
208 #define IRDA_MASK_COMPUTATION(__HANDLE__) \
209 do { \
210 if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_9B) \
211 { \
212 if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE) \
213 { \
214 (__HANDLE__)->Mask = 0x01FF ; \
215 } \
216 else \
217 { \
218 (__HANDLE__)->Mask = 0x00FF ; \
219 } \
220 } \
221 else if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_8B) \
222 { \
223 if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE) \
224 { \
225 (__HANDLE__)->Mask = 0x00FF ; \
226 } \
227 else \
228 { \
229 (__HANDLE__)->Mask = 0x007F ; \
230 } \
231 } \
232 else if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_7B) \
233 { \
234 if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE) \
235 { \
236 (__HANDLE__)->Mask = 0x007F ; \
237 } \
238 else \
239 { \
240 (__HANDLE__)->Mask = 0x003F ; \
241 } \
242 } \
243 } while(0)
244 /**
245 * @}
246 */
247
248 /* Exported functions --------------------------------------------------------*/
249 /* Initialization/de-initialization methods **********************************/
250 /* IO operation methods *******************************************************/
251 /* Peripheral Control methods ************************************************/
252 /* Peripheral State methods **************************************************/
253
254
255 /**
256 * @}
257 */
258
259 /**
260 * @}
261 */
262
263 #ifdef __cplusplus
264 }
265 #endif
266
267 #endif /* __STM32L0xx_HAL_IRDA_EX_H */
268
269 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
270
Imprint / Impressum