Subversion Repositories canSerial

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 3
Line 1... Line 1...
1
/**
1
/**
2
  ******************************************************************************
2
  ******************************************************************************
3
  * @file    stm32f1xx_hal_irda.h
3
  * @file    stm32f1xx_hal_irda.h
4
  * @author  MCD Application Team
4
  * @author  MCD Application Team
5
  * @brief   Header file of IRDA HAL module.
5
  * @brief   Header file of IRDA HAL module.
6
  ******************************************************************************
6
  ******************************************************************************
7
  * @attention
7
  * @attention
8
  *
8
  *
9
  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
9
  * Copyright (c) 2016 STMicroelectronics.
10
  * All rights reserved.</center></h2>
10
  * All rights reserved.
11
  *
11
  *
12
  * This software component is licensed by ST under BSD 3-Clause license,
12
  * This software is licensed under terms that can be found in the LICENSE file
13
  * the "License"; You may not use this file except in compliance with the
13
  * in the root directory of this software component.
14
  * License. You may obtain a copy of the License at:
14
  * If no LICENSE file comes with this software, it is provided AS-IS.
15
  *                        opensource.org/licenses/BSD-3-Clause
15
  *
16
  *
16
  ******************************************************************************
17
  ******************************************************************************
17
  */
18
  */
18
 
19
 
19
/* Define to prevent recursive inclusion -------------------------------------*/
20
/* Define to prevent recursive inclusion -------------------------------------*/
20
#ifndef __STM32F1xx_HAL_IRDA_H
21
#ifndef __STM32F1xx_HAL_IRDA_H
21
#define __STM32F1xx_HAL_IRDA_H
22
#define __STM32F1xx_HAL_IRDA_H
22
 
23
 
23
#ifdef __cplusplus
24
#ifdef __cplusplus
24
extern "C" {
25
extern "C" {
25
#endif
26
#endif
26
 
27
 
27
/* Includes ------------------------------------------------------------------*/
28
/* Includes ------------------------------------------------------------------*/
28
#include "stm32f1xx_hal_def.h"
29
#include "stm32f1xx_hal_def.h"
29
 
30
 
30
/** @addtogroup STM32F1xx_HAL_Driver
31
/** @addtogroup STM32F1xx_HAL_Driver
31
  * @{
32
  * @{
32
  */
33
  */
33
 
34
 
34
/** @addtogroup IRDA
35
/** @addtogroup IRDA
35
  * @{
36
  * @{
36
  */
37
  */
37
 
38
 
38
/* Exported types ------------------------------------------------------------*/
39
/* Exported types ------------------------------------------------------------*/
39
/** @defgroup IRDA_Exported_Types IRDA Exported Types
40
/** @defgroup IRDA_Exported_Types IRDA Exported Types
40
  * @{
41
  * @{
41
  */
42
  */
42
/**
43
/**
43
  * @brief IRDA Init Structure definition
44
  * @brief IRDA Init Structure definition
44
  */
45
  */
45
typedef struct
46
typedef struct
46
{
47
{
47
  uint32_t BaudRate;                  /*!< This member configures the IRDA communication baud rate.
48
  uint32_t BaudRate;                  /*!< This member configures the IRDA communication baud rate.
48
                                           The baud rate is computed using the following formula:
49
                                           The baud rate is computed using the following formula:
49
                                           - IntegerDivider = ((PCLKx) / (16 * (hirda->Init.BaudRate)))
50
                                           - IntegerDivider = ((PCLKx) / (16 * (hirda->Init.BaudRate)))
50
                                           - FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 16) + 0.5 */
51
                                           - FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 16) + 0.5 */
51
 
52
 
52
  uint32_t WordLength;                /*!< Specifies the number of data bits transmitted or received in a frame.
53
  uint32_t WordLength;                /*!< Specifies the number of data bits transmitted or received in a frame.
53
                                           This parameter can be a value of @ref IRDA_Word_Length */
54
                                           This parameter can be a value of @ref IRDA_Word_Length */
54
 
55
 
55
  uint32_t Parity;                    /*!< Specifies the parity mode.
56
  uint32_t Parity;                    /*!< Specifies the parity mode.
56
                                           This parameter can be a value of @ref IRDA_Parity
57
                                           This parameter can be a value of @ref IRDA_Parity
57
                                           @note When parity is enabled, the computed parity is inserted
58
                                           @note When parity is enabled, the computed parity is inserted
58
                                                 at the MSB position of the transmitted data (9th bit when
59
                                                 at the MSB position of the transmitted data (9th bit when
59
                                                 the word length is set to 9 data bits; 8th bit when the
60
                                                 the word length is set to 9 data bits; 8th bit when the
60
                                                 word length is set to 8 data bits). */
61
                                                 word length is set to 8 data bits). */
61
 
62
 
62
  uint32_t Mode;                      /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
63
  uint32_t Mode;                      /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
63
                                           This parameter can be a value of @ref IRDA_Mode */
64
                                           This parameter can be a value of @ref IRDA_Mode */
64
 
65
 
65
  uint8_t  Prescaler;                 /*!< Specifies the Prescaler value to be programmed
66
  uint8_t  Prescaler;                 /*!< Specifies the Prescaler value to be programmed
66
                                           in the IrDA low-power Baud Register, for defining pulse width on which
67
                                           in the IrDA low-power Baud Register, for defining pulse width on which
67
                                           burst acceptance/rejection will be decided. This value is used as divisor
68
                                           burst acceptance/rejection will be decided. This value is used as divisor
68
                                           of system clock to achieve required pulse width. */
69
                                           of system clock to achieve required pulse width. */
69
 
70
 
70
  uint32_t IrDAMode;                  /*!< Specifies the IrDA mode
71
  uint32_t IrDAMode;                  /*!< Specifies the IrDA mode
71
                                           This parameter can be a value of @ref IRDA_Low_Power */
72
                                           This parameter can be a value of @ref IRDA_Low_Power */
72
} IRDA_InitTypeDef;
73
} IRDA_InitTypeDef;
73
 
74
 
74
/**
75
/**
75
  * @brief HAL IRDA State structures definition
76
  * @brief HAL IRDA State structures definition
76
  * @note  HAL IRDA State value is a combination of 2 different substates: gState and RxState.
77
  * @note  HAL IRDA State value is a combination of 2 different substates: gState and RxState.
77
  *        - gState contains IRDA state information related to global Handle management
78
  *        - gState contains IRDA state information related to global Handle management
78
  *          and also information related to Tx operations.
79
  *          and also information related to Tx operations.
79
  *          gState value coding follow below described bitmap :
80
  *          gState value coding follow below described bitmap :
80
  *          b7-b6  Error information
81
  *          b7-b6  Error information
81
  *             00 : No Error
82
  *             00 : No Error
82
  *             01 : (Not Used)
83
  *             01 : (Not Used)
83
  *             10 : Timeout
84
  *             10 : Timeout
84
  *             11 : Error
85
  *             11 : Error
85
  *          b5     IP initialisation status
86
  *          b5     IP initialisation status
86
  *             0  : Reset (IP not initialized)
87
  *             0  : Reset (IP not initialized)
87
  *             1  : Init done (IP initialized. HAL IRDA Init function already called)
88
  *             1  : Init done (IP initialized. HAL IRDA Init function already called)
88
  *          b4-b3  (not used)
89
  *          b4-b3  (not used)
89
  *             xx : Should be set to 00
90
  *             xx : Should be set to 00
90
  *          b2     Intrinsic process state
91
  *          b2     Intrinsic process state
91
  *             0  : Ready
92
  *             0  : Ready
92
  *             1  : Busy (IP busy with some configuration or internal operations)
93
  *             1  : Busy (IP busy with some configuration or internal operations)
93
  *          b1     (not used)
94
  *          b1     (not used)
94
  *             x  : Should be set to 0
95
  *             x  : Should be set to 0
95
  *          b0     Tx state
96
  *          b0     Tx state
96
  *             0  : Ready (no Tx operation ongoing)
97
  *             0  : Ready (no Tx operation ongoing)
97
  *             1  : Busy (Tx operation ongoing)
98
  *             1  : Busy (Tx operation ongoing)
98
  *        - RxState contains information related to Rx operations.
99
  *        - RxState contains information related to Rx operations.
99
  *          RxState value coding follow below described bitmap :
100
  *          RxState value coding follow below described bitmap :
100
  *          b7-b6  (not used)
101
  *          b7-b6  (not used)
101
  *             xx : Should be set to 00
102
  *             xx : Should be set to 00
102
  *          b5     IP initialisation status
103
  *          b5     IP initialisation status
103
  *             0  : Reset (IP not initialized)
104
  *             0  : Reset (IP not initialized)
104
  *             1  : Init done (IP initialized)
105
  *             1  : Init done (IP initialized)
105
  *          b4-b2  (not used)
106
  *          b4-b2  (not used)
106
  *            xxx : Should be set to 000
107
  *            xxx : Should be set to 000
107
  *          b1     Rx state
108
  *          b1     Rx state
108
  *             0  : Ready (no Rx operation ongoing)
109
  *             0  : Ready (no Rx operation ongoing)
109
  *             1  : Busy (Rx operation ongoing)
110
  *             1  : Busy (Rx operation ongoing)
110
  *          b0     (not used)
111
  *          b0     (not used)
111
  *             x  : Should be set to 0.
112
  *             x  : Should be set to 0.
112
  */
