mbed library sources modified for open wear
Dependents: openwear-lifelogger-example
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_NUCLEO_F411RE/stm32f4xx_hal_irda.h@310:6188e0254baa, 2014-09-16 (annotated)
- Committer:
- janekm
- Date:
- Tue Sep 16 22:42:01 2014 +0000
- Revision:
- 310:6188e0254baa
- Parent:
- 235:685d5f11838f
N/A
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 235:685d5f11838f | 1 | /** |
mbed_official | 235:685d5f11838f | 2 | ****************************************************************************** |
mbed_official | 235:685d5f11838f | 3 | * @file stm32f4xx_hal_irda.h |
mbed_official | 235:685d5f11838f | 4 | * @author MCD Application Team |
mbed_official | 235:685d5f11838f | 5 | * @version V1.1.0 |
mbed_official | 235:685d5f11838f | 6 | * @date 19-June-2014 |
mbed_official | 235:685d5f11838f | 7 | * @brief Header file of IRDA HAL module. |
mbed_official | 235:685d5f11838f | 8 | ****************************************************************************** |
mbed_official | 235:685d5f11838f | 9 | * @attention |
mbed_official | 235:685d5f11838f | 10 | * |
mbed_official | 235:685d5f11838f | 11 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
mbed_official | 235:685d5f11838f | 12 | * |
mbed_official | 235:685d5f11838f | 13 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 235:685d5f11838f | 14 | * are permitted provided that the following conditions are met: |
mbed_official | 235:685d5f11838f | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 235:685d5f11838f | 16 | * this list of conditions and the following disclaimer. |
mbed_official | 235:685d5f11838f | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 235:685d5f11838f | 18 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 235:685d5f11838f | 19 | * and/or other materials provided with the distribution. |
mbed_official | 235:685d5f11838f | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 235:685d5f11838f | 21 | * may be used to endorse or promote products derived from this software |
mbed_official | 235:685d5f11838f | 22 | * without specific prior written permission. |
mbed_official | 235:685d5f11838f | 23 | * |
mbed_official | 235:685d5f11838f | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 235:685d5f11838f | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 235:685d5f11838f | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 235:685d5f11838f | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 235:685d5f11838f | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 235:685d5f11838f | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 235:685d5f11838f | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 235:685d5f11838f | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 235:685d5f11838f | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 235:685d5f11838f | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 235:685d5f11838f | 34 | * |
mbed_official | 235:685d5f11838f | 35 | ****************************************************************************** |
mbed_official | 235:685d5f11838f | 36 | */ |
mbed_official | 235:685d5f11838f | 37 | |
mbed_official | 235:685d5f11838f | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
mbed_official | 235:685d5f11838f | 39 | #ifndef __STM32F4xx_HAL_IRDA_H |
mbed_official | 235:685d5f11838f | 40 | #define __STM32F4xx_HAL_IRDA_H |
mbed_official | 235:685d5f11838f | 41 | |
mbed_official | 235:685d5f11838f | 42 | #ifdef __cplusplus |
mbed_official | 235:685d5f11838f | 43 | extern "C" { |
mbed_official | 235:685d5f11838f | 44 | #endif |
mbed_official | 235:685d5f11838f | 45 | |
mbed_official | 235:685d5f11838f | 46 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 235:685d5f11838f | 47 | #include "stm32f4xx_hal_def.h" |
mbed_official | 235:685d5f11838f | 48 | |
mbed_official | 235:685d5f11838f | 49 | /** @addtogroup STM32F4xx_HAL_Driver |
mbed_official | 235:685d5f11838f | 50 | * @{ |
mbed_official | 235:685d5f11838f | 51 | */ |
mbed_official | 235:685d5f11838f | 52 | |
mbed_official | 235:685d5f11838f | 53 | /** @addtogroup IRDA |
mbed_official | 235:685d5f11838f | 54 | * @{ |
mbed_official | 235:685d5f11838f | 55 | */ |
mbed_official | 235:685d5f11838f | 56 | |
mbed_official | 235:685d5f11838f | 57 | /* Exported types ------------------------------------------------------------*/ |
mbed_official | 235:685d5f11838f | 58 | |
mbed_official | 235:685d5f11838f | 59 | /** |
mbed_official | 235:685d5f11838f | 60 | * @brief IRDA Init Structure definition |
mbed_official | 235:685d5f11838f | 61 | */ |
mbed_official | 235:685d5f11838f | 62 | typedef struct |
mbed_official | 235:685d5f11838f | 63 | { |
mbed_official | 235:685d5f11838f | 64 | uint32_t BaudRate; /*!< This member configures the IRDA communication baud rate. |
mbed_official | 235:685d5f11838f | 65 | The baud rate is computed using the following formula: |
mbed_official | 235:685d5f11838f | 66 | - IntegerDivider = ((PCLKx) / (8 * (hirda->Init.BaudRate))) |
mbed_official | 235:685d5f11838f | 67 | - FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 8) + 0.5 */ |
mbed_official | 235:685d5f11838f | 68 | |
mbed_official | 235:685d5f11838f | 69 | uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame. |
mbed_official | 235:685d5f11838f | 70 | This parameter can be a value of @ref IRDA_Word_Length */ |
mbed_official | 235:685d5f11838f | 71 | |
mbed_official | 235:685d5f11838f | 72 | |
mbed_official | 235:685d5f11838f | 73 | uint32_t Parity; /*!< Specifies the parity mode. |
mbed_official | 235:685d5f11838f | 74 | This parameter can be a value of @ref IRDA_Parity |
mbed_official | 235:685d5f11838f | 75 | @note When parity is enabled, the computed parity is inserted |
mbed_official | 235:685d5f11838f | 76 | at the MSB position of the transmitted data (9th bit when |
mbed_official | 235:685d5f11838f | 77 | the word length is set to 9 data bits; 8th bit when the |
mbed_official | 235:685d5f11838f | 78 | word length is set to 8 data bits). */ |
mbed_official | 235:685d5f11838f | 79 | |
mbed_official | 235:685d5f11838f | 80 | uint32_t Mode; /*!< Specifies wether the Receive or Transmit mode is enabled or disabled. |
mbed_official | 235:685d5f11838f | 81 | This parameter can be a value of @ref IRDA_Mode */ |
mbed_official | 235:685d5f11838f | 82 | |
mbed_official | 235:685d5f11838f | 83 | uint8_t Prescaler; /*!< Specifies the Prescaler */ |
mbed_official | 235:685d5f11838f | 84 | |
mbed_official | 235:685d5f11838f | 85 | uint32_t IrDAMode; /*!< Specifies the IrDA mode |
mbed_official | 235:685d5f11838f | 86 | This parameter can be a value of @ref IrDA_Low_Power */ |
mbed_official | 235:685d5f11838f | 87 | }IRDA_InitTypeDef; |
mbed_official | 235:685d5f11838f | 88 | |
mbed_official | 235:685d5f11838f | 89 | /** |
mbed_official | 235:685d5f11838f | 90 | * @brief HAL State structures definition |
mbed_official | 235:685d5f11838f | 91 | */ |
mbed_official | 235:685d5f11838f | 92 | typedef enum |
mbed_official | 235:685d5f11838f | 93 | { |
mbed_official | 235:685d5f11838f | 94 | HAL_IRDA_STATE_RESET = 0x00, /*!< Peripheral is not yet Initialized */ |
mbed_official | 235:685d5f11838f | 95 | HAL_IRDA_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */ |
mbed_official | 235:685d5f11838f | 96 | HAL_IRDA_STATE_BUSY = 0x02, /*!< an internal process is ongoing */ |
mbed_official | 235:685d5f11838f | 97 | HAL_IRDA_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */ |
mbed_official | 235:685d5f11838f | 98 | HAL_IRDA_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */ |
mbed_official | 235:685d5f11838f | 99 | HAL_IRDA_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission and Reception process is ongoing */ |
mbed_official | 235:685d5f11838f | 100 | HAL_IRDA_STATE_TIMEOUT = 0x03, /*!< Timeout state */ |
mbed_official | 235:685d5f11838f | 101 | HAL_IRDA_STATE_ERROR = 0x04 /*!< Error */ |
mbed_official | 235:685d5f11838f | 102 | }HAL_IRDA_StateTypeDef; |
mbed_official | 235:685d5f11838f | 103 | |
mbed_official | 235:685d5f11838f | 104 | /** |
mbed_official | 235:685d5f11838f | 105 | * @brief HAL IRDA Error Code structure definition |
mbed_official | 235:685d5f11838f | 106 | */ |
mbed_official | 235:685d5f11838f | 107 | typedef enum |
mbed_official | 235:685d5f11838f | 108 | { |
mbed_official | 235:685d5f11838f | 109 | HAL_IRDA_ERROR_NONE = 0x00, /*!< No error */ |
mbed_official | 235:685d5f11838f | 110 | HAL_IRDA_ERROR_PE = 0x01, /*!< Parity error */ |
mbed_official | 235:685d5f11838f | 111 | HAL_IRDA_ERROR_NE = 0x02, /*!< Noise error */ |
mbed_official | 235:685d5f11838f | 112 | HAL_IRDA_ERROR_FE = 0x04, /*!< frame error */ |
mbed_official | 235:685d5f11838f | 113 | HAL_IRDA_ERROR_ORE = 0x08, /*!< Overrun error */ |
mbed_official | 235:685d5f11838f | 114 | HAL_IRDA_ERROR_DMA = 0x10 /*!< DMA transfer error */ |
mbed_official | 235:685d5f11838f | 115 | }HAL_IRDA_ErrorTypeDef; |
mbed_official | 235:685d5f11838f | 116 | |
mbed_official | 235:685d5f11838f | 117 | /** |
mbed_official | 235:685d5f11838f | 118 | * @brief IRDA handle Structure definition |
mbed_official | 235:685d5f11838f | 119 | */ |
mbed_official | 235:685d5f11838f | 120 | typedef struct |
mbed_official | 235:685d5f11838f | 121 | { |
mbed_official | 235:685d5f11838f | 122 | USART_TypeDef *Instance; /* USART registers base address */ |
mbed_official | 235:685d5f11838f | 123 | |
mbed_official | 235:685d5f11838f | 124 | IRDA_InitTypeDef Init; /* IRDA communication parameters */ |
mbed_official | 235:685d5f11838f | 125 | |
mbed_official | 235:685d5f11838f | 126 | uint8_t *pTxBuffPtr; /* Pointer to IRDA Tx transfer Buffer */ |
mbed_official | 235:685d5f11838f | 127 | |
mbed_official | 235:685d5f11838f | 128 | uint16_t TxXferSize; /* IRDA Tx Transfer size */ |
mbed_official | 235:685d5f11838f | 129 | |
mbed_official | 235:685d5f11838f | 130 | uint16_t TxXferCount; /* IRDA Tx Transfer Counter */ |
mbed_official | 235:685d5f11838f | 131 | |
mbed_official | 235:685d5f11838f | 132 | uint8_t *pRxBuffPtr; /* Pointer to IRDA Rx transfer Buffer */ |
mbed_official | 235:685d5f11838f | 133 | |
mbed_official | 235:685d5f11838f | 134 | uint16_t RxXferSize; /* IRDA Rx Transfer size */ |
mbed_official | 235:685d5f11838f | 135 | |
mbed_official | 235:685d5f11838f | 136 | uint16_t RxXferCount; /* IRDA Rx Transfer Counter */ |
mbed_official | 235:685d5f11838f | 137 | |
mbed_official | 235:685d5f11838f | 138 | DMA_HandleTypeDef *hdmatx; /* IRDA Tx DMA Handle parameters */ |
mbed_official | 235:685d5f11838f | 139 | |
mbed_official | 235:685d5f11838f | 140 | DMA_HandleTypeDef *hdmarx; /* IRDA Rx DMA Handle parameters */ |
mbed_official | 235:685d5f11838f | 141 | |
mbed_official | 235:685d5f11838f | 142 | HAL_LockTypeDef Lock; /* Locking object */ |
mbed_official | 235:685d5f11838f | 143 | |
mbed_official | 235:685d5f11838f | 144 | __IO HAL_IRDA_StateTypeDef State; /* IRDA communication state */ |
mbed_official | 235:685d5f11838f | 145 | |
mbed_official | 235:685d5f11838f | 146 | __IO HAL_IRDA_ErrorTypeDef ErrorCode; /* IRDA Error code */ |
mbed_official | 235:685d5f11838f | 147 | |
mbed_official | 235:685d5f11838f | 148 | }IRDA_HandleTypeDef; |
mbed_official | 235:685d5f11838f | 149 | |
mbed_official | 235:685d5f11838f | 150 | /* Exported constants --------------------------------------------------------*/ |
mbed_official | 235:685d5f11838f | 151 | /** @defgroup IRDA_Exported_Constants |
mbed_official | 235:685d5f11838f | 152 | * @{ |
mbed_official | 235:685d5f11838f | 153 | */ |
mbed_official | 235:685d5f11838f | 154 | |
mbed_official | 235:685d5f11838f | 155 | /** @defgroup IRDA_Word_Length |
mbed_official | 235:685d5f11838f | 156 | * @{ |
mbed_official | 235:685d5f11838f | 157 | */ |
mbed_official | 235:685d5f11838f | 158 | #define IRDA_WORDLENGTH_8B ((uint32_t)0x00000000) |
mbed_official | 235:685d5f11838f | 159 | #define IRDA_WORDLENGTH_9B ((uint32_t)USART_CR1_M) |
mbed_official | 235:685d5f11838f | 160 | #define IS_IRDA_WORD_LENGTH(LENGTH) (((LENGTH) == IRDA_WORDLENGTH_8B) || \ |
mbed_official | 235:685d5f11838f | 161 | ((LENGTH) == IRDA_WORDLENGTH_9B)) |
mbed_official | 235:685d5f11838f | 162 | /** |
mbed_official | 235:685d5f11838f | 163 | * @} |
mbed_official | 235:685d5f11838f | 164 | */ |
mbed_official | 235:685d5f11838f | 165 | |
mbed_official | 235:685d5f11838f | 166 | |
mbed_official | 235:685d5f11838f | 167 | /** @defgroup IRDA_Parity |
mbed_official | 235:685d5f11838f | 168 | * @{ |
mbed_official | 235:685d5f11838f | 169 | */ |
mbed_official | 235:685d5f11838f | 170 | #define IRDA_PARITY_NONE ((uint32_t)0x00000000) |
mbed_official | 235:685d5f11838f | 171 | #define IRDA_PARITY_EVEN ((uint32_t)USART_CR1_PCE) |
mbed_official | 235:685d5f11838f | 172 | #define IRDA_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS)) |
mbed_official | 235:685d5f11838f | 173 | #define IS_IRDA_PARITY(PARITY) (((PARITY) == IRDA_PARITY_NONE) || \ |
mbed_official | 235:685d5f11838f | 174 | ((PARITY) == IRDA_PARITY_EVEN) || \ |
mbed_official | 235:685d5f11838f | 175 | ((PARITY) == IRDA_PARITY_ODD)) |
mbed_official | 235:685d5f11838f | 176 | /** |
mbed_official | 235:685d5f11838f | 177 | * @} |
mbed_official | 235:685d5f11838f | 178 | */ |
mbed_official | 235:685d5f11838f | 179 | |
mbed_official | 235:685d5f11838f | 180 | |
mbed_official | 235:685d5f11838f | 181 | /** @defgroup IRDA_Mode |
mbed_official | 235:685d5f11838f | 182 | * @{ |
mbed_official | 235:685d5f11838f | 183 | */ |
mbed_official | 235:685d5f11838f | 184 | #define IRDA_MODE_RX ((uint32_t)USART_CR1_RE) |
mbed_official | 235:685d5f11838f | 185 | #define IRDA_MODE_TX ((uint32_t)USART_CR1_TE) |
mbed_official | 235:685d5f11838f | 186 | #define IRDA_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE)) |
mbed_official | 235:685d5f11838f | 187 | #define IS_IRDA_MODE(MODE) ((((MODE) & (uint32_t)0x0000FFF3) == 0x00) && ((MODE) != (uint32_t)0x000000)) |
mbed_official | 235:685d5f11838f | 188 | /** |
mbed_official | 235:685d5f11838f | 189 | * @} |
mbed_official | 235:685d5f11838f | 190 | */ |
mbed_official | 235:685d5f11838f | 191 | |
mbed_official | 235:685d5f11838f | 192 | /** @defgroup IrDA_Low_Power |
mbed_official | 235:685d5f11838f | 193 | * @{ |
mbed_official | 235:685d5f11838f | 194 | */ |
mbed_official | 235:685d5f11838f | 195 | #define IRDA_POWERMODE_LOWPOWER ((uint32_t)USART_CR3_IRLP) |
mbed_official | 235:685d5f11838f | 196 | #define IRDA_POWERMODE_NORMAL ((uint32_t)0x00000000) |
mbed_official | 235:685d5f11838f | 197 | #define IS_IRDA_POWERMODE(MODE) (((MODE) == IRDA_POWERMODE_LOWPOWER) || \ |
mbed_official | 235:685d5f11838f | 198 | ((MODE) == IRDA_POWERMODE_NORMAL)) |
mbed_official | 235:685d5f11838f | 199 | /** |
mbed_official | 235:685d5f11838f | 200 | * @} |
mbed_official | 235:685d5f11838f | 201 | */ |
mbed_official | 235:685d5f11838f | 202 | |
mbed_official | 235:685d5f11838f | 203 | /** @defgroup IRDA_Flags |
mbed_official | 235:685d5f11838f | 204 | * Elements values convention: 0xXXXX |
mbed_official | 235:685d5f11838f | 205 | * - 0xXXXX : Flag mask in the SR register |
mbed_official | 235:685d5f11838f | 206 | * @{ |
mbed_official | 235:685d5f11838f | 207 | */ |
mbed_official | 235:685d5f11838f | 208 | #define IRDA_FLAG_TXE ((uint32_t)0x00000080) |
mbed_official | 235:685d5f11838f | 209 | #define IRDA_FLAG_TC ((uint32_t)0x00000040) |
mbed_official | 235:685d5f11838f | 210 | #define IRDA_FLAG_RXNE ((uint32_t)0x00000020) |
mbed_official | 235:685d5f11838f | 211 | #define IRDA_FLAG_IDLE ((uint32_t)0x00000010) |
mbed_official | 235:685d5f11838f | 212 | #define IRDA_FLAG_ORE ((uint32_t)0x00000008) |
mbed_official | 235:685d5f11838f | 213 | #define IRDA_FLAG_NE ((uint32_t)0x00000004) |
mbed_official | 235:685d5f11838f | 214 | #define IRDA_FLAG_FE ((uint32_t)0x00000002) |
mbed_official | 235:685d5f11838f | 215 | #define IRDA_FLAG_PE ((uint32_t)0x00000001) |
mbed_official | 235:685d5f11838f | 216 | /** |
mbed_official | 235:685d5f11838f | 217 | * @} |
mbed_official | 235:685d5f11838f | 218 | */ |
mbed_official | 235:685d5f11838f | 219 | |
mbed_official | 235:685d5f11838f | 220 | /** @defgroup IRDA_Interrupt_definition |
mbed_official | 235:685d5f11838f | 221 | * Elements values convention: 0xY000XXXX |
mbed_official | 235:685d5f11838f | 222 | * - XXXX : Interrupt mask in the XX register |
mbed_official | 235:685d5f11838f | 223 | * - Y : Interrupt source register (2bits) |
mbed_official | 235:685d5f11838f | 224 | * - 01: CR1 register |
mbed_official | 235:685d5f11838f | 225 | * - 10: CR2 register |
mbed_official | 235:685d5f11838f | 226 | * - 11: CR3 register |
mbed_official | 235:685d5f11838f | 227 | * |
mbed_official | 235:685d5f11838f | 228 | * @{ |
mbed_official | 235:685d5f11838f | 229 | */ |
mbed_official | 235:685d5f11838f | 230 | |
mbed_official | 235:685d5f11838f | 231 | #define IRDA_IT_PE ((uint32_t)0x10000100) |
mbed_official | 235:685d5f11838f | 232 | #define IRDA_IT_TXE ((uint32_t)0x10000080) |
mbed_official | 235:685d5f11838f | 233 | #define IRDA_IT_TC ((uint32_t)0x10000040) |
mbed_official | 235:685d5f11838f | 234 | #define IRDA_IT_RXNE ((uint32_t)0x10000020) |
mbed_official | 235:685d5f11838f | 235 | #define IRDA_IT_IDLE ((uint32_t)0x10000010) |
mbed_official | 235:685d5f11838f | 236 | |
mbed_official | 235:685d5f11838f | 237 | #define IRDA_IT_LBD ((uint32_t)0x20000040) |
mbed_official | 235:685d5f11838f | 238 | |
mbed_official | 235:685d5f11838f | 239 | #define IRDA_IT_CTS ((uint32_t)0x30000400) |
mbed_official | 235:685d5f11838f | 240 | #define IRDA_IT_ERR ((uint32_t)0x30000001) |
mbed_official | 235:685d5f11838f | 241 | |
mbed_official | 235:685d5f11838f | 242 | /** |
mbed_official | 235:685d5f11838f | 243 | * @} |
mbed_official | 235:685d5f11838f | 244 | */ |
mbed_official | 235:685d5f11838f | 245 | |
mbed_official | 235:685d5f11838f | 246 | /** |
mbed_official | 235:685d5f11838f | 247 | * @} |
mbed_official | 235:685d5f11838f | 248 | */ |
mbed_official | 235:685d5f11838f | 249 | |
mbed_official | 235:685d5f11838f | 250 | /* Exported macro ------------------------------------------------------------*/ |
mbed_official | 235:685d5f11838f | 251 | |
mbed_official | 235:685d5f11838f | 252 | /** @brief Reset IRDA handle state |
mbed_official | 235:685d5f11838f | 253 | * @param __HANDLE__: specifies the USART Handle. |
mbed_official | 235:685d5f11838f | 254 | * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or |
mbed_official | 235:685d5f11838f | 255 | * UART peripheral. |
mbed_official | 235:685d5f11838f | 256 | * @retval None |
mbed_official | 235:685d5f11838f | 257 | */ |
mbed_official | 235:685d5f11838f | 258 | #define __HAL_IRDA_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_IRDA_STATE_RESET) |
mbed_official | 235:685d5f11838f | 259 | |
mbed_official | 235:685d5f11838f | 260 | /** @brief Flushs the IRDA DR register |
mbed_official | 235:685d5f11838f | 261 | * @param __HANDLE__: specifies the USART Handle. |
mbed_official | 235:685d5f11838f | 262 | * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or |
mbed_official | 235:685d5f11838f | 263 | * UART peripheral. |
mbed_official | 235:685d5f11838f | 264 | */ |
mbed_official | 235:685d5f11838f | 265 | #define __HAL_IRDA_FLUSH_DRREGISTER(__HANDLE__) ((__HANDLE__)->Instance->DR) |
mbed_official | 235:685d5f11838f | 266 | |
mbed_official | 235:685d5f11838f | 267 | /** @brief Checks whether the specified IRDA flag is set or not. |
mbed_official | 235:685d5f11838f | 268 | * @param __HANDLE__: specifies the USART Handle. |
mbed_official | 235:685d5f11838f | 269 | * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or |
mbed_official | 235:685d5f11838f | 270 | * UART peripheral. |
mbed_official | 235:685d5f11838f | 271 | * @param __FLAG__: specifies the flag to check. |
mbed_official | 235:685d5f11838f | 272 | * This parameter can be one of the following values: |
mbed_official | 235:685d5f11838f | 273 | * @arg IRDA_FLAG_TXE: Transmit data register empty flag |
mbed_official | 235:685d5f11838f | 274 | * @arg IRDA_FLAG_TC: Transmission Complete flag |
mbed_official | 235:685d5f11838f | 275 | * @arg IRDA_FLAG_RXNE: Receive data register not empty flag |
mbed_official | 235:685d5f11838f | 276 | * @arg IRDA_FLAG_IDLE: Idle Line detection flag |
mbed_official | 235:685d5f11838f | 277 | * @arg IRDA_FLAG_ORE: OverRun Error flag |
mbed_official | 235:685d5f11838f | 278 | * @arg IRDA_FLAG_NE: Noise Error flag |
mbed_official | 235:685d5f11838f | 279 | * @arg IRDA_FLAG_FE: Framing Error flag |
mbed_official | 235:685d5f11838f | 280 | * @arg IRDA_FLAG_PE: Parity Error flag |
mbed_official | 235:685d5f11838f | 281 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
mbed_official | 235:685d5f11838f | 282 | */ |
mbed_official | 235:685d5f11838f | 283 | #define __HAL_IRDA_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__)) |
mbed_official | 235:685d5f11838f | 284 | |
mbed_official | 235:685d5f11838f | 285 | /** @brief Clears the specified IRDA pending flag. |
mbed_official | 235:685d5f11838f | 286 | * @param __HANDLE__: specifies the USART Handle. |
mbed_official | 235:685d5f11838f | 287 | * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or |
mbed_official | 235:685d5f11838f | 288 | * UART peripheral. |
mbed_official | 235:685d5f11838f | 289 | * @param __FLAG__: specifies the flag to check. |
mbed_official | 235:685d5f11838f | 290 | * This parameter can be any combination of the following values: |
mbed_official | 235:685d5f11838f | 291 | * @arg IRDA_FLAG_TC: Transmission Complete flag. |
mbed_official | 235:685d5f11838f | 292 | * @arg IRDA_FLAG_RXNE: Receive data register not empty flag. |
mbed_official | 235:685d5f11838f | 293 | * |
mbed_official | 235:685d5f11838f | 294 | * @note PE (Parity error), FE (Framing error), NE (Noise error), ORE (OverRun |
mbed_official | 235:685d5f11838f | 295 | * error) and IDLE (Idle line detected) flags are cleared by software |
mbed_official | 235:685d5f11838f | 296 | * sequence: a read operation to USART_SR register followed by a read |
mbed_official | 235:685d5f11838f | 297 | * operation to USART_DR register. |
mbed_official | 235:685d5f11838f | 298 | * @note RXNE flag can be also cleared by a read to the USART_DR register. |
mbed_official | 235:685d5f11838f | 299 | * @note TC flag can be also cleared by software sequence: a read operation to |
mbed_official | 235:685d5f11838f | 300 | * USART_SR register followed by a write operation to USART_DR register. |
mbed_official | 235:685d5f11838f | 301 | * @note TXE flag is cleared only by a write to the USART_DR register. |
mbed_official | 235:685d5f11838f | 302 | * |
mbed_official | 235:685d5f11838f | 303 | * @retval None |
mbed_official | 235:685d5f11838f | 304 | */ |
mbed_official | 235:685d5f11838f | 305 | #define __HAL_IRDA_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__)) |
mbed_official | 235:685d5f11838f | 306 | |
mbed_official | 235:685d5f11838f | 307 | /** @brief Clear the IRDA PE pending flag. |
mbed_official | 235:685d5f11838f | 308 | * @param __HANDLE__: specifies the USART Handle. |
mbed_official | 235:685d5f11838f | 309 | * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or |
mbed_official | 235:685d5f11838f | 310 | * UART peripheral. |
mbed_official | 235:685d5f11838f | 311 | * @retval None |
mbed_official | 235:685d5f11838f | 312 | */ |
mbed_official | 235:685d5f11838f | 313 | #define __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) do{(__HANDLE__)->Instance->SR;\ |
mbed_official | 235:685d5f11838f | 314 | (__HANDLE__)->Instance->DR;}while(0) |
mbed_official | 235:685d5f11838f | 315 | /** @brief Clear the IRDA FE pending flag. |
mbed_official | 235:685d5f11838f | 316 | * @param __HANDLE__: specifies the USART Handle. |
mbed_official | 235:685d5f11838f | 317 | * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or |
mbed_official | 235:685d5f11838f | 318 | * UART peripheral. |
mbed_official | 235:685d5f11838f | 319 | * @retval None |
mbed_official | 235:685d5f11838f | 320 | */ |
mbed_official | 235:685d5f11838f | 321 | #define __HAL_IRDA_CLEAR_FEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) |
mbed_official | 235:685d5f11838f | 322 | |
mbed_official | 235:685d5f11838f | 323 | /** @brief Clear the IRDA NE pending flag. |
mbed_official | 235:685d5f11838f | 324 | * @param __HANDLE__: specifies the USART Handle. |
mbed_official | 235:685d5f11838f | 325 | * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or |
mbed_official | 235:685d5f11838f | 326 | * UART peripheral. |
mbed_official | 235:685d5f11838f | 327 | * @retval None |
mbed_official | 235:685d5f11838f | 328 | */ |
mbed_official | 235:685d5f11838f | 329 | #define __HAL_IRDA_CLEAR_NEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) |
mbed_official | 235:685d5f11838f | 330 | |
mbed_official | 235:685d5f11838f | 331 | /** @brief Clear the IRDA ORE pending flag. |
mbed_official | 235:685d5f11838f | 332 | * @param __HANDLE__: specifies the USART Handle. |
mbed_official | 235:685d5f11838f | 333 | * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or |
mbed_official | 235:685d5f11838f | 334 | * UART peripheral. |
mbed_official | 235:685d5f11838f | 335 | * @retval None |
mbed_official | 235:685d5f11838f | 336 | */ |
mbed_official | 235:685d5f11838f | 337 | #define __HAL_IRDA_CLEAR_OREFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) |
mbed_official | 235:685d5f11838f | 338 | |
mbed_official | 235:685d5f11838f | 339 | /** @brief Clear the IRDA IDLE pending flag. |
mbed_official | 235:685d5f11838f | 340 | * @param __HANDLE__: specifies the USART Handle. |
mbed_official | 235:685d5f11838f | 341 | * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or |
mbed_official | 235:685d5f11838f | 342 | * UART peripheral. |
mbed_official | 235:685d5f11838f | 343 | * @retval None |
mbed_official | 235:685d5f11838f | 344 | */ |
mbed_official | 235:685d5f11838f | 345 | #define __HAL_IRDA_CLEAR_IDLEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) |
mbed_official | 235:685d5f11838f | 346 | |
mbed_official | 235:685d5f11838f | 347 | /** @brief Enables or disables the specified IRDA interrupt. |
mbed_official | 235:685d5f11838f | 348 | * @param __HANDLE__: specifies the USART Handle. |
mbed_official | 235:685d5f11838f | 349 | * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or |
mbed_official | 235:685d5f11838f | 350 | * UART peripheral. |
mbed_official | 235:685d5f11838f | 351 | * @param __INTERRUPT__: specifies the IRDA interrupt source to check. |
mbed_official | 235:685d5f11838f | 352 | * This parameter can be one of the following values: |
mbed_official | 235:685d5f11838f | 353 | * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt |
mbed_official | 235:685d5f11838f | 354 | * @arg IRDA_IT_TC: Transmission complete interrupt |
mbed_official | 235:685d5f11838f | 355 | * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt |
mbed_official | 235:685d5f11838f | 356 | * @arg IRDA_IT_IDLE: Idle line detection interrupt |
mbed_official | 235:685d5f11838f | 357 | * @arg IRDA_IT_PE: Parity Error interrupt |
mbed_official | 235:685d5f11838f | 358 | * @arg IRDA_IT_ERR: Error interrupt(Frame error, noise error, overrun error) |
mbed_official | 235:685d5f11838f | 359 | * @param NewState: new state of the specified IRDA interrupt. |
mbed_official | 235:685d5f11838f | 360 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 235:685d5f11838f | 361 | * @retval None |
mbed_official | 235:685d5f11838f | 362 | */ |
mbed_official | 235:685d5f11838f | 363 | #define IRDA_IT_MASK ((uint32_t)0x0000FFFF) |
mbed_official | 235:685d5f11838f | 364 | #define __HAL_IRDA_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28) == 1)? ((__HANDLE__)->Instance->CR1 |= ((__INTERRUPT__) & IRDA_IT_MASK)): \ |
mbed_official | 235:685d5f11838f | 365 | (((__INTERRUPT__) >> 28) == 2)? ((__HANDLE__)->Instance->CR2 |= ((__INTERRUPT__) & IRDA_IT_MASK)): \ |
mbed_official | 235:685d5f11838f | 366 | ((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & IRDA_IT_MASK))) |
mbed_official | 235:685d5f11838f | 367 | #define __HAL_IRDA_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28) == 1)? ((__HANDLE__)->Instance->CR1 &= ~((__INTERRUPT__) & IRDA_IT_MASK)): \ |
mbed_official | 235:685d5f11838f | 368 | (((__INTERRUPT__) >> 28) == 2)? ((__HANDLE__)->Instance->CR2 &= ~((__INTERRUPT__) & IRDA_IT_MASK)): \ |
mbed_official | 235:685d5f11838f | 369 | ((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & IRDA_IT_MASK))) |
mbed_official | 235:685d5f11838f | 370 | |
mbed_official | 235:685d5f11838f | 371 | /** @brief Checks whether the specified IRDA interrupt has occurred or not. |
mbed_official | 235:685d5f11838f | 372 | * @param __HANDLE__: specifies the USART Handle. |
mbed_official | 235:685d5f11838f | 373 | * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or |
mbed_official | 235:685d5f11838f | 374 | * UART peripheral. |
mbed_official | 235:685d5f11838f | 375 | * @param __IT__: specifies the IRDA interrupt source to check. |
mbed_official | 235:685d5f11838f | 376 | * This parameter can be one of the following values: |
mbed_official | 235:685d5f11838f | 377 | * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt |
mbed_official | 235:685d5f11838f | 378 | * @arg IRDA_IT_TC: Transmission complete interrupt |
mbed_official | 235:685d5f11838f | 379 | * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt |
mbed_official | 235:685d5f11838f | 380 | * @arg IRDA_IT_IDLE: Idle line detection interrupt |
mbed_official | 235:685d5f11838f | 381 | * @arg USART_IT_ERR: Error interrupt |
mbed_official | 235:685d5f11838f | 382 | * @arg IRDA_IT_PE: Parity Error interrupt |
mbed_official | 235:685d5f11838f | 383 | * @retval The new state of __IT__ (TRUE or FALSE). |
mbed_official | 235:685d5f11838f | 384 | */ |
mbed_official | 235:685d5f11838f | 385 | #define __HAL_IRDA_GET_IT_SOURCE(__HANDLE__, __IT__) (((((__IT__) >> 28) == 1)? (__HANDLE__)->Instance->CR1:(((((uint32_t)(__IT__)) >> 28) == 2)? \ |
mbed_official | 235:685d5f11838f | 386 | (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & (((uint32_t)(__IT__)) & IRDA_IT_MASK)) |
mbed_official | 235:685d5f11838f | 387 | |
mbed_official | 235:685d5f11838f | 388 | |
mbed_official | 235:685d5f11838f | 389 | |
mbed_official | 235:685d5f11838f | 390 | #define __IRDA_ENABLE(__HANDLE__) ( (__HANDLE__)->Instance->CR1 |= USART_CR1_UE) |
mbed_official | 235:685d5f11838f | 391 | #define __IRDA_DISABLE(__HANDLE__) ( (__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE) |
mbed_official | 235:685d5f11838f | 392 | |
mbed_official | 235:685d5f11838f | 393 | #define __DIV(_PCLK_, _BAUD_) (((_PCLK_)*25)/(4*(_BAUD_))) |
mbed_official | 235:685d5f11838f | 394 | #define __DIVMANT(_PCLK_, _BAUD_) (__DIV((_PCLK_), (_BAUD_))/100) |
mbed_official | 235:685d5f11838f | 395 | #define __DIVFRAQ(_PCLK_, _BAUD_) (((__DIV((_PCLK_), (_BAUD_)) - (__DIVMANT((_PCLK_), (_BAUD_)) * 100)) * 16 + 50) / 100) |
mbed_official | 235:685d5f11838f | 396 | #define __IRDA_BRR(_PCLK_, _BAUD_) ((__DIVMANT((_PCLK_), (_BAUD_)) << 4)|(__DIVFRAQ((_PCLK_), (_BAUD_)) & 0x0F)) |
mbed_official | 235:685d5f11838f | 397 | |
mbed_official | 235:685d5f11838f | 398 | #define IS_IRDA_BAUDRATE(BAUDRATE) ((BAUDRATE) < 115201) |
mbed_official | 235:685d5f11838f | 399 | |
mbed_official | 235:685d5f11838f | 400 | |
mbed_official | 235:685d5f11838f | 401 | /* Exported functions --------------------------------------------------------*/ |
mbed_official | 235:685d5f11838f | 402 | /* Initialization/de-initialization functions **********************************/ |
mbed_official | 235:685d5f11838f | 403 | HAL_StatusTypeDef HAL_IRDA_Init(IRDA_HandleTypeDef *hirda); |
mbed_official | 235:685d5f11838f | 404 | HAL_StatusTypeDef HAL_IRDA_DeInit(IRDA_HandleTypeDef *hirda); |
mbed_official | 235:685d5f11838f | 405 | void HAL_IRDA_MspInit(IRDA_HandleTypeDef *hirda); |
mbed_official | 235:685d5f11838f | 406 | void HAL_IRDA_MspDeInit(IRDA_HandleTypeDef *hirda); |
mbed_official | 235:685d5f11838f | 407 | |
mbed_official | 235:685d5f11838f | 408 | /* IO operation functions *******************************************************/ |
mbed_official | 235:685d5f11838f | 409 | HAL_StatusTypeDef HAL_IRDA_Transmit(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
mbed_official | 235:685d5f11838f | 410 | HAL_StatusTypeDef HAL_IRDA_Receive(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
mbed_official | 235:685d5f11838f | 411 | HAL_StatusTypeDef HAL_IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); |
mbed_official | 235:685d5f11838f | 412 | HAL_StatusTypeDef HAL_IRDA_Receive_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); |
mbed_official | 235:685d5f11838f | 413 | HAL_StatusTypeDef HAL_IRDA_Transmit_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); |
mbed_official | 235:685d5f11838f | 414 | HAL_StatusTypeDef HAL_IRDA_Receive_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); |
mbed_official | 235:685d5f11838f | 415 | HAL_StatusTypeDef HAL_IRDA_DMAPause(IRDA_HandleTypeDef *hirda); |
mbed_official | 235:685d5f11838f | 416 | HAL_StatusTypeDef HAL_IRDA_DMAResume(IRDA_HandleTypeDef *hirda); |
mbed_official | 235:685d5f11838f | 417 | HAL_StatusTypeDef HAL_IRDA_DMAStop(IRDA_HandleTypeDef *hirda); |
mbed_official | 235:685d5f11838f | 418 | void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef *hirda); |
mbed_official | 235:685d5f11838f | 419 | void HAL_IRDA_TxCpltCallback(IRDA_HandleTypeDef *hirda); |
mbed_official | 235:685d5f11838f | 420 | void HAL_IRDA_RxCpltCallback(IRDA_HandleTypeDef *hirda); |
mbed_official | 235:685d5f11838f | 421 | void HAL_IRDA_TxHalfCpltCallback(IRDA_HandleTypeDef *hirda); |
mbed_official | 235:685d5f11838f | 422 | void HAL_IRDA_RxHalfCpltCallback(IRDA_HandleTypeDef *hirda); |
mbed_official | 235:685d5f11838f | 423 | void HAL_IRDA_ErrorCallback(IRDA_HandleTypeDef *hirda); |
mbed_official | 235:685d5f11838f | 424 | |
mbed_official | 235:685d5f11838f | 425 | /* Peripheral State functions **************************************************/ |
mbed_official | 235:685d5f11838f | 426 | HAL_IRDA_StateTypeDef HAL_IRDA_GetState(IRDA_HandleTypeDef *hirda); |
mbed_official | 235:685d5f11838f | 427 | uint32_t HAL_IRDA_GetError(IRDA_HandleTypeDef *hirda); |
mbed_official | 235:685d5f11838f | 428 | |
mbed_official | 235:685d5f11838f | 429 | /** |
mbed_official | 235:685d5f11838f | 430 | * @} |
mbed_official | 235:685d5f11838f | 431 | */ |
mbed_official | 235:685d5f11838f | 432 | |
mbed_official | 235:685d5f11838f | 433 | /** |
mbed_official | 235:685d5f11838f | 434 | * @} |
mbed_official | 235:685d5f11838f | 435 | */ |
mbed_official | 235:685d5f11838f | 436 | |
mbed_official | 235:685d5f11838f | 437 | #ifdef __cplusplus |
mbed_official | 235:685d5f11838f | 438 | } |
mbed_official | 235:685d5f11838f | 439 | #endif |
mbed_official | 235:685d5f11838f | 440 | |
mbed_official | 235:685d5f11838f | 441 | #endif /* __STM32F4xx_HAL_IRDA_H */ |
mbed_official | 235:685d5f11838f | 442 | |
mbed_official | 235:685d5f11838f | 443 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |