STM32F439xx HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32f4xx_hal_irda.h 00004 * @author MCD Application Team 00005 * @brief Header file of IRDA HAL module. 00006 ****************************************************************************** 00007 * @attention 00008 * 00009 * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> 00010 * 00011 * Redistribution and use in source and binary forms, with or without modification, 00012 * are permitted provided that the following conditions are met: 00013 * 1. Redistributions of source code must retain the above copyright notice, 00014 * this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright notice, 00016 * this list of conditions and the following disclaimer in the documentation 00017 * and/or other materials provided with the distribution. 00018 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00019 * may be used to endorse or promote products derived from this software 00020 * without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00023 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00024 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00025 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00026 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00027 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00028 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00030 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00031 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00032 * 00033 ****************************************************************************** 00034 */ 00035 00036 /* Define to prevent recursive inclusion -------------------------------------*/ 00037 #ifndef __STM32F4xx_HAL_IRDA_H 00038 #define __STM32F4xx_HAL_IRDA_H 00039 00040 #ifdef __cplusplus 00041 extern "C" { 00042 #endif 00043 00044 /* Includes ------------------------------------------------------------------*/ 00045 #include "stm32f4xx_hal_def.h" 00046 00047 /** @addtogroup STM32F4xx_HAL_Driver 00048 * @{ 00049 */ 00050 00051 /** @addtogroup IRDA 00052 * @{ 00053 */ 00054 00055 /* Exported types ------------------------------------------------------------*/ 00056 /** @defgroup IRDA_Exported_Types IRDA Exported Types 00057 * @{ 00058 */ 00059 /** 00060 * @brief IRDA Init Structure definition 00061 */ 00062 typedef struct 00063 { 00064 uint32_t BaudRate; /*!< This member configures the IRDA communication baud rate. 00065 The baud rate is computed using the following formula: 00066 - IntegerDivider = ((PCLKx) / (8 * (hirda->Init.BaudRate))) 00067 - FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 8) + 0.5 */ 00068 00069 uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame. 00070 This parameter can be a value of @ref IRDA_Word_Length */ 00071 00072 uint32_t Parity; /*!< Specifies the parity mode. 00073 This parameter can be a value of @ref IRDA_Parity 00074 @note When parity is enabled, the computed parity is inserted 00075 at the MSB position of the transmitted data (9th bit when 00076 the word length is set to 9 data bits; 8th bit when the 00077 word length is set to 8 data bits). */ 00078 00079 uint32_t Mode; /*!< Specifies wether the Receive or Transmit mode is enabled or disabled. 00080 This parameter can be a value of @ref IRDA_Mode */ 00081 00082 uint8_t Prescaler; /*!< Specifies the Prescaler */ 00083 00084 uint32_t IrDAMode; /*!< Specifies the IrDA mode 00085 This parameter can be a value of @ref IRDA_Low_Power */ 00086 }IRDA_InitTypeDef; 00087 00088 /** 00089 * @brief HAL IRDA State structures definition 00090 * @note HAL IRDA State value is a combination of 2 different substates: gState and RxState. 00091 * - gState contains IRDA state information related to global Handle management 00092 * and also information related to Tx operations. 00093 * gState value coding follow below described bitmap : 00094 * b7-b6 Error information 00095 * 00 : No Error 00096 * 01 : (Not Used) 00097 * 10 : Timeout 00098 * 11 : Error 00099 * b5 IP initilisation status 00100 * 0 : Reset (IP not initialized) 00101 * 1 : Init done (IP not initialized. HAL IRDA Init function already called) 00102 * b4-b3 (not used) 00103 * xx : Should be set to 00 00104 * b2 Intrinsic process state 00105 * 0 : Ready 00106 * 1 : Busy (IP busy with some configuration or internal operations) 00107 * b1 (not used) 00108 * x : Should be set to 0 00109 * b0 Tx state 00110 * 0 : Ready (no Tx operation ongoing) 00111 * 1 : Busy (Tx operation ongoing) 00112 * - RxState contains information related to Rx operations. 00113 * RxState value coding follow below described bitmap : 00114 * b7-b6 (not used) 00115 * xx : Should be set to 00 00116 * b5 IP initilisation status 00117 * 0 : Reset (IP not initialized) 00118 * 1 : Init done (IP not initialized) 00119 * b4-b2 (not used) 00120 * xxx : Should be set to 000 00121 * b1 Rx state 00122 * 0 : Ready (no Rx operation ongoing) 00123 * 1 : Busy (Rx operation ongoing) 00124 * b0 (not used) 00125 * x : Should be set to 0. 00126 */ 00127 typedef enum 00128 { 00129 HAL_IRDA_STATE_RESET = 0x00U, /*!< Peripheral is not yet Initialized 00130 Value is allowed for gState and RxState */ 00131 HAL_IRDA_STATE_READY = 0x20U, /*!< Peripheral Initialized and ready for use 00132 Value is allowed for gState and RxState */ 00133 HAL_IRDA_STATE_BUSY = 0x24U, /*!< An internal process is ongoing 00134 Value is allowed for gState only */ 00135 HAL_IRDA_STATE_BUSY_TX = 0x21U, /*!< Data Transmission process is ongoing 00136 Value is allowed for gState only */ 00137 HAL_IRDA_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing 00138 Value is allowed for RxState only */ 00139 HAL_IRDA_STATE_BUSY_TX_RX = 0x23U, /*!< Data Transmission and Reception process is ongoing 00140 Not to be used for neither gState nor RxState. 00141 Value is result of combination (Or) between gState and RxState values */ 00142 HAL_IRDA_STATE_TIMEOUT = 0xA0U, /*!< Timeout state 00143 Value is allowed for gState only */ 00144 HAL_IRDA_STATE_ERROR = 0xE0U /*!< Error 00145 Value is allowed for gState only */ 00146 }HAL_IRDA_StateTypeDef; 00147 00148 /** 00149 * @brief IRDA handle Structure definition 00150 */ 00151 typedef struct 00152 { 00153 USART_TypeDef *Instance; /* USART registers base address */ 00154 00155 IRDA_InitTypeDef Init; /* IRDA communication parameters */ 00156 00157 uint8_t *pTxBuffPtr; /* Pointer to IRDA Tx transfer Buffer */ 00158 00159 uint16_t TxXferSize; /* IRDA Tx Transfer size */ 00160 00161 __IO uint16_t TxXferCount; /* IRDA Tx Transfer Counter */ 00162 00163 uint8_t *pRxBuffPtr; /* Pointer to IRDA Rx transfer Buffer */ 00164 00165 uint16_t RxXferSize; /* IRDA Rx Transfer size */ 00166 00167 __IO uint16_t RxXferCount; /* IRDA Rx Transfer Counter */ 00168 00169 DMA_HandleTypeDef *hdmatx; /* IRDA Tx DMA Handle parameters */ 00170 00171 DMA_HandleTypeDef *hdmarx; /* IRDA Rx DMA Handle parameters */ 00172 00173 HAL_LockTypeDef Lock; /* Locking object */ 00174 00175 __IO HAL_IRDA_StateTypeDef gState; /* IRDA state information related to global Handle management 00176 and also related to Tx operations. 00177 This parameter can be a value of @ref HAL_IRDA_StateTypeDef */ 00178 00179 __IO HAL_IRDA_StateTypeDef RxState; /* IRDA state information related to Rx operations. 00180 This parameter can be a value of @ref HAL_IRDA_StateTypeDef */ 00181 00182 __IO uint32_t ErrorCode; /* IRDA Error code */ 00183 00184 }IRDA_HandleTypeDef; 00185 /** 00186 * @} 00187 */ 00188 00189 /* Exported constants --------------------------------------------------------*/ 00190 /** @defgroup IRDA_Exported_Constants IRDA Exported constants 00191 * @{ 00192 */ 00193 /** @defgroup IRDA_Error_Code IRDA Error Code 00194 * @brief IRDA Error Code 00195 * @{ 00196 */ 00197 #define HAL_IRDA_ERROR_NONE 0x00000000U /*!< No error */ 00198 #define HAL_IRDA_ERROR_PE 0x00000001U /*!< Parity error */ 00199 #define HAL_IRDA_ERROR_NE 0x00000002U /*!< Noise error */ 00200 #define HAL_IRDA_ERROR_FE 0x00000004U /*!< Frame error */ 00201 #define HAL_IRDA_ERROR_ORE 0x00000008U /*!< Overrun error */ 00202 #define HAL_IRDA_ERROR_DMA 0x00000010U /*!< DMA transfer error */ 00203 /** 00204 * @} 00205 */ 00206 00207 /** @defgroup IRDA_Word_Length IRDA Word Length 00208 * @{ 00209 */ 00210 #define IRDA_WORDLENGTH_8B 0x00000000U 00211 #define IRDA_WORDLENGTH_9B ((uint32_t)USART_CR1_M) 00212 /** 00213 * @} 00214 */ 00215 00216 /** @defgroup IRDA_Parity IRDA Parity 00217 * @{ 00218 */ 00219 #define IRDA_PARITY_NONE 0x00000000U 00220 #define IRDA_PARITY_EVEN ((uint32_t)USART_CR1_PCE) 00221 #define IRDA_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS)) 00222 /** 00223 * @} 00224 */ 00225 00226 /** @defgroup IRDA_Mode IRDA Transfer Mode 00227 * @{ 00228 */ 00229 #define IRDA_MODE_RX ((uint32_t)USART_CR1_RE) 00230 #define IRDA_MODE_TX ((uint32_t)USART_CR1_TE) 00231 #define IRDA_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE)) 00232 /** 00233 * @} 00234 */ 00235 00236 /** @defgroup IRDA_Low_Power IRDA Low Power 00237 * @{ 00238 */ 00239 #define IRDA_POWERMODE_LOWPOWER ((uint32_t)USART_CR3_IRLP) 00240 #define IRDA_POWERMODE_NORMAL 0x00000000U 00241 /** 00242 * @} 00243 */ 00244 00245 /** @defgroup IRDA_Flags IRDA Flags 00246 * Elements values convention: 0xXXXX 00247 * - 0xXXXX : Flag mask in the SR register 00248 * @{ 00249 */ 00250 #define IRDA_FLAG_TXE 0x00000080U 00251 #define IRDA_FLAG_TC 0x00000040U 00252 #define IRDA_FLAG_RXNE 0x00000020U 00253 #define IRDA_FLAG_IDLE 0x00000010U 00254 #define IRDA_FLAG_ORE 0x00000008U 00255 #define IRDA_FLAG_NE 0x00000004U 00256 #define IRDA_FLAG_FE 0x00000002U 00257 #define IRDA_FLAG_PE 0x00000001U 00258 /** 00259 * @} 00260 */ 00261 00262 /** @defgroup IRDA_Interrupt_definition IRDA Interrupt Definitions 00263 * Elements values convention: 0xY000XXXX 00264 * - XXXX : Interrupt mask in the XX register 00265 * - Y : Interrupt source register (2bits) 00266 * - 01: CR1 register 00267 * - 10: CR2 register 00268 * - 11: CR3 register 00269 * @{ 00270 */ 00271 #define IRDA_IT_PE ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_PEIE)) 00272 #define IRDA_IT_TXE ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_TXEIE)) 00273 #define IRDA_IT_TC ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_TCIE)) 00274 #define IRDA_IT_RXNE ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_RXNEIE)) 00275 #define IRDA_IT_IDLE ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_IDLEIE)) 00276 00277 #define IRDA_IT_LBD ((uint32_t)(IRDA_CR2_REG_INDEX << 28U | USART_CR2_LBDIE)) 00278 00279 #define IRDA_IT_CTS ((uint32_t)(IRDA_CR3_REG_INDEX << 28U | USART_CR3_CTSIE)) 00280 #define IRDA_IT_ERR ((uint32_t)(IRDA_CR3_REG_INDEX << 28U | USART_CR3_EIE)) 00281 /** 00282 * @} 00283 */ 00284 00285 /** 00286 * @} 00287 */ 00288 00289 /* Exported macro ------------------------------------------------------------*/ 00290 /** @defgroup IRDA_Exported_Macros IRDA Exported Macros 00291 * @{ 00292 */ 00293 00294 /** @brief Reset IRDA handle gstate & RxState 00295 * @param __HANDLE__ specifies the USART Handle. 00296 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or 00297 * UART peripheral. 00298 * @retval None 00299 */ 00300 #define __HAL_IRDA_RESET_HANDLE_STATE(__HANDLE__) do{ \ 00301 (__HANDLE__)->gState = HAL_IRDA_STATE_RESET; \ 00302 (__HANDLE__)->RxState = HAL_IRDA_STATE_RESET; \ 00303 } while(0U) 00304 00305 /** @brief Flushs the IRDA DR register 00306 * @param __HANDLE__ specifies the USART Handle. 00307 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or 00308 * UART peripheral. 00309 */ 00310 #define __HAL_IRDA_FLUSH_DRREGISTER(__HANDLE__) ((__HANDLE__)->Instance->DR) 00311 00312 /** @brief Checks whether the specified IRDA flag is set or not. 00313 * @param __HANDLE__ specifies the USART Handle. 00314 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or 00315 * UART peripheral. 00316 * @param __FLAG__ specifies the flag to check. 00317 * This parameter can be one of the following values: 00318 * @arg IRDA_FLAG_TXE: Transmit data register empty flag 00319 * @arg IRDA_FLAG_TC: Transmission Complete flag 00320 * @arg IRDA_FLAG_RXNE: Receive data register not empty flag 00321 * @arg IRDA_FLAG_IDLE: Idle Line detection flag 00322 * @arg IRDA_FLAG_ORE: OverRun Error flag 00323 * @arg IRDA_FLAG_NE: Noise Error flag 00324 * @arg IRDA_FLAG_FE: Framing Error flag 00325 * @arg IRDA_FLAG_PE: Parity Error flag 00326 * @retval The new state of __FLAG__ (TRUE or FALSE). 00327 */ 00328 #define __HAL_IRDA_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__)) 00329 00330 /** @brief Clears the specified IRDA pending flag. 00331 * @param __HANDLE__ specifies the USART Handle. 00332 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or 00333 * UART peripheral. 00334 * @param __FLAG__ specifies the flag to check. 00335 * This parameter can be any combination of the following values: 00336 * @arg IRDA_FLAG_TC: Transmission Complete flag. 00337 * @arg IRDA_FLAG_RXNE: Receive data register not empty flag. 00338 * 00339 * @note PE (Parity error), FE (Framing error), NE (Noise error), ORE (OverRun 00340 * error) and IDLE (Idle line detected) flags are cleared by software 00341 * sequence: a read operation to USART_SR register followed by a read 00342 * operation to USART_DR register. 00343 * @note RXNE flag can be also cleared by a read to the USART_DR register. 00344 * @note TC flag can be also cleared by software sequence: a read operation to 00345 * USART_SR register followed by a write operation to USART_DR register. 00346 * @note TXE flag is cleared only by a write to the USART_DR register. 00347 * 00348 * @retval None 00349 */ 00350 #define __HAL_IRDA_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__)) 00351 00352 /** @brief Clear the IRDA PE pending flag. 00353 * @param __HANDLE__ specifies the USART Handle. 00354 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or 00355 * UART peripheral. 00356 * @retval None 00357 */ 00358 #define __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) \ 00359 do{ \ 00360 __IO uint32_t tmpreg = 0x00U; \ 00361 tmpreg = (__HANDLE__)->Instance->SR; \ 00362 UNUSED(tmpreg); \ 00363 } while(0U) 00364 00365 /** @brief Clear the IRDA FE pending flag. 00366 * @param __HANDLE__ specifies the USART Handle. 00367 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or 00368 * UART peripheral. 00369 * @retval None 00370 */ 00371 #define __HAL_IRDA_CLEAR_FEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) 00372 00373 /** @brief Clear the IRDA NE pending flag. 00374 * @param __HANDLE__ specifies the USART Handle. 00375 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or 00376 * UART peripheral. 00377 * @retval None 00378 */ 00379 #define __HAL_IRDA_CLEAR_NEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) 00380 00381 /** @brief Clear the IRDA ORE pending flag. 00382 * @param __HANDLE__ specifies the USART Handle. 00383 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or 00384 * UART peripheral. 00385 * @retval None 00386 */ 00387 #define __HAL_IRDA_CLEAR_OREFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) 00388 00389 /** @brief Clear the IRDA IDLE pending flag. 00390 * @param __HANDLE__ specifies the USART Handle. 00391 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or 00392 * UART peripheral. 00393 * @retval None 00394 */ 00395 #define __HAL_IRDA_CLEAR_IDLEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) 00396 00397 /** @brief Enables or disables the specified IRDA interrupt. 00398 * @param __HANDLE__ specifies the USART Handle. 00399 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or 00400 * UART peripheral. 00401 * @param __INTERRUPT__ specifies the IRDA interrupt source to check. 00402 * This parameter can be one of the following values: 00403 * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt 00404 * @arg IRDA_IT_TC: Transmission complete interrupt 00405 * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt 00406 * @arg IRDA_IT_IDLE: Idle line detection interrupt 00407 * @arg IRDA_IT_PE: Parity Error interrupt 00408 * @arg IRDA_IT_ERR: Error interrupt(Frame error, noise error, overrun error) 00409 * @retval None 00410 */ 00411 #define __HAL_IRDA_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28U) == 1U)? ((__HANDLE__)->Instance->CR1 |= ((__INTERRUPT__) & IRDA_IT_MASK)): \ 00412 (((__INTERRUPT__) >> 28U) == 2U)? ((__HANDLE__)->Instance->CR2 |= ((__INTERRUPT__) & IRDA_IT_MASK)): \ 00413 ((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & IRDA_IT_MASK))) 00414 #define __HAL_IRDA_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28U) == 1U)? ((__HANDLE__)->Instance->CR1 &= ~((__INTERRUPT__) & IRDA_IT_MASK)): \ 00415 (((__INTERRUPT__) >> 28U) == 2U)? ((__HANDLE__)->Instance->CR2 &= ~((__INTERRUPT__) & IRDA_IT_MASK)): \ 00416 ((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & IRDA_IT_MASK))) 00417 00418 /** @brief Checks whether the specified IRDA interrupt has occurred or not. 00419 * @param __HANDLE__ specifies the USART Handle. 00420 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or 00421 * UART peripheral. 00422 * @param __IT__ specifies the IRDA interrupt source to check. 00423 * This parameter can be one of the following values: 00424 * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt 00425 * @arg IRDA_IT_TC: Transmission complete interrupt 00426 * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt 00427 * @arg IRDA_IT_IDLE: Idle line detection interrupt 00428 * @arg USART_IT_ERR: Error interrupt 00429 * @arg IRDA_IT_PE: Parity Error interrupt 00430 * @retval The new state of __IT__ (TRUE or FALSE). 00431 */ 00432 #define __HAL_IRDA_GET_IT_SOURCE(__HANDLE__, __IT__) (((((__IT__) >> 28U) == 1U)? (__HANDLE__)->Instance->CR1:(((((uint32_t)(__IT__)) >> 28U) == 2U)? \ 00433 (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & (((uint32_t)(__IT__)) & IRDA_IT_MASK)) 00434 00435 /** @brief Macro to enable the IRDA's one bit sample method 00436 * @param __HANDLE__ specifies the IRDA Handle. 00437 * @retval None 00438 */ 00439 #define __HAL_IRDA_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT) 00440 00441 /** @brief Macro to disable the IRDA's one bit sample method 00442 * @param __HANDLE__ specifies the IRDA Handle. 00443 * @retval None 00444 */ 00445 #define __HAL_IRDA_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint16_t)~((uint16_t)USART_CR3_ONEBIT)) 00446 00447 /** @brief Enable UART/USART associated to IRDA Handle 00448 * @param __HANDLE__ specifies the IRDA Handle. 00449 * IRDA Handle selects the USARTx or UARTy peripheral 00450 * (USART,UART availability and x,y values depending on device). 00451 * @retval None 00452 */ 00453 #define __HAL_IRDA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE) 00454 00455 /** @brief Disable UART/USART associated to IRDA Handle 00456 * @param __HANDLE__ specifies the IRDA Handle. 00457 * IRDA Handle selects the USARTx or UARTy peripheral 00458 * (USART,UART availability and x,y values depending on device). 00459 * @retval None 00460 */ 00461 #define __HAL_IRDA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE) 00462 00463 /** 00464 * @} 00465 */ 00466 00467 /* Exported functions --------------------------------------------------------*/ 00468 /** @addtogroup IRDA_Exported_Functions 00469 * @{ 00470 */ 00471 00472 /** @addtogroup IRDA_Exported_Functions_Group1 00473 * @{ 00474 */ 00475 /* Initialization/de-initialization functions **********************************/ 00476 HAL_StatusTypeDef HAL_IRDA_Init(IRDA_HandleTypeDef *hirda); 00477 HAL_StatusTypeDef HAL_IRDA_DeInit(IRDA_HandleTypeDef *hirda); 00478 void HAL_IRDA_MspInit(IRDA_HandleTypeDef *hirda); 00479 void HAL_IRDA_MspDeInit(IRDA_HandleTypeDef *hirda); 00480 /** 00481 * @} 00482 */ 00483 00484 /** @addtogroup IRDA_Exported_Functions_Group2 00485 * @{ 00486 */ 00487 /* IO operation functions *******************************************************/ 00488 HAL_StatusTypeDef HAL_IRDA_Transmit(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout); 00489 HAL_StatusTypeDef HAL_IRDA_Receive(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout); 00490 HAL_StatusTypeDef HAL_IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); 00491 HAL_StatusTypeDef HAL_IRDA_Receive_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); 00492 HAL_StatusTypeDef HAL_IRDA_Transmit_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); 00493 HAL_StatusTypeDef HAL_IRDA_Receive_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); 00494 HAL_StatusTypeDef HAL_IRDA_DMAPause(IRDA_HandleTypeDef *hirda); 00495 HAL_StatusTypeDef HAL_IRDA_DMAResume(IRDA_HandleTypeDef *hirda); 00496 HAL_StatusTypeDef HAL_IRDA_DMAStop(IRDA_HandleTypeDef *hirda); 00497 /* Transfer Abort functions */ 00498 HAL_StatusTypeDef HAL_IRDA_Abort(IRDA_HandleTypeDef *hirda); 00499 HAL_StatusTypeDef HAL_IRDA_AbortTransmit(IRDA_HandleTypeDef *hirda); 00500 HAL_StatusTypeDef HAL_IRDA_AbortReceive(IRDA_HandleTypeDef *hirda); 00501 HAL_StatusTypeDef HAL_IRDA_Abort_IT(IRDA_HandleTypeDef *hirda); 00502 HAL_StatusTypeDef HAL_IRDA_AbortTransmit_IT(IRDA_HandleTypeDef *hirda); 00503 HAL_StatusTypeDef HAL_IRDA_AbortReceive_IT(IRDA_HandleTypeDef *hirda); 00504 00505 void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef *hirda); 00506 void HAL_IRDA_TxCpltCallback(IRDA_HandleTypeDef *hirda); 00507 void HAL_IRDA_RxCpltCallback(IRDA_HandleTypeDef *hirda); 00508 void HAL_IRDA_TxHalfCpltCallback(IRDA_HandleTypeDef *hirda); 00509 void HAL_IRDA_RxHalfCpltCallback(IRDA_HandleTypeDef *hirda); 00510 void HAL_IRDA_ErrorCallback(IRDA_HandleTypeDef *hirda); 00511 void HAL_IRDA_AbortCpltCallback(IRDA_HandleTypeDef *hirda); 00512 void HAL_IRDA_AbortTransmitCpltCallback(IRDA_HandleTypeDef *hirda); 00513 void HAL_IRDA_AbortReceiveCpltCallback(IRDA_HandleTypeDef *hirda); 00514 /** 00515 * @} 00516 */ 00517 00518 /** @addtogroup IRDA_Exported_Functions_Group3 00519 * @{ 00520 */ 00521 /* Peripheral State functions **************************************************/ 00522 HAL_IRDA_StateTypeDef HAL_IRDA_GetState(IRDA_HandleTypeDef *hirda); 00523 uint32_t HAL_IRDA_GetError(IRDA_HandleTypeDef *hirda); 00524 /** 00525 * @} 00526 */ 00527 00528 /** 00529 * @} 00530 */ 00531 00532 /* Private types -------------------------------------------------------------*/ 00533 /* Private variables ---------------------------------------------------------*/ 00534 /* Private constants ---------------------------------------------------------*/ 00535 /** @defgroup IRDA_Private_Constants IRDA Private Constants 00536 * @{ 00537 */ 00538 00539 /** @brief IRDA interruptions flag mask 00540 * 00541 */ 00542 #define IRDA_IT_MASK ((uint32_t) USART_CR1_PEIE | USART_CR1_TXEIE | USART_CR1_TCIE | USART_CR1_RXNEIE | \ 00543 USART_CR1_IDLEIE | USART_CR2_LBDIE | USART_CR3_CTSIE | USART_CR3_EIE ) 00544 00545 #define IRDA_CR1_REG_INDEX 1U 00546 #define IRDA_CR2_REG_INDEX 2U 00547 #define IRDA_CR3_REG_INDEX 3U 00548 /** 00549 * @} 00550 */ 00551 00552 /* Private macros --------------------------------------------------------*/ 00553 /** @defgroup IRDA_Private_Macros IRDA Private Macros 00554 * @{ 00555 */ 00556 #define IS_IRDA_WORD_LENGTH(LENGTH) (((LENGTH) == IRDA_WORDLENGTH_8B) || \ 00557 ((LENGTH) == IRDA_WORDLENGTH_9B)) 00558 #define IS_IRDA_PARITY(PARITY) (((PARITY) == IRDA_PARITY_NONE) || \ 00559 ((PARITY) == IRDA_PARITY_EVEN) || \ 00560 ((PARITY) == IRDA_PARITY_ODD)) 00561 #define IS_IRDA_MODE(MODE) ((((MODE) & 0x0000FFF3U) == 0x00U) && ((MODE) != 0x00000000U)) 00562 #define IS_IRDA_POWERMODE(MODE) (((MODE) == IRDA_POWERMODE_LOWPOWER) || \ 00563 ((MODE) == IRDA_POWERMODE_NORMAL)) 00564 #define IS_IRDA_BAUDRATE(BAUDRATE) ((BAUDRATE) < 115201U) 00565 00566 #define IRDA_DIV(_PCLK_, _BAUD_) (((_PCLK_)*25U)/(4U*(_BAUD_))) 00567 #define IRDA_DIVMANT(_PCLK_, _BAUD_) (IRDA_DIV((_PCLK_), (_BAUD_))/100U) 00568 #define IRDA_DIVFRAQ(_PCLK_, _BAUD_) (((IRDA_DIV((_PCLK_), (_BAUD_)) - (IRDA_DIVMANT((_PCLK_), (_BAUD_)) * 100U)) * 16U + 50U) / 100U) 00569 /* UART BRR = mantissa + overflow + fraction 00570 = (UART DIVMANT << 4) + (UART DIVFRAQ & 0xF0) + (UART DIVFRAQ & 0x0FU) */ 00571 #define IRDA_BRR(_PCLK_, _BAUD_) (((IRDA_DIVMANT((_PCLK_), (_BAUD_)) << 4U) + \ 00572 (IRDA_DIVFRAQ((_PCLK_), (_BAUD_)) & 0xF0U)) + \ 00573 (IRDA_DIVFRAQ((_PCLK_), (_BAUD_)) & 0x0FU)) 00574 00575 /** 00576 * @} 00577 */ 00578 00579 /* Private functions ---------------------------------------------------------*/ 00580 /** @defgroup IRDA_Private_Functions IRDA Private Functions 00581 * @{ 00582 */ 00583 00584 /** 00585 * @} 00586 */ 00587 00588 /** 00589 * @} 00590 */ 00591 00592 /** 00593 * @} 00594 */ 00595 00596 #ifdef __cplusplus 00597 } 00598 #endif 00599 00600 #endif /* __STM32F4xx_HAL_IRDA_H */ 00601 00602 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/