113
  */
113
typedef enum
114
typedef enum
114
{
115
{
115
  HAL_IRDA_STATE_RESET             = 0x00U,    /*!< Peripheral is not yet Initialized
116
  HAL_IRDA_STATE_RESET             = 0x00U,    /*!< Peripheral is not yet Initialized
116
                                                   Value is allowed for gState and RxState */
117
                                                   Value is allowed for gState and RxState */
117
  HAL_IRDA_STATE_READY             = 0x20U,    /*!< Peripheral Initialized and ready for use
118
  HAL_IRDA_STATE_READY             = 0x20U,    /*!< Peripheral Initialized and ready for use
118
                                                   Value is allowed for gState and RxState */
119
                                                   Value is allowed for gState and RxState */
119
  HAL_IRDA_STATE_BUSY              = 0x24U,    /*!< An internal process is ongoing
120
  HAL_IRDA_STATE_BUSY              = 0x24U,    /*!< An internal process is ongoing
120
                                                   Value is allowed for gState only */
121
                                                   Value is allowed for gState only */
121
  HAL_IRDA_STATE_BUSY_TX           = 0x21U,    /*!< Data Transmission process is ongoing
122
  HAL_IRDA_STATE_BUSY_TX           = 0x21U,    /*!< Data Transmission process is ongoing
122
                                                   Value is allowed for gState only */
123
                                                   Value is allowed for gState only */
123
  HAL_IRDA_STATE_BUSY_RX           = 0x22U,    /*!< Data Reception process is ongoing
124
  HAL_IRDA_STATE_BUSY_RX           = 0x22U,    /*!< Data Reception process is ongoing
124
                                                   Value is allowed for RxState only */
125
                                                   Value is allowed for RxState only */
125
  HAL_IRDA_STATE_BUSY_TX_RX        = 0x23U,    /*!< Data Transmission and Reception process is ongoing
126
  HAL_IRDA_STATE_BUSY_TX_RX        = 0x23U,    /*!< Data Transmission and Reception process is ongoing
126
                                                   Not to be used for neither gState nor RxState.
127
                                                   Not to be used for neither gState nor RxState.
127
                                                   Value is result of combination (Or) between gState and RxState values */
128
                                                   Value is result of combination (Or) between gState and RxState values */
128
  HAL_IRDA_STATE_TIMEOUT           = 0xA0U,    /*!< Timeout state
129
  HAL_IRDA_STATE_TIMEOUT           = 0xA0U,    /*!< Timeout state
129
                                                   Value is allowed for gState only */
130
                                                   Value is allowed for gState only */
130
  HAL_IRDA_STATE_ERROR             = 0xE0U     /*!< Error
131
  HAL_IRDA_STATE_ERROR             = 0xE0U     /*!< Error
131
                                                   Value is allowed for gState only */
132
                                                   Value is allowed for gState only */
132
} HAL_IRDA_StateTypeDef;
133
} HAL_IRDA_StateTypeDef;
133
 
134
 
134
/**
135
/**
135
  * @brief IRDA handle Structure definition
136
  * @brief IRDA handle Structure definition
136
  */
137
  */
