Hal Drivers for L4

Dependents:   BSP OneHopeOnePrayer FINAL_AUDIO_RECORD AudioDemo

Fork of STM32L4xx_HAL_Driver by Senior Design: Sound Monitor

Committer:
EricLew
Date:
Mon Nov 02 19:37:23 2015 +0000
Revision:
0:80ee8f3b695e
Errors are with definitions of LCD and QSPI functions. I believe all .h and .c files are  uploaded, but there may need to be certain functions called.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
EricLew 0:80ee8f3b695e 1 /**
EricLew 0:80ee8f3b695e 2 ******************************************************************************
EricLew 0:80ee8f3b695e 3 * @file stm32l4xx_hal_uart.h
EricLew 0:80ee8f3b695e 4 * @author MCD Application Team
EricLew 0:80ee8f3b695e 5 * @version V1.1.0
EricLew 0:80ee8f3b695e 6 * @date 16-September-2015
EricLew 0:80ee8f3b695e 7 * @brief Header file of UART HAL module.
EricLew 0:80ee8f3b695e 8 ******************************************************************************
EricLew 0:80ee8f3b695e 9 * @attention
EricLew 0:80ee8f3b695e 10 *
EricLew 0:80ee8f3b695e 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
EricLew 0:80ee8f3b695e 12 *
EricLew 0:80ee8f3b695e 13 * Redistribution and use in source and binary forms, with or without modification,
EricLew 0:80ee8f3b695e 14 * are permitted provided that the following conditions are met:
EricLew 0:80ee8f3b695e 15 * 1. Redistributions of source code must retain the above copyright notice,
EricLew 0:80ee8f3b695e 16 * this list of conditions and the following disclaimer.
EricLew 0:80ee8f3b695e 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
EricLew 0:80ee8f3b695e 18 * this list of conditions and the following disclaimer in the documentation
EricLew 0:80ee8f3b695e 19 * and/or other materials provided with the distribution.
EricLew 0:80ee8f3b695e 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
EricLew 0:80ee8f3b695e 21 * may be used to endorse or promote products derived from this software
EricLew 0:80ee8f3b695e 22 * without specific prior written permission.
EricLew 0:80ee8f3b695e 23 *
EricLew 0:80ee8f3b695e 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
EricLew 0:80ee8f3b695e 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
EricLew 0:80ee8f3b695e 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
EricLew 0:80ee8f3b695e 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
EricLew 0:80ee8f3b695e 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
EricLew 0:80ee8f3b695e 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
EricLew 0:80ee8f3b695e 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
EricLew 0:80ee8f3b695e 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
EricLew 0:80ee8f3b695e 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
EricLew 0:80ee8f3b695e 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
EricLew 0:80ee8f3b695e 34 *
EricLew 0:80ee8f3b695e 35 ******************************************************************************
EricLew 0:80ee8f3b695e 36 */
EricLew 0:80ee8f3b695e 37
EricLew 0:80ee8f3b695e 38 /* Define to prevent recursive inclusion -------------------------------------*/
EricLew 0:80ee8f3b695e 39 #ifndef __STM32L4xx_HAL_UART_H
EricLew 0:80ee8f3b695e 40 #define __STM32L4xx_HAL_UART_H
EricLew 0:80ee8f3b695e 41
EricLew 0:80ee8f3b695e 42 #ifdef __cplusplus
EricLew 0:80ee8f3b695e 43 extern "C" {
EricLew 0:80ee8f3b695e 44 #endif
EricLew 0:80ee8f3b695e 45
EricLew 0:80ee8f3b695e 46 /* Includes ------------------------------------------------------------------*/
EricLew 0:80ee8f3b695e 47 #include "stm32l4xx_hal_def.h"
EricLew 0:80ee8f3b695e 48
EricLew 0:80ee8f3b695e 49 /** @addtogroup STM32L4xx_HAL_Driver
EricLew 0:80ee8f3b695e 50 * @{
EricLew 0:80ee8f3b695e 51 */
EricLew 0:80ee8f3b695e 52
EricLew 0:80ee8f3b695e 53 /** @addtogroup UART
EricLew 0:80ee8f3b695e 54 * @{
EricLew 0:80ee8f3b695e 55 */
EricLew 0:80ee8f3b695e 56
EricLew 0:80ee8f3b695e 57 /* Exported types ------------------------------------------------------------*/
EricLew 0:80ee8f3b695e 58 /** @defgroup UART_Exported_Types UART Exported Types
EricLew 0:80ee8f3b695e 59 * @{
EricLew 0:80ee8f3b695e 60 */
EricLew 0:80ee8f3b695e 61
EricLew 0:80ee8f3b695e 62 /**
EricLew 0:80ee8f3b695e 63 * @brief UART Init Structure definition
EricLew 0:80ee8f3b695e 64 */
EricLew 0:80ee8f3b695e 65 typedef struct
EricLew 0:80ee8f3b695e 66 {
EricLew 0:80ee8f3b695e 67 uint32_t BaudRate; /*!< This member configures the UART communication baud rate.
EricLew 0:80ee8f3b695e 68 The baud rate register is computed using the following formula:
EricLew 0:80ee8f3b695e 69 - If oversampling is 16 or in LIN mode,
EricLew 0:80ee8f3b695e 70 Baud Rate Register = ((PCLKx) / ((huart->Init.BaudRate)))
EricLew 0:80ee8f3b695e 71 - If oversampling is 8,
EricLew 0:80ee8f3b695e 72 - - Baud Rate Register[15:4] = ((2 * PCLKx) / ((huart->Init.BaudRate)))[15:4]
EricLew 0:80ee8f3b695e 73 - - Baud Rate Register[3] = 0
EricLew 0:80ee8f3b695e 74 - - Baud Rate Register[2:0] = (((2 * PCLKx) / ((huart->Init.BaudRate)))[3:0]) >> 1 */
EricLew 0:80ee8f3b695e 75
EricLew 0:80ee8f3b695e 76 uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
EricLew 0:80ee8f3b695e 77 This parameter can be a value of @ref UARTEx_Word_Length. */
EricLew 0:80ee8f3b695e 78
EricLew 0:80ee8f3b695e 79 uint32_t StopBits; /*!< Specifies the number of stop bits transmitted.
EricLew 0:80ee8f3b695e 80 This parameter can be a value of @ref UART_Stop_Bits. */
EricLew 0:80ee8f3b695e 81
EricLew 0:80ee8f3b695e 82 uint32_t Parity; /*!< Specifies the parity mode.
EricLew 0:80ee8f3b695e 83 This parameter can be a value of @ref UART_Parity
EricLew 0:80ee8f3b695e 84 @note When parity is enabled, the computed parity is inserted
EricLew 0:80ee8f3b695e 85 at the MSB position of the transmitted data (9th bit when
EricLew 0:80ee8f3b695e 86 the word length is set to 9 data bits; 8th bit when the
EricLew 0:80ee8f3b695e 87 word length is set to 8 data bits). */
EricLew 0:80ee8f3b695e 88
EricLew 0:80ee8f3b695e 89 uint32_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
EricLew 0:80ee8f3b695e 90 This parameter can be a value of @ref UART_Mode. */
EricLew 0:80ee8f3b695e 91
EricLew 0:80ee8f3b695e 92 uint32_t HwFlowCtl; /*!< Specifies whether the hardware flow control mode is enabled
EricLew 0:80ee8f3b695e 93 or disabled.
EricLew 0:80ee8f3b695e 94 This parameter can be a value of @ref UART_Hardware_Flow_Control. */
EricLew 0:80ee8f3b695e 95
EricLew 0:80ee8f3b695e 96 uint32_t OverSampling; /*!< Specifies whether the Over sampling 8 is enabled or disabled, to achieve higher speed (up to f_PCLK/8).
EricLew 0:80ee8f3b695e 97 This parameter can be a value of @ref UART_Over_Sampling. */
EricLew 0:80ee8f3b695e 98
EricLew 0:80ee8f3b695e 99 uint32_t OneBitSampling; /*!< Specifies whether a single sample or three samples' majority vote is selected.
EricLew 0:80ee8f3b695e 100 Selecting the single sample method increases the receiver tolerance to clock
EricLew 0:80ee8f3b695e 101 deviations. This parameter can be a value of @ref UART_OneBit_Sampling. */
EricLew 0:80ee8f3b695e 102 }UART_InitTypeDef;
EricLew 0:80ee8f3b695e 103
EricLew 0:80ee8f3b695e 104 /**
EricLew 0:80ee8f3b695e 105 * @brief UART Advanced Features initalization structure definition
EricLew 0:80ee8f3b695e 106 */
EricLew 0:80ee8f3b695e 107 typedef struct
EricLew 0:80ee8f3b695e 108 {
EricLew 0:80ee8f3b695e 109 uint32_t AdvFeatureInit; /*!< Specifies which advanced UART features is initialized. Several
EricLew 0:80ee8f3b695e 110 Advanced Features may be initialized at the same time .
EricLew 0:80ee8f3b695e 111 This parameter can be a value of @ref UART_Advanced_Features_Initialization_Type. */
EricLew 0:80ee8f3b695e 112
EricLew 0:80ee8f3b695e 113 uint32_t TxPinLevelInvert; /*!< Specifies whether the TX pin active level is inverted.
EricLew 0:80ee8f3b695e 114 This parameter can be a value of @ref UART_Tx_Inv. */
EricLew 0:80ee8f3b695e 115
EricLew 0:80ee8f3b695e 116 uint32_t RxPinLevelInvert; /*!< Specifies whether the RX pin active level is inverted.
EricLew 0:80ee8f3b695e 117 This parameter can be a value of @ref UART_Rx_Inv. */
EricLew 0:80ee8f3b695e 118
EricLew 0:80ee8f3b695e 119 uint32_t DataInvert; /*!< Specifies whether data are inverted (positive/direct logic
EricLew 0:80ee8f3b695e 120 vs negative/inverted logic).
EricLew 0:80ee8f3b695e 121 This parameter can be a value of @ref UART_Data_Inv. */
EricLew 0:80ee8f3b695e 122
EricLew 0:80ee8f3b695e 123 uint32_t Swap; /*!< Specifies whether TX and RX pins are swapped.
EricLew 0:80ee8f3b695e 124 This parameter can be a value of @ref UART_Rx_Tx_Swap. */
EricLew 0:80ee8f3b695e 125
EricLew 0:80ee8f3b695e 126 uint32_t OverrunDisable; /*!< Specifies whether the reception overrun detection is disabled.
EricLew 0:80ee8f3b695e 127 This parameter can be a value of @ref UART_Overrun_Disable. */
EricLew 0:80ee8f3b695e 128
EricLew 0:80ee8f3b695e 129 uint32_t DMADisableonRxError; /*!< Specifies whether the DMA is disabled in case of reception error.
EricLew 0:80ee8f3b695e 130 This parameter can be a value of @ref UART_DMA_Disable_on_Rx_Error. */
EricLew 0:80ee8f3b695e 131
EricLew 0:80ee8f3b695e 132 uint32_t AutoBaudRateEnable; /*!< Specifies whether auto Baud rate detection is enabled.
EricLew 0:80ee8f3b695e 133 This parameter can be a value of @ref UART_AutoBaudRate_Enable */
EricLew 0:80ee8f3b695e 134
EricLew 0:80ee8f3b695e 135 uint32_t AutoBaudRateMode; /*!< If auto Baud rate detection is enabled, specifies how the rate
EricLew 0:80ee8f3b695e 136 detection is carried out.
EricLew 0:80ee8f3b695e 137 This parameter can be a value of @ref UART_AutoBaud_Rate_Mode. */
EricLew 0:80ee8f3b695e 138
EricLew 0:80ee8f3b695e 139 uint32_t MSBFirst; /*!< Specifies whether MSB is sent first on UART line.
EricLew 0:80ee8f3b695e 140 This parameter can be a value of @ref UART_MSB_First. */
EricLew 0:80ee8f3b695e 141 } UART_AdvFeatureInitTypeDef;
EricLew 0:80ee8f3b695e 142
EricLew 0:80ee8f3b695e 143
EricLew 0:80ee8f3b695e 144
EricLew 0:80ee8f3b695e 145 /**
EricLew 0:80ee8f3b695e 146 * @brief HAL UART State structures definition
EricLew 0:80ee8f3b695e 147 */
EricLew 0:80ee8f3b695e 148 typedef enum
EricLew 0:80ee8f3b695e 149 {
EricLew 0:80ee8f3b695e 150 HAL_UART_STATE_RESET = 0x00, /*!< Peripheral is not initialized */
EricLew 0:80ee8f3b695e 151 HAL_UART_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */
EricLew 0:80ee8f3b695e 152 HAL_UART_STATE_BUSY = 0x02, /*!< an internal process is ongoing */
EricLew 0:80ee8f3b695e 153 HAL_UART_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */
EricLew 0:80ee8f3b695e 154 HAL_UART_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */
EricLew 0:80ee8f3b695e 155 HAL_UART_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission and Reception process is ongoing */
EricLew 0:80ee8f3b695e 156 HAL_UART_STATE_TIMEOUT = 0x03, /*!< Timeout state */
EricLew 0:80ee8f3b695e 157 HAL_UART_STATE_ERROR = 0x04 /*!< Error */
EricLew 0:80ee8f3b695e 158 }HAL_UART_StateTypeDef;
EricLew 0:80ee8f3b695e 159
EricLew 0:80ee8f3b695e 160 /**
EricLew 0:80ee8f3b695e 161 * @brief HAL UART Error Code structure definition
EricLew 0:80ee8f3b695e 162 */
EricLew 0:80ee8f3b695e 163 typedef enum
EricLew 0:80ee8f3b695e 164 {
EricLew 0:80ee8f3b695e 165 HAL_UART_ERROR_NONE = 0x00, /*!< No error */
EricLew 0:80ee8f3b695e 166 HAL_UART_ERROR_PE = 0x01, /*!< Parity error */
EricLew 0:80ee8f3b695e 167 HAL_UART_ERROR_NE = 0x02, /*!< Noise error */
EricLew 0:80ee8f3b695e 168 HAL_UART_ERROR_FE = 0x04, /*!< frame error */
EricLew 0:80ee8f3b695e 169 HAL_UART_ERROR_ORE = 0x08, /*!< Overrun error */
EricLew 0:80ee8f3b695e 170 HAL_UART_ERROR_DMA = 0x10 /*!< DMA transfer error */
EricLew 0:80ee8f3b695e 171 }HAL_UART_ErrorTypeDef;
EricLew 0:80ee8f3b695e 172
EricLew 0:80ee8f3b695e 173 /**
EricLew 0:80ee8f3b695e 174 * @brief UART clock sources definition
EricLew 0:80ee8f3b695e 175 */
EricLew 0:80ee8f3b695e 176 typedef enum
EricLew 0:80ee8f3b695e 177 {
EricLew 0:80ee8f3b695e 178 UART_CLOCKSOURCE_PCLK1 = 0x00, /*!< PCLK1 clock source */
EricLew 0:80ee8f3b695e 179 UART_CLOCKSOURCE_PCLK2 = 0x01, /*!< PCLK2 clock source */
EricLew 0:80ee8f3b695e 180 UART_CLOCKSOURCE_HSI = 0x02, /*!< HSI clock source */
EricLew 0:80ee8f3b695e 181 UART_CLOCKSOURCE_SYSCLK = 0x04, /*!< SYSCLK clock source */
EricLew 0:80ee8f3b695e 182 UART_CLOCKSOURCE_LSE = 0x08, /*!< LSE clock source */
EricLew 0:80ee8f3b695e 183 UART_CLOCKSOURCE_UNDEFINED = 0x10 /*!< Undefined clock source */
EricLew 0:80ee8f3b695e 184 }UART_ClockSourceTypeDef;
EricLew 0:80ee8f3b695e 185
EricLew 0:80ee8f3b695e 186 /**
EricLew 0:80ee8f3b695e 187 * @brief UART handle Structure definition
EricLew 0:80ee8f3b695e 188 */
EricLew 0:80ee8f3b695e 189 typedef struct
EricLew 0:80ee8f3b695e 190 {
EricLew 0:80ee8f3b695e 191 USART_TypeDef *Instance; /*!< UART registers base address */
EricLew 0:80ee8f3b695e 192
EricLew 0:80ee8f3b695e 193 UART_InitTypeDef Init; /*!< UART communication parameters */
EricLew 0:80ee8f3b695e 194
EricLew 0:80ee8f3b695e 195 UART_AdvFeatureInitTypeDef AdvancedInit; /*!< UART Advanced Features initialization parameters */
EricLew 0:80ee8f3b695e 196
EricLew 0:80ee8f3b695e 197 uint8_t *pTxBuffPtr; /*!< Pointer to UART Tx transfer Buffer */
EricLew 0:80ee8f3b695e 198
EricLew 0:80ee8f3b695e 199 uint16_t TxXferSize; /*!< UART Tx Transfer size */
EricLew 0:80ee8f3b695e 200
EricLew 0:80ee8f3b695e 201 uint16_t TxXferCount; /*!< UART Tx Transfer Counter */
EricLew 0:80ee8f3b695e 202
EricLew 0:80ee8f3b695e 203 uint8_t *pRxBuffPtr; /*!< Pointer to UART Rx transfer Buffer */
EricLew 0:80ee8f3b695e 204
EricLew 0:80ee8f3b695e 205 uint16_t RxXferSize; /*!< UART Rx Transfer size */
EricLew 0:80ee8f3b695e 206
EricLew 0:80ee8f3b695e 207 uint16_t RxXferCount; /*!< UART Rx Transfer Counter */
EricLew 0:80ee8f3b695e 208
EricLew 0:80ee8f3b695e 209 uint16_t Mask; /*!< UART Rx RDR register mask */
EricLew 0:80ee8f3b695e 210
EricLew 0:80ee8f3b695e 211 DMA_HandleTypeDef *hdmatx; /*!< UART Tx DMA Handle parameters */
EricLew 0:80ee8f3b695e 212
EricLew 0:80ee8f3b695e 213 DMA_HandleTypeDef *hdmarx; /*!< UART Rx DMA Handle parameters */
EricLew 0:80ee8f3b695e 214
EricLew 0:80ee8f3b695e 215 HAL_LockTypeDef Lock; /*!< Locking object */
EricLew 0:80ee8f3b695e 216
EricLew 0:80ee8f3b695e 217 __IO HAL_UART_StateTypeDef State; /*!< UART communication state */
EricLew 0:80ee8f3b695e 218
EricLew 0:80ee8f3b695e 219 __IO uint32_t ErrorCode; /*!< UART Error code */
EricLew 0:80ee8f3b695e 220
EricLew 0:80ee8f3b695e 221 }UART_HandleTypeDef;
EricLew 0:80ee8f3b695e 222
EricLew 0:80ee8f3b695e 223 /**
EricLew 0:80ee8f3b695e 224 * @}
EricLew 0:80ee8f3b695e 225 */
EricLew 0:80ee8f3b695e 226
EricLew 0:80ee8f3b695e 227 /* Exported constants --------------------------------------------------------*/
EricLew 0:80ee8f3b695e 228 /** @defgroup UART_Exported_Constants UART Exported Constants
EricLew 0:80ee8f3b695e 229 * @{
EricLew 0:80ee8f3b695e 230 */
EricLew 0:80ee8f3b695e 231
EricLew 0:80ee8f3b695e 232 /** @defgroup UART_Stop_Bits UART Number of Stop Bits
EricLew 0:80ee8f3b695e 233 * @{
EricLew 0:80ee8f3b695e 234 */
EricLew 0:80ee8f3b695e 235 #define UART_STOPBITS_1 ((uint32_t)0x00000000) /*!< UART frame with 1 stop bit */
EricLew 0:80ee8f3b695e 236 #define UART_STOPBITS_1_5 ((uint32_t)(USART_CR2_STOP_0 | USART_CR2_STOP_1)) /*!< UART frame with 1.5 stop bits */
EricLew 0:80ee8f3b695e 237 #define UART_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1) /*!< UART frame with 2 stop bits */
EricLew 0:80ee8f3b695e 238 /**
EricLew 0:80ee8f3b695e 239 * @}
EricLew 0:80ee8f3b695e 240 */
EricLew 0:80ee8f3b695e 241
EricLew 0:80ee8f3b695e 242 /** @defgroup UART_Parity UART Parity
EricLew 0:80ee8f3b695e 243 * @{
EricLew 0:80ee8f3b695e 244 */
EricLew 0:80ee8f3b695e 245 #define UART_PARITY_NONE ((uint32_t)0x00000000) /*!< No parity */
EricLew 0:80ee8f3b695e 246 #define UART_PARITY_EVEN ((uint32_t)USART_CR1_PCE) /*!< Even parity */
EricLew 0:80ee8f3b695e 247 #define UART_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS)) /*!< Odd parity */
EricLew 0:80ee8f3b695e 248 /**
EricLew 0:80ee8f3b695e 249 * @}
EricLew 0:80ee8f3b695e 250 */
EricLew 0:80ee8f3b695e 251
EricLew 0:80ee8f3b695e 252 /** @defgroup UART_Hardware_Flow_Control UART Hardware Flow Control
EricLew 0:80ee8f3b695e 253 * @{
EricLew 0:80ee8f3b695e 254 */
EricLew 0:80ee8f3b695e 255 #define UART_HWCONTROL_NONE ((uint32_t)0x00000000) /*!< No hardware control */
EricLew 0:80ee8f3b695e 256 #define UART_HWCONTROL_RTS ((uint32_t)USART_CR3_RTSE) /*!< Request To Send */
EricLew 0:80ee8f3b695e 257 #define UART_HWCONTROL_CTS ((uint32_t)USART_CR3_CTSE) /*!< Clear To Send */
EricLew 0:80ee8f3b695e 258 #define UART_HWCONTROL_RTS_CTS ((uint32_t)(USART_CR3_RTSE | USART_CR3_CTSE)) /*!< Request and Clear To Send */
EricLew 0:80ee8f3b695e 259 /**
EricLew 0:80ee8f3b695e 260 * @}
EricLew 0:80ee8f3b695e 261 */
EricLew 0:80ee8f3b695e 262
EricLew 0:80ee8f3b695e 263 /** @defgroup UART_Mode UART Transfer Mode
EricLew 0:80ee8f3b695e 264 * @{
EricLew 0:80ee8f3b695e 265 */
EricLew 0:80ee8f3b695e 266 #define UART_MODE_RX ((uint32_t)USART_CR1_RE) /*!< RX mode */
EricLew 0:80ee8f3b695e 267 #define UART_MODE_TX ((uint32_t)USART_CR1_TE) /*!< TX mode */
EricLew 0:80ee8f3b695e 268 #define UART_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE)) /*!< RX and TX mode */
EricLew 0:80ee8f3b695e 269 /**
EricLew 0:80ee8f3b695e 270 * @}
EricLew 0:80ee8f3b695e 271 */
EricLew 0:80ee8f3b695e 272
EricLew 0:80ee8f3b695e 273 /** @defgroup UART_State UART State
EricLew 0:80ee8f3b695e 274 * @{
EricLew 0:80ee8f3b695e 275 */
EricLew 0:80ee8f3b695e 276 #define UART_STATE_DISABLE ((uint32_t)0x00000000) /*!< UART disabled */
EricLew 0:80ee8f3b695e 277 #define UART_STATE_ENABLE ((uint32_t)USART_CR1_UE) /*!< UART enabled */
EricLew 0:80ee8f3b695e 278 /**
EricLew 0:80ee8f3b695e 279 * @}
EricLew 0:80ee8f3b695e 280 */
EricLew 0:80ee8f3b695e 281
EricLew 0:80ee8f3b695e 282 /** @defgroup UART_Over_Sampling UART Over Sampling
EricLew 0:80ee8f3b695e 283 * @{
EricLew 0:80ee8f3b695e 284 */
EricLew 0:80ee8f3b695e 285 #define UART_OVERSAMPLING_16 ((uint32_t)0x00000000) /*!< Oversampling by 16 */
EricLew 0:80ee8f3b695e 286 #define UART_OVERSAMPLING_8 ((uint32_t)USART_CR1_OVER8) /*!< Oversampling by 8 */
EricLew 0:80ee8f3b695e 287 /**
EricLew 0:80ee8f3b695e 288 * @}
EricLew 0:80ee8f3b695e 289 */
EricLew 0:80ee8f3b695e 290
EricLew 0:80ee8f3b695e 291 /** @defgroup UART_OneBit_Sampling UART One Bit Sampling Method
EricLew 0:80ee8f3b695e 292 * @{
EricLew 0:80ee8f3b695e 293 */
EricLew 0:80ee8f3b695e 294 #define UART_ONE_BIT_SAMPLE_DISABLE ((uint32_t)0x00000000) /*!< One-bit sampling disable */
EricLew 0:80ee8f3b695e 295 #define UART_ONE_BIT_SAMPLE_ENABLE ((uint32_t)USART_CR3_ONEBIT) /*!< One-bit sampling enable */
EricLew 0:80ee8f3b695e 296 /**
EricLew 0:80ee8f3b695e 297 * @}
EricLew 0:80ee8f3b695e 298 */
EricLew 0:80ee8f3b695e 299
EricLew 0:80ee8f3b695e 300 /** @defgroup UART_AutoBaud_Rate_Mode UART Advanced Feature AutoBaud Rate Mode
EricLew 0:80ee8f3b695e 301 * @{
EricLew 0:80ee8f3b695e 302 */
EricLew 0:80ee8f3b695e 303 #define UART_ADVFEATURE_AUTOBAUDRATE_ONSTARTBIT ((uint32_t)0x0000) /*!< Auto Baud rate detection on start bit */
EricLew 0:80ee8f3b695e 304 #define UART_ADVFEATURE_AUTOBAUDRATE_ONFALLINGEDGE ((uint32_t)USART_CR2_ABRMODE_0) /*!< Auto Baud rate detection on falling edge */
EricLew 0:80ee8f3b695e 305 #define UART_ADVFEATURE_AUTOBAUDRATE_ON0X7FFRAME ((uint32_t)USART_CR2_ABRMODE_1) /*!< Auto Baud rate detection on 0x7F frame detection */
EricLew 0:80ee8f3b695e 306 #define UART_ADVFEATURE_AUTOBAUDRATE_ON0X55FRAME ((uint32_t)USART_CR2_ABRMODE) /*!< Auto Baud rate detection on 0x55 frame detection */
EricLew 0:80ee8f3b695e 307 /**
EricLew 0:80ee8f3b695e 308 * @}
EricLew 0:80ee8f3b695e 309 */
EricLew 0:80ee8f3b695e 310
EricLew 0:80ee8f3b695e 311 /** @defgroup UART_Receiver_TimeOut UART Receiver TimeOut
EricLew 0:80ee8f3b695e 312 * @{
EricLew 0:80ee8f3b695e 313 */
EricLew 0:80ee8f3b695e 314 #define UART_RECEIVER_TIMEOUT_DISABLE ((uint32_t)0x00000000) /*!< UART receiver timeout disable */
EricLew 0:80ee8f3b695e 315 #define UART_RECEIVER_TIMEOUT_ENABLE ((uint32_t)USART_CR2_RTOEN) /*!< UART receiver timeout enable */
EricLew 0:80ee8f3b695e 316 /**
EricLew 0:80ee8f3b695e 317 * @}
EricLew 0:80ee8f3b695e 318 */
EricLew 0:80ee8f3b695e 319
EricLew 0:80ee8f3b695e 320 /** @defgroup UART_LIN UART Local Interconnection Network mode
EricLew 0:80ee8f3b695e 321 * @{
EricLew 0:80ee8f3b695e 322 */
EricLew 0:80ee8f3b695e 323 #define UART_LIN_DISABLE ((uint32_t)0x00000000) /*!< Local Interconnect Network disable */
EricLew 0:80ee8f3b695e 324 #define UART_LIN_ENABLE ((uint32_t)USART_CR2_LINEN) /*!< Local Interconnect Network enable */
EricLew 0:80ee8f3b695e 325 /**
EricLew 0:80ee8f3b695e 326 * @}
EricLew 0:80ee8f3b695e 327 */
EricLew 0:80ee8f3b695e 328
EricLew 0:80ee8f3b695e 329 /** @defgroup UART_LIN_Break_Detection UART LIN Break Detection
EricLew 0:80ee8f3b695e 330 * @{
EricLew 0:80ee8f3b695e 331 */
EricLew 0:80ee8f3b695e 332 #define UART_LINBREAKDETECTLENGTH_10B ((uint32_t)0x00000000) /*!< LIN 10-bit break detection length */
EricLew 0:80ee8f3b695e 333 #define UART_LINBREAKDETECTLENGTH_11B ((uint32_t)USART_CR2_LBDL) /*!< LIN 11-bit break detection length */
EricLew 0:80ee8f3b695e 334 /**
EricLew 0:80ee8f3b695e 335 * @}
EricLew 0:80ee8f3b695e 336 */
EricLew 0:80ee8f3b695e 337
EricLew 0:80ee8f3b695e 338 /** @defgroup UART_DMA_Tx UART DMA Tx
EricLew 0:80ee8f3b695e 339 * @{
EricLew 0:80ee8f3b695e 340 */
EricLew 0:80ee8f3b695e 341 #define UART_DMA_TX_DISABLE ((uint32_t)0x00000000) /*!< UART DMA TX disabled */
EricLew 0:80ee8f3b695e 342 #define UART_DMA_TX_ENABLE ((uint32_t)USART_CR3_DMAT) /*!< UART DMA TX enabled */
EricLew 0:80ee8f3b695e 343 /**
EricLew 0:80ee8f3b695e 344 * @}
EricLew 0:80ee8f3b695e 345 */
EricLew 0:80ee8f3b695e 346
EricLew 0:80ee8f3b695e 347 /** @defgroup UART_DMA_Rx UART DMA Rx
EricLew 0:80ee8f3b695e 348 * @{
EricLew 0:80ee8f3b695e 349 */
EricLew 0:80ee8f3b695e 350 #define UART_DMA_RX_DISABLE ((uint32_t)0x0000) /*!< UART DMA RX disabled */
EricLew 0:80ee8f3b695e 351 #define UART_DMA_RX_ENABLE ((uint32_t)USART_CR3_DMAR) /*!< UART DMA RX enabled */
EricLew 0:80ee8f3b695e 352 /**
EricLew 0:80ee8f3b695e 353 * @}
EricLew 0:80ee8f3b695e 354 */
EricLew 0:80ee8f3b695e 355
EricLew 0:80ee8f3b695e 356 /** @defgroup UART_Half_Duplex_Selection UART Half Duplex Selection
EricLew 0:80ee8f3b695e 357 * @{
EricLew 0:80ee8f3b695e 358 */
EricLew 0:80ee8f3b695e 359 #define UART_HALF_DUPLEX_DISABLE ((uint32_t)0x0000) /*!< UART half-duplex disabled */
EricLew 0:80ee8f3b695e 360 #define UART_HALF_DUPLEX_ENABLE ((uint32_t)USART_CR3_HDSEL) /*!< UART half-duplex enabled */
EricLew 0:80ee8f3b695e 361 /**
EricLew 0:80ee8f3b695e 362 * @}
EricLew 0:80ee8f3b695e 363 */
EricLew 0:80ee8f3b695e 364
EricLew 0:80ee8f3b695e 365 /** @defgroup UART_WakeUp_Methods UART WakeUp Methods
EricLew 0:80ee8f3b695e 366 * @{
EricLew 0:80ee8f3b695e 367 */
EricLew 0:80ee8f3b695e 368 #define UART_WAKEUPMETHOD_IDLELINE ((uint32_t)0x00000000) /*!< UART wake-up on idle line */
EricLew 0:80ee8f3b695e 369 #define UART_WAKEUPMETHOD_ADDRESSMARK ((uint32_t)USART_CR1_WAKE) /*!< UART wake-up on address mark */
EricLew 0:80ee8f3b695e 370 /**
EricLew 0:80ee8f3b695e 371 * @}
EricLew 0:80ee8f3b695e 372 */
EricLew 0:80ee8f3b695e 373
EricLew 0:80ee8f3b695e 374 /** @defgroup UART_Request_Parameters UART Request Parameters
EricLew 0:80ee8f3b695e 375 * @{
EricLew 0:80ee8f3b695e 376 */
EricLew 0:80ee8f3b695e 377 #define UART_AUTOBAUD_REQUEST ((uint32_t)USART_RQR_ABRRQ) /*!< Auto-Baud Rate Request */
EricLew 0:80ee8f3b695e 378 #define UART_SENDBREAK_REQUEST ((uint32_t)USART_RQR_SBKRQ) /*!< Send Break Request */
EricLew 0:80ee8f3b695e 379 #define UART_MUTE_MODE_REQUEST ((uint32_t)USART_RQR_MMRQ) /*!< Mute Mode Request */
EricLew 0:80ee8f3b695e 380 #define UART_RXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_RXFRQ) /*!< Receive Data flush Request */
EricLew 0:80ee8f3b695e 381 #define UART_TXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_TXFRQ) /*!< Transmit data flush Request */
EricLew 0:80ee8f3b695e 382 /**
EricLew 0:80ee8f3b695e 383 * @}
EricLew 0:80ee8f3b695e 384 */
EricLew 0:80ee8f3b695e 385
EricLew 0:80ee8f3b695e 386 /** @defgroup UART_Advanced_Features_Initialization_Type UART Advanced Feature Initialization Type
EricLew 0:80ee8f3b695e 387 * @{
EricLew 0:80ee8f3b695e 388 */
EricLew 0:80ee8f3b695e 389 #define UART_ADVFEATURE_NO_INIT ((uint32_t)0x00000000) /*!< No advanced feature initialization */
EricLew 0:80ee8f3b695e 390 #define UART_ADVFEATURE_TXINVERT_INIT ((uint32_t)0x00000001) /*!< TX pin active level inversion */
EricLew 0:80ee8f3b695e 391 #define UART_ADVFEATURE_RXINVERT_INIT ((uint32_t)0x00000002) /*!< RX pin active level inversion */
EricLew 0:80ee8f3b695e 392 #define UART_ADVFEATURE_DATAINVERT_INIT ((uint32_t)0x00000004) /*!< Binary data inversion */
EricLew 0:80ee8f3b695e 393 #define UART_ADVFEATURE_SWAP_INIT ((uint32_t)0x00000008) /*!< TX/RX pins swap */
EricLew 0:80ee8f3b695e 394 #define UART_ADVFEATURE_RXOVERRUNDISABLE_INIT ((uint32_t)0x00000010) /*!< RX overrun disable */
EricLew 0:80ee8f3b695e 395 #define UART_ADVFEATURE_DMADISABLEONERROR_INIT ((uint32_t)0x00000020) /*!< DMA disable on Reception Error */
EricLew 0:80ee8f3b695e 396 #define UART_ADVFEATURE_AUTOBAUDRATE_INIT ((uint32_t)0x00000040) /*!< Auto Baud rate detection initialization */
EricLew 0:80ee8f3b695e 397 #define UART_ADVFEATURE_MSBFIRST_INIT ((uint32_t)0x00000080) /*!< Most significant bit sent/received first */
EricLew 0:80ee8f3b695e 398 /**
EricLew 0:80ee8f3b695e 399 * @}
EricLew 0:80ee8f3b695e 400 */
EricLew 0:80ee8f3b695e 401
EricLew 0:80ee8f3b695e 402 /** @defgroup UART_Tx_Inv UART Advanced Feature TX Pin Active Level Inversion
EricLew 0:80ee8f3b695e 403 * @{
EricLew 0:80ee8f3b695e 404 */
EricLew 0:80ee8f3b695e 405 #define UART_ADVFEATURE_TXINV_DISABLE ((uint32_t)0x00000000) /*!< TX pin active level inversion disable */
EricLew 0:80ee8f3b695e 406 #define UART_ADVFEATURE_TXINV_ENABLE ((uint32_t)USART_CR2_TXINV) /*!< TX pin active level inversion enable */
EricLew 0:80ee8f3b695e 407 /**
EricLew 0:80ee8f3b695e 408 * @}
EricLew 0:80ee8f3b695e 409 */
EricLew 0:80ee8f3b695e 410
EricLew 0:80ee8f3b695e 411 /** @defgroup UART_Rx_Inv UART Advanced Feature RX Pin Active Level Inversion
EricLew 0:80ee8f3b695e 412 * @{
EricLew 0:80ee8f3b695e 413 */
EricLew 0:80ee8f3b695e 414 #define UART_ADVFEATURE_RXINV_DISABLE ((uint32_t)0x00000000) /*!< RX pin active level inversion disable */
EricLew 0:80ee8f3b695e 415 #define UART_ADVFEATURE_RXINV_ENABLE ((uint32_t)USART_CR2_RXINV) /*!< RX pin active level inversion enable */
EricLew 0:80ee8f3b695e 416 /**
EricLew 0:80ee8f3b695e 417 * @}
EricLew 0:80ee8f3b695e 418 */
EricLew 0:80ee8f3b695e 419
EricLew 0:80ee8f3b695e 420 /** @defgroup UART_Data_Inv UART Advanced Feature Binary Data Inversion
EricLew 0:80ee8f3b695e 421 * @{
EricLew 0:80ee8f3b695e 422 */
EricLew 0:80ee8f3b695e 423 #define UART_ADVFEATURE_DATAINV_DISABLE ((uint32_t)0x00000000) /*!< Binary data inversion disable */
EricLew 0:80ee8f3b695e 424 #define UART_ADVFEATURE_DATAINV_ENABLE ((uint32_t)USART_CR2_DATAINV) /*!< Binary data inversion enable */
EricLew 0:80ee8f3b695e 425 /**
EricLew 0:80ee8f3b695e 426 * @}
EricLew 0:80ee8f3b695e 427 */
EricLew 0:80ee8f3b695e 428
EricLew 0:80ee8f3b695e 429 /** @defgroup UART_Rx_Tx_Swap UART Advanced Feature RX TX Pins Swap
EricLew 0:80ee8f3b695e 430 * @{
EricLew 0:80ee8f3b695e 431 */
EricLew 0:80ee8f3b695e 432 #define UART_ADVFEATURE_SWAP_DISABLE ((uint32_t)0x00000000) /*!< TX/RX pins swap disable */
EricLew 0:80ee8f3b695e 433 #define UART_ADVFEATURE_SWAP_ENABLE ((uint32_t)USART_CR2_SWAP) /*!< TX/RX pins swap enable */
EricLew 0:80ee8f3b695e 434 /**
EricLew 0:80ee8f3b695e 435 * @}
EricLew 0:80ee8f3b695e 436 */
EricLew 0:80ee8f3b695e 437
EricLew 0:80ee8f3b695e 438 /** @defgroup UART_Overrun_Disable UART Advanced Feature Overrun Disable
EricLew 0:80ee8f3b695e 439 * @{
EricLew 0:80ee8f3b695e 440 */
EricLew 0:80ee8f3b695e 441 #define UART_ADVFEATURE_OVERRUN_ENABLE ((uint32_t)0x00000000) /*!< RX overrun enable */
EricLew 0:80ee8f3b695e 442 #define UART_ADVFEATURE_OVERRUN_DISABLE ((uint32_t)USART_CR3_OVRDIS) /*!< RX overrun disable */
EricLew 0:80ee8f3b695e 443 /**
EricLew 0:80ee8f3b695e 444 * @}
EricLew 0:80ee8f3b695e 445 */
EricLew 0:80ee8f3b695e 446
EricLew 0:80ee8f3b695e 447 /** @defgroup UART_AutoBaudRate_Enable UART Advanced Feature Auto BaudRate Enable
EricLew 0:80ee8f3b695e 448 * @{
EricLew 0:80ee8f3b695e 449 */
EricLew 0:80ee8f3b695e 450 #define UART_ADVFEATURE_AUTOBAUDRATE_DISABLE ((uint32_t)0x00000000) /*!< RX Auto Baud rate detection enable */
EricLew 0:80ee8f3b695e 451 #define UART_ADVFEATURE_AUTOBAUDRATE_ENABLE ((uint32_t)USART_CR2_ABREN) /*!< RX Auto Baud rate detection disable */
EricLew 0:80ee8f3b695e 452 /**
EricLew 0:80ee8f3b695e 453 * @}
EricLew 0:80ee8f3b695e 454 */
EricLew 0:80ee8f3b695e 455
EricLew 0:80ee8f3b695e 456 /** @defgroup UART_DMA_Disable_on_Rx_Error UART Advanced Feature DMA Disable On Rx Error
EricLew 0:80ee8f3b695e 457 * @{
EricLew 0:80ee8f3b695e 458 */
EricLew 0:80ee8f3b695e 459 #define UART_ADVFEATURE_DMA_ENABLEONRXERROR ((uint32_t)0x00000000) /*!< DMA enable on Reception Error */
EricLew 0:80ee8f3b695e 460 #define UART_ADVFEATURE_DMA_DISABLEONRXERROR ((uint32_t)USART_CR3_DDRE) /*!< DMA disable on Reception Error */
EricLew 0:80ee8f3b695e 461 /**
EricLew 0:80ee8f3b695e 462 * @}
EricLew 0:80ee8f3b695e 463 */
EricLew 0:80ee8f3b695e 464
EricLew 0:80ee8f3b695e 465 /** @defgroup UART_MSB_First UART Advanced Feature MSB First
EricLew 0:80ee8f3b695e 466 * @{
EricLew 0:80ee8f3b695e 467 */
EricLew 0:80ee8f3b695e 468 #define UART_ADVFEATURE_MSBFIRST_DISABLE ((uint32_t)0x00000000) /*!< Most significant bit sent/received first disable */
EricLew 0:80ee8f3b695e 469 #define UART_ADVFEATURE_MSBFIRST_ENABLE ((uint32_t)USART_CR2_MSBFIRST) /*!< Most significant bit sent/received first enable */
EricLew 0:80ee8f3b695e 470 /**
EricLew 0:80ee8f3b695e 471 * @}
EricLew 0:80ee8f3b695e 472 */
EricLew 0:80ee8f3b695e 473
EricLew 0:80ee8f3b695e 474 /** @defgroup UART_Stop_Mode_Enable UART Advanced Feature Stop Mode Enable
EricLew 0:80ee8f3b695e 475 * @{
EricLew 0:80ee8f3b695e 476 */
EricLew 0:80ee8f3b695e 477 #define UART_ADVFEATURE_STOPMODE_DISABLE ((uint32_t)0x00000000) /*!< UART stop mode disable */
EricLew 0:80ee8f3b695e 478 #define UART_ADVFEATURE_STOPMODE_ENABLE ((uint32_t)USART_CR1_UESM) /*!< UART stop mode enable */
EricLew 0:80ee8f3b695e 479 /**
EricLew 0:80ee8f3b695e 480 * @}
EricLew 0:80ee8f3b695e 481 */
EricLew 0:80ee8f3b695e 482
EricLew 0:80ee8f3b695e 483 /** @defgroup UART_Mute_Mode UART Advanced Feature Mute Mode Enable
EricLew 0:80ee8f3b695e 484 * @{
EricLew 0:80ee8f3b695e 485 */
EricLew 0:80ee8f3b695e 486 #define UART_ADVFEATURE_MUTEMODE_DISABLE ((uint32_t)0x00000000) /*!< UART mute mode disable */
EricLew 0:80ee8f3b695e 487 #define UART_ADVFEATURE_MUTEMODE_ENABLE ((uint32_t)USART_CR1_MME) /*!< UART mute mode enable */
EricLew 0:80ee8f3b695e 488 /**
EricLew 0:80ee8f3b695e 489 * @}
EricLew 0:80ee8f3b695e 490 */
EricLew 0:80ee8f3b695e 491
EricLew 0:80ee8f3b695e 492 /** @defgroup UART_CR2_ADDRESS_LSB_POS UART Address-matching LSB Position In CR2 Register
EricLew 0:80ee8f3b695e 493 * @{
EricLew 0:80ee8f3b695e 494 */
EricLew 0:80ee8f3b695e 495 #define UART_CR2_ADDRESS_LSB_POS ((uint32_t) 24) /*!< UART address-matching LSB position in CR2 register */
EricLew 0:80ee8f3b695e 496 /**
EricLew 0:80ee8f3b695e 497 * @}
EricLew 0:80ee8f3b695e 498 */
EricLew 0:80ee8f3b695e 499
EricLew 0:80ee8f3b695e 500 /** @defgroup UART_WakeUp_from_Stop_Selection UART WakeUp From Stop Selection
EricLew 0:80ee8f3b695e 501 * @{
EricLew 0:80ee8f3b695e 502 */
EricLew 0:80ee8f3b695e 503 #define UART_WAKEUP_ON_ADDRESS ((uint32_t)0x00000000) /*!< UART wake-up on address */
EricLew 0:80ee8f3b695e 504 #define UART_WAKEUP_ON_STARTBIT ((uint32_t)USART_CR3_WUS_1) /*!< UART wake-up on start bit */
EricLew 0:80ee8f3b695e 505 #define UART_WAKEUP_ON_READDATA_NONEMPTY ((uint32_t)USART_CR3_WUS) /*!< UART wake-up on receive data register not empty */
EricLew 0:80ee8f3b695e 506 /**
EricLew 0:80ee8f3b695e 507 * @}
EricLew 0:80ee8f3b695e 508 */
EricLew 0:80ee8f3b695e 509
EricLew 0:80ee8f3b695e 510 /** @defgroup UART_DriverEnable_Polarity UART DriverEnable Polarity
EricLew 0:80ee8f3b695e 511 * @{
EricLew 0:80ee8f3b695e 512 */
EricLew 0:80ee8f3b695e 513 #define UART_DE_POLARITY_HIGH ((uint32_t)0x00000000) /*!< Driver enable signal is active high */
EricLew 0:80ee8f3b695e 514 #define UART_DE_POLARITY_LOW ((uint32_t)USART_CR3_DEP) /*!< Driver enable signal is active low */
EricLew 0:80ee8f3b695e 515 /**
EricLew 0:80ee8f3b695e 516 * @}
EricLew 0:80ee8f3b695e 517 */
EricLew 0:80ee8f3b695e 518
EricLew 0:80ee8f3b695e 519 /** @defgroup UART_CR1_DEAT_ADDRESS_LSB_POS UART Driver Enable Assertion Time LSB Position In CR1 Register
EricLew 0:80ee8f3b695e 520 * @{
EricLew 0:80ee8f3b695e 521 */
EricLew 0:80ee8f3b695e 522 #define UART_CR1_DEAT_ADDRESS_LSB_POS ((uint32_t) 21) /*!< UART Driver Enable assertion time LSB position in CR1 register */
EricLew 0:80ee8f3b695e 523 /**
EricLew 0:80ee8f3b695e 524 * @}
EricLew 0:80ee8f3b695e 525 */
EricLew 0:80ee8f3b695e 526
EricLew 0:80ee8f3b695e 527 /** @defgroup UART_CR1_DEDT_ADDRESS_LSB_POS UART Driver Enable DeAssertion Time LSB Position In CR1 Register
EricLew 0:80ee8f3b695e 528 * @{
EricLew 0:80ee8f3b695e 529 */
EricLew 0:80ee8f3b695e 530 #define UART_CR1_DEDT_ADDRESS_LSB_POS ((uint32_t) 16) /*!< UART Driver Enable de-assertion time LSB position in CR1 register */
EricLew 0:80ee8f3b695e 531 /**
EricLew 0:80ee8f3b695e 532 * @}
EricLew 0:80ee8f3b695e 533 */
EricLew 0:80ee8f3b695e 534
EricLew 0:80ee8f3b695e 535 /** @defgroup UART_Interruption_Mask UART Interruptions Flag Mask
EricLew 0:80ee8f3b695e 536 * @{
EricLew 0:80ee8f3b695e 537 */
EricLew 0:80ee8f3b695e 538 #define UART_IT_MASK ((uint32_t)0x001F) /*!< UART interruptions flags mask */
EricLew 0:80ee8f3b695e 539 /**
EricLew 0:80ee8f3b695e 540 * @}
EricLew 0:80ee8f3b695e 541 */
EricLew 0:80ee8f3b695e 542
EricLew 0:80ee8f3b695e 543 /** @defgroup UART_TimeOut_Value UART polling-based communications time-out value
EricLew 0:80ee8f3b695e 544 * @{
EricLew 0:80ee8f3b695e 545 */
EricLew 0:80ee8f3b695e 546 #define HAL_UART_TIMEOUT_VALUE 0x1FFFFFF /*!< UART polling-based communications time-out value */
EricLew 0:80ee8f3b695e 547 /**
EricLew 0:80ee8f3b695e 548 * @}
EricLew 0:80ee8f3b695e 549 */
EricLew 0:80ee8f3b695e 550
EricLew 0:80ee8f3b695e 551 /** @defgroup UART_Flags UART Status Flags
EricLew 0:80ee8f3b695e 552 * Elements values convention: 0xXXXX
EricLew 0:80ee8f3b695e 553 * - 0xXXXX : Flag mask in the ISR register
EricLew 0:80ee8f3b695e 554 * @{
EricLew 0:80ee8f3b695e 555 */
EricLew 0:80ee8f3b695e 556 #define UART_FLAG_REACK ((uint32_t)0x00400000) /*!< UART receive enable acknowledge flag */
EricLew 0:80ee8f3b695e 557 #define UART_FLAG_TEACK ((uint32_t)0x00200000) /*!< UART transmit enable acknowledge flag */
EricLew 0:80ee8f3b695e 558 #define UART_FLAG_WUF ((uint32_t)0x00100000) /*!< UART wake-up from stop mode flag */
EricLew 0:80ee8f3b695e 559 #define UART_FLAG_RWU ((uint32_t)0x00080000) /*!< UART receiver wake-up from mute mode flag */
EricLew 0:80ee8f3b695e 560 #define UART_FLAG_SBKF ((uint32_t)0x00040000) /*!< UART send break flag */
EricLew 0:80ee8f3b695e 561 #define UART_FLAG_CMF ((uint32_t)0x00020000) /*!< UART character match flag */
EricLew 0:80ee8f3b695e 562 #define UART_FLAG_BUSY ((uint32_t)0x00010000) /*!< UART busy flag */
EricLew 0:80ee8f3b695e 563 #define UART_FLAG_ABRF ((uint32_t)0x00008000) /*!< UART auto Baud rate flag */
EricLew 0:80ee8f3b695e 564 #define UART_FLAG_ABRE ((uint32_t)0x00004000) /*!< UART uto Baud rate error */
EricLew 0:80ee8f3b695e 565 #define UART_FLAG_EOBF ((uint32_t)0x00001000) /*!< UART end of block flag */
EricLew 0:80ee8f3b695e 566 #define UART_FLAG_RTOF ((uint32_t)0x00000800) /*!< UART receiver timeout flag */
EricLew 0:80ee8f3b695e 567 #define UART_FLAG_CTS ((uint32_t)0x00000400) /*!< UART clear to send flag */
EricLew 0:80ee8f3b695e 568 #define UART_FLAG_CTSIF ((uint32_t)0x00000200) /*!< UART clear to send interrupt flag */
EricLew 0:80ee8f3b695e 569 #define UART_FLAG_LBDF ((uint32_t)0x00000100) /*!< UART LIN break detection flag */
EricLew 0:80ee8f3b695e 570 #define UART_FLAG_TXE ((uint32_t)0x00000080) /*!< UART transmit data register empty */
EricLew 0:80ee8f3b695e 571 #define UART_FLAG_TC ((uint32_t)0x00000040) /*!< UART transmission complete */
EricLew 0:80ee8f3b695e 572 #define UART_FLAG_RXNE ((uint32_t)0x00000020) /*!< UART read data register not empty */
EricLew 0:80ee8f3b695e 573 #define UART_FLAG_IDLE ((uint32_t)0x00000010) /*!< UART idle flag */
EricLew 0:80ee8f3b695e 574 #define UART_FLAG_ORE ((uint32_t)0x00000008) /*!< UART overrun error */
EricLew 0:80ee8f3b695e 575 #define UART_FLAG_NE ((uint32_t)0x00000004) /*!< UART noise error */
EricLew 0:80ee8f3b695e 576 #define UART_FLAG_FE ((uint32_t)0x00000002) /*!< UART frame error */
EricLew 0:80ee8f3b695e 577 #define UART_FLAG_PE ((uint32_t)0x00000001) /*!< UART parity error */
EricLew 0:80ee8f3b695e 578 /**
EricLew 0:80ee8f3b695e 579 * @}
EricLew 0:80ee8f3b695e 580 */
EricLew 0:80ee8f3b695e 581
EricLew 0:80ee8f3b695e 582 /** @defgroup UART_Interrupt_definition UART Interrupts Definition
EricLew 0:80ee8f3b695e 583 * Elements values convention: 000ZZZZZ0XXYYYYYb
EricLew 0:80ee8f3b695e 584 * - YYYYY : Interrupt source position in the XX register (5bits)
EricLew 0:80ee8f3b695e 585 * - XX : Interrupt source register (2bits)
EricLew 0:80ee8f3b695e 586 * - 01: CR1 register
EricLew 0:80ee8f3b695e 587 * - 10: CR2 register
EricLew 0:80ee8f3b695e 588 * - 11: CR3 register
EricLew 0:80ee8f3b695e 589 * - ZZZZZ : Flag position in the ISR register(5bits)
EricLew 0:80ee8f3b695e 590 * @{
EricLew 0:80ee8f3b695e 591 */
EricLew 0:80ee8f3b695e 592 #define UART_IT_PE ((uint32_t)0x0028) /*!< UART parity error interruption */
EricLew 0:80ee8f3b695e 593 #define UART_IT_TXE ((uint32_t)0x0727) /*!< UART transmit data register empty interruption */
EricLew 0:80ee8f3b695e 594 #define UART_IT_TC ((uint32_t)0x0626) /*!< UART transmission complete interruption */
EricLew 0:80ee8f3b695e 595 #define UART_IT_RXNE ((uint32_t)0x0525) /*!< UART read data register not empty interruption */
EricLew 0:80ee8f3b695e 596 #define UART_IT_IDLE ((uint32_t)0x0424) /*!< UART idle interruption */
EricLew 0:80ee8f3b695e 597 #define UART_IT_LBD ((uint32_t)0x0846) /*!< UART LIN break detection interruption */
EricLew 0:80ee8f3b695e 598 #define UART_IT_CTS ((uint32_t)0x096A) /*!< UART CTS interruption */
EricLew 0:80ee8f3b695e 599 #define UART_IT_CM ((uint32_t)0x112E) /*!< UART character match interruption */
EricLew 0:80ee8f3b695e 600 #define UART_IT_WUF ((uint32_t)0x1476) /*!< UART wake-up from stop mode interruption */
EricLew 0:80ee8f3b695e 601
EricLew 0:80ee8f3b695e 602 /* Elements values convention: 000000000XXYYYYYb
EricLew 0:80ee8f3b695e 603 - YYYYY : Interrupt source position in the XX register (5bits)
EricLew 0:80ee8f3b695e 604 - XX : Interrupt source register (2bits)
EricLew 0:80ee8f3b695e 605 - 01: CR1 register
EricLew 0:80ee8f3b695e 606 - 10: CR2 register
EricLew 0:80ee8f3b695e 607 - 11: CR3 register */
EricLew 0:80ee8f3b695e 608 #define UART_IT_ERR ((uint32_t)0x0060) /*!< UART error interruption */
EricLew 0:80ee8f3b695e 609
EricLew 0:80ee8f3b695e 610 /* Elements values convention: 0000ZZZZ00000000b
EricLew 0:80ee8f3b695e 611 - ZZZZ : Flag position in the ISR register(4bits) */
EricLew 0:80ee8f3b695e 612 #define UART_IT_ORE ((uint32_t)0x0300) /*!< UART overrun error interruption */
EricLew 0:80ee8f3b695e 613 #define UART_IT_NE ((uint32_t)0x0200) /*!< UART noise error interruption */
EricLew 0:80ee8f3b695e 614 #define UART_IT_FE ((uint32_t)0x0100) /*!< UART frame error interruption */
EricLew 0:80ee8f3b695e 615 /**
EricLew 0:80ee8f3b695e 616 * @}
EricLew 0:80ee8f3b695e 617 */
EricLew 0:80ee8f3b695e 618
EricLew 0:80ee8f3b695e 619 /** @defgroup UART_IT_CLEAR_Flags UART Interruption Clear Flags
EricLew 0:80ee8f3b695e 620 * @{
EricLew 0:80ee8f3b695e 621 */
EricLew 0:80ee8f3b695e 622 #define UART_CLEAR_PEF USART_ICR_PECF /*!< Parity Error Clear Flag */
EricLew 0:80ee8f3b695e 623 #define UART_CLEAR_FEF USART_ICR_FECF /*!< Framing Error Clear Flag */
EricLew 0:80ee8f3b695e 624 #define UART_CLEAR_NEF USART_ICR_NCF /*!< Noise detected Clear Flag */
EricLew 0:80ee8f3b695e 625 #define UART_CLEAR_OREF USART_ICR_ORECF /*!< OverRun Error Clear Flag */
EricLew 0:80ee8f3b695e 626 #define UART_CLEAR_IDLEF USART_ICR_IDLECF /*!< IDLE line detected Clear Flag */
EricLew 0:80ee8f3b695e 627 #define UART_CLEAR_TCF USART_ICR_TCCF /*!< Transmission Complete Clear Flag */
EricLew 0:80ee8f3b695e 628 #define UART_CLEAR_LBDF USART_ICR_LBDCF /*!< LIN Break Detection Clear Flag */
EricLew 0:80ee8f3b695e 629 #define UART_CLEAR_CTSF USART_ICR_CTSCF /*!< CTS Interrupt Clear Flag */
EricLew 0:80ee8f3b695e 630 #define UART_CLEAR_RTOF USART_ICR_RTOCF /*!< Receiver Time Out Clear Flag */
EricLew 0:80ee8f3b695e 631 #define UART_CLEAR_EOBF USART_ICR_EOBCF /*!< End Of Block Clear Flag */
EricLew 0:80ee8f3b695e 632 #define UART_CLEAR_CMF USART_ICR_CMCF /*!< Character Match Clear Flag */
EricLew 0:80ee8f3b695e 633 #define UART_CLEAR_WUF USART_ICR_WUCF /*!< Wake Up from stop mode Clear Flag */
EricLew 0:80ee8f3b695e 634 /**
EricLew 0:80ee8f3b695e 635 * @}
EricLew 0:80ee8f3b695e 636 */
EricLew 0:80ee8f3b695e 637
EricLew 0:80ee8f3b695e 638
EricLew 0:80ee8f3b695e 639 /**
EricLew 0:80ee8f3b695e 640 * @}
EricLew 0:80ee8f3b695e 641 */
EricLew 0:80ee8f3b695e 642
EricLew 0:80ee8f3b695e 643 /* Exported macros -----------------------------------------------------------*/
EricLew 0:80ee8f3b695e 644 /** @defgroup UART_Exported_Macros UART Exported Macros
EricLew 0:80ee8f3b695e 645 * @{
EricLew 0:80ee8f3b695e 646 */
EricLew 0:80ee8f3b695e 647
EricLew 0:80ee8f3b695e 648 /** @brief Reset UART handle state.
EricLew 0:80ee8f3b695e 649 * @param __HANDLE__: UART handle.
EricLew 0:80ee8f3b695e 650 * @retval None
EricLew 0:80ee8f3b695e 651 */
EricLew 0:80ee8f3b695e 652 #define __HAL_UART_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_UART_STATE_RESET)
EricLew 0:80ee8f3b695e 653
EricLew 0:80ee8f3b695e 654 /** @brief Flush the UART Data registers.
EricLew 0:80ee8f3b695e 655 * @param __HANDLE__: specifies the UART Handle.
EricLew 0:80ee8f3b695e 656 * @retval None
EricLew 0:80ee8f3b695e 657 */
EricLew 0:80ee8f3b695e 658 #define __HAL_UART_FLUSH_DRREGISTER(__HANDLE__) \
EricLew 0:80ee8f3b695e 659 do{ \
EricLew 0:80ee8f3b695e 660 SET_BIT((__HANDLE__)->Instance->RQR, UART_RXDATA_FLUSH_REQUEST); \
EricLew 0:80ee8f3b695e 661 SET_BIT((__HANDLE__)->Instance->RQR, UART_TXDATA_FLUSH_REQUEST); \
EricLew 0:80ee8f3b695e 662 } while(0)
EricLew 0:80ee8f3b695e 663
EricLew 0:80ee8f3b695e 664 /** @brief Clear the specified UART pending flag.
EricLew 0:80ee8f3b695e 665 * @param __HANDLE__: specifies the UART Handle.
EricLew 0:80ee8f3b695e 666 * @param __FLAG__: specifies the flag to check.
EricLew 0:80ee8f3b695e 667 * This parameter can be any combination of the following values:
EricLew 0:80ee8f3b695e 668 * @arg UART_CLEAR_PEF, Parity Error Clear Flag
EricLew 0:80ee8f3b695e 669 * @arg UART_CLEAR_FEF, Framing Error Clear Flag
EricLew 0:80ee8f3b695e 670 * @arg UART_CLEAR_NEF, Noise detected Clear Flag
EricLew 0:80ee8f3b695e 671 * @arg UART_CLEAR_OREF, OverRun Error Clear Flag
EricLew 0:80ee8f3b695e 672 * @arg UART_CLEAR_IDLEF, IDLE line detected Clear Flag
EricLew 0:80ee8f3b695e 673 * @arg UART_CLEAR_TCF, Transmission Complete Clear Flag
EricLew 0:80ee8f3b695e 674 * @arg UART_CLEAR_LBDF, LIN Break Detection Clear Flag
EricLew 0:80ee8f3b695e 675 * @arg UART_CLEAR_CTSF, CTS Interrupt Clear Flag
EricLew 0:80ee8f3b695e 676 * @arg UART_CLEAR_RTOF, Receiver Time Out Clear Flag
EricLew 0:80ee8f3b695e 677 * @arg UART_CLEAR_EOBF, End Of Block Clear Flag
EricLew 0:80ee8f3b695e 678 * @arg UART_CLEAR_CMF, Character Match Clear Flag
EricLew 0:80ee8f3b695e 679 * @arg UART_CLEAR_WUF, Wake Up from stop mode Clear Flag
EricLew 0:80ee8f3b695e 680 * @retval None
EricLew 0:80ee8f3b695e 681 */
EricLew 0:80ee8f3b695e 682 #define __HAL_UART_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
EricLew 0:80ee8f3b695e 683
EricLew 0:80ee8f3b695e 684 /** @brief Clear the UART PE pending flag.
EricLew 0:80ee8f3b695e 685 * @param __HANDLE__: specifies the UART Handle.
EricLew 0:80ee8f3b695e 686 * @retval None
EricLew 0:80ee8f3b695e 687 */
EricLew 0:80ee8f3b695e 688 #define __HAL_UART_CLEAR_PEFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_PEF)
EricLew 0:80ee8f3b695e 689
EricLew 0:80ee8f3b695e 690 /** @brief Clear the UART FE pending flag.
EricLew 0:80ee8f3b695e 691 * @param __HANDLE__: specifies the UART Handle.
EricLew 0:80ee8f3b695e 692 * @retval None
EricLew 0:80ee8f3b695e 693 */
EricLew 0:80ee8f3b695e 694 #define __HAL_UART_CLEAR_FEFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_FEF)
EricLew 0:80ee8f3b695e 695
EricLew 0:80ee8f3b695e 696 /** @brief Clear the UART NE pending flag.
EricLew 0:80ee8f3b695e 697 * @param __HANDLE__: specifies the UART Handle.
EricLew 0:80ee8f3b695e 698 * @retval None
EricLew 0:80ee8f3b695e 699 */
EricLew 0:80ee8f3b695e 700 #define __HAL_UART_CLEAR_NEFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_NEF)
EricLew 0:80ee8f3b695e 701
EricLew 0:80ee8f3b695e 702 /** @brief Clear the UART ORE pending flag.
EricLew 0:80ee8f3b695e 703 * @param __HANDLE__: specifies the UART Handle.
EricLew 0:80ee8f3b695e 704 * @retval None
EricLew 0:80ee8f3b695e 705 */
EricLew 0:80ee8f3b695e 706 #define __HAL_UART_CLEAR_OREFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_OREF)
EricLew 0:80ee8f3b695e 707
EricLew 0:80ee8f3b695e 708 /** @brief Clear the UART IDLE pending flag.
EricLew 0:80ee8f3b695e 709 * @param __HANDLE__: specifies the UART Handle.
EricLew 0:80ee8f3b695e 710 * @retval None
EricLew 0:80ee8f3b695e 711 */
EricLew 0:80ee8f3b695e 712 #define __HAL_UART_CLEAR_IDLEFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_IDLEF)
EricLew 0:80ee8f3b695e 713
EricLew 0:80ee8f3b695e 714 /** @brief Check whether the specified UART flag is set or not.
EricLew 0:80ee8f3b695e 715 * @param __HANDLE__: specifies the UART Handle.
EricLew 0:80ee8f3b695e 716 * @param __FLAG__: specifies the flag to check.
EricLew 0:80ee8f3b695e 717 * This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 718 * @arg UART_FLAG_REACK: Receive enable acknowledge flag
EricLew 0:80ee8f3b695e 719 * @arg UART_FLAG_TEACK: Transmit enable acknowledge flag
EricLew 0:80ee8f3b695e 720 * @arg UART_FLAG_WUF: Wake up from stop mode flag
EricLew 0:80ee8f3b695e 721 * @arg UART_FLAG_RWU: Receiver wake up flag (if the UART in mute mode)
EricLew 0:80ee8f3b695e 722 * @arg UART_FLAG_SBKF: Send Break flag
EricLew 0:80ee8f3b695e 723 * @arg UART_FLAG_CMF: Character match flag
EricLew 0:80ee8f3b695e 724 * @arg UART_FLAG_BUSY: Busy flag
EricLew 0:80ee8f3b695e 725 * @arg UART_FLAG_ABRF: Auto Baud rate detection flag
EricLew 0:80ee8f3b695e 726 * @arg UART_FLAG_ABRE: Auto Baud rate detection error flag
EricLew 0:80ee8f3b695e 727 * @arg UART_FLAG_EOBF: End of block flag
EricLew 0:80ee8f3b695e 728 * @arg UART_FLAG_RTOF: Receiver timeout flag
EricLew 0:80ee8f3b695e 729 * @arg UART_FLAG_CTS: CTS Change flag
EricLew 0:80ee8f3b695e 730 * @arg UART_FLAG_LBD: LIN Break detection flag
EricLew 0:80ee8f3b695e 731 * @arg UART_FLAG_TXE: Transmit data register empty flag
EricLew 0:80ee8f3b695e 732 * @arg UART_FLAG_TC: Transmission Complete flag
EricLew 0:80ee8f3b695e 733 * @arg UART_FLAG_RXNE: Receive data register not empty flag
EricLew 0:80ee8f3b695e 734 * @arg UART_FLAG_IDLE: Idle Line detection flag
EricLew 0:80ee8f3b695e 735 * @arg UART_FLAG_ORE: OverRun Error flag
EricLew 0:80ee8f3b695e 736 * @arg UART_FLAG_NE: Noise Error flag
EricLew 0:80ee8f3b695e 737 * @arg UART_FLAG_FE: Framing Error flag
EricLew 0:80ee8f3b695e 738 * @arg UART_FLAG_PE: Parity Error flag
EricLew 0:80ee8f3b695e 739 * @retval The new state of __FLAG__ (TRUE or FALSE).
EricLew 0:80ee8f3b695e 740 */
EricLew 0:80ee8f3b695e 741 #define __HAL_UART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))
EricLew 0:80ee8f3b695e 742
EricLew 0:80ee8f3b695e 743 /** @brief Enable the specified UART interrupt.
EricLew 0:80ee8f3b695e 744 * @param __HANDLE__: specifies the UART Handle.
EricLew 0:80ee8f3b695e 745 * @param __INTERRUPT__: specifies the UART interrupt source to enable.
EricLew 0:80ee8f3b695e 746 * This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 747 * @arg UART_IT_WUF: Wakeup from stop mode interrupt
EricLew 0:80ee8f3b695e 748 * @arg UART_IT_CM: Character match interrupt
EricLew 0:80ee8f3b695e 749 * @arg UART_IT_CTS: CTS change interrupt
EricLew 0:80ee8f3b695e 750 * @arg UART_IT_LBD: LIN Break detection interrupt
EricLew 0:80ee8f3b695e 751 * @arg UART_IT_TXE: Transmit Data Register empty interrupt
EricLew 0:80ee8f3b695e 752 * @arg UART_IT_TC: Transmission complete interrupt
EricLew 0:80ee8f3b695e 753 * @arg UART_IT_RXNE: Receive Data register not empty interrupt
EricLew 0:80ee8f3b695e 754 * @arg UART_IT_IDLE: Idle line detection interrupt
EricLew 0:80ee8f3b695e 755 * @arg UART_IT_PE: Parity Error interrupt
EricLew 0:80ee8f3b695e 756 * @arg UART_IT_ERR: Error interrupt (Frame error, noise error, overrun error)
EricLew 0:80ee8f3b695e 757 * @retval None
EricLew 0:80ee8f3b695e 758 */
EricLew 0:80ee8f3b695e 759 #define __HAL_UART_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 |= (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
EricLew 0:80ee8f3b695e 760 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 |= (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
EricLew 0:80ee8f3b695e 761 ((__HANDLE__)->Instance->CR3 |= (1U << ((__INTERRUPT__) & UART_IT_MASK))))
EricLew 0:80ee8f3b695e 762
EricLew 0:80ee8f3b695e 763
EricLew 0:80ee8f3b695e 764 /** @brief Disable the specified UART interrupt.
EricLew 0:80ee8f3b695e 765 * @param __HANDLE__: specifies the UART Handle.
EricLew 0:80ee8f3b695e 766 * @param __INTERRUPT__: specifies the UART interrupt source to disable.
EricLew 0:80ee8f3b695e 767 * This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 768 * @arg UART_IT_WUF: Wakeup from stop mode interrupt
EricLew 0:80ee8f3b695e 769 * @arg UART_IT_CM: Character match interrupt
EricLew 0:80ee8f3b695e 770 * @arg UART_IT_CTS: CTS change interrupt
EricLew 0:80ee8f3b695e 771 * @arg UART_IT_LBD: LIN Break detection interrupt
EricLew 0:80ee8f3b695e 772 * @arg UART_IT_TXE: Transmit Data Register empty interrupt
EricLew 0:80ee8f3b695e 773 * @arg UART_IT_TC: Transmission complete interrupt
EricLew 0:80ee8f3b695e 774 * @arg UART_IT_RXNE: Receive Data register not empty interrupt
EricLew 0:80ee8f3b695e 775 * @arg UART_IT_IDLE: Idle line detection interrupt
EricLew 0:80ee8f3b695e 776 * @arg UART_IT_PE: Parity Error interrupt
EricLew 0:80ee8f3b695e 777 * @arg UART_IT_ERR: Error interrupt (Frame error, noise error, overrun error)
EricLew 0:80ee8f3b695e 778 * @retval None
EricLew 0:80ee8f3b695e 779 */
EricLew 0:80ee8f3b695e 780 #define __HAL_UART_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 &= ~ (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
EricLew 0:80ee8f3b695e 781 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 &= ~ (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
EricLew 0:80ee8f3b695e 782 ((__HANDLE__)->Instance->CR3 &= ~ (1U << ((__INTERRUPT__) & UART_IT_MASK))))
EricLew 0:80ee8f3b695e 783
EricLew 0:80ee8f3b695e 784 /** @brief Check whether the specified UART interrupt has occurred or not.
EricLew 0:80ee8f3b695e 785 * @param __HANDLE__: specifies the UART Handle.
EricLew 0:80ee8f3b695e 786 * @param __IT__: specifies the UART interrupt to check.
EricLew 0:80ee8f3b695e 787 * This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 788 * @arg UART_IT_WUF: Wakeup from stop mode interrupt
EricLew 0:80ee8f3b695e 789 * @arg UART_IT_CM: Character match interrupt
EricLew 0:80ee8f3b695e 790 * @arg UART_IT_CTS: CTS change interrupt
EricLew 0:80ee8f3b695e 791 * @arg UART_IT_LBD: LIN Break detection interrupt
EricLew 0:80ee8f3b695e 792 * @arg UART_IT_TXE: Transmit Data Register empty interrupt
EricLew 0:80ee8f3b695e 793 * @arg UART_IT_TC: Transmission complete interrupt
EricLew 0:80ee8f3b695e 794 * @arg UART_IT_RXNE: Receive Data register not empty interrupt
EricLew 0:80ee8f3b695e 795 * @arg UART_IT_IDLE: Idle line detection interrupt
EricLew 0:80ee8f3b695e 796 * @arg UART_IT_ORE: OverRun Error interrupt
EricLew 0:80ee8f3b695e 797 * @arg UART_IT_NE: Noise Error interrupt
EricLew 0:80ee8f3b695e 798 * @arg UART_IT_FE: Framing Error interrupt
EricLew 0:80ee8f3b695e 799 * @arg UART_IT_PE: Parity Error interrupt
EricLew 0:80ee8f3b695e 800 * @retval The new state of __IT__ (TRUE or FALSE).
EricLew 0:80ee8f3b695e 801 */
EricLew 0:80ee8f3b695e 802 #define __HAL_UART_GET_IT(__HANDLE__, __IT__) ((__HANDLE__)->Instance->ISR & ((uint32_t)1 << ((__IT__)>> 0x08)))
EricLew 0:80ee8f3b695e 803
EricLew 0:80ee8f3b695e 804 /** @brief Check whether the specified UART interrupt source is enabled or not.
EricLew 0:80ee8f3b695e 805 * @param __HANDLE__: specifies the UART Handle.
EricLew 0:80ee8f3b695e 806 * @param __IT__: specifies the UART interrupt source to check.
EricLew 0:80ee8f3b695e 807 * This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 808 * @arg UART_IT_WUF: Wakeup from stop mode interrupt
EricLew 0:80ee8f3b695e 809 * @arg UART_IT_CM: Character match interrupt
EricLew 0:80ee8f3b695e 810 * @arg UART_IT_CTS: CTS change interrupt
EricLew 0:80ee8f3b695e 811 * @arg UART_IT_LBD: LIN Break detection interrupt
EricLew 0:80ee8f3b695e 812 * @arg UART_IT_TXE: Transmit Data Register empty interrupt
EricLew 0:80ee8f3b695e 813 * @arg UART_IT_TC: Transmission complete interrupt
EricLew 0:80ee8f3b695e 814 * @arg UART_IT_RXNE: Receive Data register not empty interrupt
EricLew 0:80ee8f3b695e 815 * @arg UART_IT_IDLE: Idle line detection interrupt
EricLew 0:80ee8f3b695e 816 * @arg UART_IT_ORE: OverRun Error interrupt
EricLew 0:80ee8f3b695e 817 * @arg UART_IT_NE: Noise Error interrupt
EricLew 0:80ee8f3b695e 818 * @arg UART_IT_FE: Framing Error interrupt
EricLew 0:80ee8f3b695e 819 * @arg UART_IT_PE: Parity Error interrupt
EricLew 0:80ee8f3b695e 820 * @retval The new state of __IT__ (TRUE or FALSE).
EricLew 0:80ee8f3b695e 821 */
EricLew 0:80ee8f3b695e 822 #define __HAL_UART_GET_IT_SOURCE(__HANDLE__, __IT__) ((((((uint8_t)(__IT__)) >> 5U) == 1)? (__HANDLE__)->Instance->CR1:(((((uint8_t)(__IT__)) >> 5U) == 2)? \
EricLew 0:80ee8f3b695e 823 (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & ((uint32_t)1 << (((uint16_t)(__IT__)) & UART_IT_MASK)))
EricLew 0:80ee8f3b695e 824
EricLew 0:80ee8f3b695e 825 /** @brief Clear the specified UART ISR flag, in setting the proper ICR register flag.
EricLew 0:80ee8f3b695e 826 * @param __HANDLE__: specifies the UART Handle.
EricLew 0:80ee8f3b695e 827 * @param __IT_CLEAR__: specifies the interrupt clear register flag that needs to be set
EricLew 0:80ee8f3b695e 828 * to clear the corresponding interrupt
EricLew 0:80ee8f3b695e 829 * This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 830 * @arg UART_CLEAR_PEF: Parity Error Clear Flag
EricLew 0:80ee8f3b695e 831 * @arg UART_CLEAR_FEF: Framing Error Clear Flag
EricLew 0:80ee8f3b695e 832 * @arg UART_CLEAR_NEF: Noise detected Clear Flag
EricLew 0:80ee8f3b695e 833 * @arg UART_CLEAR_OREF: OverRun Error Clear Flag
EricLew 0:80ee8f3b695e 834 * @arg UART_CLEAR_IDLEF: IDLE line detected Clear Flag
EricLew 0:80ee8f3b695e 835 * @arg UART_CLEAR_TCF: Transmission Complete Clear Flag
EricLew 0:80ee8f3b695e 836 * @arg UART_CLEAR_LBDF: LIN Break Detection Clear Flag
EricLew 0:80ee8f3b695e 837 * @arg UART_CLEAR_CTSF: CTS Interrupt Clear Flag
EricLew 0:80ee8f3b695e 838 * @arg UART_CLEAR_RTOF: Receiver Time Out Clear Flag
EricLew 0:80ee8f3b695e 839 * @arg UART_CLEAR_EOBF: End Of Block Clear Flag
EricLew 0:80ee8f3b695e 840 * @arg UART_CLEAR_CMF: Character Match Clear Flag
EricLew 0:80ee8f3b695e 841 * @arg UART_CLEAR_WUF: Wake Up from stop mode Clear Flag
EricLew 0:80ee8f3b695e 842 * @retval None
EricLew 0:80ee8f3b695e 843 */
EricLew 0:80ee8f3b695e 844 #define __HAL_UART_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__))
EricLew 0:80ee8f3b695e 845
EricLew 0:80ee8f3b695e 846 /** @brief Set a specific UART request flag.
EricLew 0:80ee8f3b695e 847 * @param __HANDLE__: specifies the UART Handle.
EricLew 0:80ee8f3b695e 848 * @param __REQ__: specifies the request flag to set
EricLew 0:80ee8f3b695e 849 * This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 850 * @arg UART_AUTOBAUD_REQUEST: Auto-Baud Rate Request
EricLew 0:80ee8f3b695e 851 * @arg UART_SENDBREAK_REQUEST: Send Break Request
EricLew 0:80ee8f3b695e 852 * @arg UART_MUTE_MODE_REQUEST: Mute Mode Request
EricLew 0:80ee8f3b695e 853 * @arg UART_RXDATA_FLUSH_REQUEST: Receive Data flush Request
EricLew 0:80ee8f3b695e 854 * @arg UART_TXDATA_FLUSH_REQUEST: Transmit data flush Request
EricLew 0:80ee8f3b695e 855 * @retval None
EricLew 0:80ee8f3b695e 856 */
EricLew 0:80ee8f3b695e 857 #define __HAL_UART_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (uint32_t)(__REQ__))
EricLew 0:80ee8f3b695e 858
EricLew 0:80ee8f3b695e 859 /** @brief Enable the UART one bit sample method.
EricLew 0:80ee8f3b695e 860 * @param __HANDLE__: specifies the UART Handle.
EricLew 0:80ee8f3b695e 861 * @retval None
EricLew 0:80ee8f3b695e 862 */
EricLew 0:80ee8f3b695e 863 #define __HAL_UART_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
EricLew 0:80ee8f3b695e 864
EricLew 0:80ee8f3b695e 865 /** @brief Disable the UART one bit sample method.
EricLew 0:80ee8f3b695e 866 * @param __HANDLE__: specifies the UART Handle.
EricLew 0:80ee8f3b695e 867 * @retval None
EricLew 0:80ee8f3b695e 868 */
EricLew 0:80ee8f3b695e 869 #define __HAL_UART_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint32_t)~((uint32_t)USART_CR3_ONEBIT))
EricLew 0:80ee8f3b695e 870
EricLew 0:80ee8f3b695e 871 /** @brief Enable UART.
EricLew 0:80ee8f3b695e 872 * @param __HANDLE__: specifies the UART Handle.
EricLew 0:80ee8f3b695e 873 * @retval None
EricLew 0:80ee8f3b695e 874 */
EricLew 0:80ee8f3b695e 875 #define __HAL_UART_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
EricLew 0:80ee8f3b695e 876
EricLew 0:80ee8f3b695e 877 /** @brief Disable UART.
EricLew 0:80ee8f3b695e 878 * @param __HANDLE__: specifies the UART Handle.
EricLew 0:80ee8f3b695e 879 * @retval None
EricLew 0:80ee8f3b695e 880 */
EricLew 0:80ee8f3b695e 881 #define __HAL_UART_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
EricLew 0:80ee8f3b695e 882
EricLew 0:80ee8f3b695e 883 /** @brief Enable CTS flow control.
EricLew 0:80ee8f3b695e 884 * @note This macro allows to enable CTS hardware flow control for a given UART instance,
EricLew 0:80ee8f3b695e 885 * without need to call HAL_UART_Init() function.
EricLew 0:80ee8f3b695e 886 * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
EricLew 0:80ee8f3b695e 887 * @note As macro is expected to be used for modifying CTS Hw flow control feature activation, without need
EricLew 0:80ee8f3b695e 888 * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
EricLew 0:80ee8f3b695e 889 * - UART instance should have already been initialised (through call of HAL_UART_Init() )
EricLew 0:80ee8f3b695e 890 * - macro could only be called when corresponding UART instance is disabled (i.e. __HAL_UART_DISABLE(__HANDLE__))
EricLew 0:80ee8f3b695e 891 * and should be followed by an Enable macro (i.e. __HAL_UART_ENABLE(__HANDLE__)).
EricLew 0:80ee8f3b695e 892 * @param __HANDLE__: specifies the UART Handle.
EricLew 0:80ee8f3b695e 893 * @retval None
EricLew 0:80ee8f3b695e 894 */
EricLew 0:80ee8f3b695e 895 #define __HAL_UART_HWCONTROL_CTS_ENABLE(__HANDLE__) \
EricLew 0:80ee8f3b695e 896 do{ \
EricLew 0:80ee8f3b695e 897 SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \
EricLew 0:80ee8f3b695e 898 (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_CTSE; \
EricLew 0:80ee8f3b695e 899 } while(0)
EricLew 0:80ee8f3b695e 900
EricLew 0:80ee8f3b695e 901 /** @brief Disable CTS flow control.
EricLew 0:80ee8f3b695e 902 * @note This macro allows to disable CTS hardware flow control for a given UART instance,
EricLew 0:80ee8f3b695e 903 * without need to call HAL_UART_Init() function.
EricLew 0:80ee8f3b695e 904 * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
EricLew 0:80ee8f3b695e 905 * @note As macro is expected to be used for modifying CTS Hw flow control feature activation, without need
EricLew 0:80ee8f3b695e 906 * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
EricLew 0:80ee8f3b695e 907 * - UART instance should have already been initialised (through call of HAL_UART_Init() )
EricLew 0:80ee8f3b695e 908 * - macro could only be called when corresponding UART instance is disabled (i.e. __HAL_UART_DISABLE(__HANDLE__))
EricLew 0:80ee8f3b695e 909 * and should be followed by an Enable macro (i.e. __HAL_UART_ENABLE(__HANDLE__)).
EricLew 0:80ee8f3b695e 910 * @param __HANDLE__: specifies the UART Handle.
EricLew 0:80ee8f3b695e 911 * @retval None
EricLew 0:80ee8f3b695e 912 */
EricLew 0:80ee8f3b695e 913 #define __HAL_UART_HWCONTROL_CTS_DISABLE(__HANDLE__) \
EricLew 0:80ee8f3b695e 914 do{ \
EricLew 0:80ee8f3b695e 915 CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \
EricLew 0:80ee8f3b695e 916 (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_CTSE); \
EricLew 0:80ee8f3b695e 917 } while(0)
EricLew 0:80ee8f3b695e 918
EricLew 0:80ee8f3b695e 919 /** @brief Enable RTS flow control.
EricLew 0:80ee8f3b695e 920 * @note This macro allows to enable RTS hardware flow control for a given UART instance,
EricLew 0:80ee8f3b695e 921 * without need to call HAL_UART_Init() function.
EricLew 0:80ee8f3b695e 922 * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
EricLew 0:80ee8f3b695e 923 * @note As macro is expected to be used for modifying RTS Hw flow control feature activation, without need
EricLew 0:80ee8f3b695e 924 * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
EricLew 0:80ee8f3b695e 925 * - UART instance should have already been initialised (through call of HAL_UART_Init() )
EricLew 0:80ee8f3b695e 926 * - macro could only be called when corresponding UART instance is disabled (i.e. __HAL_UART_DISABLE(__HANDLE__))
EricLew 0:80ee8f3b695e 927 * and should be followed by an Enable macro (i.e. __HAL_UART_ENABLE(__HANDLE__)).
EricLew 0:80ee8f3b695e 928 * @param __HANDLE__: specifies the UART Handle.
EricLew 0:80ee8f3b695e 929 * @retval None
EricLew 0:80ee8f3b695e 930 */
EricLew 0:80ee8f3b695e 931 #define __HAL_UART_HWCONTROL_RTS_ENABLE(__HANDLE__) \
EricLew 0:80ee8f3b695e 932 do{ \
EricLew 0:80ee8f3b695e 933 SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE); \
EricLew 0:80ee8f3b695e 934 (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_RTSE; \
EricLew 0:80ee8f3b695e 935 } while(0)
EricLew 0:80ee8f3b695e 936
EricLew 0:80ee8f3b695e 937 /** @brief Disable RTS flow control.
EricLew 0:80ee8f3b695e 938 * @note This macro allows to disable RTS hardware flow control for a given UART instance,
EricLew 0:80ee8f3b695e 939 * without need to call HAL_UART_Init() function.
EricLew 0:80ee8f3b695e 940 * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
EricLew 0:80ee8f3b695e 941 * @note As macro is expected to be used for modifying RTS Hw flow control feature activation, without need
EricLew 0:80ee8f3b695e 942 * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
EricLew 0:80ee8f3b695e 943 * - UART instance should have already been initialised (through call of HAL_UART_Init() )
EricLew 0:80ee8f3b695e 944 * - macro could only be called when corresponding UART instance is disabled (i.e. __HAL_UART_DISABLE(__HANDLE__))
EricLew 0:80ee8f3b695e 945 * and should be followed by an Enable macro (i.e. __HAL_UART_ENABLE(__HANDLE__)).
EricLew 0:80ee8f3b695e 946 * @param __HANDLE__: specifies the UART Handle.
EricLew 0:80ee8f3b695e 947 * @retval None
EricLew 0:80ee8f3b695e 948 */
EricLew 0:80ee8f3b695e 949 #define __HAL_UART_HWCONTROL_RTS_DISABLE(__HANDLE__) \
EricLew 0:80ee8f3b695e 950 do{ \
EricLew 0:80ee8f3b695e 951 CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE);\
EricLew 0:80ee8f3b695e 952 (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_RTSE); \
EricLew 0:80ee8f3b695e 953 } while(0)
EricLew 0:80ee8f3b695e 954
EricLew 0:80ee8f3b695e 955 /**
EricLew 0:80ee8f3b695e 956 * @}
EricLew 0:80ee8f3b695e 957 */
EricLew 0:80ee8f3b695e 958
EricLew 0:80ee8f3b695e 959 /* Private macros --------------------------------------------------------*/
EricLew 0:80ee8f3b695e 960 /** @defgroup UART_Private_Macros UART Private Macros
EricLew 0:80ee8f3b695e 961 * @{
EricLew 0:80ee8f3b695e 962 */
EricLew 0:80ee8f3b695e 963 /** @brief BRR division operation to set BRR register with LPUART.
EricLew 0:80ee8f3b695e 964 * @param __PCLK__: LPUART clock.
EricLew 0:80ee8f3b695e 965 * @param __BAUD__: Baud rate set by the user.
EricLew 0:80ee8f3b695e 966 * @retval Division result
EricLew 0:80ee8f3b695e 967 */
EricLew 0:80ee8f3b695e 968 #define UART_DIV_LPUART(__PCLK__, __BAUD__) (((uint64_t)(__PCLK__)*256)/((__BAUD__)))
EricLew 0:80ee8f3b695e 969
EricLew 0:80ee8f3b695e 970 /** @brief BRR division operation to set BRR register in 8-bit oversampling mode.
EricLew 0:80ee8f3b695e 971 * @param __PCLK__: UART clock.
EricLew 0:80ee8f3b695e 972 * @param __BAUD__: Baud rate set by the user.
EricLew 0:80ee8f3b695e 973 * @retval Division result
EricLew 0:80ee8f3b695e 974 */
EricLew 0:80ee8f3b695e 975 #define UART_DIV_SAMPLING8(__PCLK__, __BAUD__) (((__PCLK__)*2)/((__BAUD__)))
EricLew 0:80ee8f3b695e 976
EricLew 0:80ee8f3b695e 977 /** @brief BRR division operation to set BRR register in 16-bit oversampling mode.
EricLew 0:80ee8f3b695e 978 * @param __PCLK__: UART clock.
EricLew 0:80ee8f3b695e 979 * @param __BAUD__: Baud rate set by the user.
EricLew 0:80ee8f3b695e 980 * @retval Division result
EricLew 0:80ee8f3b695e 981 */
EricLew 0:80ee8f3b695e 982 #define UART_DIV_SAMPLING16(__PCLK__, __BAUD__) (((__PCLK__))/((__BAUD__)))
EricLew 0:80ee8f3b695e 983
EricLew 0:80ee8f3b695e 984 /** @brief Check whether or not UART instance is Low Power UART.
EricLew 0:80ee8f3b695e 985 * @param __HANDLE__: specifies the UART Handle.
EricLew 0:80ee8f3b695e 986 * @retval SET (instance is LPUART) or RESET (instance isn't LPUART)
EricLew 0:80ee8f3b695e 987 */
EricLew 0:80ee8f3b695e 988 #define UART_INSTANCE_LOWPOWER(__HANDLE__) (((__HANDLE__)->Instance == LPUART1) ? SET : RESET )
EricLew 0:80ee8f3b695e 989
EricLew 0:80ee8f3b695e 990 /** @brief Check UART Baud rate.
EricLew 0:80ee8f3b695e 991 * @param __BAUDRATE__: Baudrate specified by the user.
EricLew 0:80ee8f3b695e 992 * The maximum Baud Rate is derived from the maximum clock on L4 (i.e. 80 MHz)
EricLew 0:80ee8f3b695e 993 * divided by the smallest oversampling used on the USART (i.e. 8)
EricLew 0:80ee8f3b695e 994 * @retval SET (__BAUDRATE__ is valid) or RESET (__BAUDRATE__ is invalid)
EricLew 0:80ee8f3b695e 995 */
EricLew 0:80ee8f3b695e 996 #define IS_UART_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 10000001)
EricLew 0:80ee8f3b695e 997
EricLew 0:80ee8f3b695e 998 /** @brief Check UART assertion time.
EricLew 0:80ee8f3b695e 999 * @param __TIME__: 5-bit value assertion time.
EricLew 0:80ee8f3b695e 1000 * @retval Test result (TRUE or FALSE).
EricLew 0:80ee8f3b695e 1001 */
EricLew 0:80ee8f3b695e 1002 #define IS_UART_ASSERTIONTIME(__TIME__) ((__TIME__) <= 0x1F)
EricLew 0:80ee8f3b695e 1003
EricLew 0:80ee8f3b695e 1004 /** @brief Check UART deassertion time.
EricLew 0:80ee8f3b695e 1005 * @param __TIME__: 5-bit value deassertion time.
EricLew 0:80ee8f3b695e 1006 * @retval Test result (TRUE or FALSE).
EricLew 0:80ee8f3b695e 1007 */
EricLew 0:80ee8f3b695e 1008 #define IS_UART_DEASSERTIONTIME(__TIME__) ((__TIME__) <= 0x1F)
EricLew 0:80ee8f3b695e 1009
EricLew 0:80ee8f3b695e 1010 /**
EricLew 0:80ee8f3b695e 1011 * @brief Ensure that UART frame number of stop bits is valid.
EricLew 0:80ee8f3b695e 1012 * @param __STOPBITS__: UART frame number of stop bits.
EricLew 0:80ee8f3b695e 1013 * @retval SET (__STOPBITS__ is valid) or RESET (__STOPBITS__ is invalid)
EricLew 0:80ee8f3b695e 1014 */
EricLew 0:80ee8f3b695e 1015 #define IS_UART_STOPBITS(__STOPBITS__) (((__STOPBITS__) == UART_STOPBITS_1) || \
EricLew 0:80ee8f3b695e 1016 ((__STOPBITS__) == UART_STOPBITS_2) || \
EricLew 0:80ee8f3b695e 1017 ((__STOPBITS__) == UART_STOPBITS_1_5))
EricLew 0:80ee8f3b695e 1018
EricLew 0:80ee8f3b695e 1019 /**
EricLew 0:80ee8f3b695e 1020 * @brief Ensure that UART frame parity is valid.
EricLew 0:80ee8f3b695e 1021 * @param __PARITY__: UART frame parity.
EricLew 0:80ee8f3b695e 1022 * @retval SET (__PARITY__ is valid) or RESET (__PARITY__ is invalid)
EricLew 0:80ee8f3b695e 1023 */
EricLew 0:80ee8f3b695e 1024 #define IS_UART_PARITY(__PARITY__) (((__PARITY__) == UART_PARITY_NONE) || \
EricLew 0:80ee8f3b695e 1025 ((__PARITY__) == UART_PARITY_EVEN) || \
EricLew 0:80ee8f3b695e 1026 ((__PARITY__) == UART_PARITY_ODD))
EricLew 0:80ee8f3b695e 1027
EricLew 0:80ee8f3b695e 1028 /**
EricLew 0:80ee8f3b695e 1029 * @brief Ensure that UART hardware flow control is valid.
EricLew 0:80ee8f3b695e 1030 * @param __CONTROL__: UART hardware flow control.
EricLew 0:80ee8f3b695e 1031 * @retval SET (__CONTROL__ is valid) or RESET (__CONTROL__ is invalid)
EricLew 0:80ee8f3b695e 1032 */
EricLew 0:80ee8f3b695e 1033 #define IS_UART_HARDWARE_FLOW_CONTROL(__CONTROL__)\
EricLew 0:80ee8f3b695e 1034 (((__CONTROL__) == UART_HWCONTROL_NONE) || \
EricLew 0:80ee8f3b695e 1035 ((__CONTROL__) == UART_HWCONTROL_RTS) || \
EricLew 0:80ee8f3b695e 1036 ((__CONTROL__) == UART_HWCONTROL_CTS) || \
EricLew 0:80ee8f3b695e 1037 ((__CONTROL__) == UART_HWCONTROL_RTS_CTS))
EricLew 0:80ee8f3b695e 1038
EricLew 0:80ee8f3b695e 1039 /**
EricLew 0:80ee8f3b695e 1040 * @brief Ensure that UART communication mode is valid.
EricLew 0:80ee8f3b695e 1041 * @param __MODE__: UART communication mode.
EricLew 0:80ee8f3b695e 1042 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
EricLew 0:80ee8f3b695e 1043 */
EricLew 0:80ee8f3b695e 1044 #define IS_UART_MODE(__MODE__) ((((__MODE__) & (~((uint32_t)(UART_MODE_TX_RX)))) == (uint32_t)0x00) && ((__MODE__) != (uint32_t)0x00))
EricLew 0:80ee8f3b695e 1045
EricLew 0:80ee8f3b695e 1046 /**
EricLew 0:80ee8f3b695e 1047 * @brief Ensure that UART state is valid.
EricLew 0:80ee8f3b695e 1048 * @param __STATE__: UART state.
EricLew 0:80ee8f3b695e 1049 * @retval SET (__STATE__ is valid) or RESET (__STATE__ is invalid)
EricLew 0:80ee8f3b695e 1050 */
EricLew 0:80ee8f3b695e 1051 #define IS_UART_STATE(__STATE__) (((__STATE__) == UART_STATE_DISABLE) || \
EricLew 0:80ee8f3b695e 1052 ((__STATE__) == UART_STATE_ENABLE))
EricLew 0:80ee8f3b695e 1053
EricLew 0:80ee8f3b695e 1054 /**
EricLew 0:80ee8f3b695e 1055 * @brief Ensure that UART oversampling is valid.
EricLew 0:80ee8f3b695e 1056 * @param __SAMPLING__: UART oversampling.
EricLew 0:80ee8f3b695e 1057 * @retval SET (__SAMPLING__ is valid) or RESET (__SAMPLING__ is invalid)
EricLew 0:80ee8f3b695e 1058 */
EricLew 0:80ee8f3b695e 1059 #define IS_UART_OVERSAMPLING(__SAMPLING__) (((__SAMPLING__) == UART_OVERSAMPLING_16) || \
EricLew 0:80ee8f3b695e 1060 ((__SAMPLING__) == UART_OVERSAMPLING_8))
EricLew 0:80ee8f3b695e 1061
EricLew 0:80ee8f3b695e 1062 /**
EricLew 0:80ee8f3b695e 1063 * @brief Ensure that UART frame sampling is valid.
EricLew 0:80ee8f3b695e 1064 * @param __ONEBIT__: UART frame sampling.
EricLew 0:80ee8f3b695e 1065 * @retval SET (__ONEBIT__ is valid) or RESET (__ONEBIT__ is invalid)
EricLew 0:80ee8f3b695e 1066 */
EricLew 0:80ee8f3b695e 1067 #define IS_UART_ONE_BIT_SAMPLE(__ONEBIT__) (((__ONEBIT__) == UART_ONE_BIT_SAMPLE_DISABLE) || \
EricLew 0:80ee8f3b695e 1068 ((__ONEBIT__) == UART_ONE_BIT_SAMPLE_ENABLE))
EricLew 0:80ee8f3b695e 1069
EricLew 0:80ee8f3b695e 1070 /**
EricLew 0:80ee8f3b695e 1071 * @brief Ensure that UART auto Baud rate detection mode is valid.
EricLew 0:80ee8f3b695e 1072 * @param __MODE__: UART auto Baud rate detection mode.
EricLew 0:80ee8f3b695e 1073 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
EricLew 0:80ee8f3b695e 1074 */
EricLew 0:80ee8f3b695e 1075 #define IS_UART_ADVFEATURE_AUTOBAUDRATEMODE(__MODE__) (((__MODE__) == UART_ADVFEATURE_AUTOBAUDRATE_ONSTARTBIT) || \
EricLew 0:80ee8f3b695e 1076 ((__MODE__) == UART_ADVFEATURE_AUTOBAUDRATE_ONFALLINGEDGE) || \
EricLew 0:80ee8f3b695e 1077 ((__MODE__) == UART_ADVFEATURE_AUTOBAUDRATE_ON0X7FFRAME) || \
EricLew 0:80ee8f3b695e 1078 ((__MODE__) == UART_ADVFEATURE_AUTOBAUDRATE_ON0X55FRAME))
EricLew 0:80ee8f3b695e 1079
EricLew 0:80ee8f3b695e 1080 /**
EricLew 0:80ee8f3b695e 1081 * @brief Ensure that UART receiver timeout setting is valid.
EricLew 0:80ee8f3b695e 1082 * @param __TIMEOUT__: UART receiver timeout setting.
EricLew 0:80ee8f3b695e 1083 * @retval SET (__TIMEOUT__ is valid) or RESET (__TIMEOUT__ is invalid)
EricLew 0:80ee8f3b695e 1084 */
EricLew 0:80ee8f3b695e 1085 #define IS_UART_RECEIVER_TIMEOUT(__TIMEOUT__) (((__TIMEOUT__) == UART_RECEIVER_TIMEOUT_DISABLE) || \
EricLew 0:80ee8f3b695e 1086 ((__TIMEOUT__) == UART_RECEIVER_TIMEOUT_ENABLE))
EricLew 0:80ee8f3b695e 1087
EricLew 0:80ee8f3b695e 1088 /**
EricLew 0:80ee8f3b695e 1089 * @brief Ensure that UART LIN state is valid.
EricLew 0:80ee8f3b695e 1090 * @param __LIN__: UART LIN state.
EricLew 0:80ee8f3b695e 1091 * @retval SET (__LIN__ is valid) or RESET (__LIN__ is invalid)
EricLew 0:80ee8f3b695e 1092 */
EricLew 0:80ee8f3b695e 1093 #define IS_UART_LIN(__LIN__) (((__LIN__) == UART_LIN_DISABLE) || \
EricLew 0:80ee8f3b695e 1094 ((__LIN__) == UART_LIN_ENABLE))
EricLew 0:80ee8f3b695e 1095
EricLew 0:80ee8f3b695e 1096 /**
EricLew 0:80ee8f3b695e 1097 * @brief Ensure that UART LIN break detection length is valid.
EricLew 0:80ee8f3b695e 1098 * @param __LENGTH__: UART LIN break detection length.
EricLew 0:80ee8f3b695e 1099 * @retval SET (__LENGTH__ is valid) or RESET (__LENGTH__ is invalid)
EricLew 0:80ee8f3b695e 1100 */
EricLew 0:80ee8f3b695e 1101 #define IS_UART_LIN_BREAK_DETECT_LENGTH(__LENGTH__) (((__LENGTH__) == UART_LINBREAKDETECTLENGTH_10B) || \
EricLew 0:80ee8f3b695e 1102 ((__LENGTH__) == UART_LINBREAKDETECTLENGTH_11B))
EricLew 0:80ee8f3b695e 1103
EricLew 0:80ee8f3b695e 1104 /**
EricLew 0:80ee8f3b695e 1105 * @brief Ensure that UART DMA TX state is valid.
EricLew 0:80ee8f3b695e 1106 * @param __DMATX__: UART DMA TX state.
EricLew 0:80ee8f3b695e 1107 * @retval SET (__DMATX__ is valid) or RESET (__DMATX__ is invalid)
EricLew 0:80ee8f3b695e 1108 */
EricLew 0:80ee8f3b695e 1109 #define IS_UART_DMA_TX(__DMATX__) (((__DMATX__) == UART_DMA_TX_DISABLE) || \
EricLew 0:80ee8f3b695e 1110 ((__DMATX__) == UART_DMA_TX_ENABLE))
EricLew 0:80ee8f3b695e 1111
EricLew 0:80ee8f3b695e 1112 /**
EricLew 0:80ee8f3b695e 1113 * @brief Ensure that UART DMA RX state is valid.
EricLew 0:80ee8f3b695e 1114 * @param __DMARX__: UART DMA RX state.
EricLew 0:80ee8f3b695e 1115 * @retval SET (__DMARX__ is valid) or RESET (__DMARX__ is invalid)
EricLew 0:80ee8f3b695e 1116 */
EricLew 0:80ee8f3b695e 1117 #define IS_UART_DMA_RX(__DMARX__) (((__DMARX__) == UART_DMA_RX_DISABLE) || \
EricLew 0:80ee8f3b695e 1118 ((__DMARX__) == UART_DMA_RX_ENABLE))
EricLew 0:80ee8f3b695e 1119
EricLew 0:80ee8f3b695e 1120 /**
EricLew 0:80ee8f3b695e 1121 * @brief Ensure that UART half-duplex state is valid.
EricLew 0:80ee8f3b695e 1122 * @param __HDSEL__: UART half-duplex state.
EricLew 0:80ee8f3b695e 1123 * @retval SET (__HDSEL__ is valid) or RESET (__HDSEL__ is invalid)
EricLew 0:80ee8f3b695e 1124 */
EricLew 0:80ee8f3b695e 1125 #define IS_UART_HALF_DUPLEX(__HDSEL__) (((__HDSEL__) == UART_HALF_DUPLEX_DISABLE) || \
EricLew 0:80ee8f3b695e 1126 ((__HDSEL__) == UART_HALF_DUPLEX_ENABLE))
EricLew 0:80ee8f3b695e 1127
EricLew 0:80ee8f3b695e 1128 /**
EricLew 0:80ee8f3b695e 1129 * @brief Ensure that UART wake-up method is valid.
EricLew 0:80ee8f3b695e 1130 * @param __WAKEUP__: UART wake-up method .
EricLew 0:80ee8f3b695e 1131 * @retval SET (__WAKEUP__ is valid) or RESET (__WAKEUP__ is invalid)
EricLew 0:80ee8f3b695e 1132 */
EricLew 0:80ee8f3b695e 1133 #define IS_UART_WAKEUPMETHOD(__WAKEUP__) (((__WAKEUP__) == UART_WAKEUPMETHOD_IDLELINE) || \
EricLew 0:80ee8f3b695e 1134 ((__WAKEUP__) == UART_WAKEUPMETHOD_ADDRESSMARK))
EricLew 0:80ee8f3b695e 1135
EricLew 0:80ee8f3b695e 1136 /**
EricLew 0:80ee8f3b695e 1137 * @brief Ensure that UART request parameter is valid.
EricLew 0:80ee8f3b695e 1138 * @param __PARAM__: UART request parameter.
EricLew 0:80ee8f3b695e 1139 * @retval SET (__PARAM__ is valid) or RESET (__PARAM__ is invalid)
EricLew 0:80ee8f3b695e 1140 */
EricLew 0:80ee8f3b695e 1141 #define IS_UART_REQUEST_PARAMETER(__PARAM__) (((__PARAM__) == UART_AUTOBAUD_REQUEST) || \
EricLew 0:80ee8f3b695e 1142 ((__PARAM__) == UART_SENDBREAK_REQUEST) || \
EricLew 0:80ee8f3b695e 1143 ((__PARAM__) == UART_MUTE_MODE_REQUEST) || \
EricLew 0:80ee8f3b695e 1144 ((__PARAM__) == UART_RXDATA_FLUSH_REQUEST) || \
EricLew 0:80ee8f3b695e 1145 ((__PARAM__) == UART_TXDATA_FLUSH_REQUEST))
EricLew 0:80ee8f3b695e 1146
EricLew 0:80ee8f3b695e 1147 /**
EricLew 0:80ee8f3b695e 1148 * @brief Ensure that UART advanced features initialization is valid.
EricLew 0:80ee8f3b695e 1149 * @param __INIT__: UART advanced features initialization.
EricLew 0:80ee8f3b695e 1150 * @retval SET (__INIT__ is valid) or RESET (__INIT__ is invalid)
EricLew 0:80ee8f3b695e 1151 */
EricLew 0:80ee8f3b695e 1152 #define IS_UART_ADVFEATURE_INIT(__INIT__) ((__INIT__) <= (UART_ADVFEATURE_NO_INIT | \
EricLew 0:80ee8f3b695e 1153 UART_ADVFEATURE_TXINVERT_INIT | \
EricLew 0:80ee8f3b695e 1154 UART_ADVFEATURE_RXINVERT_INIT | \
EricLew 0:80ee8f3b695e 1155 UART_ADVFEATURE_DATAINVERT_INIT | \
EricLew 0:80ee8f3b695e 1156 UART_ADVFEATURE_SWAP_INIT | \
EricLew 0:80ee8f3b695e 1157 UART_ADVFEATURE_RXOVERRUNDISABLE_INIT | \
EricLew 0:80ee8f3b695e 1158 UART_ADVFEATURE_DMADISABLEONERROR_INIT | \
EricLew 0:80ee8f3b695e 1159 UART_ADVFEATURE_AUTOBAUDRATE_INIT | \
EricLew 0:80ee8f3b695e 1160 UART_ADVFEATURE_MSBFIRST_INIT))
EricLew 0:80ee8f3b695e 1161
EricLew 0:80ee8f3b695e 1162 /**
EricLew 0:80ee8f3b695e 1163 * @brief Ensure that UART frame TX inversion setting is valid.
EricLew 0:80ee8f3b695e 1164 * @param __TXINV__: UART frame TX inversion setting.
EricLew 0:80ee8f3b695e 1165 * @retval SET (__TXINV__ is valid) or RESET (__TXINV__ is invalid)
EricLew 0:80ee8f3b695e 1166 */
EricLew 0:80ee8f3b695e 1167 #define IS_UART_ADVFEATURE_TXINV(__TXINV__) (((__TXINV__) == UART_ADVFEATURE_TXINV_DISABLE) || \
EricLew 0:80ee8f3b695e 1168 ((__TXINV__) == UART_ADVFEATURE_TXINV_ENABLE))
EricLew 0:80ee8f3b695e 1169
EricLew 0:80ee8f3b695e 1170 /**
EricLew 0:80ee8f3b695e 1171 * @brief Ensure that UART frame RX inversion setting is valid.
EricLew 0:80ee8f3b695e 1172 * @param __RXINV__: UART frame RX inversion setting.
EricLew 0:80ee8f3b695e 1173 * @retval SET (__RXINV__ is valid) or RESET (__RXINV__ is invalid)
EricLew 0:80ee8f3b695e 1174 */
EricLew 0:80ee8f3b695e 1175 #define IS_UART_ADVFEATURE_RXINV(__RXINV__) (((__RXINV__) == UART_ADVFEATURE_RXINV_DISABLE) || \
EricLew 0:80ee8f3b695e 1176 ((__RXINV__) == UART_ADVFEATURE_RXINV_ENABLE))
EricLew 0:80ee8f3b695e 1177
EricLew 0:80ee8f3b695e 1178 /**
EricLew 0:80ee8f3b695e 1179 * @brief Ensure that UART frame data inversion setting is valid.
EricLew 0:80ee8f3b695e 1180 * @param __DATAINV__: UART frame data inversion setting.
EricLew 0:80ee8f3b695e 1181 * @retval SET (__DATAINV__ is valid) or RESET (__DATAINV__ is invalid)
EricLew 0:80ee8f3b695e 1182 */
EricLew 0:80ee8f3b695e 1183 #define IS_UART_ADVFEATURE_DATAINV(__DATAINV__) (((__DATAINV__) == UART_ADVFEATURE_DATAINV_DISABLE) || \
EricLew 0:80ee8f3b695e 1184 ((__DATAINV__) == UART_ADVFEATURE_DATAINV_ENABLE))
EricLew 0:80ee8f3b695e 1185
EricLew 0:80ee8f3b695e 1186 /**
EricLew 0:80ee8f3b695e 1187 * @brief Ensure that UART frame RX/TX pins swap setting is valid.
EricLew 0:80ee8f3b695e 1188 * @param __SWAP__: UART frame RX/TX pins swap setting.
EricLew 0:80ee8f3b695e 1189 * @retval SET (__SWAP__ is valid) or RESET (__SWAP__ is invalid)
EricLew 0:80ee8f3b695e 1190 */
EricLew 0:80ee8f3b695e 1191 #define IS_UART_ADVFEATURE_SWAP(__SWAP__) (((__SWAP__) == UART_ADVFEATURE_SWAP_DISABLE) || \
EricLew 0:80ee8f3b695e 1192 ((__SWAP__) == UART_ADVFEATURE_SWAP_ENABLE))
EricLew 0:80ee8f3b695e 1193
EricLew 0:80ee8f3b695e 1194 /**
EricLew 0:80ee8f3b695e 1195 * @brief Ensure that UART frame overrun setting is valid.
EricLew 0:80ee8f3b695e 1196 * @param __OVERRUN__: UART frame overrun setting.
EricLew 0:80ee8f3b695e 1197 * @retval SET (__OVERRUN__ is valid) or RESET (__OVERRUN__ is invalid)
EricLew 0:80ee8f3b695e 1198 */
EricLew 0:80ee8f3b695e 1199 #define IS_UART_OVERRUN(__OVERRUN__) (((__OVERRUN__) == UART_ADVFEATURE_OVERRUN_ENABLE) || \
EricLew 0:80ee8f3b695e 1200 ((__OVERRUN__) == UART_ADVFEATURE_OVERRUN_DISABLE))
EricLew 0:80ee8f3b695e 1201
EricLew 0:80ee8f3b695e 1202 /**
EricLew 0:80ee8f3b695e 1203 * @brief Ensure that UART auto Baud rate state is valid.
EricLew 0:80ee8f3b695e 1204 * @param __AUTOBAUDRATE__: UART auto Baud rate state.
EricLew 0:80ee8f3b695e 1205 * @retval SET (__AUTOBAUDRATE__ is valid) or RESET (__AUTOBAUDRATE__ is invalid)
EricLew 0:80ee8f3b695e 1206 */
EricLew 0:80ee8f3b695e 1207 #define IS_UART_ADVFEATURE_AUTOBAUDRATE(__AUTOBAUDRATE__) (((__AUTOBAUDRATE__) == UART_ADVFEATURE_AUTOBAUDRATE_DISABLE) || \
EricLew 0:80ee8f3b695e 1208 ((__AUTOBAUDRATE__) == UART_ADVFEATURE_AUTOBAUDRATE_ENABLE))
EricLew 0:80ee8f3b695e 1209
EricLew 0:80ee8f3b695e 1210 /**
EricLew 0:80ee8f3b695e 1211 * @brief Ensure that UART DMA enabling or disabling on error setting is valid.
EricLew 0:80ee8f3b695e 1212 * @param __DMA__: UART DMA enabling or disabling on error setting.
EricLew 0:80ee8f3b695e 1213 * @retval SET (__DMA__ is valid) or RESET (__DMA__ is invalid)
EricLew 0:80ee8f3b695e 1214 */
EricLew 0:80ee8f3b695e 1215 #define IS_UART_ADVFEATURE_DMAONRXERROR(__DMA__) (((__DMA__) == UART_ADVFEATURE_DMA_ENABLEONRXERROR) || \
EricLew 0:80ee8f3b695e 1216 ((__DMA__) == UART_ADVFEATURE_DMA_DISABLEONRXERROR))
EricLew 0:80ee8f3b695e 1217
EricLew 0:80ee8f3b695e 1218 /**
EricLew 0:80ee8f3b695e 1219 * @brief Ensure that UART frame MSB first setting is valid.
EricLew 0:80ee8f3b695e 1220 * @param __MSBFIRST__: UART frame MSB first setting.
EricLew 0:80ee8f3b695e 1221 * @retval SET (__MSBFIRST__ is valid) or RESET (__MSBFIRST__ is invalid)
EricLew 0:80ee8f3b695e 1222 */
EricLew 0:80ee8f3b695e 1223 #define IS_UART_ADVFEATURE_MSBFIRST(__MSBFIRST__) (((__MSBFIRST__) == UART_ADVFEATURE_MSBFIRST_DISABLE) || \
EricLew 0:80ee8f3b695e 1224 ((__MSBFIRST__) == UART_ADVFEATURE_MSBFIRST_ENABLE))
EricLew 0:80ee8f3b695e 1225
EricLew 0:80ee8f3b695e 1226 /**
EricLew 0:80ee8f3b695e 1227 * @brief Ensure that UART stop mode state is valid.
EricLew 0:80ee8f3b695e 1228 * @param __STOPMODE__: UART stop mode state.
EricLew 0:80ee8f3b695e 1229 * @retval SET (__STOPMODE__ is valid) or RESET (__STOPMODE__ is invalid)
EricLew 0:80ee8f3b695e 1230 */
EricLew 0:80ee8f3b695e 1231 #define IS_UART_ADVFEATURE_STOPMODE(__STOPMODE__) (((__STOPMODE__) == UART_ADVFEATURE_STOPMODE_DISABLE) || \
EricLew 0:80ee8f3b695e 1232 ((__STOPMODE__) == UART_ADVFEATURE_STOPMODE_ENABLE))
EricLew 0:80ee8f3b695e 1233
EricLew 0:80ee8f3b695e 1234 /**
EricLew 0:80ee8f3b695e 1235 * @brief Ensure that UART mute mode state is valid.
EricLew 0:80ee8f3b695e 1236 * @param __MUTE__: UART mute mode state.
EricLew 0:80ee8f3b695e 1237 * @retval SET (__MUTE__ is valid) or RESET (__MUTE__ is invalid)
EricLew 0:80ee8f3b695e 1238 */
EricLew 0:80ee8f3b695e 1239 #define IS_UART_MUTE_MODE(__MUTE__) (((__MUTE__) == UART_ADVFEATURE_MUTEMODE_DISABLE) || \
EricLew 0:80ee8f3b695e 1240 ((__MUTE__) == UART_ADVFEATURE_MUTEMODE_ENABLE))
EricLew 0:80ee8f3b695e 1241
EricLew 0:80ee8f3b695e 1242 /**
EricLew 0:80ee8f3b695e 1243 * @brief Ensure that UART wake-up selection is valid.
EricLew 0:80ee8f3b695e 1244 * @param __WAKE__: UART wake-up selection.
EricLew 0:80ee8f3b695e 1245 * @retval SET (__WAKE__ is valid) or RESET (__WAKE__ is invalid)
EricLew 0:80ee8f3b695e 1246 */
EricLew 0:80ee8f3b695e 1247 #define IS_UART_WAKEUP_SELECTION(__WAKE__) (((__WAKE__) == UART_WAKEUP_ON_ADDRESS) || \
EricLew 0:80ee8f3b695e 1248 ((__WAKE__) == UART_WAKEUP_ON_STARTBIT) || \
EricLew 0:80ee8f3b695e 1249 ((__WAKE__) == UART_WAKEUP_ON_READDATA_NONEMPTY))
EricLew 0:80ee8f3b695e 1250
EricLew 0:80ee8f3b695e 1251 /**
EricLew 0:80ee8f3b695e 1252 * @brief Ensure that UART driver enable polarity is valid.
EricLew 0:80ee8f3b695e 1253 * @param __POLARITY__: UART driver enable polarity.
EricLew 0:80ee8f3b695e 1254 * @retval SET (__POLARITY__ is valid) or RESET (__POLARITY__ is invalid)
EricLew 0:80ee8f3b695e 1255 */
EricLew 0:80ee8f3b695e 1256 #define IS_UART_DE_POLARITY(__POLARITY__) (((__POLARITY__) == UART_DE_POLARITY_HIGH) || \
EricLew 0:80ee8f3b695e 1257 ((__POLARITY__) == UART_DE_POLARITY_LOW))
EricLew 0:80ee8f3b695e 1258
EricLew 0:80ee8f3b695e 1259 /**
EricLew 0:80ee8f3b695e 1260 * @brief Ensure that LPUART frame number of stop bits is valid.
EricLew 0:80ee8f3b695e 1261 * @param __STOPBITS__: LPUART frame number of stop bits.
EricLew 0:80ee8f3b695e 1262 * @retval SET (__STOPBITS__ is valid) or RESET (__STOPBITS__ is invalid)
EricLew 0:80ee8f3b695e 1263 */
EricLew 0:80ee8f3b695e 1264 #define IS_LPUART_STOPBITS(__STOPBITS__) (((__STOPBITS__) == UART_STOPBITS_1) || \
EricLew 0:80ee8f3b695e 1265 ((__STOPBITS__) == UART_STOPBITS_2))
EricLew 0:80ee8f3b695e 1266
EricLew 0:80ee8f3b695e 1267 /**
EricLew 0:80ee8f3b695e 1268 * @}
EricLew 0:80ee8f3b695e 1269 */
EricLew 0:80ee8f3b695e 1270
EricLew 0:80ee8f3b695e 1271 /* Include UART HAL Extended module */
EricLew 0:80ee8f3b695e 1272 #include "stm32l4xx_hal_uart_ex.h"
EricLew 0:80ee8f3b695e 1273
EricLew 0:80ee8f3b695e 1274 /* Exported functions --------------------------------------------------------*/
EricLew 0:80ee8f3b695e 1275 /** @addtogroup UART_Exported_Functions UART Exported Functions
EricLew 0:80ee8f3b695e 1276 * @{
EricLew 0:80ee8f3b695e 1277 */
EricLew 0:80ee8f3b695e 1278
EricLew 0:80ee8f3b695e 1279 /** @addtogroup UART_Exported_Functions_Group1 Initialization and de-initialization functions
EricLew 0:80ee8f3b695e 1280 * @{
EricLew 0:80ee8f3b695e 1281 */
EricLew 0:80ee8f3b695e 1282
EricLew 0:80ee8f3b695e 1283 /* Initialization and de-initialization functions ****************************/
EricLew 0:80ee8f3b695e 1284 HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart);
EricLew 0:80ee8f3b695e 1285 HAL_StatusTypeDef HAL_HalfDuplex_Init(UART_HandleTypeDef *huart);
EricLew 0:80ee8f3b695e 1286 HAL_StatusTypeDef HAL_LIN_Init(UART_HandleTypeDef *huart, uint32_t BreakDetectLength);
EricLew 0:80ee8f3b695e 1287 HAL_StatusTypeDef HAL_MultiProcessor_Init(UART_HandleTypeDef *huart, uint8_t Address, uint32_t WakeUpMethod);
EricLew 0:80ee8f3b695e 1288 HAL_StatusTypeDef HAL_UART_DeInit (UART_HandleTypeDef *huart);
EricLew 0:80ee8f3b695e 1289 void HAL_UART_MspInit(UART_HandleTypeDef *huart);
EricLew 0:80ee8f3b695e 1290 void HAL_UART_MspDeInit(UART_HandleTypeDef *huart);
EricLew 0:80ee8f3b695e 1291
EricLew 0:80ee8f3b695e 1292 /**
EricLew 0:80ee8f3b695e 1293 * @}
EricLew 0:80ee8f3b695e 1294 */
EricLew 0:80ee8f3b695e 1295
EricLew 0:80ee8f3b695e 1296 /** @addtogroup UART_Exported_Functions_Group2 IO operation functions
EricLew 0:80ee8f3b695e 1297 * @{
EricLew 0:80ee8f3b695e 1298 */
EricLew 0:80ee8f3b695e 1299
EricLew 0:80ee8f3b695e 1300 /* IO operation functions *****************************************************/
EricLew 0:80ee8f3b695e 1301 HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
EricLew 0:80ee8f3b695e 1302 HAL_StatusTypeDef HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
EricLew 0:80ee8f3b695e 1303 HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
EricLew 0:80ee8f3b695e 1304 HAL_StatusTypeDef HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
EricLew 0:80ee8f3b695e 1305 HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
EricLew 0:80ee8f3b695e 1306 HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
EricLew 0:80ee8f3b695e 1307 HAL_StatusTypeDef HAL_UART_DMAPause(UART_HandleTypeDef *huart);
EricLew 0:80ee8f3b695e 1308 HAL_StatusTypeDef HAL_UART_DMAResume(UART_HandleTypeDef *huart);
EricLew 0:80ee8f3b695e 1309 HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart);
EricLew 0:80ee8f3b695e 1310 void HAL_UART_IRQHandler(UART_HandleTypeDef *huart);
EricLew 0:80ee8f3b695e 1311 void HAL_UART_TxHalfCpltCallback(UART_HandleTypeDef *huart);
EricLew 0:80ee8f3b695e 1312 void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart);
EricLew 0:80ee8f3b695e 1313 void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart);
EricLew 0:80ee8f3b695e 1314 void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart);
EricLew 0:80ee8f3b695e 1315 void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart);
EricLew 0:80ee8f3b695e 1316
EricLew 0:80ee8f3b695e 1317 /**
EricLew 0:80ee8f3b695e 1318 * @}
EricLew 0:80ee8f3b695e 1319 */
EricLew 0:80ee8f3b695e 1320
EricLew 0:80ee8f3b695e 1321 /** @addtogroup UART_Exported_Functions_Group3 Peripheral Control functions
EricLew 0:80ee8f3b695e 1322 * @{
EricLew 0:80ee8f3b695e 1323 */
EricLew 0:80ee8f3b695e 1324
EricLew 0:80ee8f3b695e 1325 /* Peripheral Control functions ************************************************/
EricLew 0:80ee8f3b695e 1326 HAL_StatusTypeDef HAL_LIN_SendBreak(UART_HandleTypeDef *huart);
EricLew 0:80ee8f3b695e 1327 HAL_StatusTypeDef HAL_MultiProcessor_EnableMuteMode(UART_HandleTypeDef *huart);
EricLew 0:80ee8f3b695e 1328 HAL_StatusTypeDef HAL_MultiProcessor_DisableMuteMode(UART_HandleTypeDef *huart);
EricLew 0:80ee8f3b695e 1329 void HAL_MultiProcessor_EnterMuteMode(UART_HandleTypeDef *huart);
EricLew 0:80ee8f3b695e 1330 HAL_StatusTypeDef HAL_HalfDuplex_EnableTransmitter(UART_HandleTypeDef *huart);
EricLew 0:80ee8f3b695e 1331 HAL_StatusTypeDef HAL_HalfDuplex_EnableReceiver(UART_HandleTypeDef *huart);
EricLew 0:80ee8f3b695e 1332
EricLew 0:80ee8f3b695e 1333 /**
EricLew 0:80ee8f3b695e 1334 * @}
EricLew 0:80ee8f3b695e 1335 */
EricLew 0:80ee8f3b695e 1336
EricLew 0:80ee8f3b695e 1337 /** @addtogroup UART_Exported_Functions_Group4 Peripheral State and Error functions
EricLew 0:80ee8f3b695e 1338 * @{
EricLew 0:80ee8f3b695e 1339 */
EricLew 0:80ee8f3b695e 1340
EricLew 0:80ee8f3b695e 1341 /* Peripheral State and Errors functions **************************************************/
EricLew 0:80ee8f3b695e 1342 HAL_UART_StateTypeDef HAL_UART_GetState(UART_HandleTypeDef *huart);
EricLew 0:80ee8f3b695e 1343 uint32_t HAL_UART_GetError(UART_HandleTypeDef *huart);
EricLew 0:80ee8f3b695e 1344
EricLew 0:80ee8f3b695e 1345 /**
EricLew 0:80ee8f3b695e 1346 * @}
EricLew 0:80ee8f3b695e 1347 */
EricLew 0:80ee8f3b695e 1348
EricLew 0:80ee8f3b695e 1349 /**
EricLew 0:80ee8f3b695e 1350 * @}
EricLew 0:80ee8f3b695e 1351 */
EricLew 0:80ee8f3b695e 1352
EricLew 0:80ee8f3b695e 1353 /* Private functions -----------------------------------------------------------*/
EricLew 0:80ee8f3b695e 1354 /** @addtogroup UART_Private_Functions UART Private Functions
EricLew 0:80ee8f3b695e 1355 * @{
EricLew 0:80ee8f3b695e 1356 */
EricLew 0:80ee8f3b695e 1357
EricLew 0:80ee8f3b695e 1358 HAL_StatusTypeDef UART_SetConfig(UART_HandleTypeDef *huart);
EricLew 0:80ee8f3b695e 1359 HAL_StatusTypeDef UART_CheckIdleState(UART_HandleTypeDef *huart);
EricLew 0:80ee8f3b695e 1360 HAL_StatusTypeDef UART_WaitOnFlagUntilTimeout(UART_HandleTypeDef *huart, uint32_t Flag, FlagStatus Status, uint32_t Timeout);
EricLew 0:80ee8f3b695e 1361 void UART_AdvFeatureConfig(UART_HandleTypeDef *huart);
EricLew 0:80ee8f3b695e 1362
EricLew 0:80ee8f3b695e 1363 /**
EricLew 0:80ee8f3b695e 1364 * @}
EricLew 0:80ee8f3b695e 1365 */
EricLew 0:80ee8f3b695e 1366
EricLew 0:80ee8f3b695e 1367 /**
EricLew 0:80ee8f3b695e 1368 * @}
EricLew 0:80ee8f3b695e 1369 */
EricLew 0:80ee8f3b695e 1370
EricLew 0:80ee8f3b695e 1371 /**
EricLew 0:80ee8f3b695e 1372 * @}
EricLew 0:80ee8f3b695e 1373 */
EricLew 0:80ee8f3b695e 1374
EricLew 0:80ee8f3b695e 1375 #ifdef __cplusplus
EricLew 0:80ee8f3b695e 1376 }
EricLew 0:80ee8f3b695e 1377 #endif
EricLew 0:80ee8f3b695e 1378
EricLew 0:80ee8f3b695e 1379 #endif /* __STM32L4xx_HAL_UART_H */
EricLew 0:80ee8f3b695e 1380
EricLew 0:80ee8f3b695e 1381 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
EricLew 0:80ee8f3b695e 1382