Mercurial > public > ostc4
comparison Common/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_irda.h @ 128:c78bcbd5deda FlipDisplay
Added current STM32 standandard libraries in version independend folder structure
author | Ideenmodellierer |
---|---|
date | Sun, 17 Feb 2019 21:12:22 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
127:1369f8660eaa | 128:c78bcbd5deda |
---|---|
1 /** | |
2 ****************************************************************************** | |
3 * @file stm32f4xx_hal_irda.h | |
4 * @author MCD Application Team | |
5 * @brief Header file of IRDA HAL module. | |
6 ****************************************************************************** | |
7 * @attention | |
8 * | |
9 * <h2><center>© COPYRIGHT(c) 2017 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 __STM32F4xx_HAL_IRDA_H | |
38 #define __STM32F4xx_HAL_IRDA_H | |
39 | |
40 #ifdef __cplusplus | |
41 extern "C" { | |
42 #endif | |
43 | |
44 /* Includes ------------------------------------------------------------------*/ | |
45 #include "stm32f4xx_hal_def.h" | |
46 | |
47 /** @addtogroup STM32F4xx_HAL_Driver | |
48 * @{ | |
49 */ | |
50 | |
51 /** @addtogroup IRDA | |
52 * @{ | |
53 */ | |
54 | |
55 /* Exported types ------------------------------------------------------------*/ | |
56 /** @defgroup IRDA_Exported_Types IRDA Exported Types | |
57 * @{ | |
58 */ | |
59 /** | |
60 * @brief IRDA Init Structure definition | |
61 */ | |
62 typedef struct | |
63 { | |
64 uint32_t BaudRate; /*!< This member configures the IRDA communication baud rate. | |
65 The baud rate is computed using the following formula: | |
66 - IntegerDivider = ((PCLKx) / (8 * (hirda->Init.BaudRate))) | |
67 - FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 8) + 0.5 */ | |
68 | |
69 uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame. | |
70 This parameter can be a value of @ref IRDA_Word_Length */ | |
71 | |
72 uint32_t Parity; /*!< Specifies the parity mode. | |
73 This parameter can be a value of @ref IRDA_Parity | |
74 @note When parity is enabled, the computed parity is inserted | |
75 at the MSB position of the transmitted data (9th bit when | |
76 the word length is set to 9 data bits; 8th bit when the | |
77 word length is set to 8 data bits). */ | |
78 | |
79 uint32_t Mode; /*!< Specifies wether the Receive or Transmit mode is enabled or disabled. | |
80 This parameter can be a value of @ref IRDA_Mode */ | |
81 | |
82 uint8_t Prescaler; /*!< Specifies the Prescaler */ | |
83 | |
84 uint32_t IrDAMode; /*!< Specifies the IrDA mode | |
85 This parameter can be a value of @ref IRDA_Low_Power */ | |
86 }IRDA_InitTypeDef; | |
87 | |
88 /** | |
89 * @brief HAL IRDA State structures definition | |
90 * @note HAL IRDA State value is a combination of 2 different substates: gState and RxState. | |
91 * - gState contains IRDA state information related to global Handle management | |
92 * and also information related to Tx operations. | |
93 * gState value coding follow below described bitmap : | |
94 * b7-b6 Error information | |
95 * 00 : No Error | |
96 * 01 : (Not Used) | |
97 * 10 : Timeout | |
98 * 11 : Error | |
99 * b5 IP initilisation status | |
100 * 0 : Reset (IP not initialized) | |
101 * 1 : Init done (IP not initialized. HAL IRDA Init function already called) | |
102 * b4-b3 (not used) | |
103 * xx : Should be set to 00 | |
104 * b2 Intrinsic process state | |
105 * 0 : Ready | |
106 * 1 : Busy (IP busy with some configuration or internal operations) | |
107 * b1 (not used) | |
108 * x : Should be set to 0 | |
109 * b0 Tx state | |
110 * 0 : Ready (no Tx operation ongoing) | |
111 * 1 : Busy (Tx operation ongoing) | |
112 * - RxState contains information related to Rx operations. | |
113 * RxState value coding follow below described bitmap : | |
114 * b7-b6 (not used) | |
115 * xx : Should be set to 00 | |
116 * b5 IP initilisation status | |
117 * 0 : Reset (IP not initialized) | |
118 * 1 : Init done (IP not initialized) | |
119 * b4-b2 (not used) | |
120 * xxx : Should be set to 000 | |
121 * b1 Rx state | |
122 * 0 : Ready (no Rx operation ongoing) | |
123 * 1 : Busy (Rx operation ongoing) | |
124 * b0 (not used) | |
125 * x : Should be set to 0. | |
126 */ | |
127 typedef enum | |
128 { | |
129 HAL_IRDA_STATE_RESET = 0x00U, /*!< Peripheral is not yet Initialized | |
130 Value is allowed for gState and RxState */ | |
131 HAL_IRDA_STATE_READY = 0x20U, /*!< Peripheral Initialized and ready for use | |
132 Value is allowed for gState and RxState */ | |
133 HAL_IRDA_STATE_BUSY = 0x24U, /*!< An internal process is ongoing | |
134 Value is allowed for gState only */ | |
135 HAL_IRDA_STATE_BUSY_TX = 0x21U, /*!< Data Transmission process is ongoing | |
136 Value is allowed for gState only */ | |
137 HAL_IRDA_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing | |
138 Value is allowed for RxState only */ | |
139 HAL_IRDA_STATE_BUSY_TX_RX = 0x23U, /*!< Data Transmission and Reception process is ongoing | |
140 Not to be used for neither gState nor RxState. | |
141 Value is result of combination (Or) between gState and RxState values */ | |
142 HAL_IRDA_STATE_TIMEOUT = 0xA0U, /*!< Timeout state | |
143 Value is allowed for gState only */ | |
144 HAL_IRDA_STATE_ERROR = 0xE0U /*!< Error | |
145 Value is allowed for gState only */ | |
146 }HAL_IRDA_StateTypeDef; | |
147 | |
148 /** | |
149 * @brief IRDA handle Structure definition | |
150 */ | |
151 typedef struct | |
152 { | |
153 USART_TypeDef *Instance; /* USART registers base address */ | |
154 | |
155 IRDA_InitTypeDef Init; /* IRDA communication parameters */ | |
156 | |
157 uint8_t *pTxBuffPtr; /* Pointer to IRDA Tx transfer Buffer */ | |
158 | |
159 uint16_t TxXferSize; /* IRDA Tx Transfer size */ | |
160 | |
161 __IO uint16_t TxXferCount; /* IRDA Tx Transfer Counter */ | |
162 | |
163 uint8_t *pRxBuffPtr; /* Pointer to IRDA Rx transfer Buffer */ | |
164 | |
165 uint16_t RxXferSize; /* IRDA Rx Transfer size */ | |
166 | |
167 __IO uint16_t RxXferCount; /* IRDA Rx Transfer Counter */ | |
168 | |
169 DMA_HandleTypeDef *hdmatx; /* IRDA Tx DMA Handle parameters */ | |
170 | |
171 DMA_HandleTypeDef *hdmarx; /* IRDA Rx DMA Handle parameters */ | |
172 | |
173 HAL_LockTypeDef Lock; /* Locking object */ | |
174 | |
175 __IO HAL_IRDA_StateTypeDef gState; /* IRDA state information related to global Handle management | |
176 and also related to Tx operations. | |
177 This parameter can be a value of @ref HAL_IRDA_StateTypeDef */ | |
178 | |
179 __IO HAL_IRDA_StateTypeDef RxState; /* IRDA state information related to Rx operations. | |
180 This parameter can be a value of @ref HAL_IRDA_StateTypeDef */ | |
181 | |
182 __IO uint32_t ErrorCode; /* IRDA Error code */ | |
183 | |
184 }IRDA_HandleTypeDef; | |
185 /** | |
186 * @} | |
187 */ | |
188 | |
189 /* Exported constants --------------------------------------------------------*/ | |
190 /** @defgroup IRDA_Exported_Constants IRDA Exported constants | |
191 * @{ | |
192 */ | |
193 /** @defgroup IRDA_Error_Code IRDA Error Code | |
194 * @brief IRDA Error Code | |
195 * @{ | |
196 */ | |
197 #define HAL_IRDA_ERROR_NONE 0x00000000U /*!< No error */ | |
198 #define HAL_IRDA_ERROR_PE 0x00000001U /*!< Parity error */ | |
199 #define HAL_IRDA_ERROR_NE 0x00000002U /*!< Noise error */ | |
200 #define HAL_IRDA_ERROR_FE 0x00000004U /*!< Frame error */ | |
201 #define HAL_IRDA_ERROR_ORE 0x00000008U /*!< Overrun error */ | |
202 #define HAL_IRDA_ERROR_DMA 0x00000010U /*!< DMA transfer error */ | |
203 /** | |
204 * @} | |
205 */ | |
206 | |
207 /** @defgroup IRDA_Word_Length IRDA Word Length | |
208 * @{ | |
209 */ | |
210 #define IRDA_WORDLENGTH_8B 0x00000000U | |
211 #define IRDA_WORDLENGTH_9B ((uint32_t)USART_CR1_M) | |
212 /** | |
213 * @} | |
214 */ | |
215 | |
216 /** @defgroup IRDA_Parity IRDA Parity | |
217 * @{ | |
218 */ | |
219 #define IRDA_PARITY_NONE 0x00000000U | |
220 #define IRDA_PARITY_EVEN ((uint32_t)USART_CR1_PCE) | |
221 #define IRDA_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS)) | |
222 /** | |
223 * @} | |
224 */ | |
225 | |
226 /** @defgroup IRDA_Mode IRDA Transfer Mode | |
227 * @{ | |
228 */ | |
229 #define IRDA_MODE_RX ((uint32_t)USART_CR1_RE) | |
230 #define IRDA_MODE_TX ((uint32_t)USART_CR1_TE) | |
231 #define IRDA_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE)) | |
232 /** | |
233 * @} | |
234 */ | |
235 | |
236 /** @defgroup IRDA_Low_Power IRDA Low Power | |
237 * @{ | |
238 */ | |
239 #define IRDA_POWERMODE_LOWPOWER ((uint32_t)USART_CR3_IRLP) | |
240 #define IRDA_POWERMODE_NORMAL 0x00000000U | |
241 /** | |
242 * @} | |
243 */ | |
244 | |
245 /** @defgroup IRDA_Flags IRDA Flags | |
246 * Elements values convention: 0xXXXX | |
247 * - 0xXXXX : Flag mask in the SR register | |
248 * @{ | |
249 */ | |
250 #define IRDA_FLAG_TXE 0x00000080U | |
251 #define IRDA_FLAG_TC 0x00000040U | |
252 #define IRDA_FLAG_RXNE 0x00000020U | |
253 #define IRDA_FLAG_IDLE 0x00000010U | |
254 #define IRDA_FLAG_ORE 0x00000008U | |
255 #define IRDA_FLAG_NE 0x00000004U | |
256 #define IRDA_FLAG_FE 0x00000002U | |
257 #define IRDA_FLAG_PE 0x00000001U | |
258 /** | |
259 * @} | |
260 */ | |
261 | |
262 /** @defgroup IRDA_Interrupt_definition IRDA Interrupt Definitions | |
263 * Elements values convention: 0xY000XXXX | |
264 * - XXXX : Interrupt mask in the XX register | |
265 * - Y : Interrupt source register (2bits) | |
266 * - 01: CR1 register | |
267 * - 10: CR2 register | |
268 * - 11: CR3 register | |
269 * @{ | |
270 */ | |
271 #define IRDA_IT_PE ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_PEIE)) | |
272 #define IRDA_IT_TXE ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_TXEIE)) | |
273 #define IRDA_IT_TC ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_TCIE)) | |
274 #define IRDA_IT_RXNE ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_RXNEIE)) | |
275 #define IRDA_IT_IDLE ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_IDLEIE)) | |
276 | |
277 #define IRDA_IT_LBD ((uint32_t)(IRDA_CR2_REG_INDEX << 28U | USART_CR2_LBDIE)) | |
278 | |
279 #define IRDA_IT_CTS ((uint32_t)(IRDA_CR3_REG_INDEX << 28U | USART_CR3_CTSIE)) | |
280 #define IRDA_IT_ERR ((uint32_t)(IRDA_CR3_REG_INDEX << 28U | USART_CR3_EIE)) | |
281 /** | |
282 * @} | |
283 */ | |
284 | |
285 /** | |
286 * @} | |
287 */ | |
288 | |
289 /* Exported macro ------------------------------------------------------------*/ | |
290 /** @defgroup IRDA_Exported_Macros IRDA Exported Macros | |
291 * @{ | |
292 */ | |
293 | |
294 /** @brief Reset IRDA handle gstate & RxState | |
295 * @param __HANDLE__ specifies the USART Handle. | |
296 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |
297 * UART peripheral. | |
298 * @retval None | |
299 */ | |
300 #define __HAL_IRDA_RESET_HANDLE_STATE(__HANDLE__) do{ \ | |
301 (__HANDLE__)->gState = HAL_IRDA_STATE_RESET; \ | |
302 (__HANDLE__)->RxState = HAL_IRDA_STATE_RESET; \ | |
303 } while(0U) | |
304 | |
305 /** @brief Flushs the IRDA DR register | |
306 * @param __HANDLE__ specifies the USART Handle. | |
307 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |
308 * UART peripheral. | |
309 */ | |
310 #define __HAL_IRDA_FLUSH_DRREGISTER(__HANDLE__) ((__HANDLE__)->Instance->DR) | |
311 | |
312 /** @brief Checks whether the specified IRDA flag is set or not. | |
313 * @param __HANDLE__ specifies the USART Handle. | |
314 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |
315 * UART peripheral. | |
316 * @param __FLAG__ specifies the flag to check. | |
317 * This parameter can be one of the following values: | |
318 * @arg IRDA_FLAG_TXE: Transmit data register empty flag | |
319 * @arg IRDA_FLAG_TC: Transmission Complete flag | |
320 * @arg IRDA_FLAG_RXNE: Receive data register not empty flag | |
321 * @arg IRDA_FLAG_IDLE: Idle Line detection flag | |
322 * @arg IRDA_FLAG_ORE: OverRun Error flag | |
323 * @arg IRDA_FLAG_NE: Noise Error flag | |
324 * @arg IRDA_FLAG_FE: Framing Error flag | |
325 * @arg IRDA_FLAG_PE: Parity Error flag | |
326 * @retval The new state of __FLAG__ (TRUE or FALSE). | |
327 */ | |
328 #define __HAL_IRDA_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__)) | |
329 | |
330 /** @brief Clears the specified IRDA pending flag. | |
331 * @param __HANDLE__ specifies the USART Handle. | |
332 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |
333 * UART peripheral. | |
334 * @param __FLAG__ specifies the flag to check. | |
335 * This parameter can be any combination of the following values: | |
336 * @arg IRDA_FLAG_TC: Transmission Complete flag. | |
337 * @arg IRDA_FLAG_RXNE: Receive data register not empty flag. | |
338 * | |
339 * @note PE (Parity error), FE (Framing error), NE (Noise error), ORE (OverRun | |
340 * error) and IDLE (Idle line detected) flags are cleared by software | |
341 * sequence: a read operation to USART_SR register followed by a read | |
342 * operation to USART_DR register. | |
343 * @note RXNE flag can be also cleared by a read to the USART_DR register. | |
344 * @note TC flag can be also cleared by software sequence: a read operation to | |
345 * USART_SR register followed by a write operation to USART_DR register. | |
346 * @note TXE flag is cleared only by a write to the USART_DR register. | |
347 * | |
348 * @retval None | |
349 */ | |
350 #define __HAL_IRDA_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__)) | |
351 | |
352 /** @brief Clear the IRDA PE pending flag. | |
353 * @param __HANDLE__ specifies the USART Handle. | |
354 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |
355 * UART peripheral. | |
356 * @retval None | |
357 */ | |
358 #define __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) \ | |
359 do{ \ | |
360 __IO uint32_t tmpreg = 0x00U; \ | |
361 tmpreg = (__HANDLE__)->Instance->SR; \ | |
362 UNUSED(tmpreg); \ | |
363 } while(0U) | |
364 | |
365 /** @brief Clear the IRDA FE pending flag. | |
366 * @param __HANDLE__ specifies the USART Handle. | |
367 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |
368 * UART peripheral. | |
369 * @retval None | |
370 */ | |
371 #define __HAL_IRDA_CLEAR_FEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) | |
372 | |
373 /** @brief Clear the IRDA NE pending flag. | |
374 * @param __HANDLE__ specifies the USART Handle. | |
375 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |
376 * UART peripheral. | |
377 * @retval None | |
378 */ | |
379 #define __HAL_IRDA_CLEAR_NEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) | |
380 | |
381 /** @brief Clear the IRDA ORE pending flag. | |
382 * @param __HANDLE__ specifies the USART Handle. | |
383 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |
384 * UART peripheral. | |
385 * @retval None | |
386 */ | |
387 #define __HAL_IRDA_CLEAR_OREFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) | |
388 | |
389 /** @brief Clear the IRDA IDLE pending flag. | |
390 * @param __HANDLE__ specifies the USART Handle. | |
391 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |
392 * UART peripheral. | |
393 * @retval None | |
394 */ | |
395 #define __HAL_IRDA_CLEAR_IDLEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) | |
396 | |
397 /** @brief Enables or disables the specified IRDA interrupt. | |
398 * @param __HANDLE__ specifies the USART Handle. | |
399 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |
400 * UART peripheral. | |
401 * @param __INTERRUPT__ specifies the IRDA interrupt source to check. | |
402 * This parameter can be one of the following values: | |
403 * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt | |
404 * @arg IRDA_IT_TC: Transmission complete interrupt | |
405 * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt | |
406 * @arg IRDA_IT_IDLE: Idle line detection interrupt | |
407 * @arg IRDA_IT_PE: Parity Error interrupt | |
408 * @arg IRDA_IT_ERR: Error interrupt(Frame error, noise error, overrun error) | |
409 * @retval None | |
410 */ | |
411 #define __HAL_IRDA_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28U) == 1U)? ((__HANDLE__)->Instance->CR1 |= ((__INTERRUPT__) & IRDA_IT_MASK)): \ | |
412 (((__INTERRUPT__) >> 28U) == 2U)? ((__HANDLE__)->Instance->CR2 |= ((__INTERRUPT__) & IRDA_IT_MASK)): \ | |
413 ((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & IRDA_IT_MASK))) | |
414 #define __HAL_IRDA_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28U) == 1U)? ((__HANDLE__)->Instance->CR1 &= ~((__INTERRUPT__) & IRDA_IT_MASK)): \ | |
415 (((__INTERRUPT__) >> 28U) == 2U)? ((__HANDLE__)->Instance->CR2 &= ~((__INTERRUPT__) & IRDA_IT_MASK)): \ | |
416 ((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & IRDA_IT_MASK))) | |
417 | |
418 /** @brief Checks whether the specified IRDA interrupt has occurred or not. | |
419 * @param __HANDLE__ specifies the USART Handle. | |
420 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |
421 * UART peripheral. | |
422 * @param __IT__ specifies the IRDA interrupt source to check. | |
423 * This parameter can be one of the following values: | |
424 * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt | |
425 * @arg IRDA_IT_TC: Transmission complete interrupt | |
426 * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt | |
427 * @arg IRDA_IT_IDLE: Idle line detection interrupt | |
428 * @arg USART_IT_ERR: Error interrupt | |
429 * @arg IRDA_IT_PE: Parity Error interrupt | |
430 * @retval The new state of __IT__ (TRUE or FALSE). | |
431 */ | |
432 #define __HAL_IRDA_GET_IT_SOURCE(__HANDLE__, __IT__) (((((__IT__) >> 28U) == 1U)? (__HANDLE__)->Instance->CR1:(((((uint32_t)(__IT__)) >> 28U) == 2U)? \ | |
433 (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & (((uint32_t)(__IT__)) & IRDA_IT_MASK)) | |
434 | |
435 /** @brief Macro to enable the IRDA's one bit sample method | |
436 * @param __HANDLE__ specifies the IRDA Handle. | |
437 * @retval None | |
438 */ | |
439 #define __HAL_IRDA_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT) | |
440 | |
441 /** @brief Macro to disable the IRDA's one bit sample method | |
442 * @param __HANDLE__ specifies the IRDA Handle. | |
443 * @retval None | |
444 */ | |
445 #define __HAL_IRDA_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint16_t)~((uint16_t)USART_CR3_ONEBIT)) | |
446 | |
447 /** @brief Enable UART/USART associated to IRDA Handle | |
448 * @param __HANDLE__ specifies the IRDA Handle. | |
449 * IRDA Handle selects the USARTx or UARTy peripheral | |
450 * (USART,UART availability and x,y values depending on device). | |
451 * @retval None | |
452 */ | |
453 #define __HAL_IRDA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE) | |
454 | |
455 /** @brief Disable UART/USART associated to IRDA Handle | |
456 * @param __HANDLE__ specifies the IRDA Handle. | |
457 * IRDA Handle selects the USARTx or UARTy peripheral | |
458 * (USART,UART availability and x,y values depending on device). | |
459 * @retval None | |
460 */ | |
461 #define __HAL_IRDA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE) | |
462 | |
463 /** | |
464 * @} | |
465 */ | |
466 | |
467 /* Exported functions --------------------------------------------------------*/ | |
468 /** @addtogroup IRDA_Exported_Functions | |
469 * @{ | |
470 */ | |
471 | |
472 /** @addtogroup IRDA_Exported_Functions_Group1 | |
473 * @{ | |
474 */ | |
475 /* Initialization/de-initialization functions **********************************/ | |
476 HAL_StatusTypeDef HAL_IRDA_Init(IRDA_HandleTypeDef *hirda); | |
477 HAL_StatusTypeDef HAL_IRDA_DeInit(IRDA_HandleTypeDef *hirda); | |
478 void HAL_IRDA_MspInit(IRDA_HandleTypeDef *hirda); | |
479 void HAL_IRDA_MspDeInit(IRDA_HandleTypeDef *hirda); | |
480 /** | |
481 * @} | |
482 */ | |
483 | |
484 /** @addtogroup IRDA_Exported_Functions_Group2 | |
485 * @{ | |
486 */ | |
487 /* IO operation functions *******************************************************/ | |
488 HAL_StatusTypeDef HAL_IRDA_Transmit(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout); | |
489 HAL_StatusTypeDef HAL_IRDA_Receive(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout); | |
490 HAL_StatusTypeDef HAL_IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); | |
491 HAL_StatusTypeDef HAL_IRDA_Receive_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); | |
492 HAL_StatusTypeDef HAL_IRDA_Transmit_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); | |
493 HAL_StatusTypeDef HAL_IRDA_Receive_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); | |
494 HAL_StatusTypeDef HAL_IRDA_DMAPause(IRDA_HandleTypeDef *hirda); | |
495 HAL_StatusTypeDef HAL_IRDA_DMAResume(IRDA_HandleTypeDef *hirda); | |
496 HAL_StatusTypeDef HAL_IRDA_DMAStop(IRDA_HandleTypeDef *hirda); | |
497 /* Transfer Abort functions */ | |
498 HAL_StatusTypeDef HAL_IRDA_Abort(IRDA_HandleTypeDef *hirda); | |
499 HAL_StatusTypeDef HAL_IRDA_AbortTransmit(IRDA_HandleTypeDef *hirda); | |
500 HAL_StatusTypeDef HAL_IRDA_AbortReceive(IRDA_HandleTypeDef *hirda); | |
501 HAL_StatusTypeDef HAL_IRDA_Abort_IT(IRDA_HandleTypeDef *hirda); | |
502 HAL_StatusTypeDef HAL_IRDA_AbortTransmit_IT(IRDA_HandleTypeDef *hirda); | |
503 HAL_StatusTypeDef HAL_IRDA_AbortReceive_IT(IRDA_HandleTypeDef *hirda); | |
504 | |
505 void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef *hirda); | |
506 void HAL_IRDA_TxCpltCallback(IRDA_HandleTypeDef *hirda); | |
507 void HAL_IRDA_RxCpltCallback(IRDA_HandleTypeDef *hirda); | |
508 void HAL_IRDA_TxHalfCpltCallback(IRDA_HandleTypeDef *hirda); | |
509 void HAL_IRDA_RxHalfCpltCallback(IRDA_HandleTypeDef *hirda); | |
510 void HAL_IRDA_ErrorCallback(IRDA_HandleTypeDef *hirda); | |
511 void HAL_IRDA_AbortCpltCallback(IRDA_HandleTypeDef *hirda); | |
512 void HAL_IRDA_AbortTransmitCpltCallback(IRDA_HandleTypeDef *hirda); | |
513 void HAL_IRDA_AbortReceiveCpltCallback(IRDA_HandleTypeDef *hirda); | |
514 /** | |
515 * @} | |
516 */ | |
517 | |
518 /** @addtogroup IRDA_Exported_Functions_Group3 | |
519 * @{ | |
520 */ | |
521 /* Peripheral State functions **************************************************/ | |
522 HAL_IRDA_StateTypeDef HAL_IRDA_GetState(IRDA_HandleTypeDef *hirda); | |
523 uint32_t HAL_IRDA_GetError(IRDA_HandleTypeDef *hirda); | |
524 /** | |
525 * @} | |
526 */ | |
527 | |
528 /** | |
529 * @} | |
530 */ | |
531 | |
532 /* Private types -------------------------------------------------------------*/ | |
533 /* Private variables ---------------------------------------------------------*/ | |
534 /* Private constants ---------------------------------------------------------*/ | |
535 /** @defgroup IRDA_Private_Constants IRDA Private Constants | |
536 * @{ | |
537 */ | |
538 | |
539 /** @brief IRDA interruptions flag mask | |
540 * | |
541 */ | |
542 #define IRDA_IT_MASK ((uint32_t) USART_CR1_PEIE | USART_CR1_TXEIE | USART_CR1_TCIE | USART_CR1_RXNEIE | \ | |
543 USART_CR1_IDLEIE | USART_CR2_LBDIE | USART_CR3_CTSIE | USART_CR3_EIE ) | |
544 | |
545 #define IRDA_CR1_REG_INDEX 1U | |
546 #define IRDA_CR2_REG_INDEX 2U | |
547 #define IRDA_CR3_REG_INDEX 3U | |
548 /** | |
549 * @} | |
550 */ | |
551 | |
552 /* Private macros --------------------------------------------------------*/ | |
553 /** @defgroup IRDA_Private_Macros IRDA Private Macros | |
554 * @{ | |
555 */ | |
556 #define IS_IRDA_WORD_LENGTH(LENGTH) (((LENGTH) == IRDA_WORDLENGTH_8B) || \ | |
557 ((LENGTH) == IRDA_WORDLENGTH_9B)) | |
558 #define IS_IRDA_PARITY(PARITY) (((PARITY) == IRDA_PARITY_NONE) || \ | |
559 ((PARITY) == IRDA_PARITY_EVEN) || \ | |
560 ((PARITY) == IRDA_PARITY_ODD)) | |
561 #define IS_IRDA_MODE(MODE) ((((MODE) & 0x0000FFF3U) == 0x00U) && ((MODE) != 0x00000000U)) | |
562 #define IS_IRDA_POWERMODE(MODE) (((MODE) == IRDA_POWERMODE_LOWPOWER) || \ | |
563 ((MODE) == IRDA_POWERMODE_NORMAL)) | |
564 #define IS_IRDA_BAUDRATE(BAUDRATE) ((BAUDRATE) < 115201U) | |
565 | |
566 #define IRDA_DIV(_PCLK_, _BAUD_) (((_PCLK_)*25U)/(4U*(_BAUD_))) | |
567 #define IRDA_DIVMANT(_PCLK_, _BAUD_) (IRDA_DIV((_PCLK_), (_BAUD_))/100U) | |
568 #define IRDA_DIVFRAQ(_PCLK_, _BAUD_) (((IRDA_DIV((_PCLK_), (_BAUD_)) - (IRDA_DIVMANT((_PCLK_), (_BAUD_)) * 100U)) * 16U + 50U) / 100U) | |
569 /* UART BRR = mantissa + overflow + fraction | |
570 = (UART DIVMANT << 4) + (UART DIVFRAQ & 0xF0) + (UART DIVFRAQ & 0x0FU) */ | |
571 #define IRDA_BRR(_PCLK_, _BAUD_) (((IRDA_DIVMANT((_PCLK_), (_BAUD_)) << 4U) + \ | |
572 (IRDA_DIVFRAQ((_PCLK_), (_BAUD_)) & 0xF0U)) + \ | |
573 (IRDA_DIVFRAQ((_PCLK_), (_BAUD_)) & 0x0FU)) | |
574 | |
575 /** | |
576 * @} | |
577 */ | |
578 | |
579 /* Private functions ---------------------------------------------------------*/ | |
580 /** @defgroup IRDA_Private_Functions IRDA Private Functions | |
581 * @{ | |
582 */ | |
583 | |
584 /** | |
585 * @} | |
586 */ | |
587 | |
588 /** | |
589 * @} | |
590 */ | |
591 | |
592 /** | |
593 * @} | |
594 */ | |
595 | |
596 #ifdef __cplusplus | |
597 } | |
598 #endif | |
599 | |
600 #endif /* __STM32F4xx_HAL_IRDA_H */ | |
601 | |
602 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |