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