137
#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
138
#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
138
typedef struct __IRDA_HandleTypeDef
139
typedef struct __IRDA_HandleTypeDef
139
#else
140
#else
140
typedef struct
141
typedef struct
141
#endif  /* USE_HAL_IRDA_REGISTER_CALLBACKS */
142
#endif  /* USE_HAL_IRDA_REGISTER_CALLBACKS */
142
{
143
{
143
  USART_TypeDef               *Instance;        /*!<  USART registers base address       */
144
  USART_TypeDef               *Instance;        /*!<  USART registers base address       */
144
 
145
 
145
  IRDA_InitTypeDef            Init;             /*!<  IRDA communication parameters      */
146
  IRDA_InitTypeDef            Init;             /*!<  IRDA communication parameters      */
146
 
147
 
147
  const uint8_t               *pTxBuffPtr;      /*!<  Pointer to IRDA Tx transfer Buffer */
148
  uint8_t                     *pTxBuffPtr;      /*!<  Pointer to IRDA Tx transfer Buffer */
148
 
149
 
149
  uint16_t                    TxXferSize;       /*!<  IRDA Tx Transfer size              */
150
  uint16_t                    TxXferSize;       /*!<  IRDA Tx Transfer size              */
150
 
151
 
151
  __IO uint16_t               TxXferCount;      /*!<  IRDA Tx Transfer Counter           */
152
  __IO uint16_t               TxXferCount;      /*!<  IRDA Tx Transfer Counter           */
152
 
153
 
153
  uint8_t                     *pRxBuffPtr;      /*!<  Pointer to IRDA Rx transfer Buffer */
154
  uint8_t                     *pRxBuffPtr;      /*!<  Pointer to IRDA Rx transfer Buffer */
154
 
155
 
155
  uint16_t                    RxXferSize;       /*!<  IRDA Rx Transfer size              */
156
  uint16_t                    RxXferSize;       /*!<  IRDA Rx Transfer size              */
156
 
157
 
157
  __IO uint16_t               RxXferCount;      /*!<  IRDA Rx Transfer Counter           */
158
  __IO uint16_t               RxXferCount;      /*!<  IRDA Rx Transfer Counter           */
158
 
159
 
159
  DMA_HandleTypeDef           *hdmatx;          /*!<  IRDA Tx DMA Handle parameters      */
160
  DMA_HandleTypeDef           *hdmatx;          /*!<  IRDA Tx DMA Handle parameters      */
160
 
161
 
161
  DMA_HandleTypeDef           *hdmarx;          /*!<  IRDA Rx DMA Handle parameters      */
162
  DMA_HandleTypeDef           *hdmarx;          /*!<  IRDA Rx DMA Handle parameters      */
162
 
163
 
163
  HAL_LockTypeDef             Lock;             /*!<  Locking object                     */
164
  HAL_LockTypeDef             Lock;             /*!<  Locking object                     */
164
 
165
 
165
  __IO HAL_IRDA_StateTypeDef  gState;           /*!<  IRDA state information related to global Handle management
166
  __IO HAL_IRDA_StateTypeDef  gState;           /*!<  IRDA state information related to global Handle management
166
                                                   and also related to Tx operations.
167
                                                   and also related to Tx operations.
167
                                                   This parameter can be a value of @ref HAL_IRDA_StateTypeDef */
168
                                                   This parameter can be a value of @ref HAL_IRDA_StateTypeDef */
168
 
169
 
169
  __IO HAL_IRDA_StateTypeDef  RxState;          /*!<  IRDA state information related to Rx operations.
170
  __IO HAL_IRDA_StateTypeDef  RxState;          /*!<  IRDA state information related to Rx operations.
170
                                                   This parameter can be a value of @ref HAL_IRDA_StateTypeDef */
171
                                                   This parameter can be a value of @ref HAL_IRDA_StateTypeDef */
171
 
172
 
172
  __IO uint32_t               ErrorCode;        /*!< IRDA Error code                    */
173
  __IO uint32_t               ErrorCode;        /*!< IRDA Error code                    */
173
 
174
 
174
#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
175
#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
175
  void (* TxHalfCpltCallback)(struct __IRDA_HandleTypeDef *hirda);        /*!< IRDA Tx Half Complete Callback        */
176
  void (* TxHalfCpltCallback)(struct __IRDA_HandleTypeDef *hirda);        /*!< IRDA Tx Half Complete Callback        */
176
 
177
 
177
  void (* TxCpltCallback)(struct __IRDA_HandleTypeDef *hirda);            /*!< IRDA Tx Complete Callback             */
178
  void (* TxCpltCallback)(struct __IRDA_HandleTypeDef *hirda);            /*!< IRDA Tx Complete Callback             */
178
 
179
 
179
  void (* RxHalfCpltCallback)(struct __IRDA_HandleTypeDef *hirda);        /*!< IRDA Rx Half Complete Callback        */
180
  void (* RxHalfCpltCallback)(struct __IRDA_HandleTypeDef *hirda);        /*!< IRDA Rx Half Complete Callback        */
180
 
181
 
181
  void (* RxCpltCallback)(struct __IRDA_HandleTypeDef *hirda);            /*!< IRDA Rx Complete Callback             */
182
  void (* RxCpltCallback)(struct __IRDA_HandleTypeDef *hirda);            /*!< IRDA Rx Complete Callback             */
182
 
183
 
183
  void (* ErrorCallback)(struct __IRDA_HandleTypeDef *hirda);             /*!< IRDA Error Callback                   */
184
  void (* ErrorCallback)(struct __IRDA_HandleTypeDef *hirda);             /*!< IRDA Error Callback                   */
184
 
185
 
185
  void (* AbortCpltCallback)(struct __IRDA_HandleTypeDef *hirda);         /*!< IRDA Abort Complete Callback          */
186
  void (* AbortCpltCallback)(struct __IRDA_HandleTypeDef *hirda);         /*!< IRDA Abort Complete Callback          */
186
 
187
 
187
  void (* AbortTransmitCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Abort Transmit Complete Callback */
188
  void (* AbortTransmitCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Abort Transmit Complete Callback */
188
 
189
 
189
  void (* AbortReceiveCpltCallback)(struct __IRDA_HandleTypeDef *hirda);  /*!< IRDA Abort Receive Complete Callback  */
190
  void (* AbortReceiveCpltCallback)(struct __IRDA_HandleTypeDef *hirda);  /*!< IRDA Abort Receive Complete Callback  */
190
 
191
 
191
 
192
 
192
  void (* MspInitCallback)(struct __IRDA_HandleTypeDef *hirda);           /*!< IRDA Msp Init callback                */
193
  void (* MspInitCallback)(struct __IRDA_HandleTypeDef *hirda);           /*!< IRDA Msp Init callback                */
193
 
194
 
194
  void (* MspDeInitCallback)(struct __IRDA_HandleTypeDef *hirda);         /*!< IRDA Msp DeInit callback              */
195
  void (* MspDeInitCallback)(struct __IRDA_HandleTypeDef *hirda);         /*!< IRDA Msp DeInit callback              */
195
#endif  /* USE_HAL_IRDA_REGISTER_CALLBACKS */
196
#endif  /* USE_HAL_IRDA_REGISTER_CALLBACKS */
196
 
197
 
197
} IRDA_HandleTypeDef;
198
} IRDA_HandleTypeDef;
198
 
199
 
199
#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
200
#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
200
/**
201
/**
201
  * @brief  HAL IRDA Callback ID enumeration definition
202
  * @brief  HAL IRDA Callback ID enumeration definition
202
  */
203
  */
203
typedef enum
204
typedef enum
204
{
205
{
205
  HAL_IRDA_TX_HALFCOMPLETE_CB_ID         = 0x00U,    /*!< IRDA Tx Half Complete Callback ID        */
206
  HAL_IRDA_TX_HALFCOMPLETE_CB_ID         = 0x00U,    /*!< IRDA Tx Half Complete Callback ID        */
206
  HAL_IRDA_TX_COMPLETE_CB_ID             = 0x01U,    /*!< IRDA Tx Complete Callback ID             */
207
  HAL_IRDA_TX_COMPLETE_CB_ID             = 0x01U,    /*!< IRDA Tx Complete Callback ID             */
207
  HAL_IRDA_RX_HALFCOMPLETE_CB_ID         = 0x02U,    /*!< IRDA Rx Half Complete Callback ID        */
208
  HAL_IRDA_RX_HALFCOMPLETE_CB_ID         = 0x02U,    /*!< IRDA Rx Half Complete Callback ID        */
208
  HAL_IRDA_RX_COMPLETE_CB_ID             = 0x03U,    /*!< IRDA Rx Complete Callback ID             */
209
  HAL_IRDA_RX_COMPLETE_CB_ID             = 0x03U,    /*!< IRDA Rx Complete Callback ID             */
209
  HAL_IRDA_ERROR_CB_ID                   = 0x04U,    /*!< IRDA Error Callback ID                   */
210
  HAL_IRDA_ERROR_CB_ID                   = 0x04U,    /*!< IRDA Error Callback ID                   */
210
  HAL_IRDA_ABORT_COMPLETE_CB_ID          = 0x05U,    /*!< IRDA Abort Complete Callback ID          */
211
  HAL_IRDA_ABORT_COMPLETE_CB_ID          = 0x05U,    /*!< IRDA Abort Complete Callback ID          */
211
  HAL_IRDA_ABORT_TRANSMIT_COMPLETE_CB_ID = 0x06U,    /*!< IRDA Abort Transmit Complete Callback ID */
212
  HAL_IRDA_ABORT_TRANSMIT_COMPLETE_CB_ID = 0x06U,    /*!< IRDA Abort Transmit Complete Callback ID */
212
  HAL_IRDA_ABORT_RECEIVE_COMPLETE_CB_ID  = 0x07U,    /*!< IRDA Abort Receive Complete Callback ID  */
213
  HAL_IRDA_ABORT_RECEIVE_COMPLETE_CB_ID  = 0x07U,    /*!< IRDA Abort Receive Complete Callback ID  */
213
 
214
 
214
  HAL_IRDA_MSPINIT_CB_ID                 = 0x08U,    /*!< IRDA MspInit callback ID                 */
215
  HAL_IRDA_MSPINIT_CB_ID                 = 0x08U,    /*!< IRDA MspInit callback ID                 */
215
  HAL_IRDA_MSPDEINIT_CB_ID               = 0x09U     /*!< IRDA MspDeInit callback ID               */
216
  HAL_IRDA_MSPDEINIT_CB_ID               = 0x09U     /*!< IRDA MspDeInit callback ID               */
216
 
217
 
217
} HAL_IRDA_CallbackIDTypeDef;
218
} HAL_IRDA_CallbackIDTypeDef;
218
 
219
 
219
/**
220
/**
220
  * @brief  HAL IRDA Callback pointer definition
221
  * @brief  HAL IRDA Callback pointer definition
221
  */
222
  */
222
typedef  void (*pIRDA_CallbackTypeDef)(IRDA_HandleTypeDef *hirda);  /*!< pointer to an IRDA callback function */
223
typedef  void (*pIRDA_CallbackTypeDef)(IRDA_HandleTypeDef *hirda);  /*!< pointer to an IRDA callback function */
223
 
224
 
224
#endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */
225
#endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */
225
 
226
 
226
/**
227
/**
227
  * @}
228
  * @}
228
  */
229
  */
229
 
230
 
230
/* Exported constants --------------------------------------------------------*/
231
/* Exported constants --------------------------------------------------------*/
231
/** @defgroup IRDA_Exported_Constants IRDA Exported constants
232
/** @defgroup IRDA_Exported_Constants IRDA Exported constants
232
  * @{
233
  * @{
233
  */
234
  */
234
/** @defgroup IRDA_Error_Code IRDA Error Code
235
/** @defgroup IRDA_Error_Code IRDA Error Code
235
  * @{
236
  * @{
236
  */
237
  */
237
#define HAL_IRDA_ERROR_NONE        0x00000000U   /*!< No error            */
238
#define HAL_IRDA_ERROR_NONE        0x00000000U   /*!< No error            */
238
#define HAL_IRDA_ERROR_PE          0x00000001U   /*!< Parity error        */
239
#define HAL_IRDA_ERROR_PE          0x00000001U   /*!< Parity error        */
239
#define HAL_IRDA_ERROR_NE          0x00000002U   /*!< Noise error         */
240
#define HAL_IRDA_ERROR_NE          0x00000002U   /*!< Noise error         */
240
#define HAL_IRDA_ERROR_FE          0x00000004U   /*!< Frame error         */
241
#define HAL_IRDA_ERROR_FE          0x00000004U   /*!< Frame error         */
241
#define HAL_IRDA_ERROR_ORE         0x00000008U   /*!< Overrun error       */
242
#define HAL_IRDA_ERROR_ORE         0x00000008U   /*!< Overrun error       */
242
#define HAL_IRDA_ERROR_DMA         0x00000010U   /*!< DMA transfer error  */
243
#define HAL_IRDA_ERROR_DMA         0x00000010U   /*!< DMA transfer error  */
243
#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
244
#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
244
#define HAL_IRDA_ERROR_INVALID_CALLBACK   ((uint32_t)0x00000020U)   /*!< Invalid Callback error  */
245
#define HAL_IRDA_ERROR_INVALID_CALLBACK   ((uint32_t)0x00000020U)   /*!< Invalid Callback error  */
245
#endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */
246
#endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */
246
/**
247
/**
247
  * @}
248
  * @}
248
  */
249
  */
249
 
250
 
250
/** @defgroup IRDA_Word_Length IRDA Word Length
251
/** @defgroup IRDA_Word_Length IRDA Word Length
251
  * @{
252
  * @{
252
  */
253
  */
253
#define IRDA_WORDLENGTH_8B         0x00000000U
254
#define IRDA_WORDLENGTH_8B         0x00000000U
254
#define IRDA_WORDLENGTH_9B         ((uint32_t)USART_CR1_M)
255
#define IRDA_WORDLENGTH_9B         ((uint32_t)USART_CR1_M)
255
/**
256
/**
256
  * @}
257
  * @}
257
  */
258
  */
258
 
259
 
259
/** @defgroup IRDA_Parity  IRDA Parity
260
/** @defgroup IRDA_Parity  IRDA Parity
260
  * @{
261
  * @{
261
  */
262
  */
262
#define IRDA_PARITY_NONE           0x00000000U
263
#define IRDA_PARITY_NONE           0x00000000U
263
#define IRDA_PARITY_EVEN           ((uint32_t)USART_CR1_PCE)
264
#define IRDA_PARITY_EVEN           ((uint32_t)USART_CR1_PCE)
264
#define IRDA_PARITY_ODD            ((uint32_t)(USART_CR1_PCE | USART_CR1_PS))
265
#define IRDA_PARITY_ODD            ((uint32_t)(USART_CR1_PCE | USART_CR1_PS))
265
/**
266
/**
266
  * @}
267
  * @}
267
  */
268
  */
268
 
269
 
269
/** @defgroup IRDA_Mode IRDA Transfer Mode
270
/** @defgroup IRDA_Mode IRDA Transfer Mode
270
  * @{
271
  * @{
271
  */
272
  */
272
#define IRDA_MODE_RX               ((uint32_t)USART_CR1_RE)
273
#define IRDA_MODE_RX               ((uint32_t)USART_CR1_RE)
273
#define IRDA_MODE_TX               ((uint32_t)USART_CR1_TE)
274
#define IRDA_MODE_TX               ((uint32_t)USART_CR1_TE)
274
#define IRDA_MODE_TX_RX            ((uint32_t)(USART_CR1_TE |USART_CR1_RE))
275
#define IRDA_MODE_TX_RX            ((uint32_t)(USART_CR1_TE |USART_CR1_RE))
275
/**
276
/**
276
  * @}
277
  * @}
277
  */
278
  */
278
 
279
 
279
/** @defgroup IRDA_Low_Power IRDA Low Power
280
/** @defgroup IRDA_Low_Power IRDA Low Power
280
  * @{
281
  * @{
281
  */
282
  */
282
#define IRDA_POWERMODE_LOWPOWER    ((uint32_t)USART_CR3_IRLP)
283
#define IRDA_POWERMODE_LOWPOWER    ((uint32_t)USART_CR3_IRLP)
283
#define IRDA_POWERMODE_NORMAL      0x00000000U
284
#define IRDA_POWERMODE_NORMAL      0x00000000U
284
/**
285
/**
285
  * @}
286
  * @}
286
  */
287
  */
287
 
288
 
288
/** @defgroup IRDA_Flags IRDA Flags
289
/** @defgroup IRDA_Flags IRDA Flags
289
  *        Elements values convention: 0xXXXX
290
  *        Elements values convention: 0xXXXX
290
  *           - 0xXXXX  : Flag mask in the SR register
291
  *           - 0xXXXX  : Flag mask in the SR register
291
  * @{
292
  * @{
292
  */
293
  */
293
#define IRDA_FLAG_TXE              ((uint32_t)USART_SR_TXE)
294
#define IRDA_FLAG_TXE              ((uint32_t)USART_SR_TXE)
294
#define IRDA_FLAG_TC               ((uint32_t)USART_SR_TC)
295
#define IRDA_FLAG_TC               ((uint32_t)USART_SR_TC)
295
#define IRDA_FLAG_RXNE             ((uint32_t)USART_SR_RXNE)
296
#define IRDA_FLAG_RXNE             ((uint32_t)USART_SR_RXNE)
296
#define IRDA_FLAG_IDLE             ((uint32_t)USART_SR_IDLE)
297
#define IRDA_FLAG_IDLE             ((uint32_t)USART_SR_IDLE)
297
#define IRDA_FLAG_ORE              ((uint32_t)USART_SR_ORE)
298
#define IRDA_FLAG_ORE              ((uint32_t)USART_SR_ORE)
298
#define IRDA_FLAG_NE               ((uint32_t)USART_SR_NE)
299
#define IRDA_FLAG_NE               ((uint32_t)USART_SR_NE)
299
#define IRDA_FLAG_FE               ((uint32_t)USART_SR_FE)
300
#define IRDA_FLAG_FE               ((uint32_t)USART_SR_FE)
300
#define IRDA_FLAG_PE               ((uint32_t)USART_SR_PE)
301
#define IRDA_FLAG_PE               ((uint32_t)USART_SR_PE)
301
/**
302
/**
302
  * @}
303
  * @}
303
  */
304
  */
304
 
305
 
305
/** @defgroup IRDA_Interrupt_definition IRDA Interrupt Definitions
306
/** @defgroup IRDA_Interrupt_definition IRDA Interrupt Definitions
306
  *        Elements values convention: 0xY000XXXX
307
  *        Elements values convention: 0xY000XXXX
307
  *           - XXXX  : Interrupt mask in the XX register
308
  *           - XXXX  : Interrupt mask in the XX register
308
  *           - Y  : Interrupt source register (2bits)
309
  *           - Y  : Interrupt source register (2bits)
309
  *                 - 01: CR1 register
310
  *                 - 01: CR1 register
310
  *                 - 10: CR2 register
311
  *                 - 10: CR2 register
311
  *                 - 11: CR3 register
312
  *                 - 11: CR3 register
312
  * @{
313
  * @{
313
  */
314
  */
314
#define IRDA_IT_PE                 ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_PEIE))
315
#define IRDA_IT_PE                 ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_PEIE))
315
#define IRDA_IT_TXE                ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_TXEIE))
316
#define IRDA_IT_TXE                ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_TXEIE))
316
#define IRDA_IT_TC                 ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_TCIE))
317
#define IRDA_IT_TC                 ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_TCIE))
317
#define IRDA_IT_RXNE               ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_RXNEIE))
318
#define IRDA_IT_RXNE               ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_RXNEIE))
318
#define IRDA_IT_IDLE               ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_IDLEIE))
319
#define IRDA_IT_IDLE               ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_IDLEIE))
319
 
320
 
320
#define IRDA_IT_LBD                ((uint32_t)(IRDA_CR2_REG_INDEX << 28U | USART_CR2_LBDIE))
321
#define IRDA_IT_LBD                ((uint32_t)(IRDA_CR2_REG_INDEX << 28U | USART_CR2_LBDIE))
321
 
322
 
322
#define IRDA_IT_CTS                ((uint32_t)(IRDA_CR3_REG_INDEX << 28U | USART_CR3_CTSIE))
323
#define IRDA_IT_CTS                ((uint32_t)(IRDA_CR3_REG_INDEX << 28U | USART_CR3_CTSIE))
323
#define IRDA_IT_ERR                ((uint32_t)(IRDA_CR3_REG_INDEX << 28U | USART_CR3_EIE))
324
#define IRDA_IT_ERR                ((uint32_t)(IRDA_CR3_REG_INDEX << 28U | USART_CR3_EIE))
324
/**
325
/**
325
  * @}
326
  * @}
326
  */
327
  */
327
 
328
 
328
/**
329
/**
329
  * @}
330
  * @}
330
  */
331
  */
331
 
332
 
332
/* Exported macro ------------------------------------------------------------*/
333
/* Exported macro ------------------------------------------------------------*/
333
/** @defgroup IRDA_Exported_Macros IRDA Exported Macros
334
/** @defgroup IRDA_Exported_Macros IRDA Exported Macros
334
  * @{
335
  * @{
335
  */
336
  */
336
 
337
 
337
/** @brief Reset IRDA handle gstate & RxState
338
/** @brief Reset IRDA handle gstate & RxState
338
  * @param  __HANDLE__ specifies the IRDA Handle.
339
  * @param  __HANDLE__ specifies the IRDA Handle.
339
  *         IRDA Handle selects the USARTx or UARTy peripheral
340
  *         IRDA Handle selects the USARTx or UARTy peripheral
340
  *         (USART,UART availability and x,y values depending on device).
341
  *         (USART,UART availability and x,y values depending on device).
341
  * @retval None
342
  * @retval None
342
  */
343
  */
343
#if USE_HAL_IRDA_REGISTER_CALLBACKS == 1
344
#if USE_HAL_IRDA_REGISTER_CALLBACKS == 1
344
#define __HAL_IRDA_RESET_HANDLE_STATE(__HANDLE__)  do{                                                   \
345
#define __HAL_IRDA_RESET_HANDLE_STATE(__HANDLE__)  do{                                                   \
345
                                                       (__HANDLE__)->gState = HAL_IRDA_STATE_RESET;      \
346
                                                       (__HANDLE__)->gState = HAL_IRDA_STATE_RESET;      \
346
                                                       (__HANDLE__)->RxState = HAL_IRDA_STATE_RESET;     \
347
                                                       (__HANDLE__)->RxState = HAL_IRDA_STATE_RESET;     \
347
                                                       (__HANDLE__)->MspInitCallback = NULL;             \
348
                                                       (__HANDLE__)->MspInitCallback = NULL;             \
348
                                                       (__HANDLE__)->MspDeInitCallback = NULL;           \
349
                                                       (__HANDLE__)->MspDeInitCallback = NULL;           \
349
                                                     } while(0U)
350
                                                     } while(0U)
