I2C_EEPROM

Committer:
jhon309
Date:
Thu Aug 13 00:23:16 2015 +0000
Revision:
0:ac8863619623
I2C

Who changed what in which revision?

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