DHT11

Committer:
jhon309
Date:
Thu Aug 13 00:21:57 2015 +0000
Revision:
0:c52df770855b
DHT11

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jhon309 0:c52df770855b 1 /**
jhon309 0:c52df770855b 2 ******************************************************************************
jhon309 0:c52df770855b 3 * @file stm32f0xx_hal_uart.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 UART HAL module.
jhon309 0:c52df770855b 8 ******************************************************************************
jhon309 0:c52df770855b 9 * @attention
jhon309 0:c52df770855b 10 *
jhon309 0:c52df770855b 11 * <h2><center>&copy; 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_UART_H
jhon309 0:c52df770855b 40 #define __STM32F0xx_HAL_UART_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 UART
jhon309 0:c52df770855b 54 * @{
jhon309 0:c52df770855b 55 */
jhon309 0:c52df770855b 56
jhon309 0:c52df770855b 57 /* Exported types ------------------------------------------------------------*/
jhon309 0:c52df770855b 58 /** @defgroup UART_Exported_Types UART 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 UART 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 UART communication baud rate.
jhon309 0:c52df770855b 69 The baud rate register is computed using the following formula:
jhon309 0:c52df770855b 70 - If oversampling is 16 or in LIN mode (LIN mode not available on F030xx devices),
jhon309 0:c52df770855b 71 Baud Rate Register = ((PCLKx) / ((huart->Init.BaudRate)))
jhon309 0:c52df770855b 72 - If oversampling is 8,
jhon309 0:c52df770855b 73 Baud Rate Register[15:4] = ((2 * PCLKx) / ((huart->Init.BaudRate)))[15:4]
jhon309 0:c52df770855b 74 Baud Rate Register[3] = 0
jhon309 0:c52df770855b 75 Baud Rate Register[2:0] = (((2 * PCLKx) / ((huart->Init.BaudRate)))[3:0]) >> 1 */
jhon309 0:c52df770855b 76
jhon309 0:c52df770855b 77 uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
jhon309 0:c52df770855b 78 This parameter can be a value of @ref UARTEx_Word_Length */
jhon309 0:c52df770855b 79
jhon309 0:c52df770855b 80 uint32_t StopBits; /*!< Specifies the number of stop bits transmitted.
jhon309 0:c52df770855b 81 This parameter can be a value of @ref UART_Stop_Bits */
jhon309 0:c52df770855b 82
jhon309 0:c52df770855b 83 uint32_t Parity; /*!< Specifies the parity mode.
jhon309 0:c52df770855b 84 This parameter can be a value of @ref UART_Parity
jhon309 0:c52df770855b 85 @note When parity is enabled, the computed parity is inserted
jhon309 0:c52df770855b 86 at the MSB position of the transmitted data (9th bit when
jhon309 0:c52df770855b 87 the word length is set to 9 data bits; 8th bit when the
jhon309 0:c52df770855b 88 word length is set to 8 data bits). */
jhon309 0:c52df770855b 89
jhon309 0:c52df770855b 90 uint32_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
jhon309 0:c52df770855b 91 This parameter can be a value of @ref UART_Mode */
jhon309 0:c52df770855b 92
jhon309 0:c52df770855b 93 uint32_t HwFlowCtl; /*!< Specifies whether the hardware flow control mode is enabled
jhon309 0:c52df770855b 94 or disabled.
jhon309 0:c52df770855b 95 This parameter can be a value of @ref UART_Hardware_Flow_Control */
jhon309 0:c52df770855b 96
jhon309 0:c52df770855b 97 uint32_t OverSampling; /*!< Specifies whether the Over sampling 8 is enabled or disabled, to achieve higher speed (up to fPCLK/8).
jhon309 0:c52df770855b 98 This parameter can be a value of @ref UART_Over_Sampling */
jhon309 0:c52df770855b 99
jhon309 0:c52df770855b 100 uint32_t OneBitSampling; /*!< Specifies whether a single sample or three samples' majority vote is selected.
jhon309 0:c52df770855b 101 Selecting the single sample method increases the receiver tolerance to clock
jhon309 0:c52df770855b 102 deviations. This parameter can be a value of @ref UART_OneBit_Sampling. */
jhon309 0:c52df770855b 103 }UART_InitTypeDef;
jhon309 0:c52df770855b 104
jhon309 0:c52df770855b 105 /**
jhon309 0:c52df770855b 106 * @brief UART Advanced Features initalization structure definition
jhon309 0:c52df770855b 107 */
jhon309 0:c52df770855b 108 typedef struct
jhon309 0:c52df770855b 109 {
jhon309 0:c52df770855b 110 uint32_t AdvFeatureInit; /*!< Specifies which advanced UART features is initialized. Several
jhon309 0:c52df770855b 111 Advanced Features may be initialized at the same time .
jhon309 0:c52df770855b 112 This parameter can be a value of @ref UART_Advanced_Features_Initialization_Type */
jhon309 0:c52df770855b 113
jhon309 0:c52df770855b 114 uint32_t TxPinLevelInvert; /*!< Specifies whether the TX pin active level is inverted.
jhon309 0:c52df770855b 115 This parameter can be a value of @ref UART_Tx_Inv */
jhon309 0:c52df770855b 116
jhon309 0:c52df770855b 117 uint32_t RxPinLevelInvert; /*!< Specifies whether the RX pin active level is inverted.
jhon309 0:c52df770855b 118 This parameter can be a value of @ref UART_Rx_Inv */
jhon309 0:c52df770855b 119
jhon309 0:c52df770855b 120 uint32_t DataInvert; /*!< Specifies whether data are inverted (positive/direct logic
jhon309 0:c52df770855b 121 vs negative/inverted logic).
jhon309 0:c52df770855b 122 This parameter can be a value of @ref UART_Data_Inv */
jhon309 0:c52df770855b 123
jhon309 0:c52df770855b 124 uint32_t Swap; /*!< Specifies whether TX and RX pins are swapped.
jhon309 0:c52df770855b 125 This parameter can be a value of @ref UART_Rx_Tx_Swap */
jhon309 0:c52df770855b 126
jhon309 0:c52df770855b 127 uint32_t OverrunDisable; /*!< Specifies whether the reception overrun detection is disabled.
jhon309 0:c52df770855b 128 This parameter can be a value of @ref UART_Overrun_Disable */
jhon309 0:c52df770855b 129
jhon309 0:c52df770855b 130 uint32_t DMADisableonRxError; /*!< Specifies whether the DMA is disabled in case of reception error.
jhon309 0:c52df770855b 131 This parameter can be a value of @ref UART_DMA_Disable_on_Rx_Error */
jhon309 0:c52df770855b 132
jhon309 0:c52df770855b 133 uint32_t AutoBaudRateEnable; /*!< Specifies whether auto Baud rate detection is enabled.
jhon309 0:c52df770855b 134 This parameter can be a value of @ref UART_AutoBaudRate_Enable */
jhon309 0:c52df770855b 135
jhon309 0:c52df770855b 136 uint32_t AutoBaudRateMode; /*!< If auto Baud rate detection is enabled, specifies how the rate
jhon309 0:c52df770855b 137 detection is carried out.
jhon309 0:c52df770855b 138 This parameter can be a value of @ref UARTEx_AutoBaud_Rate_Mode */
jhon309 0:c52df770855b 139
jhon309 0:c52df770855b 140 uint32_t MSBFirst; /*!< Specifies whether MSB is sent first on UART line.
jhon309 0:c52df770855b 141 This parameter can be a value of @ref UART_MSB_First */
jhon309 0:c52df770855b 142 } UART_AdvFeatureInitTypeDef;
jhon309 0:c52df770855b 143
jhon309 0:c52df770855b 144 /**
jhon309 0:c52df770855b 145 * @brief HAL UART State structures definition
jhon309 0:c52df770855b 146 */
jhon309 0:c52df770855b 147 typedef enum
jhon309 0:c52df770855b 148 {
jhon309 0:c52df770855b 149 HAL_UART_STATE_RESET = 0x00, /*!< Peripheral is not initialized */
jhon309 0:c52df770855b 150 HAL_UART_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */
jhon309 0:c52df770855b 151 HAL_UART_STATE_BUSY = 0x02, /*!< an internal process is ongoing */
jhon309 0:c52df770855b 152 HAL_UART_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */
jhon309 0:c52df770855b 153 HAL_UART_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */
jhon309 0:c52df770855b 154 HAL_UART_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission and Reception process is ongoing */
jhon309 0:c52df770855b 155 HAL_UART_STATE_TIMEOUT = 0x03, /*!< Timeout state */
jhon309 0:c52df770855b 156 HAL_UART_STATE_ERROR = 0x04 /*!< Error */
jhon309 0:c52df770855b 157 }HAL_UART_StateTypeDef;
jhon309 0:c52df770855b 158
jhon309 0:c52df770855b 159 /**
jhon309 0:c52df770855b 160 * @brief UART clock sources definition
jhon309 0:c52df770855b 161 */
jhon309 0:c52df770855b 162 typedef enum
jhon309 0:c52df770855b 163 {
jhon309 0:c52df770855b 164 UART_CLOCKSOURCE_PCLK1 = 0x00, /*!< PCLK1 clock source */
jhon309 0:c52df770855b 165 UART_CLOCKSOURCE_HSI = 0x02, /*!< HSI clock source */
jhon309 0:c52df770855b 166 UART_CLOCKSOURCE_SYSCLK = 0x04, /*!< SYSCLK clock source */
jhon309 0:c52df770855b 167 UART_CLOCKSOURCE_LSE = 0x08, /*!< LSE clock source */
jhon309 0:c52df770855b 168 UART_CLOCKSOURCE_UNDEFINED = 0x10 /*!< undefined clock source */
jhon309 0:c52df770855b 169 }UART_ClockSourceTypeDef;
jhon309 0:c52df770855b 170
jhon309 0:c52df770855b 171 /**
jhon309 0:c52df770855b 172 * @brief UART handle Structure definition
jhon309 0:c52df770855b 173 */
jhon309 0:c52df770855b 174 typedef struct
jhon309 0:c52df770855b 175 {
jhon309 0:c52df770855b 176 USART_TypeDef *Instance; /*!< UART registers base address */
jhon309 0:c52df770855b 177
jhon309 0:c52df770855b 178 UART_InitTypeDef Init; /*!< UART communication parameters */
jhon309 0:c52df770855b 179
jhon309 0:c52df770855b 180 UART_AdvFeatureInitTypeDef AdvancedInit; /*!< UART Advanced Features initialization parameters */
jhon309 0:c52df770855b 181
jhon309 0:c52df770855b 182 uint8_t *pTxBuffPtr; /*!< Pointer to UART Tx transfer Buffer */
jhon309 0:c52df770855b 183
jhon309 0:c52df770855b 184 uint16_t TxXferSize; /*!< UART Tx Transfer size */
jhon309 0:c52df770855b 185
jhon309 0:c52df770855b 186 uint16_t TxXferCount; /*!< UART Tx Transfer Counter */
jhon309 0:c52df770855b 187
jhon309 0:c52df770855b 188 uint8_t *pRxBuffPtr; /*!< Pointer to UART Rx transfer Buffer */
jhon309 0:c52df770855b 189
jhon309 0:c52df770855b 190 uint16_t RxXferSize; /*!< UART Rx Transfer size */
jhon309 0:c52df770855b 191
jhon309 0:c52df770855b 192 uint16_t RxXferCount; /*!< UART Rx Transfer Counter */
jhon309 0:c52df770855b 193
jhon309 0:c52df770855b 194 uint16_t Mask; /*!< UART Rx RDR register mask */
jhon309 0:c52df770855b 195
jhon309 0:c52df770855b 196 DMA_HandleTypeDef *hdmatx; /*!< UART Tx DMA Handle parameters */
jhon309 0:c52df770855b 197
jhon309 0:c52df770855b 198 DMA_HandleTypeDef *hdmarx; /*!< UART Rx DMA Handle parameters */
jhon309 0:c52df770855b 199
jhon309 0:c52df770855b 200 HAL_LockTypeDef Lock; /*!< Locking object */
jhon309 0:c52df770855b 201
jhon309 0:c52df770855b 202 HAL_UART_StateTypeDef State; /*!< UART communication state */
jhon309 0:c52df770855b 203
jhon309 0:c52df770855b 204 __IO uint32_t ErrorCode; /*!< UART Error code
jhon309 0:c52df770855b 205 This parameter can be a value of @ref UART_Error */
jhon309 0:c52df770855b 206
jhon309 0:c52df770855b 207 }UART_HandleTypeDef;
jhon309 0:c52df770855b 208
jhon309 0:c52df770855b 209 /**
jhon309 0:c52df770855b 210 * @}
jhon309 0:c52df770855b 211 */
jhon309 0:c52df770855b 212
jhon309 0:c52df770855b 213 /* Exported constants --------------------------------------------------------*/
jhon309 0:c52df770855b 214 /** @defgroup UART_Exported_Constants UART Exported constants
jhon309 0:c52df770855b 215 * @{
jhon309 0:c52df770855b 216 */
jhon309 0:c52df770855b 217
jhon309 0:c52df770855b 218 /** @defgroup UART_Error UART Error
jhon309 0:c52df770855b 219 * @{
jhon309 0:c52df770855b 220 */
jhon309 0:c52df770855b 221 #define HAL_UART_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */
jhon309 0:c52df770855b 222 #define HAL_UART_ERROR_PE ((uint32_t)0x00000001) /*!< Parity error */
jhon309 0:c52df770855b 223 #define HAL_UART_ERROR_NE ((uint32_t)0x00000002) /*!< Noise error */
jhon309 0:c52df770855b 224 #define HAL_UART_ERROR_FE ((uint32_t)0x00000004) /*!< frame error */
jhon309 0:c52df770855b 225 #define HAL_UART_ERROR_ORE ((uint32_t)0x00000008) /*!< Overrun error */
jhon309 0:c52df770855b 226 #define HAL_UART_ERROR_DMA ((uint32_t)0x00000010) /*!< DMA transfer error */
jhon309 0:c52df770855b 227 /**
jhon309 0:c52df770855b 228 * @}
jhon309 0:c52df770855b 229 */
jhon309 0:c52df770855b 230
jhon309 0:c52df770855b 231 /** @defgroup UART_Stop_Bits UART Number of Stop Bits
jhon309 0:c52df770855b 232 * @{
jhon309 0:c52df770855b 233 */
jhon309 0:c52df770855b 234 #define UART_STOPBITS_1 ((uint32_t)0x0000)
jhon309 0:c52df770855b 235 #define UART_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1)
jhon309 0:c52df770855b 236 #define UART_STOPBITS_1_5 ((uint32_t)(USART_CR2_STOP_0 | USART_CR2_STOP_1))
jhon309 0:c52df770855b 237 #define IS_UART_STOPBITS(STOPBITS) (((STOPBITS) == UART_STOPBITS_1) || \
jhon309 0:c52df770855b 238 ((STOPBITS) == UART_STOPBITS_2) || \
jhon309 0:c52df770855b 239 ((STOPBITS) == UART_STOPBITS_1_5))
jhon309 0:c52df770855b 240 /**
jhon309 0:c52df770855b 241 * @}
jhon309 0:c52df770855b 242 */
jhon309 0:c52df770855b 243
jhon309 0:c52df770855b 244 /** @defgroup UART_Parity UART Parity
jhon309 0:c52df770855b 245 * @{
jhon309 0:c52df770855b 246 */
jhon309 0:c52df770855b 247 #define UART_PARITY_NONE ((uint32_t)0x0000)
jhon309 0:c52df770855b 248 #define UART_PARITY_EVEN ((uint32_t)USART_CR1_PCE)
jhon309 0:c52df770855b 249 #define UART_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS))
jhon309 0:c52df770855b 250 #define IS_UART_PARITY(PARITY) (((PARITY) == UART_PARITY_NONE) || \
jhon309 0:c52df770855b 251 ((PARITY) == UART_PARITY_EVEN) || \
jhon309 0:c52df770855b 252 ((PARITY) == UART_PARITY_ODD))
jhon309 0:c52df770855b 253 /**
jhon309 0:c52df770855b 254 * @}
jhon309 0:c52df770855b 255 */
jhon309 0:c52df770855b 256
jhon309 0:c52df770855b 257 /** @defgroup UART_Hardware_Flow_Control UART Hardware Flow Control
jhon309 0:c52df770855b 258 * @{
jhon309 0:c52df770855b 259 */
jhon309 0:c52df770855b 260 #define UART_HWCONTROL_NONE ((uint32_t)0x0000)
jhon309 0:c52df770855b 261 #define UART_HWCONTROL_RTS ((uint32_t)USART_CR3_RTSE)
jhon309 0:c52df770855b 262 #define UART_HWCONTROL_CTS ((uint32_t)USART_CR3_CTSE)
jhon309 0:c52df770855b 263 #define UART_HWCONTROL_RTS_CTS ((uint32_t)(USART_CR3_RTSE | USART_CR3_CTSE))
jhon309 0:c52df770855b 264 #define IS_UART_HARDWARE_FLOW_CONTROL(CONTROL)\
jhon309 0:c52df770855b 265 (((CONTROL) == UART_HWCONTROL_NONE) || \
jhon309 0:c52df770855b 266 ((CONTROL) == UART_HWCONTROL_RTS) || \
jhon309 0:c52df770855b 267 ((CONTROL) == UART_HWCONTROL_CTS) || \
jhon309 0:c52df770855b 268 ((CONTROL) == UART_HWCONTROL_RTS_CTS))
jhon309 0:c52df770855b 269 /**
jhon309 0:c52df770855b 270 * @}
jhon309 0:c52df770855b 271 */
jhon309 0:c52df770855b 272
jhon309 0:c52df770855b 273 /** @defgroup UART_Mode UART Transfer Mode
jhon309 0:c52df770855b 274 * @{
jhon309 0:c52df770855b 275 */
jhon309 0:c52df770855b 276 #define UART_MODE_RX ((uint32_t)USART_CR1_RE)
jhon309 0:c52df770855b 277 #define UART_MODE_TX ((uint32_t)USART_CR1_TE)
jhon309 0:c52df770855b 278 #define UART_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE))
jhon309 0:c52df770855b 279 #define IS_UART_MODE(MODE) ((((MODE) & (~((uint32_t)(UART_MODE_TX_RX)))) == (uint32_t)0x00) && ((MODE) != (uint32_t)0x00))
jhon309 0:c52df770855b 280 /**
jhon309 0:c52df770855b 281 * @}
jhon309 0:c52df770855b 282 */
jhon309 0:c52df770855b 283
jhon309 0:c52df770855b 284 /** @defgroup UART_State UART State
jhon309 0:c52df770855b 285 * @{
jhon309 0:c52df770855b 286 */
jhon309 0:c52df770855b 287 #define UART_STATE_DISABLE ((uint32_t)0x0000)
jhon309 0:c52df770855b 288 #define UART_STATE_ENABLE ((uint32_t)USART_CR1_UE)
jhon309 0:c52df770855b 289 #define IS_UART_STATE(STATE) (((STATE) == UART_STATE_DISABLE) || \
jhon309 0:c52df770855b 290 ((STATE) == UART_STATE_ENABLE))
jhon309 0:c52df770855b 291 /**
jhon309 0:c52df770855b 292 * @}
jhon309 0:c52df770855b 293 */
jhon309 0:c52df770855b 294
jhon309 0:c52df770855b 295 /** @defgroup UART_Over_Sampling UART Over Sampling
jhon309 0:c52df770855b 296 * @{
jhon309 0:c52df770855b 297 */
jhon309 0:c52df770855b 298 #define UART_OVERSAMPLING_16 ((uint32_t)0x0000)
jhon309 0:c52df770855b 299 #define UART_OVERSAMPLING_8 ((uint32_t)USART_CR1_OVER8)
jhon309 0:c52df770855b 300 #define IS_UART_OVERSAMPLING(SAMPLING) (((SAMPLING) == UART_OVERSAMPLING_16) || \
jhon309 0:c52df770855b 301 ((SAMPLING) == UART_OVERSAMPLING_8))
jhon309 0:c52df770855b 302 /**
jhon309 0:c52df770855b 303 * @}
jhon309 0:c52df770855b 304 */
jhon309 0:c52df770855b 305
jhon309 0:c52df770855b 306 /** @defgroup UART_OneBit_Sampling UART One Bit Sampling Method
jhon309 0:c52df770855b 307 * @{
jhon309 0:c52df770855b 308 */
jhon309 0:c52df770855b 309 #define UART_ONEBIT_SAMPLING_DISABLED ((uint32_t)0x0000)
jhon309 0:c52df770855b 310 #define UART_ONEBIT_SAMPLING_ENABLED ((uint32_t)USART_CR3_ONEBIT)
jhon309 0:c52df770855b 311 #define IS_UART_ONEBIT_SAMPLING(ONEBIT) (((ONEBIT) == UART_ONEBIT_SAMPLING_DISABLED) || \
jhon309 0:c52df770855b 312 ((ONEBIT) == UART_ONEBIT_SAMPLING_ENABLED))
jhon309 0:c52df770855b 313 /**
jhon309 0:c52df770855b 314 * @}
jhon309 0:c52df770855b 315 */
jhon309 0:c52df770855b 316
jhon309 0:c52df770855b 317
jhon309 0:c52df770855b 318 /** @defgroup UART_Receiver_TimeOut UART Receiver TimeOut
jhon309 0:c52df770855b 319 * @{
jhon309 0:c52df770855b 320 */
jhon309 0:c52df770855b 321 #define UART_RECEIVER_TIMEOUT_DISABLE ((uint32_t)0x00000000)
jhon309 0:c52df770855b 322 #define UART_RECEIVER_TIMEOUT_ENABLE ((uint32_t)USART_CR2_RTOEN)
jhon309 0:c52df770855b 323 #define IS_UART_RECEIVER_TIMEOUT(TIMEOUT) (((TIMEOUT) == UART_RECEIVER_TIMEOUT_DISABLE) || \
jhon309 0:c52df770855b 324 ((TIMEOUT) == UART_RECEIVER_TIMEOUT_ENABLE))
jhon309 0:c52df770855b 325 /**
jhon309 0:c52df770855b 326 * @}
jhon309 0:c52df770855b 327 */
jhon309 0:c52df770855b 328
jhon309 0:c52df770855b 329 /** @defgroup UART_One_Bit UART One Bit sampling
jhon309 0:c52df770855b 330 * @{
jhon309 0:c52df770855b 331 */
jhon309 0:c52df770855b 332 #define UART_ONE_BIT_SAMPLE_DISABLED ((uint32_t)0x00000000)
jhon309 0:c52df770855b 333 #define UART_ONE_BIT_SAMPLE_ENABLED ((uint32_t)USART_CR3_ONEBIT)
jhon309 0:c52df770855b 334 #define IS_UART_ONEBIT_SAMPLE(ONEBIT) (((ONEBIT) == UART_ONE_BIT_SAMPLE_DISABLED) || \
jhon309 0:c52df770855b 335 ((ONEBIT) == UART_ONE_BIT_SAMPLE_ENABLED))
jhon309 0:c52df770855b 336 /**
jhon309 0:c52df770855b 337 * @}
jhon309 0:c52df770855b 338 */
jhon309 0:c52df770855b 339
jhon309 0:c52df770855b 340 /** @defgroup UART_DMA_Tx UART DMA Tx
jhon309 0:c52df770855b 341 * @{
jhon309 0:c52df770855b 342 */
jhon309 0:c52df770855b 343 #define UART_DMA_TX_DISABLE ((uint32_t)0x00000000)
jhon309 0:c52df770855b 344 #define UART_DMA_TX_ENABLE ((uint32_t)USART_CR3_DMAT)
jhon309 0:c52df770855b 345 #define IS_UART_DMA_TX(DMATX) (((DMATX) == UART_DMA_TX_DISABLE) || \
jhon309 0:c52df770855b 346 ((DMATX) == UART_DMA_TX_ENABLE))
jhon309 0:c52df770855b 347 /**
jhon309 0:c52df770855b 348 * @}
jhon309 0:c52df770855b 349 */
jhon309 0:c52df770855b 350
jhon309 0:c52df770855b 351 /** @defgroup UART_DMA_Rx UART DMA Rx
jhon309 0:c52df770855b 352 * @{
jhon309 0:c52df770855b 353 */
jhon309 0:c52df770855b 354 #define UART_DMA_RX_DISABLE ((uint32_t)0x0000)
jhon309 0:c52df770855b 355 #define UART_DMA_RX_ENABLE ((uint32_t)USART_CR3_DMAR)
jhon309 0:c52df770855b 356 #define IS_UART_DMA_RX(DMARX) (((DMARX) == UART_DMA_RX_DISABLE) || \
jhon309 0:c52df770855b 357 ((DMARX) == UART_DMA_RX_ENABLE))
jhon309 0:c52df770855b 358 /**
jhon309 0:c52df770855b 359 * @}
jhon309 0:c52df770855b 360 */
jhon309 0:c52df770855b 361
jhon309 0:c52df770855b 362 /** @defgroup UART_Half_Duplex_Selection UART Half Duplex Selection
jhon309 0:c52df770855b 363 * @{
jhon309 0:c52df770855b 364 */
jhon309 0:c52df770855b 365 #define UART_HALF_DUPLEX_DISABLE ((uint32_t)0x0000)
jhon309 0:c52df770855b 366 #define UART_HALF_DUPLEX_ENABLE ((uint32_t)USART_CR3_HDSEL)
jhon309 0:c52df770855b 367 #define IS_UART_HALF_DUPLEX(HDSEL) (((HDSEL) == UART_HALF_DUPLEX_DISABLE) || \
jhon309 0:c52df770855b 368 ((HDSEL) == UART_HALF_DUPLEX_ENABLE))
jhon309 0:c52df770855b 369 /**
jhon309 0:c52df770855b 370 * @}
jhon309 0:c52df770855b 371 */
jhon309 0:c52df770855b 372
jhon309 0:c52df770855b 373 /** @defgroup UART_WakeUp_Address_Length UART WakeUp Address Length
jhon309 0:c52df770855b 374 * @{
jhon309 0:c52df770855b 375 */
jhon309 0:c52df770855b 376 #define UART_ADDRESS_DETECT_4B ((uint32_t)0x00000000)
jhon309 0:c52df770855b 377 #define UART_ADDRESS_DETECT_7B ((uint32_t)USART_CR2_ADDM7)
jhon309 0:c52df770855b 378 #define IS_UART_ADDRESSLENGTH_DETECT(ADDRESS) (((ADDRESS) == UART_ADDRESS_DETECT_4B) || \
jhon309 0:c52df770855b 379 ((ADDRESS) == UART_ADDRESS_DETECT_7B))
jhon309 0:c52df770855b 380 /**
jhon309 0:c52df770855b 381 * @}
jhon309 0:c52df770855b 382 */
jhon309 0:c52df770855b 383
jhon309 0:c52df770855b 384 /** @defgroup UART_WakeUp_Methods UART WakeUp Methods
jhon309 0:c52df770855b 385 * @{
jhon309 0:c52df770855b 386 */
jhon309 0:c52df770855b 387 #define UART_WAKEUPMETHOD_IDLELINE ((uint32_t)0x00000000)
jhon309 0:c52df770855b 388 #define UART_WAKEUPMETHOD_ADDRESSMARK ((uint32_t)USART_CR1_WAKE)
jhon309 0:c52df770855b 389 #define IS_UART_WAKEUPMETHOD(WAKEUP) (((WAKEUP) == UART_WAKEUPMETHOD_IDLELINE) || \
jhon309 0:c52df770855b 390 ((WAKEUP) == UART_WAKEUPMETHOD_ADDRESSMARK))
jhon309 0:c52df770855b 391 /**
jhon309 0:c52df770855b 392 * @}
jhon309 0:c52df770855b 393 */
jhon309 0:c52df770855b 394
jhon309 0:c52df770855b 395 /** @defgroup UART_IT UART IT
jhon309 0:c52df770855b 396 * Elements values convention: 000000000XXYYYYYb
jhon309 0:c52df770855b 397 * - YYYYY : Interrupt source position in the XX register (5bits)
jhon309 0:c52df770855b 398 * - XX : Interrupt source register (2bits)
jhon309 0:c52df770855b 399 * - 01: CR1 register
jhon309 0:c52df770855b 400 * - 10: CR2 register
jhon309 0:c52df770855b 401 * - 11: CR3 register
jhon309 0:c52df770855b 402 * @{
jhon309 0:c52df770855b 403 */
jhon309 0:c52df770855b 404 #define UART_IT_ERR ((uint16_t)0x0060)
jhon309 0:c52df770855b 405
jhon309 0:c52df770855b 406 /** Elements values convention: 0000ZZZZ00000000b
jhon309 0:c52df770855b 407 * - ZZZZ : Flag position in the ISR register(4bits)
jhon309 0:c52df770855b 408 */
jhon309 0:c52df770855b 409 #define UART_IT_ORE ((uint16_t)0x0300)
jhon309 0:c52df770855b 410 #define UART_IT_NE ((uint16_t)0x0200)
jhon309 0:c52df770855b 411 #define UART_IT_FE ((uint16_t)0x0100)
jhon309 0:c52df770855b 412 /**
jhon309 0:c52df770855b 413 * @}
jhon309 0:c52df770855b 414 */
jhon309 0:c52df770855b 415
jhon309 0:c52df770855b 416 /** @defgroup UART_Advanced_Features_Initialization_Type UART Advanced Feature Initialization Type
jhon309 0:c52df770855b 417 * @{
jhon309 0:c52df770855b 418 */
jhon309 0:c52df770855b 419 #define UART_ADVFEATURE_NO_INIT ((uint32_t)0x00000000)
jhon309 0:c52df770855b 420 #define UART_ADVFEATURE_TXINVERT_INIT ((uint32_t)0x00000001)
jhon309 0:c52df770855b 421 #define UART_ADVFEATURE_RXINVERT_INIT ((uint32_t)0x00000002)
jhon309 0:c52df770855b 422 #define UART_ADVFEATURE_DATAINVERT_INIT ((uint32_t)0x00000004)
jhon309 0:c52df770855b 423 #define UART_ADVFEATURE_SWAP_INIT ((uint32_t)0x00000008)
jhon309 0:c52df770855b 424 #define UART_ADVFEATURE_RXOVERRUNDISABLE_INIT ((uint32_t)0x00000010)
jhon309 0:c52df770855b 425 #define UART_ADVFEATURE_DMADISABLEONERROR_INIT ((uint32_t)0x00000020)
jhon309 0:c52df770855b 426 #define UART_ADVFEATURE_AUTOBAUDRATE_INIT ((uint32_t)0x00000040)
jhon309 0:c52df770855b 427 #define UART_ADVFEATURE_MSBFIRST_INIT ((uint32_t)0x00000080)
jhon309 0:c52df770855b 428 #define IS_UART_ADVFEATURE_INIT(INIT) ((INIT) <= (UART_ADVFEATURE_NO_INIT | \
jhon309 0:c52df770855b 429 UART_ADVFEATURE_TXINVERT_INIT | \
jhon309 0:c52df770855b 430 UART_ADVFEATURE_RXINVERT_INIT | \
jhon309 0:c52df770855b 431 UART_ADVFEATURE_DATAINVERT_INIT | \
jhon309 0:c52df770855b 432 UART_ADVFEATURE_SWAP_INIT | \
jhon309 0:c52df770855b 433 UART_ADVFEATURE_RXOVERRUNDISABLE_INIT | \
jhon309 0:c52df770855b 434 UART_ADVFEATURE_DMADISABLEONERROR_INIT | \
jhon309 0:c52df770855b 435 UART_ADVFEATURE_AUTOBAUDRATE_INIT | \
jhon309 0:c52df770855b 436 UART_ADVFEATURE_MSBFIRST_INIT))
jhon309 0:c52df770855b 437 /**
jhon309 0:c52df770855b 438 * @}
jhon309 0:c52df770855b 439 */
jhon309 0:c52df770855b 440
jhon309 0:c52df770855b 441 /** @defgroup UART_Tx_Inv UART Advanced Feature TX Pin Active Level Inversion
jhon309 0:c52df770855b 442 * @{
jhon309 0:c52df770855b 443 */
jhon309 0:c52df770855b 444 #define UART_ADVFEATURE_TXINV_DISABLE ((uint32_t)0x00000000)
jhon309 0:c52df770855b 445 #define UART_ADVFEATURE_TXINV_ENABLE ((uint32_t)USART_CR2_TXINV)
jhon309 0:c52df770855b 446 #define IS_UART_ADVFEATURE_TXINV(TXINV) (((TXINV) == UART_ADVFEATURE_TXINV_DISABLE) || \
jhon309 0:c52df770855b 447 ((TXINV) == UART_ADVFEATURE_TXINV_ENABLE))
jhon309 0:c52df770855b 448 /**
jhon309 0:c52df770855b 449 * @}
jhon309 0:c52df770855b 450 */
jhon309 0:c52df770855b 451
jhon309 0:c52df770855b 452 /** @defgroup UART_Rx_Inv UART Advanced Feature RX Pin Active Level Inversion
jhon309 0:c52df770855b 453 * @{
jhon309 0:c52df770855b 454 */
jhon309 0:c52df770855b 455 #define UART_ADVFEATURE_RXINV_DISABLE ((uint32_t)0x00000000)
jhon309 0:c52df770855b 456 #define UART_ADVFEATURE_RXINV_ENABLE ((uint32_t)USART_CR2_RXINV)
jhon309 0:c52df770855b 457 #define IS_UART_ADVFEATURE_RXINV(RXINV) (((RXINV) == UART_ADVFEATURE_RXINV_DISABLE) || \
jhon309 0:c52df770855b 458 ((RXINV) == UART_ADVFEATURE_RXINV_ENABLE))
jhon309 0:c52df770855b 459 /**
jhon309 0:c52df770855b 460 * @}
jhon309 0:c52df770855b 461 */
jhon309 0:c52df770855b 462
jhon309 0:c52df770855b 463 /** @defgroup UART_Data_Inv UART Advanced Feature Binary Data Inversion
jhon309 0:c52df770855b 464 * @{
jhon309 0:c52df770855b 465 */
jhon309 0:c52df770855b 466 #define UART_ADVFEATURE_DATAINV_DISABLE ((uint32_t)0x00000000)
jhon309 0:c52df770855b 467 #define UART_ADVFEATURE_DATAINV_ENABLE ((uint32_t)USART_CR2_DATAINV)
jhon309 0:c52df770855b 468 #define IS_UART_ADVFEATURE_DATAINV(DATAINV) (((DATAINV) == UART_ADVFEATURE_DATAINV_DISABLE) || \
jhon309 0:c52df770855b 469 ((DATAINV) == UART_ADVFEATURE_DATAINV_ENABLE))
jhon309 0:c52df770855b 470 /**
jhon309 0:c52df770855b 471 * @}
jhon309 0:c52df770855b 472 */
jhon309 0:c52df770855b 473
jhon309 0:c52df770855b 474 /** @defgroup UART_Rx_Tx_Swap UART Advanced Feature RX TX Pins Swap
jhon309 0:c52df770855b 475 * @{
jhon309 0:c52df770855b 476 */
jhon309 0:c52df770855b 477 #define UART_ADVFEATURE_SWAP_DISABLE ((uint32_t)0x00000000)
jhon309 0:c52df770855b 478 #define UART_ADVFEATURE_SWAP_ENABLE ((uint32_t)USART_CR2_SWAP)
jhon309 0:c52df770855b 479 #define IS_UART_ADVFEATURE_SWAP(SWAP) (((SWAP) == UART_ADVFEATURE_SWAP_DISABLE) || \
jhon309 0:c52df770855b 480 ((SWAP) == UART_ADVFEATURE_SWAP_ENABLE))
jhon309 0:c52df770855b 481 /**
jhon309 0:c52df770855b 482 * @}
jhon309 0:c52df770855b 483 */
jhon309 0:c52df770855b 484
jhon309 0:c52df770855b 485 /** @defgroup UART_Overrun_Disable UART Advanced Feature Overrun Disable
jhon309 0:c52df770855b 486 * @{
jhon309 0:c52df770855b 487 */
jhon309 0:c52df770855b 488 #define UART_ADVFEATURE_OVERRUN_ENABLE ((uint32_t)0x00000000)
jhon309 0:c52df770855b 489 #define UART_ADVFEATURE_OVERRUN_DISABLE ((uint32_t)USART_CR3_OVRDIS)
jhon309 0:c52df770855b 490 #define IS_UART_OVERRUN(OVERRUN) (((OVERRUN) == UART_ADVFEATURE_OVERRUN_ENABLE) || \
jhon309 0:c52df770855b 491 ((OVERRUN) == UART_ADVFEATURE_OVERRUN_DISABLE))
jhon309 0:c52df770855b 492 /**
jhon309 0:c52df770855b 493 * @}
jhon309 0:c52df770855b 494 */
jhon309 0:c52df770855b 495
jhon309 0:c52df770855b 496 /** @defgroup UART_AutoBaudRate_Enable UART Advanced Feature Auto BaudRate Enable
jhon309 0:c52df770855b 497 * @{
jhon309 0:c52df770855b 498 */
jhon309 0:c52df770855b 499 #define UART_ADVFEATURE_AUTOBAUDRATE_DISABLE ((uint32_t)0x00000000)
jhon309 0:c52df770855b 500 #define UART_ADVFEATURE_AUTOBAUDRATE_ENABLE ((uint32_t)USART_CR2_ABREN)
jhon309 0:c52df770855b 501 #define IS_UART_ADVFEATURE_AUTOBAUDRATE(AUTOBAUDRATE) (((AUTOBAUDRATE) == UART_ADVFEATURE_AUTOBAUDRATE_DISABLE) || \
jhon309 0:c52df770855b 502 ((AUTOBAUDRATE) == UART_ADVFEATURE_AUTOBAUDRATE_ENABLE))
jhon309 0:c52df770855b 503 /**
jhon309 0:c52df770855b 504 * @}
jhon309 0:c52df770855b 505 */
jhon309 0:c52df770855b 506
jhon309 0:c52df770855b 507 /** @defgroup UART_DMA_Disable_on_Rx_Error UART Advanced Feature DMA Disable On Rx Error
jhon309 0:c52df770855b 508 * @{
jhon309 0:c52df770855b 509 */
jhon309 0:c52df770855b 510 #define UART_ADVFEATURE_DMA_ENABLEONRXERROR ((uint32_t)0x00000000)
jhon309 0:c52df770855b 511 #define UART_ADVFEATURE_DMA_DISABLEONRXERROR ((uint32_t)USART_CR3_DDRE)
jhon309 0:c52df770855b 512 #define IS_UART_ADVFEATURE_DMAONRXERROR(DMA) (((DMA) == UART_ADVFEATURE_DMA_ENABLEONRXERROR) || \
jhon309 0:c52df770855b 513 ((DMA) == UART_ADVFEATURE_DMA_DISABLEONRXERROR))
jhon309 0:c52df770855b 514 /**
jhon309 0:c52df770855b 515 * @}
jhon309 0:c52df770855b 516 */
jhon309 0:c52df770855b 517
jhon309 0:c52df770855b 518 /** @defgroup UART_MSB_First UART Advanced Feature MSB First
jhon309 0:c52df770855b 519 * @{
jhon309 0:c52df770855b 520 */
jhon309 0:c52df770855b 521 #define UART_ADVFEATURE_MSBFIRST_DISABLE ((uint32_t)0x00000000)
jhon309 0:c52df770855b 522 #define UART_ADVFEATURE_MSBFIRST_ENABLE ((uint32_t)USART_CR2_MSBFIRST)
jhon309 0:c52df770855b 523 #define IS_UART_ADVFEATURE_MSBFIRST(MSBFIRST) (((MSBFIRST) == UART_ADVFEATURE_MSBFIRST_DISABLE) || \
jhon309 0:c52df770855b 524 ((MSBFIRST) == UART_ADVFEATURE_MSBFIRST_ENABLE))
jhon309 0:c52df770855b 525 /**
jhon309 0:c52df770855b 526 * @}
jhon309 0:c52df770855b 527 */
jhon309 0:c52df770855b 528
jhon309 0:c52df770855b 529 /** @defgroup UART_Mute_Mode UART Advanced Feature Mute Mode Enable
jhon309 0:c52df770855b 530 * @{
jhon309 0:c52df770855b 531 */
jhon309 0:c52df770855b 532 #define UART_ADVFEATURE_MUTEMODE_DISABLE ((uint32_t)0x00000000)
jhon309 0:c52df770855b 533 #define UART_ADVFEATURE_MUTEMODE_ENABLE ((uint32_t)USART_CR1_MME)
jhon309 0:c52df770855b 534 #define IS_UART_MUTE_MODE(MUTE) (((MUTE) == UART_ADVFEATURE_MUTEMODE_DISABLE) || \
jhon309 0:c52df770855b 535 ((MUTE) == UART_ADVFEATURE_MUTEMODE_ENABLE))
jhon309 0:c52df770855b 536 /**
jhon309 0:c52df770855b 537 * @}
jhon309 0:c52df770855b 538 */
jhon309 0:c52df770855b 539
jhon309 0:c52df770855b 540 /** @defgroup UART_CR2_ADDRESS_LSB_POS UART Address-matching LSB Position In CR2 Register
jhon309 0:c52df770855b 541 * @{
jhon309 0:c52df770855b 542 */
jhon309 0:c52df770855b 543 #define UART_CR2_ADDRESS_LSB_POS ((uint32_t) 24)
jhon309 0:c52df770855b 544 /**
jhon309 0:c52df770855b 545 * @}
jhon309 0:c52df770855b 546 */
jhon309 0:c52df770855b 547
jhon309 0:c52df770855b 548 /** @defgroup UART_DriverEnable_Polarity UART DriverEnable Polarity
jhon309 0:c52df770855b 549 * @{
jhon309 0:c52df770855b 550 */
jhon309 0:c52df770855b 551 #define UART_DE_POLARITY_HIGH ((uint32_t)0x00000000)
jhon309 0:c52df770855b 552 #define UART_DE_POLARITY_LOW ((uint32_t)USART_CR3_DEP)
jhon309 0:c52df770855b 553 #define IS_UART_DE_POLARITY(POLARITY) (((POLARITY) == UART_DE_POLARITY_HIGH) || \
jhon309 0:c52df770855b 554 ((POLARITY) == UART_DE_POLARITY_LOW))
jhon309 0:c52df770855b 555 /**
jhon309 0:c52df770855b 556 * @}
jhon309 0:c52df770855b 557 */
jhon309 0:c52df770855b 558
jhon309 0:c52df770855b 559 /** @defgroup UART_CR1_DEAT_ADDRESS_LSB_POS UART Driver Enable Assertion Time LSB Position In CR1 Register
jhon309 0:c52df770855b 560 * @{
jhon309 0:c52df770855b 561 */
jhon309 0:c52df770855b 562 #define UART_CR1_DEAT_ADDRESS_LSB_POS ((uint32_t) 21)
jhon309 0:c52df770855b 563 /**
jhon309 0:c52df770855b 564 * @}
jhon309 0:c52df770855b 565 */
jhon309 0:c52df770855b 566
jhon309 0:c52df770855b 567 /** @defgroup UART_CR1_DEDT_ADDRESS_LSB_POS UART Driver Enable DeAssertion Time LSB Position In CR1 Register
jhon309 0:c52df770855b 568 * @{
jhon309 0:c52df770855b 569 */
jhon309 0:c52df770855b 570 #define UART_CR1_DEDT_ADDRESS_LSB_POS ((uint32_t) 16)
jhon309 0:c52df770855b 571 /**
jhon309 0:c52df770855b 572 * @}
jhon309 0:c52df770855b 573 */
jhon309 0:c52df770855b 574
jhon309 0:c52df770855b 575 /** @defgroup UART_Interruption_Mask UART Interruptions Flag Mask
jhon309 0:c52df770855b 576 * @{
jhon309 0:c52df770855b 577 */
jhon309 0:c52df770855b 578 #define UART_IT_MASK ((uint32_t)0x001F)
jhon309 0:c52df770855b 579 /**
jhon309 0:c52df770855b 580 * @}
jhon309 0:c52df770855b 581 */
jhon309 0:c52df770855b 582
jhon309 0:c52df770855b 583 /** @defgroup UART_TimeOut_Value UART polling-based communications time-out value
jhon309 0:c52df770855b 584 * @{
jhon309 0:c52df770855b 585 */
jhon309 0:c52df770855b 586 #define HAL_UART_TIMEOUT_VALUE 0x1FFFFFF
jhon309 0:c52df770855b 587 /**
jhon309 0:c52df770855b 588 * @}
jhon309 0:c52df770855b 589 */
jhon309 0:c52df770855b 590
jhon309 0:c52df770855b 591 /**
jhon309 0:c52df770855b 592 * @}
jhon309 0:c52df770855b 593 */
jhon309 0:c52df770855b 594
jhon309 0:c52df770855b 595 /* Exported macro ------------------------------------------------------------*/
jhon309 0:c52df770855b 596 /** @defgroup UART_Exported_Macros UART Exported Macros
jhon309 0:c52df770855b 597 * @{
jhon309 0:c52df770855b 598 */
jhon309 0:c52df770855b 599
jhon309 0:c52df770855b 600 /** @brief Reset UART handle state
jhon309 0:c52df770855b 601 * @param __HANDLE__: UART handle.
jhon309 0:c52df770855b 602 * @retval None
jhon309 0:c52df770855b 603 */
jhon309 0:c52df770855b 604 #define __HAL_UART_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_UART_STATE_RESET)
jhon309 0:c52df770855b 605
jhon309 0:c52df770855b 606 /** @brief Checks whether the specified UART flag is set or not.
jhon309 0:c52df770855b 607 * @param __HANDLE__: specifies the UART Handle.
jhon309 0:c52df770855b 608 * This parameter can be UARTx where x: 1, 2, 3 or 4 to select the USART or
jhon309 0:c52df770855b 609 * UART peripheral (datasheet: up to four USART/UARTs)
jhon309 0:c52df770855b 610 * @param __FLAG__: specifies the flag to check.
jhon309 0:c52df770855b 611 * This parameter can be one of the following values:
jhon309 0:c52df770855b 612 * @arg UART_FLAG_REACK: Receive enable ackowledge flag
jhon309 0:c52df770855b 613 * @arg UART_FLAG_TEACK: Transmit enable ackowledge flag
jhon309 0:c52df770855b 614 * @arg UART_FLAG_WUF: Wake up from stop mode flag (not available on F030xx devices)
jhon309 0:c52df770855b 615 * @arg UART_FLAG_RWU: Receiver wake up flag (not available on F030xx devices)
jhon309 0:c52df770855b 616 * @arg UART_FLAG_SBKF: Send Break flag
jhon309 0:c52df770855b 617 * @arg UART_FLAG_CMF: Character match flag
jhon309 0:c52df770855b 618 * @arg UART_FLAG_BUSY: Busy flag
jhon309 0:c52df770855b 619 * @arg UART_FLAG_ABRF: Auto Baud rate detection flag
jhon309 0:c52df770855b 620 * @arg UART_FLAG_ABRE: Auto Baud rate detection error flag
jhon309 0:c52df770855b 621 * @arg UART_FLAG_EOBF: End of block flag (not available on F030xx devices)
jhon309 0:c52df770855b 622 * @arg UART_FLAG_RTOF: Receiver timeout flag
jhon309 0:c52df770855b 623 * @arg UART_FLAG_CTS: CTS Change flag
jhon309 0:c52df770855b 624 * @arg UART_FLAG_LBD: LIN Break detection flag (not available on F030xx devices)
jhon309 0:c52df770855b 625 * @arg UART_FLAG_TXE: Transmit data register empty flag
jhon309 0:c52df770855b 626 * @arg UART_FLAG_TC: Transmission Complete flag
jhon309 0:c52df770855b 627 * @arg UART_FLAG_RXNE: Receive data register not empty flag
jhon309 0:c52df770855b 628 * @arg UART_FLAG_IDLE: Idle Line detection flag
jhon309 0:c52df770855b 629 * @arg UART_FLAG_ORE: OverRun Error flag
jhon309 0:c52df770855b 630 * @arg UART_FLAG_NE: Noise Error flag
jhon309 0:c52df770855b 631 * @arg UART_FLAG_FE: Framing Error flag
jhon309 0:c52df770855b 632 * @arg UART_FLAG_PE: Parity Error flag
jhon309 0:c52df770855b 633 * @retval The new state of __FLAG__ (TRUE or FALSE).
jhon309 0:c52df770855b 634 */
jhon309 0:c52df770855b 635 #define __HAL_UART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))
jhon309 0:c52df770855b 636
jhon309 0:c52df770855b 637 /** @brief Enables the specified UART interrupt.
jhon309 0:c52df770855b 638 * @param __HANDLE__: specifies the UART Handle.
jhon309 0:c52df770855b 639 * This parameter can be UARTx where x: 1, 2, 3 or 4 to select the USART or
jhon309 0:c52df770855b 640 * UART peripheral. (datasheet: up to four USART/UARTs)
jhon309 0:c52df770855b 641 * @param __INTERRUPT__: specifies the UART interrupt source to enable.
jhon309 0:c52df770855b 642 * This parameter can be one of the following values:
jhon309 0:c52df770855b 643 * @arg UART_IT_WUF: Wakeup from stop mode interrupt (not available on F030xx devices)
jhon309 0:c52df770855b 644 * @arg UART_IT_CM: Character match interrupt
jhon309 0:c52df770855b 645 * @arg UART_IT_CTS: CTS change interrupt
jhon309 0:c52df770855b 646 * @arg UART_IT_LBD: LIN Break detection interrupt (not available on F030xx devices)
jhon309 0:c52df770855b 647 * @arg UART_IT_TXE: Transmit Data Register empty interrupt
jhon309 0:c52df770855b 648 * @arg UART_IT_TC: Transmission complete interrupt
jhon309 0:c52df770855b 649 * @arg UART_IT_RXNE: Receive Data register not empty interrupt
jhon309 0:c52df770855b 650 * @arg UART_IT_IDLE: Idle line detection interrupt
jhon309 0:c52df770855b 651 * @arg UART_IT_PE: Parity Error interrupt
jhon309 0:c52df770855b 652 * @arg UART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
jhon309 0:c52df770855b 653 * @retval None
jhon309 0:c52df770855b 654 */
jhon309 0:c52df770855b 655 #define __HAL_UART_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 |= (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
jhon309 0:c52df770855b 656 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 |= (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
jhon309 0:c52df770855b 657 ((__HANDLE__)->Instance->CR3 |= (1U << ((__INTERRUPT__) & UART_IT_MASK))))
jhon309 0:c52df770855b 658
jhon309 0:c52df770855b 659
jhon309 0:c52df770855b 660 /** @brief Disables the specified UART interrupt.
jhon309 0:c52df770855b 661 * @param __HANDLE__: specifies the UART Handle.
jhon309 0:c52df770855b 662 * This parameter can be UARTx where x: 1, 2, 3 or 4 to select the USART or
jhon309 0:c52df770855b 663 * UART peripheral. (datasheet: up to four USART/UARTs)
jhon309 0:c52df770855b 664 * @param __INTERRUPT__: specifies the UART interrupt source to disable.
jhon309 0:c52df770855b 665 * This parameter can be one of the following values:
jhon309 0:c52df770855b 666 * @arg UART_IT_WUF: Wakeup from stop mode interrupt (not available on F030xx devices)
jhon309 0:c52df770855b 667 * @arg UART_IT_CM: Character match interrupt
jhon309 0:c52df770855b 668 * @arg UART_IT_CTS: CTS change interrupt
jhon309 0:c52df770855b 669 * @arg UART_IT_LBD: LIN Break detection interrupt (not available on F030xx devices)
jhon309 0:c52df770855b 670 * @arg UART_IT_TXE: Transmit Data Register empty interrupt
jhon309 0:c52df770855b 671 * @arg UART_IT_TC: Transmission complete interrupt
jhon309 0:c52df770855b 672 * @arg UART_IT_RXNE: Receive Data register not empty interrupt
jhon309 0:c52df770855b 673 * @arg UART_IT_IDLE: Idle line detection interrupt
jhon309 0:c52df770855b 674 * @arg UART_IT_PE: Parity Error interrupt
jhon309 0:c52df770855b 675 * @arg UART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
jhon309 0:c52df770855b 676 * @retval None
jhon309 0:c52df770855b 677 */
jhon309 0:c52df770855b 678 #define __HAL_UART_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 &= ~ (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
jhon309 0:c52df770855b 679 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 &= ~ (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
jhon309 0:c52df770855b 680 ((__HANDLE__)->Instance->CR3 &= ~ (1U << ((__INTERRUPT__) & UART_IT_MASK))))
jhon309 0:c52df770855b 681
jhon309 0:c52df770855b 682 /** @brief Checks whether the specified UART interrupt has occurred or not.
jhon309 0:c52df770855b 683 * @param __HANDLE__: specifies the UART Handle.
jhon309 0:c52df770855b 684 * This parameter can be UARTx where x: 1, 2, 3 or 4 to select the USART or
jhon309 0:c52df770855b 685 * UART peripheral. (datasheet: up to four USART/UARTs)
jhon309 0:c52df770855b 686 * @param __IT__: specifies the UART interrupt to check.
jhon309 0:c52df770855b 687 * This parameter can be one of the following values:
jhon309 0:c52df770855b 688 * @arg UART_IT_WUF: Wakeup from stop mode interrupt (not available on F030xx devices)
jhon309 0:c52df770855b 689 * @arg UART_IT_CM: Character match interrupt
jhon309 0:c52df770855b 690 * @arg UART_IT_CTS: CTS change interrupt
jhon309 0:c52df770855b 691 * @arg UART_IT_LBD: LIN Break detection interrupt (not available on F030xx devices)
jhon309 0:c52df770855b 692 * @arg UART_IT_TXE: Transmit Data Register empty interrupt
jhon309 0:c52df770855b 693 * @arg UART_IT_TC: Transmission complete interrupt
jhon309 0:c52df770855b 694 * @arg UART_IT_RXNE: Receive Data register not empty interrupt
jhon309 0:c52df770855b 695 * @arg UART_IT_IDLE: Idle line detection interrupt
jhon309 0:c52df770855b 696 * @arg UART_IT_ORE: OverRun Error interrupt
jhon309 0:c52df770855b 697 * @arg UART_IT_NE: Noise Error interrupt
jhon309 0:c52df770855b 698 * @arg UART_IT_FE: Framing Error interrupt
jhon309 0:c52df770855b 699 * @arg UART_IT_PE: Parity Error interrupt
jhon309 0:c52df770855b 700 * @retval The new state of __IT__ (TRUE or FALSE).
jhon309 0:c52df770855b 701 */
jhon309 0:c52df770855b 702 #define __HAL_UART_GET_IT(__HANDLE__, __IT__) ((__HANDLE__)->Instance->ISR & ((uint32_t)1 << ((__IT__)>> 0x08)))
jhon309 0:c52df770855b 703
jhon309 0:c52df770855b 704 /** @brief Checks whether the specified UART interrupt source is enabled.
jhon309 0:c52df770855b 705 * @param __HANDLE__: specifies the UART Handle.
jhon309 0:c52df770855b 706 * This parameter can be UARTx where x: 1, 2, 3 or 4 to select the USART or
jhon309 0:c52df770855b 707 * UART peripheral. (datasheet: up to four USART/UARTs)
jhon309 0:c52df770855b 708 * @param __IT__: specifies the UART interrupt source to check.
jhon309 0:c52df770855b 709 * This parameter can be one of the following values:
jhon309 0:c52df770855b 710 * @arg UART_IT_WUF: Wakeup from stop mode interrupt (not available on F030xx devices)
jhon309 0:c52df770855b 711 * @arg UART_IT_CM: Character match interrupt
jhon309 0:c52df770855b 712 * @arg UART_IT_CTS: CTS change interrupt
jhon309 0:c52df770855b 713 * @arg UART_IT_LBD: LIN Break detection interrupt (not available on F030xx devices)
jhon309 0:c52df770855b 714 * @arg UART_IT_TXE: Transmit Data Register empty interrupt
jhon309 0:c52df770855b 715 * @arg UART_IT_TC: Transmission complete interrupt
jhon309 0:c52df770855b 716 * @arg UART_IT_RXNE: Receive Data register not empty interrupt
jhon309 0:c52df770855b 717 * @arg UART_IT_IDLE: Idle line detection interrupt
jhon309 0:c52df770855b 718 * @arg UART_IT_ORE: OverRun Error interrupt
jhon309 0:c52df770855b 719 * @arg UART_IT_NE: Noise Error interrupt
jhon309 0:c52df770855b 720 * @arg UART_IT_FE: Framing Error interrupt
jhon309 0:c52df770855b 721 * @arg UART_IT_PE: Parity Error interrupt
jhon309 0:c52df770855b 722 * @retval The new state of __IT__ (TRUE or FALSE).
jhon309 0:c52df770855b 723 */
jhon309 0:c52df770855b 724 #define __HAL_UART_GET_IT_SOURCE(__HANDLE__, __IT__) ((((((uint8_t)(__IT__)) >> 5U) == 1)? (__HANDLE__)->Instance->CR1:(((((uint8_t)(__IT__)) >> 5U) == 2)? \
jhon309 0:c52df770855b 725 (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & ((uint32_t)1 << (((uint16_t)(__IT__)) & UART_IT_MASK)))
jhon309 0:c52df770855b 726
jhon309 0:c52df770855b 727 /** @brief Clears the specified UART ISR flag, in setting the proper ICR register flag.
jhon309 0:c52df770855b 728 * @param __HANDLE__: specifies the UART Handle.
jhon309 0:c52df770855b 729 * This parameter can be UARTx where x: 1, 2, 3 or 4 to select the USART or
jhon309 0:c52df770855b 730 * UART peripheral. (datasheet: up to four USART/UARTs)
jhon309 0:c52df770855b 731 * @param __IT_CLEAR__: specifies the interrupt clear register flag that needs to be set
jhon309 0:c52df770855b 732 * to clear the corresponding interrupt
jhon309 0:c52df770855b 733 * This parameter can be one of the following values:
jhon309 0:c52df770855b 734 * @arg UART_CLEAR_PEF: Parity Error Clear Flag
jhon309 0:c52df770855b 735 * @arg UART_CLEAR_FEF: Framing Error Clear Flag
jhon309 0:c52df770855b 736 * @arg UART_CLEAR_NEF: Noise detected Clear Flag
jhon309 0:c52df770855b 737 * @arg UART_CLEAR_OREF: OverRun Error Clear Flag
jhon309 0:c52df770855b 738 * @arg UART_CLEAR_IDLEF: IDLE line detected Clear Flag
jhon309 0:c52df770855b 739 * @arg UART_CLEAR_TCF: Transmission Complete Clear Flag
jhon309 0:c52df770855b 740 * @arg UART_CLEAR_LBDF: LIN Break Detection Clear Flag (not available on F030xx devices)
jhon309 0:c52df770855b 741 * @arg UART_CLEAR_CTSF: CTS Interrupt Clear Flag
jhon309 0:c52df770855b 742 * @arg UART_CLEAR_RTOF: Receiver Time Out Clear Flag
jhon309 0:c52df770855b 743 * @arg UART_CLEAR_EOBF: End Of Block Clear Flag (not available on F030xx devices)
jhon309 0:c52df770855b 744 * @arg UART_CLEAR_CMF: Character Match Clear Flag
jhon309 0:c52df770855b 745 * @arg UART_CLEAR_WUF: Wake Up from stop mode Clear Flag (not available on F030xx devices)
jhon309 0:c52df770855b 746 * @retval None
jhon309 0:c52df770855b 747 */
jhon309 0:c52df770855b 748 #define __HAL_UART_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__))
jhon309 0:c52df770855b 749
jhon309 0:c52df770855b 750 /** @brief Set a specific UART request flag.
jhon309 0:c52df770855b 751 * @param __HANDLE__: specifies the UART Handle.
jhon309 0:c52df770855b 752 * This parameter can be UARTx where x: 1, 2, 3 or 4 to select the USART or
jhon309 0:c52df770855b 753 * UART peripheral. (datasheet: up to four USART/UARTs)
jhon309 0:c52df770855b 754 * @param __REQ__: specifies the request flag to set
jhon309 0:c52df770855b 755 * This parameter can be one of the following values:
jhon309 0:c52df770855b 756 * @arg UART_AUTOBAUD_REQUEST: Auto-Baud Rate Request
jhon309 0:c52df770855b 757 * @arg UART_SENDBREAK_REQUEST: Send Break Request
jhon309 0:c52df770855b 758 * @arg UART_MUTE_MODE_REQUEST: Mute Mode Request
jhon309 0:c52df770855b 759 * @arg UART_RXDATA_FLUSH_REQUEST: Receive Data flush Request
jhon309 0:c52df770855b 760 * @arg UART_TXDATA_FLUSH_REQUEST: Transmit data flush Request (not available on F030xx devices)
jhon309 0:c52df770855b 761 * @retval None
jhon309 0:c52df770855b 762 */
jhon309 0:c52df770855b 763 #define __HAL_UART_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (uint16_t)(__REQ__))
jhon309 0:c52df770855b 764
jhon309 0:c52df770855b 765 /** @brief Enable UART
jhon309 0:c52df770855b 766 * @param __HANDLE__: specifies the UART Handle.
jhon309 0:c52df770855b 767 * The Handle Instance can be UARTx where x: 1, 2, 3, 4 or 5 to select the UART peripheral
jhon309 0:c52df770855b 768 * @retval None
jhon309 0:c52df770855b 769 */
jhon309 0:c52df770855b 770 #define __HAL_UART_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
jhon309 0:c52df770855b 771
jhon309 0:c52df770855b 772 /** @brief Disable UART
jhon309 0:c52df770855b 773 * @param __HANDLE__: specifies the UART Handle.
jhon309 0:c52df770855b 774 * The Handle Instance can be UARTx where x: 1, 2, 3, 4 or 5 to select the UART peripheral
jhon309 0:c52df770855b 775 * @retval None
jhon309 0:c52df770855b 776 */
jhon309 0:c52df770855b 777 #define __HAL_UART_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
jhon309 0:c52df770855b 778
jhon309 0:c52df770855b 779 /**
jhon309 0:c52df770855b 780 * @}
jhon309 0:c52df770855b 781 */
jhon309 0:c52df770855b 782
jhon309 0:c52df770855b 783 /* Private macros --------------------------------------------------------*/
jhon309 0:c52df770855b 784 /** @defgroup UART_Private_Macros UART Private Macros
jhon309 0:c52df770855b 785 * @{
jhon309 0:c52df770855b 786 */
jhon309 0:c52df770855b 787
jhon309 0:c52df770855b 788 /** @brief BRR division operation to set BRR register in 8-bit oversampling mode
jhon309 0:c52df770855b 789 * @param _PCLK_: UART clock
jhon309 0:c52df770855b 790 * @param _BAUD_: Baud rate set by the user
jhon309 0:c52df770855b 791 * @retval Division result
jhon309 0:c52df770855b 792 */
jhon309 0:c52df770855b 793 #define __DIV_SAMPLING8(_PCLK_, _BAUD_) (((_PCLK_)*2)/((_BAUD_)))
jhon309 0:c52df770855b 794
jhon309 0:c52df770855b 795 /** @brief BRR division operation to set BRR register in 16-bit oversampling mode
jhon309 0:c52df770855b 796 * @param _PCLK_: UART clock
jhon309 0:c52df770855b 797 * @param _BAUD_: Baud rate set by the user
jhon309 0:c52df770855b 798 * @retval Division result
jhon309 0:c52df770855b 799 */
jhon309 0:c52df770855b 800 #define __DIV_SAMPLING16(_PCLK_, _BAUD_) (((_PCLK_))/((_BAUD_)))
jhon309 0:c52df770855b 801
jhon309 0:c52df770855b 802 /** @brief Check UART Baud rate
jhon309 0:c52df770855b 803 * @param BAUDRATE: Baudrate specified by the user
jhon309 0:c52df770855b 804 * The maximum Baud Rate is derived from the maximum clock on F0 (i.e. 48 MHz)
jhon309 0:c52df770855b 805 * divided by the smallest oversampling used on the USART (i.e. 8)
jhon309 0:c52df770855b 806 * @retval Test result (TRUE or FALSE).
jhon309 0:c52df770855b 807 */
jhon309 0:c52df770855b 808 #define IS_UART_BAUDRATE(BAUDRATE) ((BAUDRATE) < 9000001)
jhon309 0:c52df770855b 809
jhon309 0:c52df770855b 810 /** @brief Check UART assertion time
jhon309 0:c52df770855b 811 * @param TIME: 5-bit value assertion time
jhon309 0:c52df770855b 812 * @retval Test result (TRUE or FALSE).
jhon309 0:c52df770855b 813 */
jhon309 0:c52df770855b 814 #define IS_UART_ASSERTIONTIME(TIME) ((TIME) <= 0x1F)
jhon309 0:c52df770855b 815
jhon309 0:c52df770855b 816 /** @brief Check UART deassertion time
jhon309 0:c52df770855b 817 * @param TIME: 5-bit value deassertion time
jhon309 0:c52df770855b 818 * @retval Test result (TRUE or FALSE).
jhon309 0:c52df770855b 819 */
jhon309 0:c52df770855b 820 #define IS_UART_DEASSERTIONTIME(TIME) ((TIME) <= 0x1F)
jhon309 0:c52df770855b 821
jhon309 0:c52df770855b 822 /**
jhon309 0:c52df770855b 823 * @}
jhon309 0:c52df770855b 824 */
jhon309 0:c52df770855b 825
jhon309 0:c52df770855b 826 /* Include UART HAL Extension module */
jhon309 0:c52df770855b 827 #include "stm32f0xx_hal_uart_ex.h"
jhon309 0:c52df770855b 828
jhon309 0:c52df770855b 829 /* Exported functions --------------------------------------------------------*/
jhon309 0:c52df770855b 830
jhon309 0:c52df770855b 831 /** @addtogroup UART_Exported_Functions UART Exported Functions
jhon309 0:c52df770855b 832 * @{
jhon309 0:c52df770855b 833 */
jhon309 0:c52df770855b 834
jhon309 0:c52df770855b 835 /** @addtogroup UART_Exported_Functions_Group1 Initialization and de-initialization functions
jhon309 0:c52df770855b 836 * @{
jhon309 0:c52df770855b 837 */
jhon309 0:c52df770855b 838
jhon309 0:c52df770855b 839 /* Initialization and de-initialization functions ****************************/
jhon309 0:c52df770855b 840 HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart);
jhon309 0:c52df770855b 841 HAL_StatusTypeDef HAL_HalfDuplex_Init(UART_HandleTypeDef *huart);
jhon309 0:c52df770855b 842 HAL_StatusTypeDef HAL_MultiProcessor_Init(UART_HandleTypeDef *huart, uint8_t Address, uint32_t WakeUpMethod);
jhon309 0:c52df770855b 843 HAL_StatusTypeDef HAL_UART_DeInit (UART_HandleTypeDef *huart);
jhon309 0:c52df770855b 844 void HAL_UART_MspInit(UART_HandleTypeDef *huart);
jhon309 0:c52df770855b 845 void HAL_UART_MspDeInit(UART_HandleTypeDef *huart);
jhon309 0:c52df770855b 846
jhon309 0:c52df770855b 847 /**
jhon309 0:c52df770855b 848 * @}
jhon309 0:c52df770855b 849 */
jhon309 0:c52df770855b 850
jhon309 0:c52df770855b 851 /** @addtogroup UART_Exported_Functions_Group2 IO operation functions
jhon309 0:c52df770855b 852 * @{
jhon309 0:c52df770855b 853 */
jhon309 0:c52df770855b 854
jhon309 0:c52df770855b 855 /* IO operation functions *****************************************************/
jhon309 0:c52df770855b 856 HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
jhon309 0:c52df770855b 857 HAL_StatusTypeDef HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
jhon309 0:c52df770855b 858 HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
jhon309 0:c52df770855b 859 HAL_StatusTypeDef HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
jhon309 0:c52df770855b 860 HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
jhon309 0:c52df770855b 861 HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
jhon309 0:c52df770855b 862 HAL_StatusTypeDef HAL_UART_DMAPause(UART_HandleTypeDef *huart);
jhon309 0:c52df770855b 863 HAL_StatusTypeDef HAL_UART_DMAResume(UART_HandleTypeDef *huart);
jhon309 0:c52df770855b 864 HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart);
jhon309 0:c52df770855b 865 void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart);
jhon309 0:c52df770855b 866 void HAL_UART_TxHalfCpltCallback(UART_HandleTypeDef *huart);
jhon309 0:c52df770855b 867 void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart);
jhon309 0:c52df770855b 868 void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart);
jhon309 0:c52df770855b 869 void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart);
jhon309 0:c52df770855b 870
jhon309 0:c52df770855b 871 /**
jhon309 0:c52df770855b 872 * @}
jhon309 0:c52df770855b 873 */
jhon309 0:c52df770855b 874
jhon309 0:c52df770855b 875 /** @addtogroup UART_Exported_Functions_Group3 Peripheral Control functions
jhon309 0:c52df770855b 876 * @{
jhon309 0:c52df770855b 877 */
jhon309 0:c52df770855b 878
jhon309 0:c52df770855b 879 /* Peripheral Control functions ***********************************************/
jhon309 0:c52df770855b 880 void HAL_MultiProcessor_EnterMuteMode(UART_HandleTypeDef *huart);
jhon309 0:c52df770855b 881 HAL_StatusTypeDef HAL_MultiProcessor_EnableMuteMode(UART_HandleTypeDef *huart);
jhon309 0:c52df770855b 882 HAL_StatusTypeDef HAL_MultiProcessor_DisableMuteMode(UART_HandleTypeDef *huart);
jhon309 0:c52df770855b 883 HAL_StatusTypeDef HAL_HalfDuplex_EnableTransmitter(UART_HandleTypeDef *huart);
jhon309 0:c52df770855b 884 HAL_StatusTypeDef HAL_HalfDuplex_EnableReceiver(UART_HandleTypeDef *huart);
jhon309 0:c52df770855b 885
jhon309 0:c52df770855b 886 /**
jhon309 0:c52df770855b 887 * @}
jhon309 0:c52df770855b 888 */
jhon309 0:c52df770855b 889
jhon309 0:c52df770855b 890 /** @addtogroup UART_Exported_Functions_Group4 Peripheral State and Errors functions
jhon309 0:c52df770855b 891 * @{
jhon309 0:c52df770855b 892 */
jhon309 0:c52df770855b 893
jhon309 0:c52df770855b 894 /* Peripheral State and Errors functions **************************************************/
jhon309 0:c52df770855b 895 HAL_UART_StateTypeDef HAL_UART_GetState(UART_HandleTypeDef *huart);
jhon309 0:c52df770855b 896 uint32_t HAL_UART_GetError(UART_HandleTypeDef *huart);
jhon309 0:c52df770855b 897
jhon309 0:c52df770855b 898 /**
jhon309 0:c52df770855b 899 * @}
jhon309 0:c52df770855b 900 */
jhon309 0:c52df770855b 901
jhon309 0:c52df770855b 902 /**
jhon309 0:c52df770855b 903 * @}
jhon309 0:c52df770855b 904 */
jhon309 0:c52df770855b 905
jhon309 0:c52df770855b 906 /** @addtogroup UART_Private_Functions
jhon309 0:c52df770855b 907 * @{
jhon309 0:c52df770855b 908 */
jhon309 0:c52df770855b 909 void UART_AdvFeatureConfig(UART_HandleTypeDef *huart);
jhon309 0:c52df770855b 910 HAL_StatusTypeDef UART_CheckIdleState(UART_HandleTypeDef *huart);
jhon309 0:c52df770855b 911 HAL_StatusTypeDef UART_SetConfig(UART_HandleTypeDef *huart);
jhon309 0:c52df770855b 912 HAL_StatusTypeDef UART_Transmit_IT(UART_HandleTypeDef *huart);
jhon309 0:c52df770855b 913 HAL_StatusTypeDef UART_Receive_IT(UART_HandleTypeDef *huart);
jhon309 0:c52df770855b 914 HAL_StatusTypeDef UART_WaitOnFlagUntilTimeout(UART_HandleTypeDef *huart, uint32_t Flag, FlagStatus Status, uint32_t Timeout);
jhon309 0:c52df770855b 915 /**
jhon309 0:c52df770855b 916 * @}
jhon309 0:c52df770855b 917 */
jhon309 0:c52df770855b 918
jhon309 0:c52df770855b 919 /**
jhon309 0:c52df770855b 920 * @}
jhon309 0:c52df770855b 921 */
jhon309 0:c52df770855b 922
jhon309 0:c52df770855b 923 /**
jhon309 0:c52df770855b 924 * @}
jhon309 0:c52df770855b 925 */
jhon309 0:c52df770855b 926
jhon309 0:c52df770855b 927 #ifdef __cplusplus
jhon309 0:c52df770855b 928 }
jhon309 0:c52df770855b 929 #endif
jhon309 0:c52df770855b 930
jhon309 0:c52df770855b 931 #endif /* __STM32F0xx_HAL_UART_H */
jhon309 0:c52df770855b 932
jhon309 0:c52df770855b 933 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
jhon309 0:c52df770855b 934