350
#else
351
#else
351
#define __HAL_IRDA_RESET_HANDLE_STATE(__HANDLE__)  do{                                                   \
352
#define __HAL_IRDA_RESET_HANDLE_STATE(__HANDLE__)  do{                                                   \
352
                                                       (__HANDLE__)->gState = HAL_IRDA_STATE_RESET;      \
353
                                                       (__HANDLE__)->gState = HAL_IRDA_STATE_RESET;      \
353
                                                       (__HANDLE__)->RxState = HAL_IRDA_STATE_RESET;     \
354
                                                       (__HANDLE__)->RxState = HAL_IRDA_STATE_RESET;     \
354
                                                     } while(0U)
355
                                                     } while(0U)
355
#endif /*USE_HAL_IRDA_REGISTER_CALLBACKS  */
356
#endif /*USE_HAL_IRDA_REGISTER_CALLBACKS  */
356
 
357
 
357
/** @brief  Flush the IRDA DR register
358
/** @brief  Flush the IRDA DR register
358
  * @param  __HANDLE__ specifies the IRDA Handle.
359
  * @param  __HANDLE__ specifies the IRDA Handle.
359
  *         IRDA Handle selects the USARTx or UARTy peripheral
360
  *         IRDA Handle selects the USARTx or UARTy peripheral
360
  *         (USART,UART availability and x,y values depending on device).
361
  *         (USART,UART availability and x,y values depending on device).
361
  * @retval None
362
  * @retval None
362
  */
