DHT11
TARGET_NUCLEO_F072RB/stm32f0xx_hal_usart.h@0:c52df770855b, 2015-08-13 (annotated)
- Committer:
- jhon309
- Date:
- Thu Aug 13 00:21:57 2015 +0000
- Revision:
- 0:c52df770855b
DHT11
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jhon309 | 0:c52df770855b | 1 | /** |
jhon309 | 0:c52df770855b | 2 | ****************************************************************************** |
jhon309 | 0:c52df770855b | 3 | * @file stm32f0xx_hal_usart.h |
jhon309 | 0:c52df770855b | 4 | * @author MCD Application Team |
jhon309 | 0:c52df770855b | 5 | * @version V1.2.0 |
jhon309 | 0:c52df770855b | 6 | * @date 11-December-2014 |
jhon309 | 0:c52df770855b | 7 | * @brief Header file of USART HAL module. |
jhon309 | 0:c52df770855b | 8 | ****************************************************************************** |
jhon309 | 0:c52df770855b | 9 | * @attention |
jhon309 | 0:c52df770855b | 10 | * |
jhon309 | 0:c52df770855b | 11 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
jhon309 | 0:c52df770855b | 12 | * |
jhon309 | 0:c52df770855b | 13 | * Redistribution and use in source and binary forms, with or without modification, |
jhon309 | 0:c52df770855b | 14 | * are permitted provided that the following conditions are met: |
jhon309 | 0:c52df770855b | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
jhon309 | 0:c52df770855b | 16 | * this list of conditions and the following disclaimer. |
jhon309 | 0:c52df770855b | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
jhon309 | 0:c52df770855b | 18 | * this list of conditions and the following disclaimer in the documentation |
jhon309 | 0:c52df770855b | 19 | * and/or other materials provided with the distribution. |
jhon309 | 0:c52df770855b | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
jhon309 | 0:c52df770855b | 21 | * may be used to endorse or promote products derived from this software |
jhon309 | 0:c52df770855b | 22 | * without specific prior written permission. |
jhon309 | 0:c52df770855b | 23 | * |
jhon309 | 0:c52df770855b | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
jhon309 | 0:c52df770855b | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
jhon309 | 0:c52df770855b | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
jhon309 | 0:c52df770855b | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
jhon309 | 0:c52df770855b | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
jhon309 | 0:c52df770855b | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
jhon309 | 0:c52df770855b | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
jhon309 | 0:c52df770855b | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
jhon309 | 0:c52df770855b | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
jhon309 | 0:c52df770855b | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
jhon309 | 0:c52df770855b | 34 | * |
jhon309 | 0:c52df770855b | 35 | ****************************************************************************** |
jhon309 | 0:c52df770855b | 36 | */ |
jhon309 | 0:c52df770855b | 37 | |
jhon309 | 0:c52df770855b | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
jhon309 | 0:c52df770855b | 39 | #ifndef __STM32F0xx_HAL_USART_H |
jhon309 | 0:c52df770855b | 40 | #define __STM32F0xx_HAL_USART_H |
jhon309 | 0:c52df770855b | 41 | |
jhon309 | 0:c52df770855b | 42 | #ifdef __cplusplus |
jhon309 | 0:c52df770855b | 43 | extern "C" { |
jhon309 | 0:c52df770855b | 44 | #endif |
jhon309 | 0:c52df770855b | 45 | |
jhon309 | 0:c52df770855b | 46 | /* Includes ------------------------------------------------------------------*/ |
jhon309 | 0:c52df770855b | 47 | #include "stm32f0xx_hal_def.h" |
jhon309 | 0:c52df770855b | 48 | |
jhon309 | 0:c52df770855b | 49 | /** @addtogroup STM32F0xx_HAL_Driver |
jhon309 | 0:c52df770855b | 50 | * @{ |
jhon309 | 0:c52df770855b | 51 | */ |
jhon309 | 0:c52df770855b | 52 | |
jhon309 | 0:c52df770855b | 53 | /** @addtogroup USART |
jhon309 | 0:c52df770855b | 54 | * @{ |
jhon309 | 0:c52df770855b | 55 | */ |
jhon309 | 0:c52df770855b | 56 | |
jhon309 | 0:c52df770855b | 57 | /* Exported types ------------------------------------------------------------*/ |
jhon309 | 0:c52df770855b | 58 | /** @defgroup USART_Exported_Types USART Exported Types |
jhon309 | 0:c52df770855b | 59 | * @{ |
jhon309 | 0:c52df770855b | 60 | */ |
jhon309 | 0:c52df770855b | 61 | |
jhon309 | 0:c52df770855b | 62 | |
jhon309 | 0:c52df770855b | 63 | /** |
jhon309 | 0:c52df770855b | 64 | * @brief USART Init Structure definition |
jhon309 | 0:c52df770855b | 65 | */ |
jhon309 | 0:c52df770855b | 66 | typedef struct |
jhon309 | 0:c52df770855b | 67 | { |
jhon309 | 0:c52df770855b | 68 | uint32_t BaudRate; /*!< This member configures the Usart communication baud rate. |
jhon309 | 0:c52df770855b | 69 | The baud rate is computed using the following formula: |
jhon309 | 0:c52df770855b | 70 | Baud Rate Register = ((PCLKx) / ((huart->Init.BaudRate))) */ |
jhon309 | 0:c52df770855b | 71 | |
jhon309 | 0:c52df770855b | 72 | uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame. |
jhon309 | 0:c52df770855b | 73 | This parameter can be a value of @ref USARTEx_Word_Length */ |
jhon309 | 0:c52df770855b | 74 | |
jhon309 | 0:c52df770855b | 75 | uint32_t StopBits; /*!< Specifies the number of stop bits transmitted. |
jhon309 | 0:c52df770855b | 76 | This parameter can be a value of @ref USART_Stop_Bits */ |
jhon309 | 0:c52df770855b | 77 | |
jhon309 | 0:c52df770855b | 78 | uint32_t Parity; /*!< Specifies the parity mode. |
jhon309 | 0:c52df770855b | 79 | This parameter can be a value of @ref USART_Parity |
jhon309 | 0:c52df770855b | 80 | @note When parity is enabled, the computed parity is inserted |
jhon309 | 0:c52df770855b | 81 | at the MSB position of the transmitted data (9th bit when |
jhon309 | 0:c52df770855b | 82 | the word length is set to 9 data bits; 8th bit when the |
jhon309 | 0:c52df770855b | 83 | word length is set to 8 data bits). */ |
jhon309 | 0:c52df770855b | 84 | |
jhon309 | 0:c52df770855b | 85 | uint32_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled. |
jhon309 | 0:c52df770855b | 86 | This parameter can be a value of @ref USART_Mode */ |
jhon309 | 0:c52df770855b | 87 | |
jhon309 | 0:c52df770855b | 88 | uint32_t CLKPolarity; /*!< Specifies the steady state of the serial clock. |
jhon309 | 0:c52df770855b | 89 | This parameter can be a value of @ref USART_Clock_Polarity */ |
jhon309 | 0:c52df770855b | 90 | |
jhon309 | 0:c52df770855b | 91 | uint32_t CLKPhase; /*!< Specifies the clock transition on which the bit capture is made. |
jhon309 | 0:c52df770855b | 92 | This parameter can be a value of @ref USART_Clock_Phase */ |
jhon309 | 0:c52df770855b | 93 | |
jhon309 | 0:c52df770855b | 94 | uint32_t CLKLastBit; /*!< Specifies whether the clock pulse corresponding to the last transmitted |
jhon309 | 0:c52df770855b | 95 | data bit (MSB) has to be output on the SCLK pin in synchronous mode. |
jhon309 | 0:c52df770855b | 96 | This parameter can be a value of @ref USART_Last_Bit */ |
jhon309 | 0:c52df770855b | 97 | }USART_InitTypeDef; |
jhon309 | 0:c52df770855b | 98 | |
jhon309 | 0:c52df770855b | 99 | /** |
jhon309 | 0:c52df770855b | 100 | * @brief HAL State structures definition |
jhon309 | 0:c52df770855b | 101 | */ |
jhon309 | 0:c52df770855b | 102 | typedef enum |
jhon309 | 0:c52df770855b | 103 | { |
jhon309 | 0:c52df770855b | 104 | HAL_USART_STATE_RESET = 0x00, /*!< Peripheral is not initialized */ |
jhon309 | 0:c52df770855b | 105 | HAL_USART_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */ |
jhon309 | 0:c52df770855b | 106 | HAL_USART_STATE_BUSY = 0x02, /*!< an internal process is ongoing */ |
jhon309 | 0:c52df770855b | 107 | HAL_USART_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */ |
jhon309 | 0:c52df770855b | 108 | HAL_USART_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */ |
jhon309 | 0:c52df770855b | 109 | HAL_USART_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission Reception process is ongoing */ |
jhon309 | 0:c52df770855b | 110 | HAL_USART_STATE_TIMEOUT = 0x03, /*!< Timeout state */ |
jhon309 | 0:c52df770855b | 111 | HAL_USART_STATE_ERROR = 0x04 /*!< Error */ |
jhon309 | 0:c52df770855b | 112 | }HAL_USART_StateTypeDef; |
jhon309 | 0:c52df770855b | 113 | |
jhon309 | 0:c52df770855b | 114 | /** |
jhon309 | 0:c52df770855b | 115 | * @brief USART clock sources definitions |
jhon309 | 0:c52df770855b | 116 | */ |
jhon309 | 0:c52df770855b | 117 | typedef enum |
jhon309 | 0:c52df770855b | 118 | { |
jhon309 | 0:c52df770855b | 119 | USART_CLOCKSOURCE_PCLK1 = 0x00, /*!< PCLK1 clock source */ |
jhon309 | 0:c52df770855b | 120 | USART_CLOCKSOURCE_HSI = 0x02, /*!< HSI clock source */ |
jhon309 | 0:c52df770855b | 121 | USART_CLOCKSOURCE_SYSCLK = 0x04, /*!< SYSCLK clock source */ |
jhon309 | 0:c52df770855b | 122 | USART_CLOCKSOURCE_LSE = 0x08, /*!< LSE clock source */ |
jhon309 | 0:c52df770855b | 123 | USART_CLOCKSOURCE_UNDEFINED = 0x10 /*!< undefined clock source */ |
jhon309 | 0:c52df770855b | 124 | }USART_ClockSourceTypeDef; |
jhon309 | 0:c52df770855b | 125 | |
jhon309 | 0:c52df770855b | 126 | /** |
jhon309 | 0:c52df770855b | 127 | * @brief USART handle Structure definition |
jhon309 | 0:c52df770855b | 128 | */ |
jhon309 | 0:c52df770855b | 129 | typedef struct |
jhon309 | 0:c52df770855b | 130 | { |
jhon309 | 0:c52df770855b | 131 | USART_TypeDef *Instance; /*!< USART registers base address */ |
jhon309 | 0:c52df770855b | 132 | |
jhon309 | 0:c52df770855b | 133 | USART_InitTypeDef Init; /*!< USART communication parameters */ |
jhon309 | 0:c52df770855b | 134 | |
jhon309 | 0:c52df770855b | 135 | uint8_t *pTxBuffPtr; /*!< Pointer to USART Tx transfer Buffer */ |
jhon309 | 0:c52df770855b | 136 | |
jhon309 | 0:c52df770855b | 137 | uint16_t TxXferSize; /*!< USART Tx Transfer size */ |
jhon309 | 0:c52df770855b | 138 | |
jhon309 | 0:c52df770855b | 139 | uint16_t TxXferCount; /*!< USART Tx Transfer Counter */ |
jhon309 | 0:c52df770855b | 140 | |
jhon309 | 0:c52df770855b | 141 | uint8_t *pRxBuffPtr; /*!< Pointer to USART Rx transfer Buffer */ |
jhon309 | 0:c52df770855b | 142 | |
jhon309 | 0:c52df770855b | 143 | uint16_t RxXferSize; /*!< USART Rx Transfer size */ |
jhon309 | 0:c52df770855b | 144 | |
jhon309 | 0:c52df770855b | 145 | uint16_t RxXferCount; /*!< USART Rx Transfer Counter */ |
jhon309 | 0:c52df770855b | 146 | |
jhon309 | 0:c52df770855b | 147 | uint16_t Mask; /*!< USART Rx RDR register mask */ |
jhon309 | 0:c52df770855b | 148 | |
jhon309 | 0:c52df770855b | 149 | DMA_HandleTypeDef *hdmatx; /*!< USART Tx DMA Handle parameters */ |
jhon309 | 0:c52df770855b | 150 | |
jhon309 | 0:c52df770855b | 151 | DMA_HandleTypeDef *hdmarx; /*!< USART Rx DMA Handle parameters */ |
jhon309 | 0:c52df770855b | 152 | |
jhon309 | 0:c52df770855b | 153 | HAL_LockTypeDef Lock; /*!< Locking object */ |
jhon309 | 0:c52df770855b | 154 | |
jhon309 | 0:c52df770855b | 155 | HAL_USART_StateTypeDef State; /*!< USART communication state */ |
jhon309 | 0:c52df770855b | 156 | |
jhon309 | 0:c52df770855b | 157 | __IO uint32_t ErrorCode; /*!< USART Error code |
jhon309 | 0:c52df770855b | 158 | This parameter can be a value of @ref USART_Error */ |
jhon309 | 0:c52df770855b | 159 | |
jhon309 | 0:c52df770855b | 160 | }USART_HandleTypeDef; |
jhon309 | 0:c52df770855b | 161 | |
jhon309 | 0:c52df770855b | 162 | /** |
jhon309 | 0:c52df770855b | 163 | * @} |
jhon309 | 0:c52df770855b | 164 | */ |
jhon309 | 0:c52df770855b | 165 | |
jhon309 | 0:c52df770855b | 166 | /* Exported constants --------------------------------------------------------*/ |
jhon309 | 0:c52df770855b | 167 | /** @defgroup USART_Exported_Constants USART Exported constants |
jhon309 | 0:c52df770855b | 168 | * @{ |
jhon309 | 0:c52df770855b | 169 | */ |
jhon309 | 0:c52df770855b | 170 | |
jhon309 | 0:c52df770855b | 171 | /** @defgroup USART_Error USART Error |
jhon309 | 0:c52df770855b | 172 | * @{ |
jhon309 | 0:c52df770855b | 173 | */ |
jhon309 | 0:c52df770855b | 174 | #define HAL_USART_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */ |
jhon309 | 0:c52df770855b | 175 | #define HAL_USART_ERROR_PE ((uint32_t)0x00000001) /*!< Parity error */ |
jhon309 | 0:c52df770855b | 176 | #define HAL_USART_ERROR_NE ((uint32_t)0x00000002) /*!< Noise error */ |
jhon309 | 0:c52df770855b | 177 | #define HAL_USART_ERROR_FE ((uint32_t)0x00000004) /*!< frame error */ |
jhon309 | 0:c52df770855b | 178 | #define HAL_USART_ERROR_ORE ((uint32_t)0x00000008) /*!< Overrun error */ |
jhon309 | 0:c52df770855b | 179 | #define HAL_USART_ERROR_DMA ((uint32_t)0x00000010) /*!< DMA transfer error */ |
jhon309 | 0:c52df770855b | 180 | /** |
jhon309 | 0:c52df770855b | 181 | * @} |
jhon309 | 0:c52df770855b | 182 | */ |
jhon309 | 0:c52df770855b | 183 | |
jhon309 | 0:c52df770855b | 184 | /** @defgroup USART_Stop_Bits USART Number of Stop Bits |
jhon309 | 0:c52df770855b | 185 | * @{ |
jhon309 | 0:c52df770855b | 186 | */ |
jhon309 | 0:c52df770855b | 187 | #define USART_STOPBITS_1 ((uint32_t)0x0000) |
jhon309 | 0:c52df770855b | 188 | #define USART_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1) |
jhon309 | 0:c52df770855b | 189 | #define USART_STOPBITS_1_5 ((uint32_t)(USART_CR2_STOP_0 | USART_CR2_STOP_1)) |
jhon309 | 0:c52df770855b | 190 | #define IS_USART_STOPBITS(STOPBITS) (((STOPBITS) == USART_STOPBITS_1) || \ |
jhon309 | 0:c52df770855b | 191 | ((STOPBITS) == USART_STOPBITS_1_5) || \ |
jhon309 | 0:c52df770855b | 192 | ((STOPBITS) == USART_STOPBITS_2)) |
jhon309 | 0:c52df770855b | 193 | /** |
jhon309 | 0:c52df770855b | 194 | * @} |
jhon309 | 0:c52df770855b | 195 | */ |
jhon309 | 0:c52df770855b | 196 | |
jhon309 | 0:c52df770855b | 197 | /** @defgroup USART_Parity USART Parity |
jhon309 | 0:c52df770855b | 198 | * @{ |
jhon309 | 0:c52df770855b | 199 | */ |
jhon309 | 0:c52df770855b | 200 | #define USART_PARITY_NONE ((uint32_t)0x0000) |
jhon309 | 0:c52df770855b | 201 | #define USART_PARITY_EVEN ((uint32_t)USART_CR1_PCE) |
jhon309 | 0:c52df770855b | 202 | #define USART_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS)) |
jhon309 | 0:c52df770855b | 203 | #define IS_USART_PARITY(PARITY) (((PARITY) == USART_PARITY_NONE) || \ |
jhon309 | 0:c52df770855b | 204 | ((PARITY) == USART_PARITY_EVEN) || \ |
jhon309 | 0:c52df770855b | 205 | ((PARITY) == USART_PARITY_ODD)) |
jhon309 | 0:c52df770855b | 206 | /** |
jhon309 | 0:c52df770855b | 207 | * @} |
jhon309 | 0:c52df770855b | 208 | */ |
jhon309 | 0:c52df770855b | 209 | |
jhon309 | 0:c52df770855b | 210 | /** @defgroup USART_Mode USART Mode |
jhon309 | 0:c52df770855b | 211 | * @{ |
jhon309 | 0:c52df770855b | 212 | */ |
jhon309 | 0:c52df770855b | 213 | #define USART_MODE_RX ((uint32_t)USART_CR1_RE) |
jhon309 | 0:c52df770855b | 214 | #define USART_MODE_TX ((uint32_t)USART_CR1_TE) |
jhon309 | 0:c52df770855b | 215 | #define USART_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE)) |
jhon309 | 0:c52df770855b | 216 | #define IS_USART_MODE(MODE) ((((MODE) & (uint32_t)0xFFFFFFF3) == 0x00) && ((MODE) != (uint32_t)0x00)) |
jhon309 | 0:c52df770855b | 217 | /** |
jhon309 | 0:c52df770855b | 218 | * @} |
jhon309 | 0:c52df770855b | 219 | */ |
jhon309 | 0:c52df770855b | 220 | |
jhon309 | 0:c52df770855b | 221 | /** @defgroup USART_Clock USART Clock |
jhon309 | 0:c52df770855b | 222 | * @{ |
jhon309 | 0:c52df770855b | 223 | */ |
jhon309 | 0:c52df770855b | 224 | #define USART_CLOCK_DISABLED ((uint32_t)0x0000) |
jhon309 | 0:c52df770855b | 225 | #define USART_CLOCK_ENABLED ((uint32_t)USART_CR2_CLKEN) |
jhon309 | 0:c52df770855b | 226 | #define IS_USART_CLOCK(CLOCK) (((CLOCK) == USART_CLOCK_DISABLED) || \ |
jhon309 | 0:c52df770855b | 227 | ((CLOCK) == USART_CLOCK_ENABLED)) |
jhon309 | 0:c52df770855b | 228 | /** |
jhon309 | 0:c52df770855b | 229 | * @} |
jhon309 | 0:c52df770855b | 230 | */ |
jhon309 | 0:c52df770855b | 231 | |
jhon309 | 0:c52df770855b | 232 | /** @defgroup USART_Clock_Polarity USART Clock Polarity |
jhon309 | 0:c52df770855b | 233 | * @{ |
jhon309 | 0:c52df770855b | 234 | */ |
jhon309 | 0:c52df770855b | 235 | #define USART_POLARITY_LOW ((uint32_t)0x0000) |
jhon309 | 0:c52df770855b | 236 | #define USART_POLARITY_HIGH ((uint32_t)USART_CR2_CPOL) |
jhon309 | 0:c52df770855b | 237 | #define IS_USART_POLARITY(CPOL) (((CPOL) == USART_POLARITY_LOW) || ((CPOL) == USART_POLARITY_HIGH)) |
jhon309 | 0:c52df770855b | 238 | /** |
jhon309 | 0:c52df770855b | 239 | * @} |
jhon309 | 0:c52df770855b | 240 | */ |
jhon309 | 0:c52df770855b | 241 | |
jhon309 | 0:c52df770855b | 242 | /** @defgroup USART_Clock_Phase USART Clock Phase |
jhon309 | 0:c52df770855b | 243 | * @{ |
jhon309 | 0:c52df770855b | 244 | */ |
jhon309 | 0:c52df770855b | 245 | #define USART_PHASE_1EDGE ((uint32_t)0x0000) |
jhon309 | 0:c52df770855b | 246 | #define USART_PHASE_2EDGE ((uint32_t)USART_CR2_CPHA) |
jhon309 | 0:c52df770855b | 247 | #define IS_USART_PHASE(CPHA) (((CPHA) == USART_PHASE_1EDGE) || ((CPHA) == USART_PHASE_2EDGE)) |
jhon309 | 0:c52df770855b | 248 | /** |
jhon309 | 0:c52df770855b | 249 | * @} |
jhon309 | 0:c52df770855b | 250 | */ |
jhon309 | 0:c52df770855b | 251 | |
jhon309 | 0:c52df770855b | 252 | /** @defgroup USART_Last_Bit USART Last Bit |
jhon309 | 0:c52df770855b | 253 | * @{ |
jhon309 | 0:c52df770855b | 254 | */ |
jhon309 | 0:c52df770855b | 255 | #define USART_LASTBIT_DISABLE ((uint32_t)0x0000) |
jhon309 | 0:c52df770855b | 256 | #define USART_LASTBIT_ENABLE ((uint32_t)USART_CR2_LBCL) |
jhon309 | 0:c52df770855b | 257 | #define IS_USART_LASTBIT(LASTBIT) (((LASTBIT) == USART_LASTBIT_DISABLE) || \ |
jhon309 | 0:c52df770855b | 258 | ((LASTBIT) == USART_LASTBIT_ENABLE)) |
jhon309 | 0:c52df770855b | 259 | /** |
jhon309 | 0:c52df770855b | 260 | * @} |
jhon309 | 0:c52df770855b | 261 | */ |
jhon309 | 0:c52df770855b | 262 | |
jhon309 | 0:c52df770855b | 263 | |
jhon309 | 0:c52df770855b | 264 | /** @defgroup USART_Flags USART Flags |
jhon309 | 0:c52df770855b | 265 | * Elements values convention: 0xXXXX |
jhon309 | 0:c52df770855b | 266 | * - 0xXXXX : Flag mask in the ISR register |
jhon309 | 0:c52df770855b | 267 | * @{ |
jhon309 | 0:c52df770855b | 268 | */ |
jhon309 | 0:c52df770855b | 269 | #define USART_FLAG_REACK ((uint32_t)0x00400000) |
jhon309 | 0:c52df770855b | 270 | #define USART_FLAG_TEACK ((uint32_t)0x00200000) |
jhon309 | 0:c52df770855b | 271 | #define USART_FLAG_BUSY ((uint32_t)0x00010000) |
jhon309 | 0:c52df770855b | 272 | #define USART_FLAG_CTS ((uint32_t)0x00000400) |
jhon309 | 0:c52df770855b | 273 | #define USART_FLAG_CTSIF ((uint32_t)0x00000200) |
jhon309 | 0:c52df770855b | 274 | #define USART_FLAG_LBDF ((uint32_t)0x00000100) |
jhon309 | 0:c52df770855b | 275 | #define USART_FLAG_TXE ((uint32_t)0x00000080) |
jhon309 | 0:c52df770855b | 276 | #define USART_FLAG_TC ((uint32_t)0x00000040) |
jhon309 | 0:c52df770855b | 277 | #define USART_FLAG_RXNE ((uint32_t)0x00000020) |
jhon309 | 0:c52df770855b | 278 | #define USART_FLAG_IDLE ((uint32_t)0x00000010) |
jhon309 | 0:c52df770855b | 279 | #define USART_FLAG_ORE ((uint32_t)0x00000008) |
jhon309 | 0:c52df770855b | 280 | #define USART_FLAG_NE ((uint32_t)0x00000004) |
jhon309 | 0:c52df770855b | 281 | #define USART_FLAG_FE ((uint32_t)0x00000002) |
jhon309 | 0:c52df770855b | 282 | #define USART_FLAG_PE ((uint32_t)0x00000001) |
jhon309 | 0:c52df770855b | 283 | /** |
jhon309 | 0:c52df770855b | 284 | * @} |
jhon309 | 0:c52df770855b | 285 | */ |
jhon309 | 0:c52df770855b | 286 | |
jhon309 | 0:c52df770855b | 287 | /** @defgroup USART_Interrupt_definition USART Interrupts Definition |
jhon309 | 0:c52df770855b | 288 | * Elements values convention: 0000ZZZZ0XXYYYYYb |
jhon309 | 0:c52df770855b | 289 | * - YYYYY : Interrupt source position in the XX register (5bits) |
jhon309 | 0:c52df770855b | 290 | * - XX : Interrupt source register (2bits) |
jhon309 | 0:c52df770855b | 291 | * - 01: CR1 register |
jhon309 | 0:c52df770855b | 292 | * - 10: CR2 register |
jhon309 | 0:c52df770855b | 293 | * - 11: CR3 register |
jhon309 | 0:c52df770855b | 294 | * - ZZZZ : Flag position in the ISR register(4bits) |
jhon309 | 0:c52df770855b | 295 | * @{ |
jhon309 | 0:c52df770855b | 296 | */ |
jhon309 | 0:c52df770855b | 297 | |
jhon309 | 0:c52df770855b | 298 | #define USART_IT_PE ((uint16_t)0x0028) |
jhon309 | 0:c52df770855b | 299 | #define USART_IT_TXE ((uint16_t)0x0727) |
jhon309 | 0:c52df770855b | 300 | #define USART_IT_TC ((uint16_t)0x0626) |
jhon309 | 0:c52df770855b | 301 | #define USART_IT_RXNE ((uint16_t)0x0525) |
jhon309 | 0:c52df770855b | 302 | #define USART_IT_IDLE ((uint16_t)0x0424) |
jhon309 | 0:c52df770855b | 303 | #define USART_IT_ERR ((uint16_t)0x0060) |
jhon309 | 0:c52df770855b | 304 | |
jhon309 | 0:c52df770855b | 305 | #define USART_IT_ORE ((uint16_t)0x0300) |
jhon309 | 0:c52df770855b | 306 | #define USART_IT_NE ((uint16_t)0x0200) |
jhon309 | 0:c52df770855b | 307 | #define USART_IT_FE ((uint16_t)0x0100) |
jhon309 | 0:c52df770855b | 308 | /** |
jhon309 | 0:c52df770855b | 309 | * @} |
jhon309 | 0:c52df770855b | 310 | */ |
jhon309 | 0:c52df770855b | 311 | |
jhon309 | 0:c52df770855b | 312 | /** @defgroup USART_IT_CLEAR_Flags USART Interruption Clear Flags |
jhon309 | 0:c52df770855b | 313 | * @{ |
jhon309 | 0:c52df770855b | 314 | */ |
jhon309 | 0:c52df770855b | 315 | #define USART_CLEAR_PEF USART_ICR_PECF /*!< Parity Error Clear Flag */ |
jhon309 | 0:c52df770855b | 316 | #define USART_CLEAR_FEF USART_ICR_FECF /*!< Framing Error Clear Flag */ |
jhon309 | 0:c52df770855b | 317 | #define USART_CLEAR_NEF USART_ICR_NCF /*!< Noise detected Clear Flag */ |
jhon309 | 0:c52df770855b | 318 | #define USART_CLEAR_OREF USART_ICR_ORECF /*!< OverRun Error Clear Flag */ |
jhon309 | 0:c52df770855b | 319 | #define USART_CLEAR_IDLEF USART_ICR_IDLECF /*!< IDLE line detected Clear Flag */ |
jhon309 | 0:c52df770855b | 320 | #define USART_CLEAR_TCF USART_ICR_TCCF /*!< Transmission Complete Clear Flag */ |
jhon309 | 0:c52df770855b | 321 | #define USART_CLEAR_CTSF USART_ICR_CTSCF /*!< CTS Interrupt Clear Flag */ |
jhon309 | 0:c52df770855b | 322 | /** |
jhon309 | 0:c52df770855b | 323 | * @} |
jhon309 | 0:c52df770855b | 324 | */ |
jhon309 | 0:c52df770855b | 325 | |
jhon309 | 0:c52df770855b | 326 | /** @defgroup USART_Request_Parameters USART Request Parameters |
jhon309 | 0:c52df770855b | 327 | * @{ |
jhon309 | 0:c52df770855b | 328 | */ |
jhon309 | 0:c52df770855b | 329 | #define USART_RXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_RXFRQ) /*!< Receive Data flush Request */ |
jhon309 | 0:c52df770855b | 330 | #define USART_TXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_TXFRQ) /*!< Transmit data flush Request */ |
jhon309 | 0:c52df770855b | 331 | #define IS_USART_REQUEST_PARAMETER(PARAM) (((PARAM) == USART_RXDATA_FLUSH_REQUEST) || \ |
jhon309 | 0:c52df770855b | 332 | ((PARAM) == USART_TXDATA_FLUSH_REQUEST)) |
jhon309 | 0:c52df770855b | 333 | /** |
jhon309 | 0:c52df770855b | 334 | * @} |
jhon309 | 0:c52df770855b | 335 | */ |
jhon309 | 0:c52df770855b | 336 | |
jhon309 | 0:c52df770855b | 337 | /** @defgroup USART_Interruption_Mask USART interruptions flag mask |
jhon309 | 0:c52df770855b | 338 | * @{ |
jhon309 | 0:c52df770855b | 339 | */ |
jhon309 | 0:c52df770855b | 340 | #define USART_IT_MASK ((uint16_t)0x001F) |
jhon309 | 0:c52df770855b | 341 | /** |
jhon309 | 0:c52df770855b | 342 | * @} |
jhon309 | 0:c52df770855b | 343 | */ |
jhon309 | 0:c52df770855b | 344 | |
jhon309 | 0:c52df770855b | 345 | /** |
jhon309 | 0:c52df770855b | 346 | * @} |
jhon309 | 0:c52df770855b | 347 | */ |
jhon309 | 0:c52df770855b | 348 | |
jhon309 | 0:c52df770855b | 349 | /* Exported macro ------------------------------------------------------------*/ |
jhon309 | 0:c52df770855b | 350 | /** @defgroup USART_Exported_Macros USART Exported Macros |
jhon309 | 0:c52df770855b | 351 | * @{ |
jhon309 | 0:c52df770855b | 352 | */ |
jhon309 | 0:c52df770855b | 353 | |
jhon309 | 0:c52df770855b | 354 | |
jhon309 | 0:c52df770855b | 355 | /** @brief Reset USART handle state |
jhon309 | 0:c52df770855b | 356 | * @param __HANDLE__: USART handle. |
jhon309 | 0:c52df770855b | 357 | * @retval None |
jhon309 | 0:c52df770855b | 358 | */ |
jhon309 | 0:c52df770855b | 359 | #define __HAL_USART_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_USART_STATE_RESET) |
jhon309 | 0:c52df770855b | 360 | |
jhon309 | 0:c52df770855b | 361 | /** @brief Checks whether the specified USART flag is set or not. |
jhon309 | 0:c52df770855b | 362 | * @param __HANDLE__: specifies the USART Handle |
jhon309 | 0:c52df770855b | 363 | * @param __FLAG__: specifies the flag to check. |
jhon309 | 0:c52df770855b | 364 | * This parameter can be one of the following values: |
jhon309 | 0:c52df770855b | 365 | * @arg USART_FLAG_REACK: Receive enable ackowledge flag |
jhon309 | 0:c52df770855b | 366 | * @arg USART_FLAG_TEACK: Transmit enable ackowledge flag |
jhon309 | 0:c52df770855b | 367 | * @arg USART_FLAG_BUSY: Busy flag |
jhon309 | 0:c52df770855b | 368 | * @arg USART_FLAG_CTS: CTS Change flag |
jhon309 | 0:c52df770855b | 369 | * @arg USART_FLAG_TXE: Transmit data register empty flag |
jhon309 | 0:c52df770855b | 370 | * @arg USART_FLAG_TC: Transmission Complete flag |
jhon309 | 0:c52df770855b | 371 | * @arg USART_FLAG_RXNE: Receive data register not empty flag |
jhon309 | 0:c52df770855b | 372 | * @arg USART_FLAG_IDLE: Idle Line detection flag |
jhon309 | 0:c52df770855b | 373 | * @arg USART_FLAG_ORE: OverRun Error flag |
jhon309 | 0:c52df770855b | 374 | * @arg USART_FLAG_NE: Noise Error flag |
jhon309 | 0:c52df770855b | 375 | * @arg USART_FLAG_FE: Framing Error flag |
jhon309 | 0:c52df770855b | 376 | * @arg USART_FLAG_PE: Parity Error flag |
jhon309 | 0:c52df770855b | 377 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
jhon309 | 0:c52df770855b | 378 | */ |
jhon309 | 0:c52df770855b | 379 | #define __HAL_USART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__)) |
jhon309 | 0:c52df770855b | 380 | |
jhon309 | 0:c52df770855b | 381 | |
jhon309 | 0:c52df770855b | 382 | /** @brief Enables the specified USART interrupt. |
jhon309 | 0:c52df770855b | 383 | * @param __HANDLE__: specifies the USART Handle |
jhon309 | 0:c52df770855b | 384 | * @param __INTERRUPT__: specifies the USART interrupt source to enable. |
jhon309 | 0:c52df770855b | 385 | * This parameter can be one of the following values: |
jhon309 | 0:c52df770855b | 386 | * @arg USART_IT_TXE: Transmit Data Register empty interrupt |
jhon309 | 0:c52df770855b | 387 | * @arg USART_IT_TC: Transmission complete interrupt |
jhon309 | 0:c52df770855b | 388 | * @arg USART_IT_RXNE: Receive Data register not empty interrupt |
jhon309 | 0:c52df770855b | 389 | * @arg USART_IT_IDLE: Idle line detection interrupt |
jhon309 | 0:c52df770855b | 390 | * @arg USART_IT_PE: Parity Error interrupt |
jhon309 | 0:c52df770855b | 391 | * @arg USART_IT_ERR: Error interrupt(Frame error, noise error, overrun error) |
jhon309 | 0:c52df770855b | 392 | * @retval None |
jhon309 | 0:c52df770855b | 393 | */ |
jhon309 | 0:c52df770855b | 394 | #define __HAL_USART_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 |= (1U << ((__INTERRUPT__) & USART_IT_MASK))): \ |
jhon309 | 0:c52df770855b | 395 | ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 |= (1U << ((__INTERRUPT__) & USART_IT_MASK))): \ |
jhon309 | 0:c52df770855b | 396 | ((__HANDLE__)->Instance->CR3 |= (1U << ((__INTERRUPT__) & USART_IT_MASK)))) |
jhon309 | 0:c52df770855b | 397 | |
jhon309 | 0:c52df770855b | 398 | /** @brief Disables the specified USART interrupt. |
jhon309 | 0:c52df770855b | 399 | * @param __HANDLE__: specifies the USART Handle. |
jhon309 | 0:c52df770855b | 400 | * @param __INTERRUPT__: specifies the USART interrupt source to disable. |
jhon309 | 0:c52df770855b | 401 | * This parameter can be one of the following values: |
jhon309 | 0:c52df770855b | 402 | * @arg USART_IT_TXE: Transmit Data Register empty interrupt |
jhon309 | 0:c52df770855b | 403 | * @arg USART_IT_TC: Transmission complete interrupt |
jhon309 | 0:c52df770855b | 404 | * @arg USART_IT_RXNE: Receive Data register not empty interrupt |
jhon309 | 0:c52df770855b | 405 | * @arg USART_IT_IDLE: Idle line detection interrupt |
jhon309 | 0:c52df770855b | 406 | * @arg USART_IT_PE: Parity Error interrupt |
jhon309 | 0:c52df770855b | 407 | * @arg USART_IT_ERR: Error interrupt(Frame error, noise error, overrun error) |
jhon309 | 0:c52df770855b | 408 | * @retval None |
jhon309 | 0:c52df770855b | 409 | */ |
jhon309 | 0:c52df770855b | 410 | #define __HAL_USART_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK))): \ |
jhon309 | 0:c52df770855b | 411 | ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK))): \ |
jhon309 | 0:c52df770855b | 412 | ((__HANDLE__)->Instance->CR3 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK)))) |
jhon309 | 0:c52df770855b | 413 | |
jhon309 | 0:c52df770855b | 414 | |
jhon309 | 0:c52df770855b | 415 | /** @brief Checks whether the specified USART interrupt has occurred or not. |
jhon309 | 0:c52df770855b | 416 | * @param __HANDLE__: specifies the USART Handle |
jhon309 | 0:c52df770855b | 417 | * @param __IT__: specifies the USART interrupt source to check. |
jhon309 | 0:c52df770855b | 418 | * This parameter can be one of the following values: |
jhon309 | 0:c52df770855b | 419 | * @arg USART_IT_TXE: Transmit Data Register empty interrupt |
jhon309 | 0:c52df770855b | 420 | * @arg USART_IT_TC: Transmission complete interrupt |
jhon309 | 0:c52df770855b | 421 | * @arg USART_IT_RXNE: Receive Data register not empty interrupt |
jhon309 | 0:c52df770855b | 422 | * @arg USART_IT_IDLE: Idle line detection interrupt |
jhon309 | 0:c52df770855b | 423 | * @arg USART_IT_ORE: OverRun Error interrupt |
jhon309 | 0:c52df770855b | 424 | * @arg USART_IT_NE: Noise Error interrupt |
jhon309 | 0:c52df770855b | 425 | * @arg USART_IT_FE: Framing Error interrupt |
jhon309 | 0:c52df770855b | 426 | * @arg USART_IT_PE: Parity Error interrupt |
jhon309 | 0:c52df770855b | 427 | * @retval The new state of __IT__ (TRUE or FALSE). |
jhon309 | 0:c52df770855b | 428 | */ |
jhon309 | 0:c52df770855b | 429 | #define __HAL_USART_GET_IT(__HANDLE__, __IT__) ((__HANDLE__)->Instance->ISR & ((uint32_t)1 << ((__IT__)>> 0x08))) |
jhon309 | 0:c52df770855b | 430 | |
jhon309 | 0:c52df770855b | 431 | /** @brief Checks whether the specified USART interrupt source is enabled. |
jhon309 | 0:c52df770855b | 432 | * @param __HANDLE__: specifies the USART Handle. |
jhon309 | 0:c52df770855b | 433 | * @param __IT__: specifies the USART interrupt source to check. |
jhon309 | 0:c52df770855b | 434 | * This parameter can be one of the following values: |
jhon309 | 0:c52df770855b | 435 | * @arg USART_IT_TXE: Transmit Data Register empty interrupt |
jhon309 | 0:c52df770855b | 436 | * @arg USART_IT_TC: Transmission complete interrupt |
jhon309 | 0:c52df770855b | 437 | * @arg USART_IT_RXNE: Receive Data register not empty interrupt |
jhon309 | 0:c52df770855b | 438 | * @arg USART_IT_IDLE: Idle line detection interrupt |
jhon309 | 0:c52df770855b | 439 | * @arg USART_IT_ORE: OverRun Error interrupt |
jhon309 | 0:c52df770855b | 440 | * @arg USART_IT_NE: Noise Error interrupt |
jhon309 | 0:c52df770855b | 441 | * @arg USART_IT_FE: Framing Error interrupt |
jhon309 | 0:c52df770855b | 442 | * @arg USART_IT_PE: Parity Error interrupt |
jhon309 | 0:c52df770855b | 443 | * @retval The new state of __IT__ (TRUE or FALSE). |
jhon309 | 0:c52df770855b | 444 | */ |
jhon309 | 0:c52df770855b | 445 | #define __HAL_USART_GET_IT_SOURCE(__HANDLE__, __IT__) ((((((uint8_t)(__IT__)) >> 5) == 1)? (__HANDLE__)->Instance->CR1:(((((uint8_t)(__IT__)) >> 5) == 2)? \ |
jhon309 | 0:c52df770855b | 446 | (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & ((uint32_t)1 << \ |
jhon309 | 0:c52df770855b | 447 | (((uint16_t)(__IT__)) & USART_IT_MASK))) |
jhon309 | 0:c52df770855b | 448 | |
jhon309 | 0:c52df770855b | 449 | |
jhon309 | 0:c52df770855b | 450 | /** @brief Clears the specified USART ISR flag, in setting the proper ICR register flag. |
jhon309 | 0:c52df770855b | 451 | * @param __HANDLE__: specifies the USART Handle. |
jhon309 | 0:c52df770855b | 452 | * @param __IT_CLEAR__: specifies the interrupt clear register flag that needs to be set |
jhon309 | 0:c52df770855b | 453 | * to clear the corresponding interrupt |
jhon309 | 0:c52df770855b | 454 | * This parameter can be one of the following values: |
jhon309 | 0:c52df770855b | 455 | * @arg USART_CLEAR_PEF: Parity Error Clear Flag |
jhon309 | 0:c52df770855b | 456 | * @arg USART_CLEAR_FEF: Framing Error Clear Flag |
jhon309 | 0:c52df770855b | 457 | * @arg USART_CLEAR_NEF: Noise detected Clear Flag |
jhon309 | 0:c52df770855b | 458 | * @arg USART_CLEAR_OREF: OverRun Error Clear Flag |
jhon309 | 0:c52df770855b | 459 | * @arg USART_CLEAR_IDLEF: IDLE line detected Clear Flag |
jhon309 | 0:c52df770855b | 460 | * @arg USART_CLEAR_TCF: Transmission Complete Clear Flag |
jhon309 | 0:c52df770855b | 461 | * @arg USART_CLEAR_CTSF: CTS Interrupt Clear Flag |
jhon309 | 0:c52df770855b | 462 | * @retval None |
jhon309 | 0:c52df770855b | 463 | */ |
jhon309 | 0:c52df770855b | 464 | #define __HAL_USART_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__)) |
jhon309 | 0:c52df770855b | 465 | |
jhon309 | 0:c52df770855b | 466 | /** @brief Set a specific USART request flag. |
jhon309 | 0:c52df770855b | 467 | * @param __HANDLE__: specifies the USART Handle. |
jhon309 | 0:c52df770855b | 468 | * @param __REQ__: specifies the request flag to set |
jhon309 | 0:c52df770855b | 469 | * This parameter can be one of the following values: |
jhon309 | 0:c52df770855b | 470 | * @arg USART_RXDATA_FLUSH_REQUEST: Receive Data flush Request |
jhon309 | 0:c52df770855b | 471 | * @arg USART_TXDATA_FLUSH_REQUEST: Transmit data flush Request |
jhon309 | 0:c52df770855b | 472 | * |
jhon309 | 0:c52df770855b | 473 | * @retval None |
jhon309 | 0:c52df770855b | 474 | */ |
jhon309 | 0:c52df770855b | 475 | #define __HAL_USART_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (uint16_t)(__REQ__)) |
jhon309 | 0:c52df770855b | 476 | |
jhon309 | 0:c52df770855b | 477 | /** @brief Enable USART |
jhon309 | 0:c52df770855b | 478 | * @param __HANDLE__: specifies the USART Handle. |
jhon309 | 0:c52df770855b | 479 | * @retval None |
jhon309 | 0:c52df770855b | 480 | */ |
jhon309 | 0:c52df770855b | 481 | #define __HAL_USART_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE) |
jhon309 | 0:c52df770855b | 482 | |
jhon309 | 0:c52df770855b | 483 | /** @brief Disable USART |
jhon309 | 0:c52df770855b | 484 | * @param __HANDLE__: specifies the USART Handle. |
jhon309 | 0:c52df770855b | 485 | * @retval None |
jhon309 | 0:c52df770855b | 486 | */ |
jhon309 | 0:c52df770855b | 487 | #define __HAL_USART_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE) |
jhon309 | 0:c52df770855b | 488 | |
jhon309 | 0:c52df770855b | 489 | /** |
jhon309 | 0:c52df770855b | 490 | * @} |
jhon309 | 0:c52df770855b | 491 | */ |
jhon309 | 0:c52df770855b | 492 | |
jhon309 | 0:c52df770855b | 493 | /* Private macros --------------------------------------------------------*/ |
jhon309 | 0:c52df770855b | 494 | /** @defgroup USART_Private_Macros USART Private Macros |
jhon309 | 0:c52df770855b | 495 | * @{ |
jhon309 | 0:c52df770855b | 496 | */ |
jhon309 | 0:c52df770855b | 497 | |
jhon309 | 0:c52df770855b | 498 | /** @brief Check USART Baud rate |
jhon309 | 0:c52df770855b | 499 | * @param BAUDRATE: Baudrate specified by the user |
jhon309 | 0:c52df770855b | 500 | * The maximum Baud Rate is derived from the maximum clock on F0 (i.e. 48 MHz) |
jhon309 | 0:c52df770855b | 501 | * divided by the smallest oversampling used on the USART (i.e. 8) |
jhon309 | 0:c52df770855b | 502 | * @retval Test result (TRUE or FALSE) |
jhon309 | 0:c52df770855b | 503 | */ |
jhon309 | 0:c52df770855b | 504 | #define IS_USART_BAUDRATE(BAUDRATE) ((BAUDRATE) < 9000001) |
jhon309 | 0:c52df770855b | 505 | /** |
jhon309 | 0:c52df770855b | 506 | * @} |
jhon309 | 0:c52df770855b | 507 | */ |
jhon309 | 0:c52df770855b | 508 | |
jhon309 | 0:c52df770855b | 509 | /* Include USART HAL Extension module */ |
jhon309 | 0:c52df770855b | 510 | #include "stm32f0xx_hal_usart_ex.h" |
jhon309 | 0:c52df770855b | 511 | |
jhon309 | 0:c52df770855b | 512 | /* Exported functions --------------------------------------------------------*/ |
jhon309 | 0:c52df770855b | 513 | |
jhon309 | 0:c52df770855b | 514 | /** @addtogroup USART_Exported_Functions USART Exported Functions |
jhon309 | 0:c52df770855b | 515 | * @{ |
jhon309 | 0:c52df770855b | 516 | */ |
jhon309 | 0:c52df770855b | 517 | |
jhon309 | 0:c52df770855b | 518 | /** @addtogroup USART_Exported_Functions_Group1 Initialization and de-initialization functions |
jhon309 | 0:c52df770855b | 519 | * @{ |
jhon309 | 0:c52df770855b | 520 | */ |
jhon309 | 0:c52df770855b | 521 | |
jhon309 | 0:c52df770855b | 522 | /* Initialization and de-initialization functions ******************************/ |
jhon309 | 0:c52df770855b | 523 | HAL_StatusTypeDef HAL_USART_Init(USART_HandleTypeDef *husart); |
jhon309 | 0:c52df770855b | 524 | HAL_StatusTypeDef HAL_USART_DeInit(USART_HandleTypeDef *husart); |
jhon309 | 0:c52df770855b | 525 | void HAL_USART_MspInit(USART_HandleTypeDef *husart); |
jhon309 | 0:c52df770855b | 526 | void HAL_USART_MspDeInit(USART_HandleTypeDef *husart); |
jhon309 | 0:c52df770855b | 527 | HAL_StatusTypeDef HAL_USART_CheckIdleState(USART_HandleTypeDef *husart); |
jhon309 | 0:c52df770855b | 528 | |
jhon309 | 0:c52df770855b | 529 | /** |
jhon309 | 0:c52df770855b | 530 | * @} |
jhon309 | 0:c52df770855b | 531 | */ |
jhon309 | 0:c52df770855b | 532 | |
jhon309 | 0:c52df770855b | 533 | /** @addtogroup USART_Exported_Functions_Group2 IO operation functions |
jhon309 | 0:c52df770855b | 534 | * @{ |
jhon309 | 0:c52df770855b | 535 | */ |
jhon309 | 0:c52df770855b | 536 | |
jhon309 | 0:c52df770855b | 537 | /* IO operation functions *******************************************************/ |
jhon309 | 0:c52df770855b | 538 | HAL_StatusTypeDef HAL_USART_Transmit(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size, uint32_t Timeout); |
jhon309 | 0:c52df770855b | 539 | HAL_StatusTypeDef HAL_USART_Receive(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size, uint32_t Timeout); |
jhon309 | 0:c52df770855b | 540 | HAL_StatusTypeDef HAL_USART_TransmitReceive(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout); |
jhon309 | 0:c52df770855b | 541 | HAL_StatusTypeDef HAL_USART_Transmit_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size); |
jhon309 | 0:c52df770855b | 542 | HAL_StatusTypeDef HAL_USART_Receive_IT(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size); |
jhon309 | 0:c52df770855b | 543 | HAL_StatusTypeDef HAL_USART_TransmitReceive_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size); |
jhon309 | 0:c52df770855b | 544 | HAL_StatusTypeDef HAL_USART_Transmit_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size); |
jhon309 | 0:c52df770855b | 545 | HAL_StatusTypeDef HAL_USART_Receive_DMA(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size); |
jhon309 | 0:c52df770855b | 546 | HAL_StatusTypeDef HAL_USART_TransmitReceive_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size); |
jhon309 | 0:c52df770855b | 547 | HAL_StatusTypeDef HAL_USART_DMAPause(USART_HandleTypeDef *husart); |
jhon309 | 0:c52df770855b | 548 | HAL_StatusTypeDef HAL_USART_DMAResume(USART_HandleTypeDef *husart); |
jhon309 | 0:c52df770855b | 549 | HAL_StatusTypeDef HAL_USART_DMAStop(USART_HandleTypeDef *husart); |
jhon309 | 0:c52df770855b | 550 | void HAL_USART_IRQHandler(USART_HandleTypeDef *husart); |
jhon309 | 0:c52df770855b | 551 | void HAL_USART_TxCpltCallback(USART_HandleTypeDef *husart); |
jhon309 | 0:c52df770855b | 552 | void HAL_USART_RxCpltCallback(USART_HandleTypeDef *husart); |
jhon309 | 0:c52df770855b | 553 | void HAL_USART_TxHalfCpltCallback(USART_HandleTypeDef *husart); |
jhon309 | 0:c52df770855b | 554 | void HAL_USART_RxHalfCpltCallback(USART_HandleTypeDef *husart); |
jhon309 | 0:c52df770855b | 555 | void HAL_USART_TxRxCpltCallback(USART_HandleTypeDef *husart); |
jhon309 | 0:c52df770855b | 556 | void HAL_USART_ErrorCallback(USART_HandleTypeDef *husart); |
jhon309 | 0:c52df770855b | 557 | |
jhon309 | 0:c52df770855b | 558 | /** |
jhon309 | 0:c52df770855b | 559 | * @} |
jhon309 | 0:c52df770855b | 560 | */ |
jhon309 | 0:c52df770855b | 561 | |
jhon309 | 0:c52df770855b | 562 | /* Peripheral Control functions ***********************************************/ |
jhon309 | 0:c52df770855b | 563 | |
jhon309 | 0:c52df770855b | 564 | /** @addtogroup USART_Exported_Functions_Group3 Peripheral State and Errors functions |
jhon309 | 0:c52df770855b | 565 | * @{ |
jhon309 | 0:c52df770855b | 566 | */ |
jhon309 | 0:c52df770855b | 567 | |
jhon309 | 0:c52df770855b | 568 | /* Peripheral State and Error functions ***************************************/ |
jhon309 | 0:c52df770855b | 569 | HAL_USART_StateTypeDef HAL_USART_GetState(USART_HandleTypeDef *husart); |
jhon309 | 0:c52df770855b | 570 | uint32_t HAL_USART_GetError(USART_HandleTypeDef *husart); |
jhon309 | 0:c52df770855b | 571 | |
jhon309 | 0:c52df770855b | 572 | /** |
jhon309 | 0:c52df770855b | 573 | * @} |
jhon309 | 0:c52df770855b | 574 | */ |
jhon309 | 0:c52df770855b | 575 | |
jhon309 | 0:c52df770855b | 576 | /** |
jhon309 | 0:c52df770855b | 577 | * @} |
jhon309 | 0:c52df770855b | 578 | */ |
jhon309 | 0:c52df770855b | 579 | |
jhon309 | 0:c52df770855b | 580 | /** |
jhon309 | 0:c52df770855b | 581 | * @} |
jhon309 | 0:c52df770855b | 582 | */ |
jhon309 | 0:c52df770855b | 583 | |
jhon309 | 0:c52df770855b | 584 | /** |
jhon309 | 0:c52df770855b | 585 | * @} |
jhon309 | 0:c52df770855b | 586 | */ |
jhon309 | 0:c52df770855b | 587 | |
jhon309 | 0:c52df770855b | 588 | #ifdef __cplusplus |
jhon309 | 0:c52df770855b | 589 | } |
jhon309 | 0:c52df770855b | 590 | #endif |
jhon309 | 0:c52df770855b | 591 | |
jhon309 | 0:c52df770855b | 592 | #endif /* __STM32F0xx_HAL_USART_H */ |
jhon309 | 0:c52df770855b | 593 | |
jhon309 | 0:c52df770855b | 594 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
jhon309 | 0:c52df770855b | 595 |