mbed(SerialHalfDuplex入り)

Fork of mbed by mbed official

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