363
  */
363
#define __HAL_IRDA_FLUSH_DRREGISTER(__HANDLE__) ((__HANDLE__)->Instance->DR)
364
#define __HAL_IRDA_FLUSH_DRREGISTER(__HANDLE__) ((__HANDLE__)->Instance->DR)
364
 
365
 
365
/** @brief  Check whether the specified IRDA flag is set or not.
366
/** @brief  Check whether the specified IRDA flag is set or not.
366
  * @param  __HANDLE__ specifies the IRDA Handle.
367
  * @param  __HANDLE__ specifies the IRDA Handle.
367
  *         IRDA Handle selects the USARTx or UARTy peripheral
368
  *         IRDA Handle selects the USARTx or UARTy peripheral
368
  *         (USART,UART availability and x,y values depending on device).
369
  *         (USART,UART availability and x,y values depending on device).
369
  * @param  __FLAG__ specifies the flag to check.
370
  * @param  __FLAG__ specifies the flag to check.
370
  *        This parameter can be one of the following values:
371
  *        This parameter can be one of the following values:
371
  *            @arg IRDA_FLAG_TXE:  Transmit data register empty flag
372
  *            @arg IRDA_FLAG_TXE:  Transmit data register empty flag
372
  *            @arg IRDA_FLAG_TC:   Transmission Complete flag
373
  *            @arg IRDA_FLAG_TC:   Transmission Complete flag
373
  *            @arg IRDA_FLAG_RXNE: Receive data register not empty flag
374
  *            @arg IRDA_FLAG_RXNE: Receive data register not empty flag
374
  *            @arg IRDA_FLAG_IDLE: Idle Line detection flag
375
  *            @arg IRDA_FLAG_IDLE: Idle Line detection flag
375
  *            @arg IRDA_FLAG_ORE:  OverRun Error flag
376
  *            @arg IRDA_FLAG_ORE:  OverRun Error flag
376
  *            @arg IRDA_FLAG_NE:   Noise Error flag
377
  *            @arg IRDA_FLAG_NE:   Noise Error flag
377
  *            @arg IRDA_FLAG_FE:   Framing Error flag
378
  *            @arg IRDA_FLAG_FE:   Framing Error flag
378
  *            @arg IRDA_FLAG_PE:   Parity Error flag
379
  *            @arg IRDA_FLAG_PE:   Parity Error flag
379
  * @retval The new state of __FLAG__ (TRUE or FALSE).
380
  * @retval The new state of __FLAG__ (TRUE or FALSE).
380
  */
381
  */
381
#define __HAL_IRDA_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
382
#define __HAL_IRDA_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
382
 
383
 
383
/** @brief  Clear the specified IRDA pending flag.
384
/** @brief  Clear the specified IRDA pending flag.
384
  * @param  __HANDLE__ specifies the IRDA Handle.
385
  * @param  __HANDLE__ specifies the IRDA Handle.
385
  *         IRDA Handle selects the USARTx or UARTy peripheral
386
  *         IRDA Handle selects the USARTx or UARTy peripheral
386
  *         (USART,UART availability and x,y values depending on device).
387
  *         (USART,UART availability and x,y values depending on device).
387
  * @param  __FLAG__ specifies the flag to check.
388
  * @param  __FLAG__ specifies the flag to check.
388
  *          This parameter can be any combination of the following values:
389
  *          This parameter can be any combination of the following values:
389
  *            @arg IRDA_FLAG_TC:   Transmission Complete flag.
390
  *            @arg IRDA_FLAG_TC:   Transmission Complete flag.
390
  *            @arg IRDA_FLAG_RXNE: Receive data register not empty flag.
391
  *            @arg IRDA_FLAG_RXNE: Receive data register not empty flag.
391
  *
392
  *
392
  * @note   PE (Parity error), FE (Framing error), NE (Noise error), ORE (OverRun
393
  * @note   PE (Parity error), FE (Framing error), NE (Noise error), ORE (OverRun
393
  *          error) and IDLE (Idle line detected) flags are cleared by software
394
  *          error) and IDLE (Idle line detected) flags are cleared by software
394
  *          sequence: a read operation to USART_SR register followed by a read
395
  *          sequence: a read operation to USART_SR register followed by a read
395
  *          operation to USART_DR register.
396
  *          operation to USART_DR register.
396
  * @note   RXNE flag can be also cleared by a read to the USART_DR register.
397
  * @note   RXNE flag can be also cleared by a read to the USART_DR register.
397
  * @note   TC flag can be also cleared by software sequence: a read operation to
398
  * @note   TC flag can be also cleared by software sequence: a read operation to
398
  *          USART_SR register followed by a write operation to USART_DR register.
399
  *          USART_SR register followed by a write operation to USART_DR register.
399
  * @note   TXE flag is cleared only by a write to the USART_DR register.
400
  * @note   TXE flag is cleared only by a write to the USART_DR register.
400
  * @retval None
401
  * @retval None
401
  */
402
  */
402
#define __HAL_IRDA_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__))
403
#define __HAL_IRDA_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__))
403
 
404
 
404
/** @brief  Clear the IRDA PE pending flag.
405
/** @brief  Clear the IRDA PE pending flag.
405
  * @param  __HANDLE__ specifies the IRDA Handle.
406
  * @param  __HANDLE__ specifies the IRDA Handle.
406
  *         IRDA Handle selects the USARTx or UARTy peripheral
407
  *         IRDA Handle selects the USARTx or UARTy peripheral
407
  *         (USART,UART availability and x,y values depending on device).
408
  *         (USART,UART availability and x,y values depending on device).
408
  * @retval None
409
  * @retval None
409
  */
410
  */
410
#define __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__)     \
411
#define __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__)     \
411
  do{                                           \
412
  do{                                           \
412
    __IO uint32_t tmpreg = 0x00U;               \
413
    __IO uint32_t tmpreg = 0x00U;               \
413
    tmpreg = (__HANDLE__)->Instance->SR;        \
414
    tmpreg = (__HANDLE__)->Instance->SR;        \
414
    tmpreg = (__HANDLE__)->Instance->DR;        \
415
    tmpreg = (__HANDLE__)->Instance->DR;        \
415
    UNUSED(tmpreg);                             \
416
    UNUSED(tmpreg);                             \
416
  } while(0U)
417
  } while(0U)
417
 
418
 
418
/** @brief  Clear the IRDA FE pending flag.
419
/** @brief  Clear the IRDA FE pending flag.
419
  * @param  __HANDLE__ specifies the IRDA Handle.
420
  * @param  __HANDLE__ specifies the IRDA Handle.
420
  *         IRDA Handle selects the USARTx or UARTy peripheral
421
  *         IRDA Handle selects the USARTx or UARTy peripheral
421
  *         (USART,UART availability and x,y values depending on device).
422
  *         (USART,UART availability and x,y values depending on device).
422
  * @retval None
423
  * @retval None
423
  */
424
  */
424
#define __HAL_IRDA_CLEAR_FEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__)
425
#define __HAL_IRDA_CLEAR_FEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__)
425
 
426
 
426
/** @brief  Clear the IRDA NE pending flag.
427
/** @brief  Clear the IRDA NE pending flag.
427
  * @param  __HANDLE__ specifies the IRDA Handle.
428
  * @param  __HANDLE__ specifies the IRDA Handle.
428
  *         IRDA Handle selects the USARTx or UARTy peripheral
429
  *         IRDA Handle selects the USARTx or UARTy peripheral
429
  *         (USART,UART availability and x,y values depending on device).
430
  *         (USART,UART availability and x,y values depending on device).
430
  * @retval None
431
  * @retval None
431
  */
432
  */
432
#define __HAL_IRDA_CLEAR_NEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__)
433
#define __HAL_IRDA_CLEAR_NEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__)
433
 
434
 
434
/** @brief  Clear the IRDA ORE pending flag.
435
/** @brief  Clear the IRDA ORE pending flag.
435
  * @param  __HANDLE__ specifies the IRDA Handle.
436
  * @param  __HANDLE__ specifies the IRDA Handle.
436
  *         IRDA Handle selects the USARTx or UARTy peripheral
437
  *         IRDA Handle selects the USARTx or UARTy peripheral
437
  *         (USART,UART availability and x,y values depending on device).
438
  *         (USART,UART availability and x,y values depending on device).
438
  * @retval None
439
  * @retval None
439
  */
440
  */
440
#define __HAL_IRDA_CLEAR_OREFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__)
441
#define __HAL_IRDA_CLEAR_OREFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__)
441
 
442
 
442
/** @brief  Clear the IRDA IDLE pending flag.
443
/** @brief  Clear the IRDA IDLE pending flag.
443
  * @param  __HANDLE__ specifies the IRDA Handle.
444
  * @param  __HANDLE__ specifies the IRDA Handle.
444
  *         IRDA Handle selects the USARTx or UARTy peripheral
445
  *         IRDA Handle selects the USARTx or UARTy peripheral
445
  *         (USART,UART availability and x,y values depending on device).
446
  *         (USART,UART availability and x,y values depending on device).
446
  * @retval None
447
  * @retval None
447
  */
448
  */
448
#define __HAL_IRDA_CLEAR_IDLEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__)
449
#define __HAL_IRDA_CLEAR_IDLEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__)
449
 
