001

Committer:
ganlikun
Date:
Sun Jun 12 14:02:44 2022 +0000
Revision:
0:13413ea9a877
00

Who changed what in which revision?

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