Initial commit

Dependencies:   FastPWM

Committer:
lypinator
Date:
Wed Sep 16 01:11:49 2020 +0000
Revision:
0:bb348c97df44
Added PWM

Who changed what in which revision?

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