450
 
450
/** @brief  Enable the specified IRDA interrupt.
451
/** @brief  Enable the specified IRDA interrupt.
451
  * @param  __HANDLE__ specifies the IRDA Handle.
452
  * @param  __HANDLE__ specifies the IRDA Handle.
452
  *         IRDA Handle selects the USARTx or UARTy peripheral
453
  *         IRDA Handle selects the USARTx or UARTy peripheral
453
  *         (USART,UART availability and x,y values depending on device).
454
  *         (USART,UART availability and x,y values depending on device).
454
  * @param  __INTERRUPT__ specifies the IRDA interrupt source to enable.
455
  * @param  __INTERRUPT__ specifies the IRDA interrupt source to enable.
455
  *          This parameter can be one of the following values:
456
  *          This parameter can be one of the following values:
456
  *            @arg IRDA_IT_TXE:  Transmit Data Register empty interrupt
457
  *            @arg IRDA_IT_TXE:  Transmit Data Register empty interrupt
457
  *            @arg IRDA_IT_TC:   Transmission complete interrupt
458
  *            @arg IRDA_IT_TC:   Transmission complete interrupt
458
  *            @arg IRDA_IT_RXNE: Receive Data register not empty interrupt
459
  *            @arg IRDA_IT_RXNE: Receive Data register not empty interrupt
459
  *            @arg IRDA_IT_IDLE: Idle line detection interrupt
460
  *            @arg IRDA_IT_IDLE: Idle line detection interrupt
460
  *            @arg IRDA_IT_PE:   Parity Error interrupt
461
  *            @arg IRDA_IT_PE:   Parity Error interrupt
461
  *            @arg IRDA_IT_ERR:  Error interrupt(Frame error, noise error, overrun error)
462
  *            @arg IRDA_IT_ERR:  Error interrupt(Frame error, noise error, overrun error)
462
  * @retval None
463
  * @retval None
463
  */
464
  */
464
#define __HAL_IRDA_ENABLE_IT(__HANDLE__, __INTERRUPT__)   ((((__INTERRUPT__) >> 28U) == IRDA_CR1_REG_INDEX)? ((__HANDLE__)->Instance->CR1 |= ((__INTERRUPT__) & IRDA_IT_MASK)): \
465
#define __HAL_IRDA_ENABLE_IT(__HANDLE__, __INTERRUPT__)   ((((__INTERRUPT__) >> 28U) == IRDA_CR1_REG_INDEX)? ((__HANDLE__)->Instance->CR1 |= ((__INTERRUPT__) & IRDA_IT_MASK)): \
465
                                                           (((__INTERRUPT__) >> 28U) == IRDA_CR2_REG_INDEX)? ((__HANDLE__)->Instance->CR2 |=  ((__INTERRUPT__) & IRDA_IT_MASK)): \
466
                                                           (((__INTERRUPT__) >> 28U) == IRDA_CR2_REG_INDEX)? ((__HANDLE__)->Instance->CR2 |=  ((__INTERRUPT__) & IRDA_IT_MASK)): \
466
                                                            ((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & IRDA_IT_MASK)))
467
                                                            ((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & IRDA_IT_MASK)))
467
/** @brief  Disable the specified IRDA interrupt.
468
/** @brief  Disable the specified IRDA interrupt.
468
  * @param  __HANDLE__ specifies the IRDA Handle.
469
  * @param  __HANDLE__ specifies the IRDA Handle.
469
  *         IRDA Handle selects the USARTx or UARTy peripheral
470
  *         IRDA Handle selects the USARTx or UARTy peripheral
470
  *         (USART,UART availability and x,y values depending on device).
471
  *         (USART,UART availability and x,y values depending on device).
471
  * @param  __INTERRUPT__ specifies the IRDA interrupt source to disable.
472
  * @param  __INTERRUPT__ specifies the IRDA interrupt source to disable.
472
  *          This parameter can be one of the following values:
473
  *          This parameter can be one of the following values:
473
  *            @arg IRDA_IT_TXE:  Transmit Data Register empty interrupt
474
  *            @arg IRDA_IT_TXE:  Transmit Data Register empty interrupt
474
  *            @arg IRDA_IT_TC:   Transmission complete interrupt
475
  *            @arg IRDA_IT_TC:   Transmission complete interrupt
475
  *            @arg IRDA_IT_RXNE: Receive Data register not empty interrupt
476
  *            @arg IRDA_IT_RXNE: Receive Data register not empty interrupt
476
  *            @arg IRDA_IT_IDLE: Idle line detection interrupt
477
  *            @arg IRDA_IT_IDLE: Idle line detection interrupt
477
  *            @arg IRDA_IT_PE:   Parity Error interrupt
478
  *            @arg IRDA_IT_PE:   Parity Error interrupt
478
  *            @arg IRDA_IT_ERR:  Error interrupt(Frame error, noise error, overrun error)
479
  *            @arg IRDA_IT_ERR:  Error interrupt(Frame error, noise error, overrun error)
479
  * @retval None
480
  * @retval None
480
  */
481
  */
481
#define __HAL_IRDA_DISABLE_IT(__HANDLE__, __INTERRUPT__)  ((((__INTERRUPT__) >> 28U) == IRDA_CR1_REG_INDEX)? ((__HANDLE__)->Instance->CR1 &= ~((__INTERRUPT__) & IRDA_IT_MASK)): \
482
#define __HAL_IRDA_DISABLE_IT(__HANDLE__, __INTERRUPT__)  ((((__INTERRUPT__) >> 28U) == IRDA_CR1_REG_INDEX)? ((__HANDLE__)->Instance->CR1 &= ~((__INTERRUPT__) & IRDA_IT_MASK)): \
482
                                                           (((__INTERRUPT__) >> 28U) == IRDA_CR2_REG_INDEX)? ((__HANDLE__)->Instance->CR2 &= ~((__INTERRUPT__) & IRDA_IT_MASK)): \
483
                                                           (((__INTERRUPT__) >> 28U) == IRDA_CR2_REG_INDEX)? ((__HANDLE__)->Instance->CR2 &= ~((__INTERRUPT__) & IRDA_IT_MASK)): \
483
                                                           ((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & IRDA_IT_MASK)))
484
                                                           ((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & IRDA_IT_MASK)))
484
 
485
 
485
/** @brief  Check whether the specified IRDA interrupt has occurred or not.
486
/** @brief  Check whether the specified IRDA interrupt has occurred or not.
486
  * @param  __HANDLE__ specifies the IRDA Handle.
487
  * @param  __HANDLE__ specifies the IRDA Handle.
487
  *         IRDA Handle selects the USARTx or UARTy peripheral
488
  *         IRDA Handle selects the USARTx or UARTy peripheral
488
  *         (USART,UART availability and x,y values depending on device).
489
  *         (USART,UART availability and x,y values depending on device).
489
  * @param  __IT__ specifies the IRDA interrupt source to check.
490
  * @param  __IT__ specifies the IRDA interrupt source to check.
490
  *          This parameter can be one of the following values:
491
  *          This parameter can be one of the following values:
491
  *            @arg IRDA_IT_TXE: Transmit Data Register empty interrupt
492
  *            @arg IRDA_IT_TXE: Transmit Data Register empty interrupt
492
  *            @arg IRDA_IT_TC:  Transmission complete interrupt
493
  *            @arg IRDA_IT_TC:  Transmission complete interrupt
493
  *            @arg IRDA_IT_RXNE: Receive Data register not empty interrupt
494
  *            @arg IRDA_IT_RXNE: Receive Data register not empty interrupt
494
  *            @arg IRDA_IT_IDLE: Idle line detection interrupt
495
  *            @arg IRDA_IT_IDLE: Idle line detection interrupt
495
  *            @arg IRDA_IT_ERR: Error interrupt
496
  *            @arg IRDA_IT_ERR: Error interrupt
496
  *            @arg IRDA_IT_PE: Parity Error interrupt
497
  *            @arg IRDA_IT_PE: Parity Error interrupt
497
  * @retval The new state of __IT__ (TRUE or FALSE).
498
  * @retval The new state of __IT__ (TRUE or FALSE).
498
  */
499
  */
499
#define __HAL_IRDA_GET_IT_SOURCE(__HANDLE__, __IT__) (((((__IT__) >> 28U) == IRDA_CR1_REG_INDEX)? (__HANDLE__)->Instance->CR1:(((((uint32_t)(__IT__)) >> 28U) == IRDA_CR2_REG_INDEX)? \
500
#define __HAL_IRDA_GET_IT_SOURCE(__HANDLE__, __IT__) (((((__IT__) >> 28U) == IRDA_CR1_REG_INDEX)? (__HANDLE__)->Instance->CR1:(((((uint32_t)(__IT__)) >> 28U) == IRDA_CR2_REG_INDEX)? \
500
                                                      (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & (((uint32_t)(__IT__)) & IRDA_IT_MASK))
501
                                                      (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & (((uint32_t)(__IT__)) & IRDA_IT_MASK))
501
 
502
 
