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