my fork

Dependents:   Nucleo_blueNRG

Fork of mbed by mbed official

Committer:
Kojto
Date:
Tue Mar 17 14:27:45 2015 +0000
Revision:
96:487b796308b0
Parent:
92:4fc01daae5a5
Release 96 of the mbed library

Changes:
- IAR support for ble boards, lpc, ethernet stack
- RTC - attach function to redirect time functions
- Nucleo F103RB - cube driver
- k20xx - fixes for teensy and k20 platforms in sleep/deepsleep and usb
- STM32L0, Nucleo/Disco L053 - refactoring

Who changed what in which revision?

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