502
/** @brief  Enable UART/USART associated to IRDA Handle
503
/** @brief  Enable UART/USART associated to IRDA Handle
503
  * @param  __HANDLE__ specifies the IRDA Handle.
504
  * @param  __HANDLE__ specifies the IRDA Handle.
504
  *         IRDA Handle selects the USARTx or UARTy peripheral
505
  *         IRDA Handle selects the USARTx or UARTy peripheral
505
  *         (USART,UART availability and x,y values depending on device).
506
  *         (USART,UART availability and x,y values depending on device).
506
  * @retval None
507
  * @retval None
507
  */
508
  */
508
#define __HAL_IRDA_ENABLE(__HANDLE__)                   (SET_BIT((__HANDLE__)->Instance->CR1, USART_CR1_UE))
509
#define __HAL_IRDA_ENABLE(__HANDLE__)                   (SET_BIT((__HANDLE__)->Instance->CR1, USART_CR1_UE))
509
 
510
 
510
/** @brief  Disable UART/USART associated to IRDA Handle
511
/** @brief  Disable UART/USART associated to IRDA Handle
511
  * @param  __HANDLE__ specifies the IRDA Handle.
512
  * @param  __HANDLE__ specifies the IRDA Handle.
512
  *         IRDA Handle selects the USARTx or UARTy peripheral
513
  *         IRDA Handle selects the USARTx or UARTy peripheral
513
  *         (USART,UART availability and x,y values depending on device).
514
  *         (USART,UART availability and x,y values depending on device).
514
  * @retval None
515
  * @retval None
515
  */
516
  */
516
#define __HAL_IRDA_DISABLE(__HANDLE__)                  (CLEAR_BIT((__HANDLE__)->Instance->CR1, USART_CR1_UE))
517
#define __HAL_IRDA_DISABLE(__HANDLE__)                  (CLEAR_BIT((__HANDLE__)->Instance->CR1, USART_CR1_UE))
517
 
518
 
518
/**
519
/**
519
  * @}
520
  * @}
520
  */
521
  */
521
 
522
 
522
/* Exported functions --------------------------------------------------------*/
523
/* Exported functions --------------------------------------------------------*/
523
/** @addtogroup IRDA_Exported_Functions
524
/** @addtogroup IRDA_Exported_Functions
524
  * @{
525
  * @{
525
  */
526
  */
526
 
527
 
527
/** @addtogroup IRDA_Exported_Functions_Group1
528
/** @addtogroup IRDA_Exported_Functions_Group1
528
  * @{
529
  * @{
529
  */
530
  */
530
/* Initialization/de-initialization functions  **********************************/
531
/* Initialization/de-initialization functions  **********************************/
531
HAL_StatusTypeDef HAL_IRDA_Init(IRDA_HandleTypeDef *hirda);
532
HAL_StatusTypeDef HAL_IRDA_Init(IRDA_HandleTypeDef *hirda);
532
HAL_StatusTypeDef HAL_IRDA_DeInit(IRDA_HandleTypeDef *hirda);
533
HAL_StatusTypeDef HAL_IRDA_DeInit(IRDA_HandleTypeDef *hirda);
533
void HAL_IRDA_MspInit(IRDA_HandleTypeDef *hirda);
534
void HAL_IRDA_MspInit(IRDA_HandleTypeDef *hirda);
534
void HAL_IRDA_MspDeInit(IRDA_HandleTypeDef *hirda);
535
void HAL_IRDA_MspDeInit(IRDA_HandleTypeDef *hirda);
535
 
536
 
536
#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
537
#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
537
/* Callbacks Register/UnRegister functions  ***********************************/
538
/* Callbacks Register/UnRegister functions  ***********************************/
538
HAL_StatusTypeDef HAL_IRDA_RegisterCallback(IRDA_HandleTypeDef *hirda, HAL_IRDA_CallbackIDTypeDef CallbackID, pIRDA_CallbackTypeDef pCallback);
539
HAL_StatusTypeDef HAL_IRDA_RegisterCallback(IRDA_HandleTypeDef *hirda, HAL_IRDA_CallbackIDTypeDef CallbackID, pIRDA_CallbackTypeDef pCallback);
539
HAL_StatusTypeDef HAL_IRDA_UnRegisterCallback(IRDA_HandleTypeDef *hirda, HAL_IRDA_CallbackIDTypeDef CallbackID);
540
HAL_StatusTypeDef HAL_IRDA_UnRegisterCallback(IRDA_HandleTypeDef *hirda, HAL_IRDA_CallbackIDTypeDef CallbackID);
540
#endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */
541
#endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */
541
 
542
 
542
/**
543
/**
543
  * @}
544
  * @}
544
  */
545
  */
545
 
546
 
546
/** @addtogroup IRDA_Exported_Functions_Group2
547
/** @addtogroup IRDA_Exported_Functions_Group2
547
  * @{
548
  * @{
548
  */
549
  */
549
/* IO operation functions *******************************************************/
550
/* IO operation functions *******************************************************/
550
HAL_StatusTypeDef HAL_IRDA_Transmit(IRDA_HandleTypeDef *hirda, const uint8_t *pData, uint16_t Size, uint32_t Timeout);
551
HAL_StatusTypeDef HAL_IRDA_Transmit(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout);
551
HAL_StatusTypeDef HAL_IRDA_Receive(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout);
552
HAL_StatusTypeDef HAL_IRDA_Receive(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout);
552
HAL_StatusTypeDef HAL_IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda, const uint8_t *pData, uint16_t Size);
553
HAL_StatusTypeDef HAL_IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
553
HAL_StatusTypeDef HAL_IRDA_Receive_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
554
HAL_StatusTypeDef HAL_IRDA_Receive_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
554
HAL_StatusTypeDef HAL_IRDA_Transmit_DMA(IRDA_HandleTypeDef *hirda, const uint8_t *pData, uint16_t Size);
555
HAL_StatusTypeDef HAL_IRDA_Transmit_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
555
HAL_StatusTypeDef HAL_IRDA_Receive_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
556
HAL_StatusTypeDef HAL_IRDA_Receive_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
556
HAL_StatusTypeDef HAL_IRDA_DMAPause(IRDA_HandleTypeDef *hirda);
557
HAL_StatusTypeDef HAL_IRDA_DMAPause(IRDA_HandleTypeDef *hirda);
557
HAL_StatusTypeDef HAL_IRDA_DMAResume(IRDA_HandleTypeDef *hirda);
558
HAL_StatusTypeDef HAL_IRDA_DMAResume(IRDA_HandleTypeDef *hirda);
558
HAL_StatusTypeDef HAL_IRDA_DMAStop(IRDA_HandleTypeDef *hirda);
559
HAL_StatusTypeDef HAL_IRDA_DMAStop(IRDA_HandleTypeDef *hirda);
559
/* Transfer Abort functions */
560
/* Transfer Abort functions */
560
HAL_StatusTypeDef HAL_IRDA_Abort(IRDA_HandleTypeDef *hirda);
561
HAL_StatusTypeDef HAL_IRDA_Abort(IRDA_HandleTypeDef *hirda);
561
HAL_StatusTypeDef HAL_IRDA_AbortTransmit(IRDA_HandleTypeDef *hirda);
562
HAL_StatusTypeDef HAL_IRDA_AbortTransmit(IRDA_HandleTypeDef *hirda);
562
HAL_StatusTypeDef HAL_IRDA_AbortReceive(IRDA_HandleTypeDef *hirda);
563
HAL_StatusTypeDef HAL_IRDA_AbortReceive(IRDA_HandleTypeDef *hirda);
563
HAL_StatusTypeDef HAL_IRDA_Abort_IT(IRDA_HandleTypeDef *hirda);
564
HAL_StatusTypeDef HAL_IRDA_Abort_IT(IRDA_HandleTypeDef *hirda);
564
HAL_StatusTypeDef HAL_IRDA_AbortTransmit_IT(IRDA_HandleTypeDef *hirda);
565
HAL_StatusTypeDef HAL_IRDA_AbortTransmit_IT(IRDA_HandleTypeDef *hirda);
565
HAL_StatusTypeDef HAL_IRDA_AbortReceive_IT(IRDA_HandleTypeDef *hirda);
566
HAL_StatusTypeDef HAL_IRDA_AbortReceive_IT(IRDA_HandleTypeDef *hirda);
566
 
567
 
567
void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef *hirda);
568
void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef *hirda);
568
void HAL_IRDA_TxCpltCallback(IRDA_HandleTypeDef *hirda);
569
void HAL_IRDA_TxCpltCallback(IRDA_HandleTypeDef *hirda);
569
void HAL_IRDA_RxCpltCallback(IRDA_HandleTypeDef *hirda);
570
void HAL_IRDA_RxCpltCallback(IRDA_HandleTypeDef *hirda);
570
void HAL_IRDA_TxHalfCpltCallback(IRDA_HandleTypeDef *hirda);
571
void HAL_IRDA_TxHalfCpltCallback(IRDA_HandleTypeDef *hirda);
571
void HAL_IRDA_RxHalfCpltCallback(IRDA_HandleTypeDef *hirda);
572
void HAL_IRDA_RxHalfCpltCallback(IRDA_HandleTypeDef *hirda);
572
void HAL_IRDA_ErrorCallback(IRDA_HandleTypeDef *hirda);
573
void HAL_IRDA_ErrorCallback(IRDA_HandleTypeDef *hirda);
573
void HAL_IRDA_AbortCpltCallback(IRDA_HandleTypeDef *hirda);
574
void HAL_IRDA_AbortCpltCallback(IRDA_HandleTypeDef *hirda);
574
void HAL_IRDA_AbortTransmitCpltCallback(IRDA_HandleTypeDef *hirda);
575
void HAL_IRDA_AbortTransmitCpltCallback(IRDA_HandleTypeDef *hirda);
575
void HAL_IRDA_AbortReceiveCpltCallback(IRDA_HandleTypeDef *hirda);
576
void HAL_IRDA_AbortReceiveCpltCallback(IRDA_HandleTypeDef *hirda);
576
/**
577
/**
577
  * @}
578
  * @}
578
  */
