]> git.gir.st - tmk_keyboard.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F3/stm32f3xx_hal_irda.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[tmk_keyboard.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_STM / TARGET_STM32F3 / stm32f3xx_hal_irda.h
1 /**
2 ******************************************************************************
3 * @file stm32f3xx_hal_irda.h
4 * @author MCD Application Team
5 * @version V1.1.0
6 * @date 12-Sept-2014
7 * @brief Header file of IRDA HAL 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 __STM32F3xx_HAL_IRDA_H
40 #define __STM32F3xx_HAL_IRDA_H
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32f3xx_hal_def.h"
48
49 /** @addtogroup STM32F3xx_HAL_Driver
50 * @{
51 */
52
53 /** @addtogroup IRDA IRDA HAL module driver
54 * @{
55 */
56
57 /* Exported types ------------------------------------------------------------*/
58 /** @defgroup IRDA_Exported_Types IRDA Exported Types
59 * @{
60 */
61
62 /**
63 * @brief IRDA Init Structure definition
64 */
65 typedef struct
66 {
67 uint32_t BaudRate; /*!< This member configures the IRDA communication baud rate.
68 The baud rate register is computed using the following formula:
69 Baud Rate Register = ((PCLKx) / ((hirda->Init.BaudRate))) */
70
71 uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
72 This parameter can be a value of @ref IRDAEx_Word_Length */
73
74 uint16_t Parity; /*!< Specifies the parity mode.
75 This parameter can be a value of @ref IRDA_Parity
76 @note When parity is enabled, the computed parity is inserted
77 at the MSB position of the transmitted data (9th bit when
78 the word length is set to 9 data bits; 8th bit when the
79 word length is set to 8 data bits). */
80
81 uint16_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
82 This parameter can be a value of @ref IRDA_Mode */
83
84 uint8_t Prescaler; /*!< Specifies the Prescaler value for dividing the UART/USART source clock
85 to achieve low-power frequency.
86 @note Prescaler value 0 is forbidden */
87
88 uint16_t PowerMode; /*!< Specifies the IRDA power mode.
89 This parameter can be a value of @ref IRDA_Low_Power */
90 }IRDA_InitTypeDef;
91
92 /**
93 * @brief HAL IRDA State structures definition
94 */
95 typedef enum
96 {
97 HAL_IRDA_STATE_RESET = 0x00, /*!< Peripheral is not initialized */
98 HAL_IRDA_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */
99 HAL_IRDA_STATE_BUSY = 0x02, /*!< an internal process is ongoing */
100 HAL_IRDA_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */
101 HAL_IRDA_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */
102 HAL_IRDA_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission and Reception process is ongoing */
103 HAL_IRDA_STATE_TIMEOUT = 0x03, /*!< Timeout state */
104 HAL_IRDA_STATE_ERROR = 0x04 /*!< Error */
105 }HAL_IRDA_StateTypeDef;
106
107 /**
108 * @brief HAL IRDA Error Code structure definition
109 */
110 typedef enum
111 {
112 HAL_IRDA_ERROR_NONE = 0x00, /*!< No error */
113 HAL_IRDA_ERROR_PE = 0x01, /*!< Parity error */
114 HAL_IRDA_ERROR_NE = 0x02, /*!< Noise error */
115 HAL_IRDA_ERROR_FE = 0x04, /*!< frame error */
116 HAL_IRDA_ERROR_ORE = 0x08, /*!< Overrun error */
117 HAL_IRDA_ERROR_DMA = 0x10 /*!< DMA transfer error */
118 }HAL_IRDA_ErrorTypeDef;
119
120 /**
121 * @brief IRDA clock sources definition
122 */
123 typedef enum
124 {
125 IRDA_CLOCKSOURCE_PCLK1 = 0x00, /*!< PCLK1 clock source */
126 IRDA_CLOCKSOURCE_PCLK2 = 0x01, /*!< PCLK2 clock source */
127 IRDA_CLOCKSOURCE_HSI = 0x02, /*!< HSI clock source */
128 IRDA_CLOCKSOURCE_SYSCLK = 0x04, /*!< SYSCLK clock source */
129 IRDA_CLOCKSOURCE_LSE = 0x08, /*!< LSE clock source */
130 IRDA_CLOCKSOURCE_UNDEFINED = 0x10 /*!< Undefined clock source */
131 }IRDA_ClockSourceTypeDef;
132
133 /**
134 * @brief IRDA handle Structure definition
135 */
136 typedef struct
137 {
138 USART_TypeDef *Instance; /* USART registers base address */
139
140 IRDA_InitTypeDef Init; /* IRDA communication parameters */
141
142 uint8_t *pTxBuffPtr; /* Pointer to IRDA Tx transfer Buffer */
143
144 uint16_t TxXferSize; /* IRDA Tx Transfer size */
145
146 uint16_t TxXferCount; /* IRDA Tx Transfer Counter */
147
148 uint8_t *pRxBuffPtr; /* Pointer to IRDA Rx transfer Buffer */
149
150 uint16_t RxXferSize; /* IRDA Rx Transfer size */
151
152 uint16_t RxXferCount; /* IRDA Rx Transfer Counter */
153
154 uint16_t Mask; /* USART RX RDR register mask */
155
156 DMA_HandleTypeDef *hdmatx; /* IRDA Tx DMA Handle parameters */
157
158 DMA_HandleTypeDef *hdmarx; /* IRDA Rx DMA Handle parameters */
159
160 HAL_LockTypeDef Lock; /* Locking object */
161
162 HAL_IRDA_StateTypeDef State; /* IRDA communication state */
163
164 HAL_IRDA_ErrorTypeDef ErrorCode; /* IRDA Error code */
165
166 }IRDA_HandleTypeDef;
167
168 /**
169 * @brief IRDA Configuration enumeration values definition
170 */
171 typedef enum
172 {
173 IRDA_BAUDRATE = 0x00,
174 IRDA_PARITY = 0x01,
175 IRDA_WORDLENGTH = 0x02,
176 IRDA_MODE = 0x03,
177 IRDA_PRESCALER = 0x04,
178 IRDA_POWERMODE = 0x05
179 }IRDA_ControlTypeDef;
180
181 /**
182 * @}
183 */
184
185 /* Exported constants --------------------------------------------------------*/
186 /** @defgroup IRDA_Exported_Constants IRDA Exported Constants
187 * @{
188 */
189
190 /** @defgroup IRDA_Parity IRDA Parity
191 * @{
192 */
193 #define IRDA_PARITY_NONE ((uint16_t)0x0000)
194 #define IRDA_PARITY_EVEN ((uint16_t)USART_CR1_PCE)
195 #define IRDA_PARITY_ODD ((uint16_t)(USART_CR1_PCE | USART_CR1_PS))
196 #define IS_IRDA_PARITY(PARITY) (((PARITY) == IRDA_PARITY_NONE) || \
197 ((PARITY) == IRDA_PARITY_EVEN) || \
198 ((PARITY) == IRDA_PARITY_ODD))
199 /**
200 * @}
201 */
202
203
204 /** @defgroup IRDA_Transfer_Mode IRDA Transfer Mode
205 * @{
206 */
207 #define IRDA_MODE_RX ((uint16_t)USART_CR1_RE)
208 #define IRDA_MODE_TX ((uint16_t)USART_CR1_TE)
209 #define IRDA_MODE_TX_RX ((uint16_t)(USART_CR1_TE |USART_CR1_RE))
210 #define IS_IRDA_TX_RX_MODE(MODE) ((((MODE) & (~((uint16_t)(IRDA_MODE_TX_RX)))) == (uint16_t)0x00) && ((MODE) != (uint16_t)0x00))
211 /**
212 * @}
213 */
214
215 /** @defgroup IRDA_Low_Power IRDA Low Power
216 * @{
217 */
218 #define IRDA_POWERMODE_NORMAL ((uint16_t)0x0000)
219 #define IRDA_POWERMODE_LOWPOWER ((uint16_t)USART_CR3_IRLP)
220 #define IS_IRDA_POWERMODE(MODE) (((MODE) == IRDA_POWERMODE_LOWPOWER) || \
221 ((MODE) == IRDA_POWERMODE_NORMAL))
222 /**
223 * @}
224 */
225
226 /** @defgroup IRDA_State IRDA State
227 * @{
228 */
229 #define IRDA_STATE_DISABLE ((uint16_t)0x0000)
230 #define IRDA_STATE_ENABLE ((uint16_t)USART_CR1_UE)
231 #define IS_IRDA_STATE(STATE) (((STATE) == IRDA_STATE_DISABLE) || \
232 ((STATE) == IRDA_STATE_ENABLE))
233 /**
234 * @}
235 */
236
237 /** @defgroup IRDA_Mode IRDA Mode
238 * @{
239 */
240 #define IRDA_MODE_DISABLE ((uint16_t)0x0000)
241 #define IRDA_MODE_ENABLE ((uint16_t)USART_CR3_IREN)
242 #define IS_IRDA_MODE(STATE) (((STATE) == IRDA_MODE_DISABLE) || \
243 ((STATE) == IRDA_MODE_ENABLE))
244 /**
245 * @}
246 */
247
248 /** @defgroup IRDA_One_Bit IRDA One Bit Sampling
249 * @{
250 */
251 #define IRDA_ONE_BIT_SAMPLE_DISABLED ((uint16_t)0x00000000)
252 #define IRDA_ONE_BIT_SAMPLE_ENABLED ((uint16_t)USART_CR3_ONEBIT)
253 #define IS_IRDA_ONEBIT_SAMPLE(ONEBIT) (((ONEBIT) == IRDA_ONE_BIT_SAMPLE_DISABLED) || \
254 ((ONEBIT) == IRDA_ONE_BIT_SAMPLE_ENABLED))
255 /**
256 * @}
257 */
258
259 /** @defgroup IRDA_DMA_Tx IRDA DMA Tx
260 * @{
261 */
262 #define IRDA_DMA_TX_DISABLE ((uint16_t)0x00000000)
263 #define IRDA_DMA_TX_ENABLE ((uint16_t)USART_CR3_DMAT)
264 #define IS_IRDA_DMA_TX(DMATX) (((DMATX) == IRDA_DMA_TX_DISABLE) || \
265 ((DMATX) == IRDA_DMA_TX_ENABLE))
266 /**
267 * @}
268 */
269
270 /** @defgroup IRDA_DMA_Rx IRDA DMA Rx
271 * @{
272 */
273 #define IRDA_DMA_RX_DISABLE ((uint16_t)0x0000)
274 #define IRDA_DMA_RX_ENABLE ((uint16_t)USART_CR3_DMAR)
275 #define IS_IRDA_DMA_RX(DMARX) (((DMARX) == IRDA_DMA_RX_DISABLE) || \
276 ((DMARX) == IRDA_DMA_RX_ENABLE))
277 /**
278 * @}
279 */
280
281 /** @defgroup IRDA_Flags IRDA Flags
282 * Elements values convention: 0xXXXX
283 * - 0xXXXX : Flag mask in the ISR register
284 * @{
285 */
286 #define IRDA_FLAG_REACK ((uint32_t)0x00400000)
287 #define IRDA_FLAG_TEACK ((uint32_t)0x00200000)
288 #define IRDA_FLAG_BUSY ((uint32_t)0x00010000)
289 #define IRDA_FLAG_ABRF ((uint32_t)0x00008000)
290 #define IRDA_FLAG_ABRE ((uint32_t)0x00004000)
291 #define IRDA_FLAG_TXE ((uint32_t)0x00000080)
292 #define IRDA_FLAG_TC ((uint32_t)0x00000040)
293 #define IRDA_FLAG_RXNE ((uint32_t)0x00000020)
294 #define IRDA_FLAG_ORE ((uint32_t)0x00000008)
295 #define IRDA_FLAG_NE ((uint32_t)0x00000004)
296 #define IRDA_FLAG_FE ((uint32_t)0x00000002)
297 #define IRDA_FLAG_PE ((uint32_t)0x00000001)
298 /**
299 * @}
300 */
301
302 /** @defgroup IRDA_Interrupt_definition IRDA Interrupts Definition
303 * Elements values convention: 0000ZZZZ0XXYYYYYb
304 * - YYYYY : Interrupt source position in the XX register (5bits)
305 * - XX : Interrupt source register (2bits)
306 * - 01: CR1 register
307 * - 10: CR2 register
308 * - 11: CR3 register
309 * - ZZZZ : Flag position in the ISR register(4bits)
310 * @{
311 */
312 #define IRDA_IT_PE ((uint16_t)0x0028)
313 #define IRDA_IT_TXE ((uint16_t)0x0727)
314 #define IRDA_IT_TC ((uint16_t)0x0626)
315 #define IRDA_IT_RXNE ((uint16_t)0x0525)
316 #define IRDA_IT_IDLE ((uint16_t)0x0424)
317
318
319
320 /** Elements values convention: 000000000XXYYYYYb
321 * - YYYYY : Interrupt source position in the XX register (5bits)
322 * - XX : Interrupt source register (2bits)
323 * - 01: CR1 register
324 * - 10: CR2 register
325 * - 11: CR3 register
326 */
327 #define IRDA_IT_ERR ((uint16_t)0x0060)
328
329 /** Elements values convention: 0000ZZZZ00000000b
330 * - ZZZZ : Flag position in the ISR register(4bits)
331 */
332 #define IRDA_IT_ORE ((uint16_t)0x0300)
333 #define IRDA_IT_NE ((uint16_t)0x0200)
334 #define IRDA_IT_FE ((uint16_t)0x0100)
335 /**
336 * @}
337 */
338
339 /** @defgroup IRDA_IT_CLEAR_Flags IRDA Interruption Clear Flags
340 * @{
341 */
342 #define IRDA_CLEAR_PEF USART_ICR_PECF /*!< Parity Error Clear Flag */
343 #define IRDA_CLEAR_FEF USART_ICR_FECF /*!< Framing Error Clear Flag */
344 #define IRDA_CLEAR_NEF USART_ICR_NCF /*!< Noise detected Clear Flag */
345 #define IRDA_CLEAR_OREF USART_ICR_ORECF /*!< OverRun Error Clear Flag */
346 #define IRDA_CLEAR_TCF USART_ICR_TCCF /*!< Transmission Complete Clear Flag */
347 /**
348 * @}
349 */
350
351
352
353 /** @defgroup IRDA_Request_Parameters IRDA Request Parameters
354 * @{
355 */
356 #define IRDA_AUTOBAUD_REQUEST ((uint16_t)USART_RQR_ABRRQ) /*!< Auto-Baud Rate Request */
357 #define IRDA_RXDATA_FLUSH_REQUEST ((uint16_t)USART_RQR_RXFRQ) /*!< Receive Data flush Request */
358 #define IRDA_TXDATA_FLUSH_REQUEST ((uint16_t)USART_RQR_TXFRQ) /*!< Transmit data flush Request */
359 #define IS_IRDA_REQUEST_PARAMETER(PARAM) (((PARAM) == IRDA_AUTOBAUD_REQUEST) || \
360 ((PARAM) == IRDA_SENDBREAK_REQUEST) || \
361 ((PARAM) == IRDA_MUTE_MODE_REQUEST) || \
362 ((PARAM) == IRDA_RXDATA_FLUSH_REQUEST) || \
363 ((PARAM) == IRDA_TXDATA_FLUSH_REQUEST))
364 /**
365 * @}
366 */
367
368 /** @defgroup IRDA_Interruption_Mask IRDA interruptions flag mask
369 * @{
370 */
371 #define IRDA_IT_MASK ((uint16_t)0x001F)
372 /**
373 * @}
374 */
375
376 /**
377 * @}
378 */
379
380 /* Exported macros -----------------------------------------------------------*/
381 /** @defgroup IRDA_Exported_Macros IRDA Exported Macros
382 * @{
383 */
384
385 /** @brief Reset IRDA handle state
386 * @param __HANDLE__: IRDA handle.
387 * @retval None
388 */
389 #define __HAL_IRDA_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_IRDA_STATE_RESET)
390
391 /** @brief Checks whether the specified IRDA flag is set or not.
392 * @param __HANDLE__: specifies the IRDA Handle.
393 * The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or
394 * UART peripheral
395 * @param __FLAG__: specifies the flag to check.
396 * This parameter can be one of the following values:
397 * @arg IRDA_FLAG_REACK: Receive enable ackowledge flag
398 * @arg IRDA_FLAG_TEACK: Transmit enable ackowledge flag
399 * @arg IRDA_FLAG_BUSY: Busy flag
400 * @arg IRDA_FLAG_ABRF: Auto Baud rate detection flag
401 * @arg IRDA_FLAG_ABRE: Auto Baud rate detection error flag
402 * @arg IRDA_FLAG_TXE: Transmit data register empty flag
403 * @arg IRDA_FLAG_TC: Transmission Complete flag
404 * @arg IRDA_FLAG_RXNE: Receive data register not empty flag
405 * @arg IRDA_FLAG_IDLE: Idle Line detection flag
406 * @arg IRDA_FLAG_ORE: OverRun Error flag
407 * @arg IRDA_FLAG_NE: Noise Error flag
408 * @arg IRDA_FLAG_FE: Framing Error flag
409 * @arg IRDA_FLAG_PE: Parity Error flag
410 * @retval The new state of __FLAG__ (TRUE or FALSE).
411 */
412 #define __HAL_IRDA_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))
413
414 /** @brief Enables the specified IRDA interrupt.
415 * @param __HANDLE__: specifies the IRDA Handle.
416 * The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or
417 * UART peripheral
418 * @param __INTERRUPT__: specifies the IRDA interrupt source to enable.
419 * This parameter can be one of the following values:
420 * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt
421 * @arg IRDA_IT_TC: Transmission complete interrupt
422 * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt
423 * @arg IRDA_IT_IDLE: Idle line detection interrupt
424 * @arg IRDA_IT_PE: Parity Error interrupt
425 * @arg IRDA_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
426 * @retval None
427 */
428 #define __HAL_IRDA_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 |= (1U << ((__INTERRUPT__) & IRDA_IT_MASK))): \
429 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 |= (1U << ((__INTERRUPT__) & IRDA_IT_MASK))): \
430 ((__HANDLE__)->Instance->CR3 |= (1U << ((__INTERRUPT__) & IRDA_IT_MASK))))
431
432 /** @brief Disables the specified IRDA interrupt.
433 * @param __HANDLE__: specifies the IRDA Handle.
434 * The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or
435 * UART peripheral
436 * @param __INTERRUPT__: specifies the IRDA interrupt source to disable.
437 * This parameter can be one of the following values:
438 * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt
439 * @arg IRDA_IT_TC: Transmission complete interrupt
440 * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt
441 * @arg IRDA_IT_IDLE: Idle line detection interrupt
442 * @arg IRDA_IT_PE: Parity Error interrupt
443 * @arg IRDA_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
444 * @retval None
445 */
446 #define __HAL_IRDA_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 &= ~ (1U << ((__INTERRUPT__) & IRDA_IT_MASK))): \
447 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 &= ~ (1U << ((__INTERRUPT__) & IRDA_IT_MASK))): \
448 ((__HANDLE__)->Instance->CR3 &= ~ (1U << ((__INTERRUPT__) & IRDA_IT_MASK))))
449
450
451 /** @brief Checks whether the specified IRDA interrupt has occurred or not.
452 * @param __HANDLE__: specifies the IRDA Handle.
453 * The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or
454 * UART peripheral
455 * @param __IT__: specifies the IRDA interrupt source to check.
456 * This parameter can be one of the following values:
457 * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt
458 * @arg IRDA_IT_TC: Transmission complete interrupt
459 * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt
460 * @arg IRDA_IT_IDLE: Idle line detection interrupt
461 * @arg IRDA_IT_ORE: OverRun Error interrupt
462 * @arg IRDA_IT_NE: Noise Error interrupt
463 * @arg IRDA_IT_FE: Framing Error interrupt
464 * @arg IRDA_IT_PE: Parity Error interrupt
465 * @retval The new state of __IT__ (TRUE or FALSE).
466 */
467 #define __HAL_IRDA_GET_IT(__HANDLE__, __IT__) ((__HANDLE__)->Instance->ISR & ((uint32_t)1U << ((__IT__)>> 0x08)))
468
469 /** @brief Checks whether the specified IRDA interrupt source is enabled.
470 * @param __HANDLE__: specifies the IRDA Handle.
471 * The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or
472 * UART peripheral
473 * @param __IT__: specifies the IRDA interrupt source to check.
474 * This parameter can be one of the following values:
475 * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt
476 * @arg IRDA_IT_TC: Transmission complete interrupt
477 * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt
478 * @arg IRDA_IT_IDLE: Idle line detection interrupt
479 * @arg IRDA_IT_ORE: OverRun Error interrupt
480 * @arg IRDA_IT_NE: Noise Error interrupt
481 * @arg IRDA_IT_FE: Framing Error interrupt
482 * @arg IRDA_IT_PE: Parity Error interrupt
483 * @retval The new state of __IT__ (TRUE or FALSE).
484 */
485 #define __HAL_IRDA_GET_IT_SOURCE(__HANDLE__, __IT__) ((((((uint8_t)(__IT__)) >> 5U) == 1)? (__HANDLE__)->Instance->CR1:(((((uint8_t)(__IT__)) >> 5U) == 2)? \
486 (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & ((uint32_t)1 << (((uint16_t)(__IT__)) & IRDA_IT_MASK)))
487
488
489 /** @brief Clears the specified IRDA ISR flag, in setting the proper ICR register flag.
490 * @param __HANDLE__: specifies the IRDA Handle.
491 * The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or
492 * UART peripheral
493 * @param __IT_CLEAR__: specifies the interrupt clear register flag that needs to be set
494 * to clear the corresponding interrupt
495 * This parameter can be one of the following values:
496 * @arg IRDA_CLEAR_PEF: Parity Error Clear Flag
497 * @arg IRDA_CLEAR_FEF: Framing Error Clear Flag
498 * @arg IRDA_CLEAR_NEF: Noise detected Clear Flag
499 * @arg IRDA_CLEAR_OREF: OverRun Error Clear Flag
500 * @arg IRDA_CLEAR_TCF: Transmission Complete Clear Flag
501 * @retval None
502 */
503 #define __HAL_IRDA_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__))
504
505
506 /** @brief Set a specific IRDA request flag.
507 * @param __HANDLE__: specifies the IRDA Handle.
508 * The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or
509 * UART peripheral
510 * @param __REQ__: specifies the request flag to set
511 * This parameter can be one of the following values:
512 * @arg IRDA_AUTOBAUD_REQUEST: Auto-Baud Rate Request
513 * @arg IRDA_RXDATA_FLUSH_REQUEST: Receive Data flush Request
514 * @arg IRDA_TXDATA_FLUSH_REQUEST: Transmit data flush Request
515 *
516 * @retval None
517 */
518 #define __HAL_IRDA_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (uint16_t)(__REQ__))
519
520
521
522 /** @brief Enable UART/USART associated to IRDA Handle
523 * @param __HANDLE__: specifies the IRDA Handle.
524 * The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or
525 * UART peripheral
526 * @retval None
527 */
528 #define __HAL_IRDA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
529
530 /** @brief Disable UART/USART associated to IRDA Handle
531 * @param __HANDLE__: specifies the IRDA Handle.
532 * The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or
533 * UART peripheral
534 * @retval None
535 */
536 #define __HAL_IRDA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
537
538 /** @brief Ensure that IRDA Baud rate is less or equal to maximum value
539 * @param __BAUDRATE__: specifies the IRDA Baudrate set by the user.
540 * @retval True or False
541 */
542 #define IS_IRDA_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 115201)
543
544 /** @brief Ensure that IRDA prescaler value is strictly larger than 0
545 * @param __PRESCALER__: specifies the IRDA prescaler value set by the user.
546 * @retval True or False
547 */
548 #define IS_IRDA_PRESCALER(__PRESCALER__) ((__PRESCALER__) > 0)
549
550 /**
551 * @}
552 */
553
554 /* Include IRDA HAL Extended module */
555 #include "stm32f3xx_hal_irda_ex.h"
556
557 /* Exported functions --------------------------------------------------------*/
558
559 /** @addtogroup IRDA_Exported_Functions IRDA Exported Functions
560 * @{
561 */
562
563 /** @addtogroup IRDA_Exported_Functions_Group1 Initialization and de-initialization functions
564 * @{
565 */
566
567 /* Initialization and de-initialization functions ****************************/
568 HAL_StatusTypeDef HAL_IRDA_Init(IRDA_HandleTypeDef *hirda);
569 HAL_StatusTypeDef HAL_IRDA_DeInit(IRDA_HandleTypeDef *hirda);
570 void HAL_IRDA_MspInit(IRDA_HandleTypeDef *hirda);
571 void HAL_IRDA_MspDeInit(IRDA_HandleTypeDef *hirda);
572
573 /**
574 * @}
575 */
576
577 /** @addtogroup IRDA_Exported_Functions_Group2 Input and Output operation functions
578 * @{
579 */
580
581 /* IO operation functions *****************************************************/
582 HAL_StatusTypeDef HAL_IRDA_Transmit(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout);
583 HAL_StatusTypeDef HAL_IRDA_Receive(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout);
584 HAL_StatusTypeDef HAL_IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
585 HAL_StatusTypeDef HAL_IRDA_Receive_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
586 HAL_StatusTypeDef HAL_IRDA_Transmit_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
587 HAL_StatusTypeDef HAL_IRDA_Receive_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
588 void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef *hirda);
589 void HAL_IRDA_TxCpltCallback(IRDA_HandleTypeDef *hirda);
590 void HAL_IRDA_RxCpltCallback(IRDA_HandleTypeDef *hirda);
591 void HAL_IRDA_ErrorCallback(IRDA_HandleTypeDef *hirda);
592
593 /**
594 * @}
595 */
596
597 /** @addtogroup IRDA_Exported_Functions_Group3 Peripheral State and Errors functions
598 * @{
599 */
600
601 /* Peripheral State and Error functions ***************************************/
602 HAL_IRDA_StateTypeDef HAL_IRDA_GetState(IRDA_HandleTypeDef *hirda);
603 uint32_t HAL_IRDA_GetError(IRDA_HandleTypeDef *hirda);
604
605 /**
606 * @}
607 */
608
609 /**
610 * @}
611 */
612
613 /**
614 * @}
615 */
616
617 /**
618 * @}
619 */
620 #ifdef __cplusplus
621 }
622 #endif
623
624 #endif /* __STM32F3xx_HAL_IRDA_H */
625
626 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Imprint / Impressum