Fork of the official mbed C/C SDK provides the software platform and libraries to build your applications for RenBED.

Dependents:   1-RenBuggyTimed RenBED_RGB RenBED_RGB_PWM RenBED_RGB

Fork of mbed by mbed official

Committer:
Kojto
Date:
Fri Oct 02 07:35:07 2015 +0200
Revision:
108:34e6b704fe68
Parent:
93:e188a91d3eaa
Release 108  of the mbed library

Changes:
- new platforms - ELMO_F411RE, WIZNET_7500P, ARM_MPS2_BEID
- EFM32 - bugfixes in rtc, serial
- Cortex A cmsis - update files
- STML4 - RAM fixes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 85:024bf7f99721 1 /**
bogdanm 85:024bf7f99721 2 ******************************************************************************
bogdanm 85:024bf7f99721 3 * @file stm32f0xx_hal_irda.h
bogdanm 85:024bf7f99721 4 * @author MCD Application Team
Kojto 108:34e6b704fe68 5 * @version V1.3.0
Kojto 108:34e6b704fe68 6 * @date 26-June-2015
bogdanm 92:4fc01daae5a5 7 * @brief This file contains all the functions prototypes for the IRDA
bogdanm 92:4fc01daae5a5 8 * firmware library.
bogdanm 85:024bf7f99721 9 ******************************************************************************
bogdanm 85:024bf7f99721 10 * @attention
bogdanm 85:024bf7f99721 11 *
Kojto 108:34e6b704fe68 12 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
bogdanm 85:024bf7f99721 13 *
bogdanm 85:024bf7f99721 14 * Redistribution and use in source and binary forms, with or without modification,
bogdanm 85:024bf7f99721 15 * are permitted provided that the following conditions are met:
bogdanm 85:024bf7f99721 16 * 1. Redistributions of source code must retain the above copyright notice,
bogdanm 85:024bf7f99721 17 * this list of conditions and the following disclaimer.
bogdanm 85:024bf7f99721 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
bogdanm 85:024bf7f99721 19 * this list of conditions and the following disclaimer in the documentation
bogdanm 85:024bf7f99721 20 * and/or other materials provided with the distribution.
bogdanm 85:024bf7f99721 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bogdanm 85:024bf7f99721 22 * may be used to endorse or promote products derived from this software
bogdanm 85:024bf7f99721 23 * without specific prior written permission.
bogdanm 85:024bf7f99721 24 *
bogdanm 85:024bf7f99721 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bogdanm 85:024bf7f99721 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bogdanm 85:024bf7f99721 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bogdanm 85:024bf7f99721 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bogdanm 85:024bf7f99721 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bogdanm 85:024bf7f99721 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bogdanm 85:024bf7f99721 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bogdanm 85:024bf7f99721 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bogdanm 85:024bf7f99721 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bogdanm 85:024bf7f99721 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bogdanm 85:024bf7f99721 35 *
Kojto 108:34e6b704fe68 36 ******************************************************************************
bogdanm 85:024bf7f99721 37 */
bogdanm 85:024bf7f99721 38
bogdanm 85:024bf7f99721 39 /* Define to prevent recursive inclusion -------------------------------------*/
bogdanm 85:024bf7f99721 40 #ifndef __STM32F0xx_HAL_IRDA_H
bogdanm 85:024bf7f99721 41 #define __STM32F0xx_HAL_IRDA_H
bogdanm 85:024bf7f99721 42
bogdanm 85:024bf7f99721 43 #ifdef __cplusplus
bogdanm 85:024bf7f99721 44 extern "C" {
bogdanm 85:024bf7f99721 45 #endif
bogdanm 85:024bf7f99721 46
Kojto 93:e188a91d3eaa 47 #if !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC)
bogdanm 85:024bf7f99721 48
bogdanm 85:024bf7f99721 49 /* Includes ------------------------------------------------------------------*/
bogdanm 85:024bf7f99721 50 #include "stm32f0xx_hal_def.h"
bogdanm 85:024bf7f99721 51
bogdanm 85:024bf7f99721 52 /** @addtogroup STM32F0xx_HAL_Driver
bogdanm 85:024bf7f99721 53 * @{
bogdanm 85:024bf7f99721 54 */
bogdanm 85:024bf7f99721 55
bogdanm 85:024bf7f99721 56 /** @addtogroup IRDA
bogdanm 85:024bf7f99721 57 * @{
Kojto 108:34e6b704fe68 58 */
bogdanm 85:024bf7f99721 59
bogdanm 85:024bf7f99721 60 /* Exported types ------------------------------------------------------------*/
bogdanm 92:4fc01daae5a5 61 /** @defgroup IRDA_Exported_Types IRDA Exported Types
bogdanm 92:4fc01daae5a5 62 * @{
Kojto 108:34e6b704fe68 63 */
bogdanm 85:024bf7f99721 64
Kojto 108:34e6b704fe68 65 /**
Kojto 108:34e6b704fe68 66 * @brief IRDA Init Structure definition
Kojto 108:34e6b704fe68 67 */
bogdanm 85:024bf7f99721 68 typedef struct
bogdanm 85:024bf7f99721 69 {
bogdanm 85:024bf7f99721 70 uint32_t BaudRate; /*!< This member configures the IRDA communication baud rate.
bogdanm 85:024bf7f99721 71 The baud rate register is computed using the following formula:
bogdanm 85:024bf7f99721 72 Baud Rate Register = ((PCLKx) / ((hirda->Init.BaudRate))) */
bogdanm 85:024bf7f99721 73
bogdanm 85:024bf7f99721 74 uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
bogdanm 85:024bf7f99721 75 This parameter can be a value of @ref IRDAEx_Word_Length */
bogdanm 85:024bf7f99721 76
Kojto 108:34e6b704fe68 77 uint32_t Parity; /*!< Specifies the parity mode.
bogdanm 85:024bf7f99721 78 This parameter can be a value of @ref IRDA_Parity
bogdanm 85:024bf7f99721 79 @note When parity is enabled, the computed parity is inserted
bogdanm 85:024bf7f99721 80 at the MSB position of the transmitted data (9th bit when
bogdanm 85:024bf7f99721 81 the word length is set to 9 data bits; 8th bit when the
bogdanm 85:024bf7f99721 82 word length is set to 8 data bits). */
Kojto 108:34e6b704fe68 83
Kojto 108:34e6b704fe68 84 uint32_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
bogdanm 85:024bf7f99721 85 This parameter can be a value of @ref IRDA_Mode */
Kojto 108:34e6b704fe68 86
bogdanm 85:024bf7f99721 87 uint8_t Prescaler; /*!< Specifies the Prescaler value for dividing the UART/USART source clock
bogdanm 85:024bf7f99721 88 to achieve low-power frequency.
bogdanm 85:024bf7f99721 89 @note Prescaler value 0 is forbidden */
Kojto 108:34e6b704fe68 90
bogdanm 85:024bf7f99721 91 uint16_t PowerMode; /*!< Specifies the IRDA power mode.
bogdanm 85:024bf7f99721 92 This parameter can be a value of @ref IRDA_Low_Power */
bogdanm 85:024bf7f99721 93 }IRDA_InitTypeDef;
bogdanm 85:024bf7f99721 94
Kojto 108:34e6b704fe68 95 /**
Kojto 108:34e6b704fe68 96 * @brief HAL IRDA State structures definition
Kojto 108:34e6b704fe68 97 */
bogdanm 85:024bf7f99721 98 typedef enum
bogdanm 85:024bf7f99721 99 {
Kojto 108:34e6b704fe68 100 HAL_IRDA_STATE_RESET = 0x00, /*!< Peripheral is not initialized */
Kojto 108:34e6b704fe68 101 HAL_IRDA_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */
Kojto 108:34e6b704fe68 102 HAL_IRDA_STATE_BUSY = 0x02, /*!< an internal process is ongoing */
bogdanm 85:024bf7f99721 103 HAL_IRDA_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */
bogdanm 85:024bf7f99721 104 HAL_IRDA_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */
bogdanm 85:024bf7f99721 105 HAL_IRDA_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission and Reception process is ongoing */
bogdanm 85:024bf7f99721 106 HAL_IRDA_STATE_TIMEOUT = 0x03, /*!< Timeout state */
bogdanm 85:024bf7f99721 107 HAL_IRDA_STATE_ERROR = 0x04 /*!< Error */
bogdanm 85:024bf7f99721 108 }HAL_IRDA_StateTypeDef;
bogdanm 85:024bf7f99721 109
bogdanm 92:4fc01daae5a5 110 /**
bogdanm 92:4fc01daae5a5 111 * @brief IRDA clock sources definition
bogdanm 92:4fc01daae5a5 112 */
bogdanm 92:4fc01daae5a5 113 typedef enum
bogdanm 92:4fc01daae5a5 114 {
bogdanm 92:4fc01daae5a5 115 IRDA_CLOCKSOURCE_PCLK1 = 0x00, /*!< PCLK1 clock source */
bogdanm 92:4fc01daae5a5 116 IRDA_CLOCKSOURCE_HSI = 0x02, /*!< HSI clock source */
bogdanm 92:4fc01daae5a5 117 IRDA_CLOCKSOURCE_SYSCLK = 0x04, /*!< SYSCLK clock source */
bogdanm 92:4fc01daae5a5 118 IRDA_CLOCKSOURCE_LSE = 0x08, /*!< LSE clock source */
Kojto 108:34e6b704fe68 119 IRDA_CLOCKSOURCE_UNDEFINED = 0x10 /*!< undefined clock source */
bogdanm 92:4fc01daae5a5 120 }IRDA_ClockSourceTypeDef;
bogdanm 92:4fc01daae5a5 121
Kojto 108:34e6b704fe68 122 /**
Kojto 108:34e6b704fe68 123 * @brief IRDA handle Structure definition
Kojto 108:34e6b704fe68 124 */
bogdanm 85:024bf7f99721 125 typedef struct
bogdanm 85:024bf7f99721 126 {
Kojto 93:e188a91d3eaa 127 USART_TypeDef *Instance; /*!< USART registers base address */
Kojto 108:34e6b704fe68 128
Kojto 93:e188a91d3eaa 129 IRDA_InitTypeDef Init; /*!< IRDA communication parameters */
Kojto 108:34e6b704fe68 130
Kojto 93:e188a91d3eaa 131 uint8_t *pTxBuffPtr; /*!< Pointer to IRDA Tx transfer Buffer */
Kojto 108:34e6b704fe68 132
Kojto 93:e188a91d3eaa 133 uint16_t TxXferSize; /*!< IRDA Tx Transfer size */
Kojto 108:34e6b704fe68 134
Kojto 93:e188a91d3eaa 135 uint16_t TxXferCount; /*!< IRDA Tx Transfer Counter */
Kojto 108:34e6b704fe68 136
Kojto 93:e188a91d3eaa 137 uint8_t *pRxBuffPtr; /*!< Pointer to IRDA Rx transfer Buffer */
Kojto 108:34e6b704fe68 138
Kojto 93:e188a91d3eaa 139 uint16_t RxXferSize; /*!< IRDA Rx Transfer size */
Kojto 108:34e6b704fe68 140
Kojto 93:e188a91d3eaa 141 uint16_t RxXferCount; /*!< IRDA Rx Transfer Counter */
Kojto 108:34e6b704fe68 142
Kojto 108:34e6b704fe68 143 uint16_t Mask; /*!< USART RX RDR register mask */
Kojto 108:34e6b704fe68 144
Kojto 93:e188a91d3eaa 145 DMA_HandleTypeDef *hdmatx; /*!< IRDA Tx DMA Handle parameters */
Kojto 108:34e6b704fe68 146
Kojto 93:e188a91d3eaa 147 DMA_HandleTypeDef *hdmarx; /*!< IRDA Rx DMA Handle parameters */
Kojto 108:34e6b704fe68 148
Kojto 93:e188a91d3eaa 149 HAL_LockTypeDef Lock; /*!< Locking object */
bogdanm 85:024bf7f99721 150
Kojto 108:34e6b704fe68 151 __IO HAL_IRDA_StateTypeDef State; /*!< IRDA communication state */
Kojto 108:34e6b704fe68 152
Kojto 93:e188a91d3eaa 153 __IO uint32_t ErrorCode; /*!< IRDA Error code
Kojto 93:e188a91d3eaa 154 This parameter can be a value of @ref IRDA_Error */
Kojto 93:e188a91d3eaa 155
bogdanm 85:024bf7f99721 156 }IRDA_HandleTypeDef;
bogdanm 85:024bf7f99721 157
Kojto 108:34e6b704fe68 158 /**
Kojto 108:34e6b704fe68 159 * @brief IRDA Configuration enumeration values definition
bogdanm 85:024bf7f99721 160 */
Kojto 108:34e6b704fe68 161 typedef enum
bogdanm 85:024bf7f99721 162 {
Kojto 108:34e6b704fe68 163 IRDA_BAUDRATE = 0x00, /*!< IRDA Baud rate */
Kojto 108:34e6b704fe68 164 IRDA_PARITY = 0x01, /*!< IRDA frame parity */
Kojto 108:34e6b704fe68 165 IRDA_WORDLENGTH = 0x02, /*!< IRDA frame length */
Kojto 108:34e6b704fe68 166 IRDA_MODE = 0x03, /*!< IRDA communication mode */
Kojto 108:34e6b704fe68 167 IRDA_PRESCALER = 0x04, /*!< IRDA prescaling */
Kojto 108:34e6b704fe68 168 IRDA_POWERMODE = 0x05 /*!< IRDA power mode */
bogdanm 85:024bf7f99721 169 }IRDA_ControlTypeDef;
bogdanm 85:024bf7f99721 170
bogdanm 92:4fc01daae5a5 171 /**
bogdanm 92:4fc01daae5a5 172 * @}
bogdanm 92:4fc01daae5a5 173 */
bogdanm 92:4fc01daae5a5 174
bogdanm 85:024bf7f99721 175 /* Exported constants --------------------------------------------------------*/
Kojto 108:34e6b704fe68 176 /** @defgroup IRDA_Exported_Constants IRDA Exported Constants
bogdanm 85:024bf7f99721 177 * @{
bogdanm 85:024bf7f99721 178 */
bogdanm 85:024bf7f99721 179
Kojto 93:e188a91d3eaa 180 /** @defgroup IRDA_Error IRDA Error
Kojto 93:e188a91d3eaa 181 * @{
Kojto 108:34e6b704fe68 182 */
Kojto 93:e188a91d3eaa 183 #define HAL_IRDA_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */
Kojto 93:e188a91d3eaa 184 #define HAL_IRDA_ERROR_PE ((uint32_t)0x00000001) /*!< Parity error */
Kojto 93:e188a91d3eaa 185 #define HAL_IRDA_ERROR_NE ((uint32_t)0x00000002) /*!< Noise error */
Kojto 93:e188a91d3eaa 186 #define HAL_IRDA_ERROR_FE ((uint32_t)0x00000004) /*!< frame error */
Kojto 93:e188a91d3eaa 187 #define HAL_IRDA_ERROR_ORE ((uint32_t)0x00000008) /*!< Overrun error */
Kojto 93:e188a91d3eaa 188 #define HAL_IRDA_ERROR_DMA ((uint32_t)0x00000010) /*!< DMA transfer error */
Kojto 93:e188a91d3eaa 189 /**
Kojto 93:e188a91d3eaa 190 * @}
Kojto 108:34e6b704fe68 191 */
Kojto 93:e188a91d3eaa 192
Kojto 108:34e6b704fe68 193 /** @defgroup IRDA_Parity IRDA Parity
bogdanm 85:024bf7f99721 194 * @{
Kojto 108:34e6b704fe68 195 */
Kojto 108:34e6b704fe68 196 #define IRDA_PARITY_NONE ((uint32_t)0x00000000) /*!< No parity */
Kojto 108:34e6b704fe68 197 #define IRDA_PARITY_EVEN ((uint32_t)USART_CR1_PCE) /*!< Even parity */
Kojto 108:34e6b704fe68 198 #define IRDA_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS)) /*!< Odd parity */
bogdanm 85:024bf7f99721 199 /**
bogdanm 85:024bf7f99721 200 * @}
bogdanm 85:024bf7f99721 201 */
bogdanm 85:024bf7f99721 202
Kojto 108:34e6b704fe68 203 /** @defgroup IRDA_Transfer_Mode IRDA Transfer Mode
bogdanm 85:024bf7f99721 204 * @{
bogdanm 85:024bf7f99721 205 */
Kojto 108:34e6b704fe68 206 #define IRDA_MODE_RX ((uint32_t)USART_CR1_RE) /*!< RX mode */
Kojto 108:34e6b704fe68 207 #define IRDA_MODE_TX ((uint32_t)USART_CR1_TE) /*!< TX mode */
Kojto 108:34e6b704fe68 208 #define IRDA_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE)) /*!< RX and TX mode */
bogdanm 85:024bf7f99721 209 /**
bogdanm 85:024bf7f99721 210 * @}
bogdanm 85:024bf7f99721 211 */
Kojto 108:34e6b704fe68 212
Kojto 108:34e6b704fe68 213 /** @defgroup IRDA_Low_Power IRDA Low Power
bogdanm 85:024bf7f99721 214 * @{
Kojto 108:34e6b704fe68 215 */
Kojto 108:34e6b704fe68 216 #define IRDA_POWERMODE_NORMAL ((uint32_t)0x00000000) /*!< IRDA normal power mode */
Kojto 108:34e6b704fe68 217 #define IRDA_POWERMODE_LOWPOWER ((uint32_t)USART_CR3_IRLP) /*!< IRDA low power mode */
Kojto 108:34e6b704fe68 218 /**
Kojto 108:34e6b704fe68 219 * @}
Kojto 108:34e6b704fe68 220 */
Kojto 108:34e6b704fe68 221
Kojto 108:34e6b704fe68 222 /** @defgroup IRDA_State IRDA State
Kojto 108:34e6b704fe68 223 * @{
Kojto 108:34e6b704fe68 224 */
Kojto 108:34e6b704fe68 225 #define IRDA_STATE_DISABLE ((uint32_t)0x00000000) /*!< IRDA disabled */
Kojto 108:34e6b704fe68 226 #define IRDA_STATE_ENABLE ((uint32_t)USART_CR1_UE) /*!< IRDA enabled */
bogdanm 85:024bf7f99721 227 /**
bogdanm 85:024bf7f99721 228 * @}
bogdanm 85:024bf7f99721 229 */
bogdanm 85:024bf7f99721 230
bogdanm 85:024bf7f99721 231 /** @defgroup IRDA_Mode IRDA Mode
bogdanm 85:024bf7f99721 232 * @{
Kojto 108:34e6b704fe68 233 */
Kojto 108:34e6b704fe68 234 #define IRDA_MODE_DISABLE ((uint32_t)0x00000000) /*!< Associated UART disabled in IRDA mode */
Kojto 108:34e6b704fe68 235 #define IRDA_MODE_ENABLE ((uint32_t)USART_CR3_IREN) /*!< Associated UART enabled in IRDA mode */
bogdanm 85:024bf7f99721 236 /**
bogdanm 85:024bf7f99721 237 * @}
bogdanm 85:024bf7f99721 238 */
bogdanm 85:024bf7f99721 239
bogdanm 85:024bf7f99721 240 /** @defgroup IRDA_One_Bit IRDA One Bit Sampling
bogdanm 85:024bf7f99721 241 * @{
bogdanm 85:024bf7f99721 242 */
Kojto 108:34e6b704fe68 243 #define IRDA_ONE_BIT_SAMPLE_DISABLE ((uint32_t)0x00000000) /*!< One-bit sampling disabled */
Kojto 108:34e6b704fe68 244 #define IRDA_ONE_BIT_SAMPLE_ENABLE ((uint32_t)USART_CR3_ONEBIT) /*!< One-bit sampling enabled */
bogdanm 85:024bf7f99721 245 /**
bogdanm 85:024bf7f99721 246 * @}
Kojto 108:34e6b704fe68 247 */
Kojto 108:34e6b704fe68 248
bogdanm 85:024bf7f99721 249 /** @defgroup IRDA_DMA_Tx IRDA DMA Tx
bogdanm 85:024bf7f99721 250 * @{
bogdanm 85:024bf7f99721 251 */
Kojto 108:34e6b704fe68 252 #define IRDA_DMA_TX_DISABLE ((uint32_t)0x00000000) /*!< IRDA DMA TX disabled */
Kojto 108:34e6b704fe68 253 #define IRDA_DMA_TX_ENABLE ((uint32_t)USART_CR3_DMAT) /*!< IRDA DMA TX enabled */
bogdanm 85:024bf7f99721 254 /**
bogdanm 85:024bf7f99721 255 * @}
Kojto 108:34e6b704fe68 256 */
Kojto 108:34e6b704fe68 257
bogdanm 85:024bf7f99721 258 /** @defgroup IRDA_DMA_Rx IRDA DMA Rx
bogdanm 85:024bf7f99721 259 * @{
bogdanm 85:024bf7f99721 260 */
Kojto 108:34e6b704fe68 261 #define IRDA_DMA_RX_DISABLE ((uint32_t)0x00000000) /*!< IRDA DMA RX disabled */
Kojto 108:34e6b704fe68 262 #define IRDA_DMA_RX_ENABLE ((uint32_t)USART_CR3_DMAR) /*!< IRDA DMA RX enabled */
bogdanm 85:024bf7f99721 263 /**
bogdanm 85:024bf7f99721 264 * @}
bogdanm 85:024bf7f99721 265 */
Kojto 108:34e6b704fe68 266
Kojto 108:34e6b704fe68 267 /** @defgroup IRDA_Request_Parameters IRDA Request Parameters
Kojto 108:34e6b704fe68 268 * @{
Kojto 108:34e6b704fe68 269 */
Kojto 108:34e6b704fe68 270 #define IRDA_AUTOBAUD_REQUEST ((uint32_t)USART_RQR_ABRRQ) /*!< Auto-Baud Rate Request */
Kojto 108:34e6b704fe68 271 #define IRDA_RXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_RXFRQ) /*!< Receive Data flush Request */
Kojto 108:34e6b704fe68 272 #define IRDA_TXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_TXFRQ) /*!< Transmit data flush Request */
Kojto 108:34e6b704fe68 273 /**
Kojto 108:34e6b704fe68 274 * @}
Kojto 108:34e6b704fe68 275 */
Kojto 108:34e6b704fe68 276
bogdanm 85:024bf7f99721 277 /** @defgroup IRDA_Flags IRDA Flags
bogdanm 85:024bf7f99721 278 * Elements values convention: 0xXXXX
bogdanm 85:024bf7f99721 279 * - 0xXXXX : Flag mask in the ISR register
bogdanm 85:024bf7f99721 280 * @{
bogdanm 85:024bf7f99721 281 */
Kojto 108:34e6b704fe68 282 #define IRDA_FLAG_REACK ((uint32_t)0x00400000) /*!< IRDA Receive enable acknowledge flag */
Kojto 108:34e6b704fe68 283 #define IRDA_FLAG_TEACK ((uint32_t)0x00200000) /*!< IRDA Transmit enable acknowledge flag */
Kojto 108:34e6b704fe68 284 #define IRDA_FLAG_BUSY ((uint32_t)0x00010000) /*!< IRDA Busy flag */
Kojto 108:34e6b704fe68 285 #define IRDA_FLAG_ABRF ((uint32_t)0x00008000) /*!< IRDA Auto baud rate flag */
Kojto 108:34e6b704fe68 286 #define IRDA_FLAG_ABRE ((uint32_t)0x00004000) /*!< IRDA Auto baud rate error */
Kojto 108:34e6b704fe68 287 #define IRDA_FLAG_TXE ((uint32_t)0x00000080) /*!< IRDA Transmit data register empty */
Kojto 108:34e6b704fe68 288 #define IRDA_FLAG_TC ((uint32_t)0x00000040) /*!< IRDA Transmission complete */
Kojto 108:34e6b704fe68 289 #define IRDA_FLAG_RXNE ((uint32_t)0x00000020) /*!< IRDA Read data register not empty */
Kojto 108:34e6b704fe68 290 #define IRDA_FLAG_ORE ((uint32_t)0x00000008) /*!< IRDA Overrun error */
Kojto 108:34e6b704fe68 291 #define IRDA_FLAG_NE ((uint32_t)0x00000004) /*!< IRDA Noise error */
Kojto 108:34e6b704fe68 292 #define IRDA_FLAG_FE ((uint32_t)0x00000002) /*!< IRDA Noise error */
Kojto 108:34e6b704fe68 293 #define IRDA_FLAG_PE ((uint32_t)0x00000001) /*!< IRDA Parity error */
bogdanm 85:024bf7f99721 294 /**
bogdanm 85:024bf7f99721 295 * @}
Kojto 108:34e6b704fe68 296 */
bogdanm 85:024bf7f99721 297
Kojto 108:34e6b704fe68 298 /** @defgroup IRDA_Interrupt_definition IRDA Interrupts Definition
bogdanm 85:024bf7f99721 299 * Elements values convention: 0000ZZZZ0XXYYYYYb
bogdanm 85:024bf7f99721 300 * - YYYYY : Interrupt source position in the XX register (5bits)
bogdanm 85:024bf7f99721 301 * - XX : Interrupt source register (2bits)
bogdanm 85:024bf7f99721 302 * - 01: CR1 register
bogdanm 85:024bf7f99721 303 * - 10: CR2 register
bogdanm 85:024bf7f99721 304 * - 11: CR3 register
bogdanm 85:024bf7f99721 305 * - ZZZZ : Flag position in the ISR register(4bits)
Kojto 108:34e6b704fe68 306 * @{
Kojto 108:34e6b704fe68 307 */
Kojto 108:34e6b704fe68 308 #define IRDA_IT_PE ((uint16_t)0x0028) /*!< IRDA Parity error interruption */
Kojto 108:34e6b704fe68 309 #define IRDA_IT_TXE ((uint16_t)0x0727) /*!< IRDA Transmit data register empty interruption */
Kojto 108:34e6b704fe68 310 #define IRDA_IT_TC ((uint16_t)0x0626) /*!< IRDA Transmission complete interruption */
Kojto 108:34e6b704fe68 311 #define IRDA_IT_RXNE ((uint16_t)0x0525) /*!< IRDA Read data register not empty interruption */
Kojto 108:34e6b704fe68 312 #define IRDA_IT_IDLE ((uint16_t)0x0424) /*!< IRDA Idle interruption */
bogdanm 85:024bf7f99721 313
bogdanm 85:024bf7f99721 314 /** Elements values convention: 000000000XXYYYYYb
bogdanm 85:024bf7f99721 315 * - YYYYY : Interrupt source position in the XX register (5bits)
bogdanm 85:024bf7f99721 316 * - XX : Interrupt source register (2bits)
bogdanm 85:024bf7f99721 317 * - 01: CR1 register
bogdanm 85:024bf7f99721 318 * - 10: CR2 register
bogdanm 85:024bf7f99721 319 * - 11: CR3 register
bogdanm 85:024bf7f99721 320 */
Kojto 108:34e6b704fe68 321 #define IRDA_IT_ERR ((uint16_t)0x0060) /*!< IRDA Error interruption */
bogdanm 85:024bf7f99721 322
bogdanm 85:024bf7f99721 323 /** Elements values convention: 0000ZZZZ00000000b
bogdanm 85:024bf7f99721 324 * - ZZZZ : Flag position in the ISR register(4bits)
bogdanm 85:024bf7f99721 325 */
Kojto 108:34e6b704fe68 326 #define IRDA_IT_ORE ((uint16_t)0x0300) /*!< IRDA Overrun error interruption */
Kojto 108:34e6b704fe68 327 #define IRDA_IT_NE ((uint16_t)0x0200) /*!< IRDA Noise error interruption */
Kojto 108:34e6b704fe68 328 #define IRDA_IT_FE ((uint16_t)0x0100) /*!< IRDA Frame error interruption */
bogdanm 85:024bf7f99721 329 /**
bogdanm 85:024bf7f99721 330 * @}
bogdanm 85:024bf7f99721 331 */
Kojto 108:34e6b704fe68 332
bogdanm 85:024bf7f99721 333 /** @defgroup IRDA_IT_CLEAR_Flags IRDA Interruption Clear Flags
bogdanm 85:024bf7f99721 334 * @{
bogdanm 85:024bf7f99721 335 */
bogdanm 85:024bf7f99721 336 #define IRDA_CLEAR_PEF USART_ICR_PECF /*!< Parity Error Clear Flag */
bogdanm 85:024bf7f99721 337 #define IRDA_CLEAR_FEF USART_ICR_FECF /*!< Framing Error Clear Flag */
bogdanm 85:024bf7f99721 338 #define IRDA_CLEAR_NEF USART_ICR_NCF /*!< Noise detected Clear Flag */
bogdanm 85:024bf7f99721 339 #define IRDA_CLEAR_OREF USART_ICR_ORECF /*!< OverRun Error Clear Flag */
bogdanm 85:024bf7f99721 340 #define IRDA_CLEAR_TCF USART_ICR_TCCF /*!< Transmission Complete Clear Flag */
bogdanm 85:024bf7f99721 341 /**
bogdanm 85:024bf7f99721 342 * @}
Kojto 108:34e6b704fe68 343 */
bogdanm 85:024bf7f99721 344
Kojto 108:34e6b704fe68 345 /** @defgroup IRDA_Interruption_Mask IRDA interruptions flags mask
bogdanm 85:024bf7f99721 346 * @{
bogdanm 85:024bf7f99721 347 */
Kojto 108:34e6b704fe68 348 #define IRDA_IT_MASK ((uint16_t)0x001F) /*!< IRDA Interruptions flags mask */
bogdanm 85:024bf7f99721 349 /**
bogdanm 85:024bf7f99721 350 * @}
bogdanm 85:024bf7f99721 351 */
Kojto 108:34e6b704fe68 352
bogdanm 85:024bf7f99721 353 /**
bogdanm 85:024bf7f99721 354 * @}
bogdanm 85:024bf7f99721 355 */
bogdanm 85:024bf7f99721 356
Kojto 108:34e6b704fe68 357
Kojto 108:34e6b704fe68 358 /* Exported macros -----------------------------------------------------------*/
bogdanm 92:4fc01daae5a5 359 /** @defgroup IRDA_Exported_Macros IRDA Exported Macros
bogdanm 85:024bf7f99721 360 * @{
bogdanm 85:024bf7f99721 361 */
Kojto 108:34e6b704fe68 362
Kojto 108:34e6b704fe68 363 /** @brief Reset IRDA handle state.
bogdanm 85:024bf7f99721 364 * @param __HANDLE__: IRDA handle.
bogdanm 85:024bf7f99721 365 * @retval None
bogdanm 85:024bf7f99721 366 */
bogdanm 85:024bf7f99721 367 #define __HAL_IRDA_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_IRDA_STATE_RESET)
bogdanm 85:024bf7f99721 368
Kojto 108:34e6b704fe68 369 /** @brief Flush the IRDA DR register.
Kojto 108:34e6b704fe68 370 * @param __HANDLE__: specifies the IRDA Handle.
Kojto 108:34e6b704fe68 371 * @retval None
Kojto 108:34e6b704fe68 372 */
Kojto 108:34e6b704fe68 373 #define __HAL_IRDA_FLUSH_DRREGISTER(__HANDLE__) \
Kojto 108:34e6b704fe68 374 do{ \
Kojto 108:34e6b704fe68 375 SET_BIT((__HANDLE__)->Instance->RQR, IRDA_RXDATA_FLUSH_REQUEST); \
Kojto 108:34e6b704fe68 376 SET_BIT((__HANDLE__)->Instance->RQR, IRDA_TXDATA_FLUSH_REQUEST); \
Kojto 108:34e6b704fe68 377 } while(0)
Kojto 108:34e6b704fe68 378
Kojto 108:34e6b704fe68 379
Kojto 108:34e6b704fe68 380 /** @brief Clear the specified IRDA pending flag.
Kojto 108:34e6b704fe68 381 * @param __HANDLE__: specifies the IRDA Handle.
Kojto 108:34e6b704fe68 382 * @param __FLAG__: specifies the flag to check.
Kojto 108:34e6b704fe68 383 * This parameter can be any combination of the following values:
Kojto 108:34e6b704fe68 384 * @arg IRDA_CLEAR_PEF
Kojto 108:34e6b704fe68 385 * @arg IRDA_CLEAR_FEF
Kojto 108:34e6b704fe68 386 * @arg IRDA_CLEAR_NEF
Kojto 108:34e6b704fe68 387 * @arg IRDA_CLEAR_OREF
Kojto 108:34e6b704fe68 388 * @arg IRDA_CLEAR_TCF
Kojto 108:34e6b704fe68 389 * @arg IRDA_CLEAR_IDLEF
Kojto 108:34e6b704fe68 390 * @retval None
Kojto 108:34e6b704fe68 391 */
Kojto 108:34e6b704fe68 392 #define __HAL_IRDA_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
Kojto 108:34e6b704fe68 393
Kojto 108:34e6b704fe68 394 /** @brief Clear the IRDA PE pending flag.
Kojto 108:34e6b704fe68 395 * @param __HANDLE__: specifies the IRDA Handle.
Kojto 108:34e6b704fe68 396 * @retval None
Kojto 108:34e6b704fe68 397 */
Kojto 108:34e6b704fe68 398 #define __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_PEF)
Kojto 108:34e6b704fe68 399
Kojto 108:34e6b704fe68 400
Kojto 108:34e6b704fe68 401 /** @brief Clear the IRDA FE pending flag.
Kojto 108:34e6b704fe68 402 * @param __HANDLE__: specifies the IRDA Handle.
Kojto 108:34e6b704fe68 403 * @retval None
Kojto 108:34e6b704fe68 404 */
Kojto 108:34e6b704fe68 405 #define __HAL_IRDA_CLEAR_FEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_FEF)
Kojto 108:34e6b704fe68 406
Kojto 108:34e6b704fe68 407 /** @brief Clear the IRDA NE pending flag.
Kojto 108:34e6b704fe68 408 * @param __HANDLE__: specifies the IRDA Handle.
Kojto 108:34e6b704fe68 409 * @retval None
Kojto 108:34e6b704fe68 410 */
Kojto 108:34e6b704fe68 411 #define __HAL_IRDA_CLEAR_NEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_NEF)
Kojto 108:34e6b704fe68 412
Kojto 108:34e6b704fe68 413 /** @brief Clear the IRDA ORE pending flag.
Kojto 108:34e6b704fe68 414 * @param __HANDLE__: specifies the IRDA Handle.
Kojto 108:34e6b704fe68 415 * @retval None
Kojto 108:34e6b704fe68 416 */
Kojto 108:34e6b704fe68 417 #define __HAL_IRDA_CLEAR_OREFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_OREF)
Kojto 108:34e6b704fe68 418
Kojto 108:34e6b704fe68 419 /** @brief Clear the IRDA IDLE pending flag.
Kojto 108:34e6b704fe68 420 * @param __HANDLE__: specifies the IRDA Handle.
Kojto 108:34e6b704fe68 421 * @retval None
Kojto 108:34e6b704fe68 422 */
Kojto 108:34e6b704fe68 423 #define __HAL_IRDA_CLEAR_IDLEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_IDLEF)
Kojto 108:34e6b704fe68 424
Kojto 108:34e6b704fe68 425 /** @brief Check whether the specified IRDA flag is set or not.
bogdanm 85:024bf7f99721 426 * @param __HANDLE__: specifies the IRDA Handle.
bogdanm 85:024bf7f99721 427 * The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or
bogdanm 85:024bf7f99721 428 * UART peripheral
bogdanm 85:024bf7f99721 429 * @param __FLAG__: specifies the flag to check.
bogdanm 85:024bf7f99721 430 * This parameter can be one of the following values:
Kojto 108:34e6b704fe68 431 * @arg IRDA_FLAG_REACK: Receive enable acknowledge flag
Kojto 108:34e6b704fe68 432 * @arg IRDA_FLAG_TEACK: Transmit enable acknowledge flag
bogdanm 85:024bf7f99721 433 * @arg IRDA_FLAG_BUSY: Busy flag
bogdanm 85:024bf7f99721 434 * @arg IRDA_FLAG_ABRF: Auto Baud rate detection flag
bogdanm 85:024bf7f99721 435 * @arg IRDA_FLAG_ABRE: Auto Baud rate detection error flag
bogdanm 85:024bf7f99721 436 * @arg IRDA_FLAG_TXE: Transmit data register empty flag
bogdanm 85:024bf7f99721 437 * @arg IRDA_FLAG_TC: Transmission Complete flag
bogdanm 85:024bf7f99721 438 * @arg IRDA_FLAG_RXNE: Receive data register not empty flag
bogdanm 85:024bf7f99721 439 * @arg IRDA_FLAG_IDLE: Idle Line detection flag
bogdanm 85:024bf7f99721 440 * @arg IRDA_FLAG_ORE: OverRun Error flag
bogdanm 85:024bf7f99721 441 * @arg IRDA_FLAG_NE: Noise Error flag
bogdanm 85:024bf7f99721 442 * @arg IRDA_FLAG_FE: Framing Error flag
bogdanm 85:024bf7f99721 443 * @arg IRDA_FLAG_PE: Parity Error flag
bogdanm 85:024bf7f99721 444 * @retval The new state of __FLAG__ (TRUE or FALSE).
bogdanm 85:024bf7f99721 445 */
Kojto 108:34e6b704fe68 446 #define __HAL_IRDA_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))
bogdanm 85:024bf7f99721 447
Kojto 108:34e6b704fe68 448
Kojto 108:34e6b704fe68 449 /** @brief Enable the specified IRDA interrupt.
bogdanm 85:024bf7f99721 450 * @param __HANDLE__: specifies the IRDA Handle.
bogdanm 85:024bf7f99721 451 * The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or
bogdanm 85:024bf7f99721 452 * UART peripheral
bogdanm 85:024bf7f99721 453 * @param __INTERRUPT__: specifies the IRDA interrupt source to enable.
bogdanm 85:024bf7f99721 454 * This parameter can be one of the following values:
bogdanm 85:024bf7f99721 455 * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt
bogdanm 85:024bf7f99721 456 * @arg IRDA_IT_TC: Transmission complete interrupt
bogdanm 85:024bf7f99721 457 * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt
bogdanm 85:024bf7f99721 458 * @arg IRDA_IT_IDLE: Idle line detection interrupt
bogdanm 85:024bf7f99721 459 * @arg IRDA_IT_PE: Parity Error interrupt
bogdanm 85:024bf7f99721 460 * @arg IRDA_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
bogdanm 85:024bf7f99721 461 * @retval None
bogdanm 85:024bf7f99721 462 */
bogdanm 85:024bf7f99721 463 #define __HAL_IRDA_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 |= (1U << ((__INTERRUPT__) & IRDA_IT_MASK))): \
bogdanm 85:024bf7f99721 464 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 |= (1U << ((__INTERRUPT__) & IRDA_IT_MASK))): \
bogdanm 85:024bf7f99721 465 ((__HANDLE__)->Instance->CR3 |= (1U << ((__INTERRUPT__) & IRDA_IT_MASK))))
bogdanm 85:024bf7f99721 466
Kojto 108:34e6b704fe68 467 /** @brief Disable the specified IRDA interrupt.
bogdanm 85:024bf7f99721 468 * @param __HANDLE__: specifies the IRDA Handle.
bogdanm 85:024bf7f99721 469 * The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or
bogdanm 85:024bf7f99721 470 * UART peripheral
bogdanm 85:024bf7f99721 471 * @param __INTERRUPT__: specifies the IRDA interrupt source to disable.
bogdanm 85:024bf7f99721 472 * This parameter can be one of the following values:
bogdanm 85:024bf7f99721 473 * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt
bogdanm 85:024bf7f99721 474 * @arg IRDA_IT_TC: Transmission complete interrupt
bogdanm 85:024bf7f99721 475 * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt
bogdanm 85:024bf7f99721 476 * @arg IRDA_IT_IDLE: Idle line detection interrupt
bogdanm 85:024bf7f99721 477 * @arg IRDA_IT_PE: Parity Error interrupt
bogdanm 85:024bf7f99721 478 * @arg IRDA_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
bogdanm 85:024bf7f99721 479 * @retval None
bogdanm 85:024bf7f99721 480 */
bogdanm 85:024bf7f99721 481 #define __HAL_IRDA_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 &= ~ (1U << ((__INTERRUPT__) & IRDA_IT_MASK))): \
bogdanm 85:024bf7f99721 482 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 &= ~ (1U << ((__INTERRUPT__) & IRDA_IT_MASK))): \
bogdanm 85:024bf7f99721 483 ((__HANDLE__)->Instance->CR3 &= ~ (1U << ((__INTERRUPT__) & IRDA_IT_MASK))))
Kojto 108:34e6b704fe68 484
Kojto 108:34e6b704fe68 485
Kojto 108:34e6b704fe68 486 /** @brief Check whether the specified IRDA interrupt has occurred or not.
bogdanm 85:024bf7f99721 487 * @param __HANDLE__: specifies the IRDA Handle.
bogdanm 85:024bf7f99721 488 * The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or
bogdanm 85:024bf7f99721 489 * UART peripheral
bogdanm 85:024bf7f99721 490 * @param __IT__: specifies the IRDA interrupt source to check.
bogdanm 85:024bf7f99721 491 * This parameter can be one of the following values:
bogdanm 85:024bf7f99721 492 * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt
bogdanm 85:024bf7f99721 493 * @arg IRDA_IT_TC: Transmission complete interrupt
bogdanm 85:024bf7f99721 494 * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt
bogdanm 85:024bf7f99721 495 * @arg IRDA_IT_IDLE: Idle line detection interrupt
bogdanm 85:024bf7f99721 496 * @arg IRDA_IT_ORE: OverRun Error interrupt
bogdanm 85:024bf7f99721 497 * @arg IRDA_IT_NE: Noise Error interrupt
bogdanm 85:024bf7f99721 498 * @arg IRDA_IT_FE: Framing Error interrupt
Kojto 108:34e6b704fe68 499 * @arg IRDA_IT_PE: Parity Error interrupt
bogdanm 85:024bf7f99721 500 * @retval The new state of __IT__ (TRUE or FALSE).
bogdanm 85:024bf7f99721 501 */
Kojto 108:34e6b704fe68 502 #define __HAL_IRDA_GET_IT(__HANDLE__, __IT__) ((__HANDLE__)->Instance->ISR & ((uint32_t)1U << ((__IT__)>> 0x08)))
bogdanm 85:024bf7f99721 503
Kojto 108:34e6b704fe68 504 /** @brief Check whether the specified IRDA interrupt source is enabled or not.
bogdanm 85:024bf7f99721 505 * @param __HANDLE__: specifies the IRDA Handle.
bogdanm 85:024bf7f99721 506 * The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or
bogdanm 85:024bf7f99721 507 * UART peripheral
bogdanm 85:024bf7f99721 508 * @param __IT__: specifies the IRDA interrupt source to check.
bogdanm 85:024bf7f99721 509 * This parameter can be one of the following values:
bogdanm 85:024bf7f99721 510 * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt
bogdanm 85:024bf7f99721 511 * @arg IRDA_IT_TC: Transmission complete interrupt
bogdanm 85:024bf7f99721 512 * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt
bogdanm 85:024bf7f99721 513 * @arg IRDA_IT_IDLE: Idle line detection interrupt
bogdanm 85:024bf7f99721 514 * @arg IRDA_IT_ORE: OverRun Error interrupt
bogdanm 85:024bf7f99721 515 * @arg IRDA_IT_NE: Noise Error interrupt
bogdanm 85:024bf7f99721 516 * @arg IRDA_IT_FE: Framing Error interrupt
Kojto 108:34e6b704fe68 517 * @arg IRDA_IT_PE: Parity Error interrupt
bogdanm 85:024bf7f99721 518 * @retval The new state of __IT__ (TRUE or FALSE).
bogdanm 85:024bf7f99721 519 */
bogdanm 85:024bf7f99721 520 #define __HAL_IRDA_GET_IT_SOURCE(__HANDLE__, __IT__) ((((((uint8_t)(__IT__)) >> 5U) == 1)? (__HANDLE__)->Instance->CR1:(((((uint8_t)(__IT__)) >> 5U) == 2)? \
bogdanm 85:024bf7f99721 521 (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & ((uint32_t)1 << (((uint16_t)(__IT__)) & IRDA_IT_MASK)))
bogdanm 85:024bf7f99721 522
bogdanm 85:024bf7f99721 523
Kojto 108:34e6b704fe68 524 /** @brief Clear the specified IRDA ISR flag, in setting the proper ICR register flag.
bogdanm 85:024bf7f99721 525 * @param __HANDLE__: specifies the IRDA Handle.
bogdanm 85:024bf7f99721 526 * The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or
bogdanm 85:024bf7f99721 527 * UART peripheral
bogdanm 85:024bf7f99721 528 * @param __IT_CLEAR__: specifies the interrupt clear register flag that needs to be set
bogdanm 85:024bf7f99721 529 * to clear the corresponding interrupt
bogdanm 85:024bf7f99721 530 * This parameter can be one of the following values:
Kojto 108:34e6b704fe68 531 * @arg IRDA_CLEAR_PEF: Parity Error Clear Flag
Kojto 108:34e6b704fe68 532 * @arg IRDA_CLEAR_FEF: Framing Error Clear Flag
Kojto 108:34e6b704fe68 533 * @arg IRDA_CLEAR_NEF: Noise detected Clear Flag
Kojto 108:34e6b704fe68 534 * @arg IRDA_CLEAR_OREF: OverRun Error Clear Flag
Kojto 108:34e6b704fe68 535 * @arg IRDA_CLEAR_TCF: Transmission Complete Clear Flag
bogdanm 85:024bf7f99721 536 * @retval None
bogdanm 85:024bf7f99721 537 */
Kojto 108:34e6b704fe68 538 #define __HAL_IRDA_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__))
bogdanm 85:024bf7f99721 539
bogdanm 85:024bf7f99721 540
bogdanm 85:024bf7f99721 541 /** @brief Set a specific IRDA request flag.
bogdanm 85:024bf7f99721 542 * @param __HANDLE__: specifies the IRDA Handle.
bogdanm 85:024bf7f99721 543 * The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or
bogdanm 85:024bf7f99721 544 * UART peripheral
bogdanm 85:024bf7f99721 545 * @param __REQ__: specifies the request flag to set
bogdanm 85:024bf7f99721 546 * This parameter can be one of the following values:
Kojto 108:34e6b704fe68 547 * @arg IRDA_AUTOBAUD_REQUEST: Auto-Baud Rate Request
Kojto 108:34e6b704fe68 548 * @arg IRDA_RXDATA_FLUSH_REQUEST: Receive Data flush Request
Kojto 108:34e6b704fe68 549 * @arg IRDA_TXDATA_FLUSH_REQUEST: Transmit data flush Request
bogdanm 85:024bf7f99721 550 *
bogdanm 85:024bf7f99721 551 * @retval None
Kojto 108:34e6b704fe68 552 */
Kojto 108:34e6b704fe68 553 #define __HAL_IRDA_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (uint16_t)(__REQ__))
bogdanm 85:024bf7f99721 554
Kojto 108:34e6b704fe68 555 /** @brief Enable the IRDA one bit sample method.
Kojto 108:34e6b704fe68 556 * @param __HANDLE__: specifies the IRDA Handle.
Kojto 108:34e6b704fe68 557 * The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or
Kojto 108:34e6b704fe68 558 * UART peripheral
Kojto 108:34e6b704fe68 559 * @retval None
Kojto 108:34e6b704fe68 560 */
Kojto 108:34e6b704fe68 561 #define __HAL_IRDA_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
bogdanm 85:024bf7f99721 562
Kojto 108:34e6b704fe68 563 /** @brief Disable the IRDA one bit sample method.
Kojto 108:34e6b704fe68 564 * @param __HANDLE__: specifies the IRDA Handle.
Kojto 108:34e6b704fe68 565 * The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or
Kojto 108:34e6b704fe68 566 * UART peripheral
Kojto 108:34e6b704fe68 567 * @retval None
Kojto 108:34e6b704fe68 568 */
Kojto 108:34e6b704fe68 569 #define __HAL_IRDA_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint32_t)~((uint32_t)USART_CR3_ONEBIT))
Kojto 108:34e6b704fe68 570
Kojto 108:34e6b704fe68 571 /** @brief Enable UART/USART associated to IRDA Handle.
bogdanm 85:024bf7f99721 572 * @param __HANDLE__: specifies the IRDA Handle.
bogdanm 85:024bf7f99721 573 * The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or
bogdanm 85:024bf7f99721 574 * UART peripheral
bogdanm 85:024bf7f99721 575 * @retval None
Kojto 108:34e6b704fe68 576 */
bogdanm 85:024bf7f99721 577 #define __HAL_IRDA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
bogdanm 85:024bf7f99721 578
Kojto 108:34e6b704fe68 579 /** @brief Disable UART/USART associated to IRDA Handle.
bogdanm 85:024bf7f99721 580 * @param __HANDLE__: specifies the IRDA Handle.
bogdanm 85:024bf7f99721 581 * The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or
bogdanm 85:024bf7f99721 582 * UART peripheral
bogdanm 85:024bf7f99721 583 * @retval None
bogdanm 85:024bf7f99721 584 */
bogdanm 85:024bf7f99721 585 #define __HAL_IRDA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
bogdanm 85:024bf7f99721 586
Kojto 108:34e6b704fe68 587 /**
Kojto 108:34e6b704fe68 588 * @}
Kojto 108:34e6b704fe68 589 */
Kojto 108:34e6b704fe68 590
Kojto 108:34e6b704fe68 591 /* Private macros --------------------------------------------------------*/
Kojto 108:34e6b704fe68 592 /** @defgroup IRDA_Private_Macros IRDA Private Macros
Kojto 108:34e6b704fe68 593 * @{
Kojto 108:34e6b704fe68 594 */
Kojto 108:34e6b704fe68 595
Kojto 108:34e6b704fe68 596 /** @brief Ensure that IRDA Baud rate is less or equal to maximum value.
bogdanm 85:024bf7f99721 597 * @param __BAUDRATE__: specifies the IRDA Baudrate set by the user.
bogdanm 85:024bf7f99721 598 * @retval True or False
Kojto 108:34e6b704fe68 599 */
bogdanm 85:024bf7f99721 600 #define IS_IRDA_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 115201)
bogdanm 85:024bf7f99721 601
Kojto 108:34e6b704fe68 602 /** @brief Ensure that IRDA prescaler value is strictly larger than 0.
bogdanm 85:024bf7f99721 603 * @param __PRESCALER__: specifies the IRDA prescaler value set by the user.
bogdanm 85:024bf7f99721 604 * @retval True or False
Kojto 108:34e6b704fe68 605 */
Kojto 108:34e6b704fe68 606 #define IS_IRDA_PRESCALER(__PRESCALER__) ((__PRESCALER__) > 0)
Kojto 108:34e6b704fe68 607
Kojto 108:34e6b704fe68 608 /**
Kojto 108:34e6b704fe68 609 * @brief Ensure that IRDA frame parity is valid.
Kojto 108:34e6b704fe68 610 * @param __PARITY__: IRDA frame parity.
Kojto 108:34e6b704fe68 611 * @retval SET (__PARITY__ is valid) or RESET (__PARITY__ is invalid)
Kojto 108:34e6b704fe68 612 */
Kojto 108:34e6b704fe68 613 #define IS_IRDA_PARITY(__PARITY__) (((__PARITY__) == IRDA_PARITY_NONE) || \
Kojto 108:34e6b704fe68 614 ((__PARITY__) == IRDA_PARITY_EVEN) || \
Kojto 108:34e6b704fe68 615 ((__PARITY__) == IRDA_PARITY_ODD))
Kojto 108:34e6b704fe68 616
Kojto 108:34e6b704fe68 617 /**
Kojto 108:34e6b704fe68 618 * @brief Ensure that IRDA communication mode is valid.
Kojto 108:34e6b704fe68 619 * @param __MODE__: IRDA communication mode.
Kojto 108:34e6b704fe68 620 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
Kojto 108:34e6b704fe68 621 */
Kojto 108:34e6b704fe68 622 #define IS_IRDA_TX_RX_MODE(__MODE__) ((((__MODE__) & (~((uint32_t)(IRDA_MODE_TX_RX)))) == (uint32_t)0x00) && ((__MODE__) != (uint32_t)0x00))
Kojto 108:34e6b704fe68 623
Kojto 108:34e6b704fe68 624 /**
Kojto 108:34e6b704fe68 625 * @brief Ensure that IRDA power mode is valid.
Kojto 108:34e6b704fe68 626 * @param __MODE__: IRDA power mode.
Kojto 108:34e6b704fe68 627 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
Kojto 108:34e6b704fe68 628 */
Kojto 108:34e6b704fe68 629 #define IS_IRDA_POWERMODE(__MODE__) (((__MODE__) == IRDA_POWERMODE_LOWPOWER) || \
Kojto 108:34e6b704fe68 630 ((__MODE__) == IRDA_POWERMODE_NORMAL))
Kojto 108:34e6b704fe68 631
Kojto 108:34e6b704fe68 632 /**
Kojto 108:34e6b704fe68 633 * @brief Ensure that IRDA state is valid.
Kojto 108:34e6b704fe68 634 * @param __STATE__: IRDA state mode.
Kojto 108:34e6b704fe68 635 * @retval SET (__STATE__ is valid) or RESET (__STATE__ is invalid)
Kojto 108:34e6b704fe68 636 */
Kojto 108:34e6b704fe68 637 #define IS_IRDA_STATE(__STATE__) (((__STATE__) == IRDA_STATE_DISABLE) || \
Kojto 108:34e6b704fe68 638 ((__STATE__) == IRDA_STATE_ENABLE))
bogdanm 85:024bf7f99721 639
bogdanm 85:024bf7f99721 640 /**
Kojto 108:34e6b704fe68 641 * @brief Ensure that IRDA associated UART/USART mode is valid.
Kojto 108:34e6b704fe68 642 * @param __MODE__: IRDA associated UART/USART mode.
Kojto 108:34e6b704fe68 643 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
Kojto 108:34e6b704fe68 644 */
Kojto 108:34e6b704fe68 645 #define IS_IRDA_MODE(__MODE__) (((__MODE__) == IRDA_MODE_DISABLE) || \
Kojto 108:34e6b704fe68 646 ((__MODE__) == IRDA_MODE_ENABLE))
Kojto 108:34e6b704fe68 647
Kojto 108:34e6b704fe68 648 /**
Kojto 108:34e6b704fe68 649 * @brief Ensure that IRDA sampling rate is valid.
Kojto 108:34e6b704fe68 650 * @param __ONEBIT__: IRDA sampling rate.
Kojto 108:34e6b704fe68 651 * @retval SET (__ONEBIT__ is valid) or RESET (__ONEBIT__ is invalid)
Kojto 108:34e6b704fe68 652 */
Kojto 108:34e6b704fe68 653 #define IS_IRDA_ONE_BIT_SAMPLE(__ONEBIT__) (((__ONEBIT__) == IRDA_ONE_BIT_SAMPLE_DISABLE) || \
Kojto 108:34e6b704fe68 654 ((__ONEBIT__) == IRDA_ONE_BIT_SAMPLE_ENABLE))
Kojto 108:34e6b704fe68 655
Kojto 108:34e6b704fe68 656 /**
Kojto 108:34e6b704fe68 657 * @brief Ensure that IRDA DMA TX mode is valid.
Kojto 108:34e6b704fe68 658 * @param __DMATX__: IRDA DMA TX mode.
Kojto 108:34e6b704fe68 659 * @retval SET (__DMATX__ is valid) or RESET (__DMATX__ is invalid)
Kojto 108:34e6b704fe68 660 */
Kojto 108:34e6b704fe68 661 #define IS_IRDA_DMA_TX(__DMATX__) (((__DMATX__) == IRDA_DMA_TX_DISABLE) || \
Kojto 108:34e6b704fe68 662 ((__DMATX__) == IRDA_DMA_TX_ENABLE))
Kojto 108:34e6b704fe68 663
Kojto 108:34e6b704fe68 664 /**
Kojto 108:34e6b704fe68 665 * @brief Ensure that IRDA DMA RX mode is valid.
Kojto 108:34e6b704fe68 666 * @param __DMARX__: IRDA DMA RX mode.
Kojto 108:34e6b704fe68 667 * @retval SET (__DMARX__ is valid) or RESET (__DMARX__ is invalid)
Kojto 108:34e6b704fe68 668 */
Kojto 108:34e6b704fe68 669 #define IS_IRDA_DMA_RX(__DMARX__) (((__DMARX__) == IRDA_DMA_RX_DISABLE) || \
Kojto 108:34e6b704fe68 670 ((__DMARX__) == IRDA_DMA_RX_ENABLE))
Kojto 108:34e6b704fe68 671
Kojto 108:34e6b704fe68 672 /**
Kojto 108:34e6b704fe68 673 * @brief Ensure that IRDA request is valid.
Kojto 108:34e6b704fe68 674 * @param __PARAM__: IRDA request.
Kojto 108:34e6b704fe68 675 * @retval SET (__PARAM__ is valid) or RESET (__PARAM__ is invalid)
Kojto 108:34e6b704fe68 676 */
Kojto 108:34e6b704fe68 677 #define IS_IRDA_REQUEST_PARAMETER(__PARAM__) (((__PARAM__) == IRDA_AUTOBAUD_REQUEST) || \
Kojto 108:34e6b704fe68 678 ((__PARAM__) == IRDA_RXDATA_FLUSH_REQUEST) || \
Kojto 108:34e6b704fe68 679 ((__PARAM__) == IRDA_TXDATA_FLUSH_REQUEST))
Kojto 108:34e6b704fe68 680 /**
bogdanm 85:024bf7f99721 681 * @}
bogdanm 85:024bf7f99721 682 */
bogdanm 85:024bf7f99721 683
Kojto 93:e188a91d3eaa 684 /* Include IRDA HAL Extended module */
Kojto 108:34e6b704fe68 685 #include "stm32f0xx_hal_irda_ex.h"
bogdanm 85:024bf7f99721 686
bogdanm 85:024bf7f99721 687 /* Exported functions --------------------------------------------------------*/
bogdanm 92:4fc01daae5a5 688 /** @addtogroup IRDA_Exported_Functions IRDA Exported Functions
bogdanm 92:4fc01daae5a5 689 * @{
bogdanm 92:4fc01daae5a5 690 */
Kojto 108:34e6b704fe68 691
Kojto 108:34e6b704fe68 692 /** @addtogroup IRDA_Exported_Functions_Group1 Initialization and de-initialization functions
bogdanm 92:4fc01daae5a5 693 * @{
bogdanm 92:4fc01daae5a5 694 */
bogdanm 92:4fc01daae5a5 695
bogdanm 85:024bf7f99721 696 /* Initialization and de-initialization functions ****************************/
bogdanm 85:024bf7f99721 697 HAL_StatusTypeDef HAL_IRDA_Init(IRDA_HandleTypeDef *hirda);
bogdanm 85:024bf7f99721 698 HAL_StatusTypeDef HAL_IRDA_DeInit(IRDA_HandleTypeDef *hirda);
bogdanm 85:024bf7f99721 699 void HAL_IRDA_MspInit(IRDA_HandleTypeDef *hirda);
bogdanm 85:024bf7f99721 700 void HAL_IRDA_MspDeInit(IRDA_HandleTypeDef *hirda);
bogdanm 85:024bf7f99721 701
bogdanm 92:4fc01daae5a5 702 /**
bogdanm 92:4fc01daae5a5 703 * @}
bogdanm 92:4fc01daae5a5 704 */
bogdanm 92:4fc01daae5a5 705
Kojto 108:34e6b704fe68 706 /** @addtogroup IRDA_Exported_Functions_Group2 IO operation functions
bogdanm 92:4fc01daae5a5 707 * @{
bogdanm 92:4fc01daae5a5 708 */
bogdanm 85:024bf7f99721 709
bogdanm 85:024bf7f99721 710 /* IO operation functions *****************************************************/
bogdanm 85:024bf7f99721 711 HAL_StatusTypeDef HAL_IRDA_Transmit(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout);
bogdanm 85:024bf7f99721 712 HAL_StatusTypeDef HAL_IRDA_Receive(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout);
bogdanm 85:024bf7f99721 713 HAL_StatusTypeDef HAL_IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
bogdanm 85:024bf7f99721 714 HAL_StatusTypeDef HAL_IRDA_Receive_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
bogdanm 85:024bf7f99721 715 HAL_StatusTypeDef HAL_IRDA_Transmit_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
bogdanm 85:024bf7f99721 716 HAL_StatusTypeDef HAL_IRDA_Receive_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
Kojto 108:34e6b704fe68 717 HAL_StatusTypeDef HAL_IRDA_DMAPause(IRDA_HandleTypeDef *hirda);
Kojto 108:34e6b704fe68 718 HAL_StatusTypeDef HAL_IRDA_DMAResume(IRDA_HandleTypeDef *hirda);
Kojto 108:34e6b704fe68 719 HAL_StatusTypeDef HAL_IRDA_DMAStop(IRDA_HandleTypeDef *hirda);
bogdanm 85:024bf7f99721 720 void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef *hirda);
bogdanm 85:024bf7f99721 721 void HAL_IRDA_TxCpltCallback(IRDA_HandleTypeDef *hirda);
bogdanm 85:024bf7f99721 722 void HAL_IRDA_RxCpltCallback(IRDA_HandleTypeDef *hirda);
Kojto 108:34e6b704fe68 723 void HAL_IRDA_TxHalfCpltCallback(IRDA_HandleTypeDef *hirda);
Kojto 108:34e6b704fe68 724 void HAL_IRDA_RxHalfCpltCallback(IRDA_HandleTypeDef *hirda);
bogdanm 85:024bf7f99721 725 void HAL_IRDA_ErrorCallback(IRDA_HandleTypeDef *hirda);
bogdanm 85:024bf7f99721 726
bogdanm 92:4fc01daae5a5 727 /**
bogdanm 92:4fc01daae5a5 728 * @}
bogdanm 92:4fc01daae5a5 729 */
bogdanm 92:4fc01daae5a5 730
Kojto 108:34e6b704fe68 731 /* Peripheral Control functions ************************************************/
Kojto 108:34e6b704fe68 732
Kojto 108:34e6b704fe68 733 /** @addtogroup IRDA_Exported_Functions_Group3 Peripheral State and Error functions
bogdanm 92:4fc01daae5a5 734 * @{
bogdanm 92:4fc01daae5a5 735 */
bogdanm 92:4fc01daae5a5 736
bogdanm 85:024bf7f99721 737 /* Peripheral State and Error functions ***************************************/
bogdanm 85:024bf7f99721 738 HAL_IRDA_StateTypeDef HAL_IRDA_GetState(IRDA_HandleTypeDef *hirda);
Kojto 108:34e6b704fe68 739 uint32_t HAL_IRDA_GetError(IRDA_HandleTypeDef *hirda);
bogdanm 85:024bf7f99721 740
bogdanm 85:024bf7f99721 741 /**
bogdanm 85:024bf7f99721 742 * @}
Kojto 108:34e6b704fe68 743 */
bogdanm 85:024bf7f99721 744
bogdanm 85:024bf7f99721 745 /**
bogdanm 85:024bf7f99721 746 * @}
Kojto 108:34e6b704fe68 747 */
bogdanm 85:024bf7f99721 748
bogdanm 92:4fc01daae5a5 749 /**
bogdanm 92:4fc01daae5a5 750 * @}
Kojto 108:34e6b704fe68 751 */
bogdanm 92:4fc01daae5a5 752
bogdanm 92:4fc01daae5a5 753 /**
bogdanm 92:4fc01daae5a5 754 * @}
bogdanm 92:4fc01daae5a5 755 */
bogdanm 92:4fc01daae5a5 756
Kojto 93:e188a91d3eaa 757 #endif /* !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) */
Kojto 108:34e6b704fe68 758
bogdanm 85:024bf7f99721 759 #ifdef __cplusplus
bogdanm 85:024bf7f99721 760 }
bogdanm 85:024bf7f99721 761 #endif
bogdanm 85:024bf7f99721 762
bogdanm 85:024bf7f99721 763 #endif /* __STM32F0xx_HAL_IRDA_H */
bogdanm 85:024bf7f99721 764
bogdanm 85:024bf7f99721 765 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
bogdanm 92:4fc01daae5a5 766