579
  */
579
 
580
 
580
/** @addtogroup IRDA_Exported_Functions_Group3
581
/** @addtogroup IRDA_Exported_Functions_Group3
581
  * @{
582
  * @{
582
  */
583
  */
583
/* Peripheral State functions  **************************************************/
584
/* Peripheral State functions  **************************************************/
584
HAL_IRDA_StateTypeDef HAL_IRDA_GetState(const IRDA_HandleTypeDef *hirda);
585
HAL_IRDA_StateTypeDef HAL_IRDA_GetState(IRDA_HandleTypeDef *hirda);
585
uint32_t HAL_IRDA_GetError(const IRDA_HandleTypeDef *hirda);
586
uint32_t HAL_IRDA_GetError(IRDA_HandleTypeDef *hirda);
586
/**
587
/**
587
  * @}
588
  * @}
588
  */
589
  */
589
 
590
 
590
/**
591
/**
591
  * @}
592
  * @}
592
  */
593
  */
593
 
594
 
594
/* Private types -------------------------------------------------------------*/
595
/* Private types -------------------------------------------------------------*/
595
/* Private variables ---------------------------------------------------------*/
596
/* Private variables ---------------------------------------------------------*/
596
/* Private constants ---------------------------------------------------------*/
597
/* Private constants ---------------------------------------------------------*/
597
/** @defgroup IRDA_Private_Constants IRDA Private Constants
598
/** @defgroup IRDA_Private_Constants IRDA Private Constants
598
  * @{
599
  * @{
599
  */
600
  */
600
 
601
 
601
/** @brief IRDA interruptions flag mask
602
/** @brief IRDA interruptions flag mask
602
  *
603
  *
603
  */
604
  */
604
#define IRDA_IT_MASK  ((uint32_t) USART_CR1_PEIE | USART_CR1_TXEIE | USART_CR1_TCIE | USART_CR1_RXNEIE | \
605
#define IRDA_IT_MASK  ((uint32_t) USART_CR1_PEIE | USART_CR1_TXEIE | USART_CR1_TCIE | USART_CR1_RXNEIE | \
605
                                  USART_CR1_IDLEIE | USART_CR2_LBDIE | USART_CR3_CTSIE | USART_CR3_EIE )
606
                                  USART_CR1_IDLEIE | USART_CR2_LBDIE | USART_CR3_CTSIE | USART_CR3_EIE )
606
 
607
 
607
#define IRDA_CR1_REG_INDEX         1U
608
#define IRDA_CR1_REG_INDEX         1U
608
#define IRDA_CR2_REG_INDEX         2U
609
#define IRDA_CR2_REG_INDEX         2U
609
#define IRDA_CR3_REG_INDEX         3U
610
#define IRDA_CR3_REG_INDEX         3U
610
/**
611
/**
611
  * @}
612
  * @}
612
  */
613
  */
613
 
614
 
614
/* Private macros --------------------------------------------------------*/
615
/* Private macros --------------------------------------------------------*/
615
/** @defgroup IRDA_Private_Macros   IRDA Private Macros
616
/** @defgroup IRDA_Private_Macros   IRDA Private Macros
616
  * @{
617
  * @{
617
  */
618
  */
618
#define IS_IRDA_WORD_LENGTH(LENGTH)   (((LENGTH) == IRDA_WORDLENGTH_8B) || \
619
#define IS_IRDA_WORD_LENGTH(LENGTH)   (((LENGTH) == IRDA_WORDLENGTH_8B) || \
619
                                       ((LENGTH) == IRDA_WORDLENGTH_9B))
620
                                       ((LENGTH) == IRDA_WORDLENGTH_9B))
620
 
621
 
621
#define IS_IRDA_PARITY(PARITY)        (((PARITY) == IRDA_PARITY_NONE) || \
622
#define IS_IRDA_PARITY(PARITY)        (((PARITY) == IRDA_PARITY_NONE) || \
622
                                       ((PARITY) == IRDA_PARITY_EVEN) || \
623
                                       ((PARITY) == IRDA_PARITY_EVEN) || \
623
                                       ((PARITY) == IRDA_PARITY_ODD))
624
                                       ((PARITY) == IRDA_PARITY_ODD))
624
 
625
 
625
#define IS_IRDA_MODE(MODE)            ((((MODE) & 0x0000FFF3U) == 0x00U) && ((MODE) != 0x00000000U))
626
#define IS_IRDA_MODE(MODE)            ((((MODE) & 0x0000FFF3U) == 0x00U) && ((MODE) != 0x00000000U))
626
 
627
 
627
#define IS_IRDA_POWERMODE(MODE)       (((MODE) == IRDA_POWERMODE_LOWPOWER) || \
628
#define IS_IRDA_POWERMODE(MODE)       (((MODE) == IRDA_POWERMODE_LOWPOWER) || \
628
                                       ((MODE) == IRDA_POWERMODE_NORMAL))
629
                                       ((MODE) == IRDA_POWERMODE_NORMAL))
629
 
630
 
630
#define IS_IRDA_BAUDRATE(BAUDRATE)    ((BAUDRATE) < 115201U)
631
#define IS_IRDA_BAUDRATE(BAUDRATE)    ((BAUDRATE) < 115201U)
631
 
632
 
632
#define IRDA_DIV(_PCLK_, _BAUD_)      (((_PCLK_)*25U)/(4U*(_BAUD_)))
633
#define IRDA_DIV(_PCLK_, _BAUD_)      (((_PCLK_)*25U)/(4U*(_BAUD_)))
633
 
634
 
634
#define IRDA_DIVMANT(_PCLK_, _BAUD_)  (IRDA_DIV((_PCLK_), (_BAUD_))/100U)
635
#define IRDA_DIVMANT(_PCLK_, _BAUD_)  (IRDA_DIV((_PCLK_), (_BAUD_))/100U)
635
 
636
 
636
#define IRDA_DIVFRAQ(_PCLK_, _BAUD_)  ((((IRDA_DIV((_PCLK_), (_BAUD_)) - (IRDA_DIVMANT((_PCLK_), (_BAUD_)) * 100U)) * 16U) + 50U) / 100U)
637
#define IRDA_DIVFRAQ(_PCLK_, _BAUD_)  ((((IRDA_DIV((_PCLK_), (_BAUD_)) - (IRDA_DIVMANT((_PCLK_), (_BAUD_)) * 100U)) * 16U) + 50U) / 100U)
637
 
638
 
638
/* UART BRR = mantissa + overflow + fraction
639
/* UART BRR = mantissa + overflow + fraction
639
            = (UART DIVMANT << 4) + (UART DIVFRAQ & 0xF0) + (UART DIVFRAQ & 0x0FU) */
640
            = (UART DIVMANT << 4) + (UART DIVFRAQ & 0xF0) + (UART DIVFRAQ & 0x0FU) */
640
#define IRDA_BRR(_PCLK_, _BAUD_)      (((IRDA_DIVMANT((_PCLK_), (_BAUD_)) << 4U) + \
641
#define IRDA_BRR(_PCLK_, _BAUD_)      (((IRDA_DIVMANT((_PCLK_), (_BAUD_)) << 4U) + \
641
                                        (IRDA_DIVFRAQ((_PCLK_), (_BAUD_)) & 0xF0U)) + \
642
                                        (IRDA_DIVFRAQ((_PCLK_), (_BAUD_)) & 0xF0U)) + \
642
                                        (IRDA_DIVFRAQ((_PCLK_), (_BAUD_)) & 0x0FU))
643
                                        (IRDA_DIVFRAQ((_PCLK_), (_BAUD_)) & 0x0FU))
643
 
644
 
644
/**
645
/**
645
  * @}
646
  * @}
646
  */
647
  */
647
 
648
 
648
/* Private functions ---------------------------------------------------------*/
649
/* Private functions ---------------------------------------------------------*/
649
/** @defgroup IRDA_Private_Functions IRDA Private Functions
650
/** @defgroup IRDA_Private_Functions IRDA Private Functions
650
  * @{
651
  * @{
651
  */
652
  */
652
 
653
 
653
/**
654
/**
654
  * @}
655
  * @}
655
  */
656
  */
656
 
657
 
657
/**
658
/**
658
  * @}
659
  * @}
659
  */
660
  */
660
 
661
 
661
/**
662
/**
662
  * @}
663
  * @}
663
  */
664
  */
664
 
665
 
665
#ifdef __cplusplus
666
#ifdef __cplusplus
666
}
667
}
667
#endif
668
#endif
668
 
669
 
669
#endif /* __STM32F1xx_HAL_IRDA_H */
670
#endif /* __STM32F1xx_HAL_IRDA_H */
670
 
671
 
-
 
672
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
-