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