Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: BSP OneHopeOnePrayer FINAL_AUDIO_RECORD AudioDemo
Fork of STM32L4xx_HAL_Driver by
Inc/stm32l4xx_hal_usart.h@0:80ee8f3b695e, 2015-11-02 (annotated)
- 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?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| EricLew | 0:80ee8f3b695e | 1 | /** |
| EricLew | 0:80ee8f3b695e | 2 | ****************************************************************************** |
| EricLew | 0:80ee8f3b695e | 3 | * @file stm32l4xx_hal_usart.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 USART HAL module. |
| EricLew | 0:80ee8f3b695e | 8 | ****************************************************************************** |
| EricLew | 0:80ee8f3b695e | 9 | * @attention |
| EricLew | 0:80ee8f3b695e | 10 | * |
| EricLew | 0:80ee8f3b695e | 11 | * <h2><center>© 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_USART_H |
| EricLew | 0:80ee8f3b695e | 40 | #define __STM32L4xx_HAL_USART_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 USART |
| EricLew | 0:80ee8f3b695e | 54 | * @{ |
| EricLew | 0:80ee8f3b695e | 55 | */ |
| EricLew | 0:80ee8f3b695e | 56 | |
| EricLew | 0:80ee8f3b695e | 57 | /* Exported types ------------------------------------------------------------*/ |
| EricLew | 0:80ee8f3b695e | 58 | /** @defgroup USART_Exported_Types USART Exported Types |
| EricLew | 0:80ee8f3b695e | 59 | * @{ |
| EricLew | 0:80ee8f3b695e | 60 | */ |
| EricLew | 0:80ee8f3b695e | 61 | |
| EricLew | 0:80ee8f3b695e | 62 | /** |
| EricLew | 0:80ee8f3b695e | 63 | * @brief USART 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 Usart communication baud rate. |
| EricLew | 0:80ee8f3b695e | 68 | The baud rate is computed using the following formula: |
| EricLew | 0:80ee8f3b695e | 69 | Baud Rate Register = ((PCLKx) / ((huart->Init.BaudRate))). */ |
| EricLew | 0:80ee8f3b695e | 70 | |
| EricLew | 0:80ee8f3b695e | 71 | uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame. |
| EricLew | 0:80ee8f3b695e | 72 | This parameter can be a value of @ref USARTEx_Word_Length. */ |
| EricLew | 0:80ee8f3b695e | 73 | |
| EricLew | 0:80ee8f3b695e | 74 | uint32_t StopBits; /*!< Specifies the number of stop bits transmitted. |
| EricLew | 0:80ee8f3b695e | 75 | This parameter can be a value of @ref USART_Stop_Bits. */ |
| EricLew | 0:80ee8f3b695e | 76 | |
| EricLew | 0:80ee8f3b695e | 77 | uint32_t Parity; /*!< Specifies the parity mode. |
| EricLew | 0:80ee8f3b695e | 78 | This parameter can be a value of @ref USART_Parity |
| EricLew | 0:80ee8f3b695e | 79 | @note When parity is enabled, the computed parity is inserted |
| EricLew | 0:80ee8f3b695e | 80 | at the MSB position of the transmitted data (9th bit when |
| EricLew | 0:80ee8f3b695e | 81 | the word length is set to 9 data bits; 8th bit when the |
| EricLew | 0:80ee8f3b695e | 82 | word length is set to 8 data bits). */ |
| EricLew | 0:80ee8f3b695e | 83 | |
| EricLew | 0:80ee8f3b695e | 84 | uint32_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled. |
| EricLew | 0:80ee8f3b695e | 85 | This parameter can be a value of @ref USART_Mode. */ |
| EricLew | 0:80ee8f3b695e | 86 | |
| EricLew | 0:80ee8f3b695e | 87 | uint32_t CLKPolarity; /*!< Specifies the steady state of the serial clock. |
| EricLew | 0:80ee8f3b695e | 88 | This parameter can be a value of @ref USART_Clock_Polarity. */ |
| EricLew | 0:80ee8f3b695e | 89 | |
| EricLew | 0:80ee8f3b695e | 90 | uint32_t CLKPhase; /*!< Specifies the clock transition on which the bit capture is made. |
| EricLew | 0:80ee8f3b695e | 91 | This parameter can be a value of @ref USART_Clock_Phase. */ |
| EricLew | 0:80ee8f3b695e | 92 | |
| EricLew | 0:80ee8f3b695e | 93 | uint32_t CLKLastBit; /*!< Specifies whether the clock pulse corresponding to the last transmitted |
| EricLew | 0:80ee8f3b695e | 94 | data bit (MSB) has to be output on the SCLK pin in synchronous mode. |
| EricLew | 0:80ee8f3b695e | 95 | This parameter can be a value of @ref USART_Last_Bit. */ |
| EricLew | 0:80ee8f3b695e | 96 | }USART_InitTypeDef; |
| EricLew | 0:80ee8f3b695e | 97 | |
| EricLew | 0:80ee8f3b695e | 98 | /** |
| EricLew | 0:80ee8f3b695e | 99 | * @brief HAL USART State structures definition |
| EricLew | 0:80ee8f3b695e | 100 | */ |
| EricLew | 0:80ee8f3b695e | 101 | typedef enum |
| EricLew | 0:80ee8f3b695e | 102 | { |
| EricLew | 0:80ee8f3b695e | 103 | HAL_USART_STATE_RESET = 0x00, /*!< Peripheral is not initialized */ |
| EricLew | 0:80ee8f3b695e | 104 | HAL_USART_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */ |
| EricLew | 0:80ee8f3b695e | 105 | HAL_USART_STATE_BUSY = 0x02, /*!< an internal process is ongoing */ |
| EricLew | 0:80ee8f3b695e | 106 | HAL_USART_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */ |
| EricLew | 0:80ee8f3b695e | 107 | HAL_USART_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */ |
| EricLew | 0:80ee8f3b695e | 108 | HAL_USART_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission Reception process is ongoing */ |
| EricLew | 0:80ee8f3b695e | 109 | HAL_USART_STATE_TIMEOUT = 0x03, /*!< Timeout state */ |
| EricLew | 0:80ee8f3b695e | 110 | HAL_USART_STATE_ERROR = 0x04 /*!< Error */ |
| EricLew | 0:80ee8f3b695e | 111 | }HAL_USART_StateTypeDef; |
| EricLew | 0:80ee8f3b695e | 112 | |
| EricLew | 0:80ee8f3b695e | 113 | /** |
| EricLew | 0:80ee8f3b695e | 114 | * @brief HAL USART Error Code structure definition |
| EricLew | 0:80ee8f3b695e | 115 | */ |
| EricLew | 0:80ee8f3b695e | 116 | typedef enum |
| EricLew | 0:80ee8f3b695e | 117 | { |
| EricLew | 0:80ee8f3b695e | 118 | HAL_USART_ERROR_NONE = 0x00, /*!< No error */ |
| EricLew | 0:80ee8f3b695e | 119 | HAL_USART_ERROR_PE = 0x01, /*!< Parity error */ |
| EricLew | 0:80ee8f3b695e | 120 | HAL_USART_ERROR_NE = 0x02, /*!< Noise error */ |
| EricLew | 0:80ee8f3b695e | 121 | HAL_USART_ERROR_FE = 0x04, /*!< frame error */ |
| EricLew | 0:80ee8f3b695e | 122 | HAL_USART_ERROR_ORE = 0x08, /*!< Overrun error */ |
| EricLew | 0:80ee8f3b695e | 123 | HAL_USART_ERROR_DMA = 0x10 /*!< DMA transfer error */ |
| EricLew | 0:80ee8f3b695e | 124 | }HAL_USART_ErrorTypeDef; |
| EricLew | 0:80ee8f3b695e | 125 | |
| EricLew | 0:80ee8f3b695e | 126 | /** |
| EricLew | 0:80ee8f3b695e | 127 | * @brief USART clock sources definitions |
| EricLew | 0:80ee8f3b695e | 128 | */ |
| EricLew | 0:80ee8f3b695e | 129 | typedef enum |
| EricLew | 0:80ee8f3b695e | 130 | { |
| EricLew | 0:80ee8f3b695e | 131 | USART_CLOCKSOURCE_PCLK1 = 0x00, /*!< PCLK1 clock source */ |
| EricLew | 0:80ee8f3b695e | 132 | USART_CLOCKSOURCE_PCLK2 = 0x01, /*!< PCLK2 clock source */ |
| EricLew | 0:80ee8f3b695e | 133 | USART_CLOCKSOURCE_HSI = 0x02, /*!< HSI clock source */ |
| EricLew | 0:80ee8f3b695e | 134 | USART_CLOCKSOURCE_SYSCLK = 0x04, /*!< SYSCLK clock source */ |
| EricLew | 0:80ee8f3b695e | 135 | USART_CLOCKSOURCE_LSE = 0x08, /*!< LSE clock source */ |
| EricLew | 0:80ee8f3b695e | 136 | USART_CLOCKSOURCE_UNDEFINED = 0x10 /*!< Undefined clock source */ |
| EricLew | 0:80ee8f3b695e | 137 | }USART_ClockSourceTypeDef; |
| EricLew | 0:80ee8f3b695e | 138 | |
| EricLew | 0:80ee8f3b695e | 139 | |
| EricLew | 0:80ee8f3b695e | 140 | /** |
| EricLew | 0:80ee8f3b695e | 141 | * @brief USART handle Structure definition |
| EricLew | 0:80ee8f3b695e | 142 | */ |
| EricLew | 0:80ee8f3b695e | 143 | typedef struct |
| EricLew | 0:80ee8f3b695e | 144 | { |
| EricLew | 0:80ee8f3b695e | 145 | USART_TypeDef *Instance; /*!< USART registers base address */ |
| EricLew | 0:80ee8f3b695e | 146 | |
| EricLew | 0:80ee8f3b695e | 147 | USART_InitTypeDef Init; /*!< USART communication parameters */ |
| EricLew | 0:80ee8f3b695e | 148 | |
| EricLew | 0:80ee8f3b695e | 149 | uint8_t *pTxBuffPtr; /*!< Pointer to USART Tx transfer Buffer */ |
| EricLew | 0:80ee8f3b695e | 150 | |
| EricLew | 0:80ee8f3b695e | 151 | uint16_t TxXferSize; /*!< USART Tx Transfer size */ |
| EricLew | 0:80ee8f3b695e | 152 | |
| EricLew | 0:80ee8f3b695e | 153 | uint16_t TxXferCount; /*!< USART Tx Transfer Counter */ |
| EricLew | 0:80ee8f3b695e | 154 | |
| EricLew | 0:80ee8f3b695e | 155 | uint8_t *pRxBuffPtr; /*!< Pointer to USART Rx transfer Buffer */ |
| EricLew | 0:80ee8f3b695e | 156 | |
| EricLew | 0:80ee8f3b695e | 157 | uint16_t RxXferSize; /*!< USART Rx Transfer size */ |
| EricLew | 0:80ee8f3b695e | 158 | |
| EricLew | 0:80ee8f3b695e | 159 | uint16_t RxXferCount; /*!< USART Rx Transfer Counter */ |
| EricLew | 0:80ee8f3b695e | 160 | |
| EricLew | 0:80ee8f3b695e | 161 | uint16_t Mask; /*!< USART Rx RDR register mask */ |
| EricLew | 0:80ee8f3b695e | 162 | |
| EricLew | 0:80ee8f3b695e | 163 | DMA_HandleTypeDef *hdmatx; /*!< USART Tx DMA Handle parameters */ |
| EricLew | 0:80ee8f3b695e | 164 | |
| EricLew | 0:80ee8f3b695e | 165 | DMA_HandleTypeDef *hdmarx; /*!< USART Rx DMA Handle parameters */ |
| EricLew | 0:80ee8f3b695e | 166 | |
| EricLew | 0:80ee8f3b695e | 167 | HAL_LockTypeDef Lock; /*!< Locking object */ |
| EricLew | 0:80ee8f3b695e | 168 | |
| EricLew | 0:80ee8f3b695e | 169 | __IO HAL_USART_StateTypeDef State; /*!< USART communication state */ |
| EricLew | 0:80ee8f3b695e | 170 | |
| EricLew | 0:80ee8f3b695e | 171 | __IO uint32_t ErrorCode; /*!< USART Error code */ |
| EricLew | 0:80ee8f3b695e | 172 | |
| EricLew | 0:80ee8f3b695e | 173 | }USART_HandleTypeDef; |
| EricLew | 0:80ee8f3b695e | 174 | |
| EricLew | 0:80ee8f3b695e | 175 | /** |
| EricLew | 0:80ee8f3b695e | 176 | * @} |
| EricLew | 0:80ee8f3b695e | 177 | */ |
| EricLew | 0:80ee8f3b695e | 178 | |
| EricLew | 0:80ee8f3b695e | 179 | /* Exported constants --------------------------------------------------------*/ |
| EricLew | 0:80ee8f3b695e | 180 | /** @defgroup USART_Exported_Constants USART Exported Constants |
| EricLew | 0:80ee8f3b695e | 181 | * @{ |
| EricLew | 0:80ee8f3b695e | 182 | */ |
| EricLew | 0:80ee8f3b695e | 183 | |
| EricLew | 0:80ee8f3b695e | 184 | /** @defgroup USART_Stop_Bits USART Number of Stop Bits |
| EricLew | 0:80ee8f3b695e | 185 | * @{ |
| EricLew | 0:80ee8f3b695e | 186 | */ |
| EricLew | 0:80ee8f3b695e | 187 | #define USART_STOPBITS_1 ((uint32_t)0x00000000) /*!< USART frame with 1 stop bit */ |
| EricLew | 0:80ee8f3b695e | 188 | #define USART_STOPBITS_1_5 ((uint32_t)(USART_CR2_STOP_0 | USART_CR2_STOP_1)) /*!< USART frame with 1.5 stop bits */ |
| EricLew | 0:80ee8f3b695e | 189 | #define USART_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1) /*!< USART frame with 2 stop bits */ |
| EricLew | 0:80ee8f3b695e | 190 | /** |
| EricLew | 0:80ee8f3b695e | 191 | * @} |
| EricLew | 0:80ee8f3b695e | 192 | */ |
| EricLew | 0:80ee8f3b695e | 193 | |
| EricLew | 0:80ee8f3b695e | 194 | /** @defgroup USART_Parity USART Parity |
| EricLew | 0:80ee8f3b695e | 195 | * @{ |
| EricLew | 0:80ee8f3b695e | 196 | */ |
| EricLew | 0:80ee8f3b695e | 197 | #define USART_PARITY_NONE ((uint32_t)0x00000000) /*!< No parity */ |
| EricLew | 0:80ee8f3b695e | 198 | #define USART_PARITY_EVEN ((uint32_t)USART_CR1_PCE) /*!< Even parity */ |
| EricLew | 0:80ee8f3b695e | 199 | #define USART_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS)) /*!< Odd parity */ |
| EricLew | 0:80ee8f3b695e | 200 | /** |
| EricLew | 0:80ee8f3b695e | 201 | * @} |
| EricLew | 0:80ee8f3b695e | 202 | */ |
| EricLew | 0:80ee8f3b695e | 203 | |
| EricLew | 0:80ee8f3b695e | 204 | /** @defgroup USART_Mode USART Mode |
| EricLew | 0:80ee8f3b695e | 205 | * @{ |
| EricLew | 0:80ee8f3b695e | 206 | */ |
| EricLew | 0:80ee8f3b695e | 207 | #define USART_MODE_RX ((uint32_t)USART_CR1_RE) /*!< RX mode */ |
| EricLew | 0:80ee8f3b695e | 208 | #define USART_MODE_TX ((uint32_t)USART_CR1_TE) /*!< TX mode */ |
| EricLew | 0:80ee8f3b695e | 209 | #define USART_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE)) /*!< RX and TX mode */ |
| EricLew | 0:80ee8f3b695e | 210 | /** |
| EricLew | 0:80ee8f3b695e | 211 | * @} |
| EricLew | 0:80ee8f3b695e | 212 | */ |
| EricLew | 0:80ee8f3b695e | 213 | |
| EricLew | 0:80ee8f3b695e | 214 | /** @defgroup USART_Over_Sampling USART Over Sampling |
| EricLew | 0:80ee8f3b695e | 215 | * @{ |
| EricLew | 0:80ee8f3b695e | 216 | */ |
| EricLew | 0:80ee8f3b695e | 217 | #define USART_OVERSAMPLING_16 ((uint32_t)0x00000000) /*!< Oversampling by 16 */ |
| EricLew | 0:80ee8f3b695e | 218 | #define USART_OVERSAMPLING_8 ((uint32_t)USART_CR1_OVER8) /*!< Oversampling by 8 */ |
| EricLew | 0:80ee8f3b695e | 219 | /** |
| EricLew | 0:80ee8f3b695e | 220 | * @} |
| EricLew | 0:80ee8f3b695e | 221 | */ |
| EricLew | 0:80ee8f3b695e | 222 | |
| EricLew | 0:80ee8f3b695e | 223 | /** @defgroup USART_Clock USART Clock |
| EricLew | 0:80ee8f3b695e | 224 | * @{ |
| EricLew | 0:80ee8f3b695e | 225 | */ |
| EricLew | 0:80ee8f3b695e | 226 | #define USART_CLOCK_DISABLE ((uint32_t)0x00000000) /*!< USART clock disable */ |
| EricLew | 0:80ee8f3b695e | 227 | #define USART_CLOCK_ENABLE ((uint32_t)USART_CR2_CLKEN) /*!< USART clock enable */ |
| EricLew | 0:80ee8f3b695e | 228 | /** |
| EricLew | 0:80ee8f3b695e | 229 | * @} |
| EricLew | 0:80ee8f3b695e | 230 | */ |
| EricLew | 0:80ee8f3b695e | 231 | |
| EricLew | 0:80ee8f3b695e | 232 | /** @defgroup USART_Clock_Polarity USART Clock Polarity |
| EricLew | 0:80ee8f3b695e | 233 | * @{ |
| EricLew | 0:80ee8f3b695e | 234 | */ |
| EricLew | 0:80ee8f3b695e | 235 | #define USART_POLARITY_LOW ((uint32_t)0x00000000) /*!< Driver enable signal is active high */ |
| EricLew | 0:80ee8f3b695e | 236 | #define USART_POLARITY_HIGH ((uint32_t)USART_CR2_CPOL) /*!< Driver enable signal is active low */ |
| EricLew | 0:80ee8f3b695e | 237 | /** |
| EricLew | 0:80ee8f3b695e | 238 | * @} |
| EricLew | 0:80ee8f3b695e | 239 | */ |
| EricLew | 0:80ee8f3b695e | 240 | |
| EricLew | 0:80ee8f3b695e | 241 | /** @defgroup USART_Clock_Phase USART Clock Phase |
| EricLew | 0:80ee8f3b695e | 242 | * @{ |
| EricLew | 0:80ee8f3b695e | 243 | */ |
| EricLew | 0:80ee8f3b695e | 244 | #define USART_PHASE_1EDGE ((uint32_t)0x00000000) /*!< USART frame phase on first clock transition */ |
| EricLew | 0:80ee8f3b695e | 245 | #define USART_PHASE_2EDGE ((uint32_t)USART_CR2_CPHA) /*!< USART frame phase on second clock transition */ |
| EricLew | 0:80ee8f3b695e | 246 | /** |
| EricLew | 0:80ee8f3b695e | 247 | * @} |
| EricLew | 0:80ee8f3b695e | 248 | */ |
| EricLew | 0:80ee8f3b695e | 249 | |
| EricLew | 0:80ee8f3b695e | 250 | /** @defgroup USART_Last_Bit USART Last Bit |
| EricLew | 0:80ee8f3b695e | 251 | * @{ |
| EricLew | 0:80ee8f3b695e | 252 | */ |
| EricLew | 0:80ee8f3b695e | 253 | #define USART_LASTBIT_DISABLE ((uint32_t)0x00000000) /*!< USART frame last data bit clock pulse not output to SCLK pin */ |
| EricLew | 0:80ee8f3b695e | 254 | #define USART_LASTBIT_ENABLE ((uint32_t)USART_CR2_LBCL) /*!< USART frame last data bit clock pulse output to SCLK pin */ |
| EricLew | 0:80ee8f3b695e | 255 | /** |
| EricLew | 0:80ee8f3b695e | 256 | * @} |
| EricLew | 0:80ee8f3b695e | 257 | */ |
| EricLew | 0:80ee8f3b695e | 258 | |
| EricLew | 0:80ee8f3b695e | 259 | /** @defgroup USART_Request_Parameters USART Request Parameters |
| EricLew | 0:80ee8f3b695e | 260 | * @{ |
| EricLew | 0:80ee8f3b695e | 261 | */ |
| EricLew | 0:80ee8f3b695e | 262 | #define USART_RXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_RXFRQ) /*!< Receive Data flush Request */ |
| EricLew | 0:80ee8f3b695e | 263 | #define USART_TXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_TXFRQ) /*!< Transmit data flush Request */ |
| EricLew | 0:80ee8f3b695e | 264 | /** |
| EricLew | 0:80ee8f3b695e | 265 | * @} |
| EricLew | 0:80ee8f3b695e | 266 | */ |
| EricLew | 0:80ee8f3b695e | 267 | |
| EricLew | 0:80ee8f3b695e | 268 | /** @defgroup USART_Flags USART Flags |
| EricLew | 0:80ee8f3b695e | 269 | * Elements values convention: 0xXXXX |
| EricLew | 0:80ee8f3b695e | 270 | * - 0xXXXX : Flag mask in the ISR register |
| EricLew | 0:80ee8f3b695e | 271 | * @{ |
| EricLew | 0:80ee8f3b695e | 272 | */ |
| EricLew | 0:80ee8f3b695e | 273 | #define USART_FLAG_REACK ((uint32_t)0x00400000) /*!< USART receive enable acknowledge flag */ |
| EricLew | 0:80ee8f3b695e | 274 | #define USART_FLAG_TEACK ((uint32_t)0x00200000) /*!< USART transmit enable acknowledge flag */ |
| EricLew | 0:80ee8f3b695e | 275 | #define USART_FLAG_BUSY ((uint32_t)0x00010000) /*!< USART busy flag */ |
| EricLew | 0:80ee8f3b695e | 276 | #define USART_FLAG_CTS ((uint32_t)0x00000400) /*!< USART clear to send flag */ |
| EricLew | 0:80ee8f3b695e | 277 | #define USART_FLAG_CTSIF ((uint32_t)0x00000200) /*!< USART clear to send interrupt flag */ |
| EricLew | 0:80ee8f3b695e | 278 | #define USART_FLAG_LBDF ((uint32_t)0x00000100) /*!< USART LIN break detection flag */ |
| EricLew | 0:80ee8f3b695e | 279 | #define USART_FLAG_TXE ((uint32_t)0x00000080) /*!< USART transmit data register empty */ |
| EricLew | 0:80ee8f3b695e | 280 | #define USART_FLAG_TC ((uint32_t)0x00000040) /*!< USART transmission complete */ |
| EricLew | 0:80ee8f3b695e | 281 | #define USART_FLAG_RXNE ((uint32_t)0x00000020) /*!< USART read data register not empty */ |
| EricLew | 0:80ee8f3b695e | 282 | #define USART_FLAG_IDLE ((uint32_t)0x00000010) /*!< USART idle flag */ |
| EricLew | 0:80ee8f3b695e | 283 | #define USART_FLAG_ORE ((uint32_t)0x00000008) /*!< USART overrun error */ |
| EricLew | 0:80ee8f3b695e | 284 | #define USART_FLAG_NE ((uint32_t)0x00000004) /*!< USART noise error */ |
| EricLew | 0:80ee8f3b695e | 285 | #define USART_FLAG_FE ((uint32_t)0x00000002) /*!< USART frame error */ |
| EricLew | 0:80ee8f3b695e | 286 | #define USART_FLAG_PE ((uint32_t)0x00000001) /*!< USART parity error */ |
| EricLew | 0:80ee8f3b695e | 287 | /** |
| EricLew | 0:80ee8f3b695e | 288 | * @} |
| EricLew | 0:80ee8f3b695e | 289 | */ |
| EricLew | 0:80ee8f3b695e | 290 | |
| EricLew | 0:80ee8f3b695e | 291 | /** @defgroup USART_Interrupt_definition USART Interrupts Definition |
| EricLew | 0:80ee8f3b695e | 292 | * Elements values convention: 0000ZZZZ0XXYYYYYb |
| EricLew | 0:80ee8f3b695e | 293 | * - YYYYY : Interrupt source position in the XX register (5bits) |
| EricLew | 0:80ee8f3b695e | 294 | * - XX : Interrupt source register (2bits) |
| EricLew | 0:80ee8f3b695e | 295 | * - 01: CR1 register |
| EricLew | 0:80ee8f3b695e | 296 | * - 10: CR2 register |
| EricLew | 0:80ee8f3b695e | 297 | * - 11: CR3 register |
| EricLew | 0:80ee8f3b695e | 298 | * - ZZZZ : Flag position in the ISR register(4bits) |
| EricLew | 0:80ee8f3b695e | 299 | * @{ |
| EricLew | 0:80ee8f3b695e | 300 | */ |
| EricLew | 0:80ee8f3b695e | 301 | |
| EricLew | 0:80ee8f3b695e | 302 | #define USART_IT_PE ((uint16_t)0x0028) /*!< USART parity error interruption */ |
| EricLew | 0:80ee8f3b695e | 303 | #define USART_IT_TXE ((uint16_t)0x0727) /*!< USART transmit data register empty interruption */ |
| EricLew | 0:80ee8f3b695e | 304 | #define USART_IT_TC ((uint16_t)0x0626) /*!< USART transmission complete interruption */ |
| EricLew | 0:80ee8f3b695e | 305 | #define USART_IT_RXNE ((uint16_t)0x0525) /*!< USART read data register not empty interruption */ |
| EricLew | 0:80ee8f3b695e | 306 | #define USART_IT_IDLE ((uint16_t)0x0424) /*!< USART idle interruption */ |
| EricLew | 0:80ee8f3b695e | 307 | #define USART_IT_ERR ((uint16_t)0x0060) /*!< USART error interruption */ |
| EricLew | 0:80ee8f3b695e | 308 | #define USART_IT_ORE ((uint16_t)0x0300) /*!< USART overrun error interruption */ |
| EricLew | 0:80ee8f3b695e | 309 | #define USART_IT_NE ((uint16_t)0x0200) /*!< USART noise error interruption */ |
| EricLew | 0:80ee8f3b695e | 310 | #define USART_IT_FE ((uint16_t)0x0100) /*!< USART frame error interruption */ |
| EricLew | 0:80ee8f3b695e | 311 | /** |
| EricLew | 0:80ee8f3b695e | 312 | * @} |
| EricLew | 0:80ee8f3b695e | 313 | */ |
| EricLew | 0:80ee8f3b695e | 314 | |
| EricLew | 0:80ee8f3b695e | 315 | /** @defgroup USART_IT_CLEAR_Flags USART Interruption Clear Flags |
| EricLew | 0:80ee8f3b695e | 316 | * @{ |
| EricLew | 0:80ee8f3b695e | 317 | */ |
| EricLew | 0:80ee8f3b695e | 318 | #define USART_CLEAR_PEF USART_ICR_PECF /*!< Parity Error Clear Flag */ |
| EricLew | 0:80ee8f3b695e | 319 | #define USART_CLEAR_FEF USART_ICR_FECF /*!< Framing Error Clear Flag */ |
| EricLew | 0:80ee8f3b695e | 320 | #define USART_CLEAR_NEF USART_ICR_NCF /*!< Noise detected Clear Flag */ |
| EricLew | 0:80ee8f3b695e | 321 | #define USART_CLEAR_OREF USART_ICR_ORECF /*!< OverRun Error Clear Flag */ |
| EricLew | 0:80ee8f3b695e | 322 | #define USART_CLEAR_IDLEF USART_ICR_IDLECF /*!< IDLE line detected Clear Flag */ |
| EricLew | 0:80ee8f3b695e | 323 | #define USART_CLEAR_TCF USART_ICR_TCCF /*!< Transmission Complete Clear Flag */ |
| EricLew | 0:80ee8f3b695e | 324 | #define USART_CLEAR_CTSF USART_ICR_CTSCF /*!< CTS Interrupt Clear Flag */ |
| EricLew | 0:80ee8f3b695e | 325 | /** |
| EricLew | 0:80ee8f3b695e | 326 | * @} |
| EricLew | 0:80ee8f3b695e | 327 | */ |
| EricLew | 0:80ee8f3b695e | 328 | |
| EricLew | 0:80ee8f3b695e | 329 | /** @defgroup USART_Interruption_Mask USART Interruption Flags Mask |
| EricLew | 0:80ee8f3b695e | 330 | * @{ |
| EricLew | 0:80ee8f3b695e | 331 | */ |
| EricLew | 0:80ee8f3b695e | 332 | #define USART_IT_MASK ((uint16_t)0x001F) /*!< USART interruptions flags mask */ |
| EricLew | 0:80ee8f3b695e | 333 | /** |
| EricLew | 0:80ee8f3b695e | 334 | * @} |
| EricLew | 0:80ee8f3b695e | 335 | */ |
| EricLew | 0:80ee8f3b695e | 336 | |
| EricLew | 0:80ee8f3b695e | 337 | /** |
| EricLew | 0:80ee8f3b695e | 338 | * @} |
| EricLew | 0:80ee8f3b695e | 339 | */ |
| EricLew | 0:80ee8f3b695e | 340 | |
| EricLew | 0:80ee8f3b695e | 341 | /* Exported macros -----------------------------------------------------------*/ |
| EricLew | 0:80ee8f3b695e | 342 | /** @defgroup USART_Exported_Macros USART Exported Macros |
| EricLew | 0:80ee8f3b695e | 343 | * @{ |
| EricLew | 0:80ee8f3b695e | 344 | */ |
| EricLew | 0:80ee8f3b695e | 345 | |
| EricLew | 0:80ee8f3b695e | 346 | /** @brief Reset USART handle state. |
| EricLew | 0:80ee8f3b695e | 347 | * @param __HANDLE__: USART handle. |
| EricLew | 0:80ee8f3b695e | 348 | * @retval None |
| EricLew | 0:80ee8f3b695e | 349 | */ |
| EricLew | 0:80ee8f3b695e | 350 | #define __HAL_USART_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_USART_STATE_RESET) |
| EricLew | 0:80ee8f3b695e | 351 | |
| EricLew | 0:80ee8f3b695e | 352 | /** @brief Check whether the specified USART flag is set or not. |
| EricLew | 0:80ee8f3b695e | 353 | * @param __HANDLE__: specifies the USART Handle |
| EricLew | 0:80ee8f3b695e | 354 | * @param __FLAG__: specifies the flag to check. |
| EricLew | 0:80ee8f3b695e | 355 | * This parameter can be one of the following values: |
| EricLew | 0:80ee8f3b695e | 356 | * @arg USART_FLAG_REACK: Receive enable acknowledge flag |
| EricLew | 0:80ee8f3b695e | 357 | * @arg USART_FLAG_TEACK: Transmit enable acknowledge flag |
| EricLew | 0:80ee8f3b695e | 358 | * @arg USART_FLAG_BUSY: Busy flag |
| EricLew | 0:80ee8f3b695e | 359 | * @arg USART_FLAG_CTS: CTS Change flag |
| EricLew | 0:80ee8f3b695e | 360 | * @arg USART_FLAG_TXE: Transmit data register empty flag |
| EricLew | 0:80ee8f3b695e | 361 | * @arg USART_FLAG_TC: Transmission Complete flag |
| EricLew | 0:80ee8f3b695e | 362 | * @arg USART_FLAG_RXNE: Receive data register not empty flag |
| EricLew | 0:80ee8f3b695e | 363 | * @arg USART_FLAG_IDLE: Idle Line detection flag |
| EricLew | 0:80ee8f3b695e | 364 | * @arg USART_FLAG_ORE: OverRun Error flag |
| EricLew | 0:80ee8f3b695e | 365 | * @arg USART_FLAG_NE: Noise Error flag |
| EricLew | 0:80ee8f3b695e | 366 | * @arg USART_FLAG_FE: Framing Error flag |
| EricLew | 0:80ee8f3b695e | 367 | * @arg USART_FLAG_PE: Parity Error flag |
| EricLew | 0:80ee8f3b695e | 368 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
| EricLew | 0:80ee8f3b695e | 369 | */ |
| EricLew | 0:80ee8f3b695e | 370 | #define __HAL_USART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__)) |
| EricLew | 0:80ee8f3b695e | 371 | |
| EricLew | 0:80ee8f3b695e | 372 | /** @brief Clear the specified USART pending flag. |
| EricLew | 0:80ee8f3b695e | 373 | * @param __HANDLE__: specifies the USART Handle. |
| EricLew | 0:80ee8f3b695e | 374 | * @param __FLAG__: specifies the flag to check. |
| EricLew | 0:80ee8f3b695e | 375 | * This parameter can be any combination of the following values: |
| EricLew | 0:80ee8f3b695e | 376 | * @arg USART_CLEAR_PEF |
| EricLew | 0:80ee8f3b695e | 377 | * @arg USART_CLEAR_FEF |
| EricLew | 0:80ee8f3b695e | 378 | * @arg USART_CLEAR_NEF |
| EricLew | 0:80ee8f3b695e | 379 | * @arg USART_CLEAR_OREF |
| EricLew | 0:80ee8f3b695e | 380 | * @arg USART_CLEAR_IDLEF |
| EricLew | 0:80ee8f3b695e | 381 | * @arg USART_CLEAR_TCF |
| EricLew | 0:80ee8f3b695e | 382 | * @arg USART_CLEAR_LBDF |
| EricLew | 0:80ee8f3b695e | 383 | * @arg USART_CLEAR_CTSF |
| EricLew | 0:80ee8f3b695e | 384 | * @arg USART_CLEAR_RTOF |
| EricLew | 0:80ee8f3b695e | 385 | * @arg USART_CLEAR_EOBF |
| EricLew | 0:80ee8f3b695e | 386 | * @arg USART_CLEAR_CMF |
| EricLew | 0:80ee8f3b695e | 387 | * @arg USART_CLEAR_WUF |
| EricLew | 0:80ee8f3b695e | 388 | * @retval None |
| EricLew | 0:80ee8f3b695e | 389 | */ |
| EricLew | 0:80ee8f3b695e | 390 | #define __HAL_USART_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__)) |
| EricLew | 0:80ee8f3b695e | 391 | |
| EricLew | 0:80ee8f3b695e | 392 | /** @brief Clear the USART PE pending flag. |
| EricLew | 0:80ee8f3b695e | 393 | * @param __HANDLE__: specifies the USART Handle. |
| EricLew | 0:80ee8f3b695e | 394 | * @retval None |
| EricLew | 0:80ee8f3b695e | 395 | */ |
| EricLew | 0:80ee8f3b695e | 396 | #define __HAL_USART_CLEAR_PEFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_PEF) |
| EricLew | 0:80ee8f3b695e | 397 | |
| EricLew | 0:80ee8f3b695e | 398 | /** @brief Clear the USART FE pending flag. |
| EricLew | 0:80ee8f3b695e | 399 | * @param __HANDLE__: specifies the USART Handle. |
| EricLew | 0:80ee8f3b695e | 400 | * @retval None |
| EricLew | 0:80ee8f3b695e | 401 | */ |
| EricLew | 0:80ee8f3b695e | 402 | #define __HAL_USART_CLEAR_FEFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_FEF) |
| EricLew | 0:80ee8f3b695e | 403 | |
| EricLew | 0:80ee8f3b695e | 404 | /** @brief Clear the USART NE pending flag. |
| EricLew | 0:80ee8f3b695e | 405 | * @param __HANDLE__: specifies the USART Handle. |
| EricLew | 0:80ee8f3b695e | 406 | * @retval None |
| EricLew | 0:80ee8f3b695e | 407 | */ |
| EricLew | 0:80ee8f3b695e | 408 | #define __HAL_USART_CLEAR_NEFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_NEF) |
| EricLew | 0:80ee8f3b695e | 409 | |
| EricLew | 0:80ee8f3b695e | 410 | /** @brief Clear the USART ORE pending flag. |
| EricLew | 0:80ee8f3b695e | 411 | * @param __HANDLE__: specifies the USART Handle. |
| EricLew | 0:80ee8f3b695e | 412 | * @retval None |
| EricLew | 0:80ee8f3b695e | 413 | */ |
| EricLew | 0:80ee8f3b695e | 414 | #define __HAL_USART_CLEAR_OREFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_OREF) |
| EricLew | 0:80ee8f3b695e | 415 | |
| EricLew | 0:80ee8f3b695e | 416 | /** @brief Clear the USART IDLE pending flag. |
| EricLew | 0:80ee8f3b695e | 417 | * @param __HANDLE__: specifies the USART Handle. |
| EricLew | 0:80ee8f3b695e | 418 | * @retval None |
| EricLew | 0:80ee8f3b695e | 419 | */ |
| EricLew | 0:80ee8f3b695e | 420 | #define __HAL_USART_CLEAR_IDLEFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_IDLEF) |
| EricLew | 0:80ee8f3b695e | 421 | |
| EricLew | 0:80ee8f3b695e | 422 | /** @brief Enable the specified USART interrupt. |
| EricLew | 0:80ee8f3b695e | 423 | * @param __HANDLE__: specifies the USART Handle. |
| EricLew | 0:80ee8f3b695e | 424 | * @param __INTERRUPT__: specifies the USART interrupt source to enable. |
| EricLew | 0:80ee8f3b695e | 425 | * This parameter can be one of the following values: |
| EricLew | 0:80ee8f3b695e | 426 | * @arg USART_IT_TXE: Transmit Data Register empty interrupt |
| EricLew | 0:80ee8f3b695e | 427 | * @arg USART_IT_TC: Transmission complete interrupt |
| EricLew | 0:80ee8f3b695e | 428 | * @arg USART_IT_RXNE: Receive Data register not empty interrupt |
| EricLew | 0:80ee8f3b695e | 429 | * @arg USART_IT_IDLE: Idle line detection interrupt |
| EricLew | 0:80ee8f3b695e | 430 | * @arg USART_IT_PE: Parity Error interrupt |
| EricLew | 0:80ee8f3b695e | 431 | * @arg USART_IT_ERR: Error interrupt(Frame error, noise error, overrun error) |
| EricLew | 0:80ee8f3b695e | 432 | * @retval None |
| EricLew | 0:80ee8f3b695e | 433 | */ |
| EricLew | 0:80ee8f3b695e | 434 | #define __HAL_USART_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 |= (1U << ((__INTERRUPT__) & USART_IT_MASK))): \ |
| EricLew | 0:80ee8f3b695e | 435 | ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 |= (1U << ((__INTERRUPT__) & USART_IT_MASK))): \ |
| EricLew | 0:80ee8f3b695e | 436 | ((__HANDLE__)->Instance->CR3 |= (1U << ((__INTERRUPT__) & USART_IT_MASK)))) |
| EricLew | 0:80ee8f3b695e | 437 | |
| EricLew | 0:80ee8f3b695e | 438 | /** @brief Disable the specified USART interrupt. |
| EricLew | 0:80ee8f3b695e | 439 | * @param __HANDLE__: specifies the USART Handle. |
| EricLew | 0:80ee8f3b695e | 440 | * @param __INTERRUPT__: specifies the USART interrupt source to disable. |
| EricLew | 0:80ee8f3b695e | 441 | * This parameter can be one of the following values: |
| EricLew | 0:80ee8f3b695e | 442 | * @arg USART_IT_TXE: Transmit Data Register empty interrupt |
| EricLew | 0:80ee8f3b695e | 443 | * @arg USART_IT_TC: Transmission complete interrupt |
| EricLew | 0:80ee8f3b695e | 444 | * @arg USART_IT_RXNE: Receive Data register not empty interrupt |
| EricLew | 0:80ee8f3b695e | 445 | * @arg USART_IT_IDLE: Idle line detection interrupt |
| EricLew | 0:80ee8f3b695e | 446 | * @arg USART_IT_PE: Parity Error interrupt |
| EricLew | 0:80ee8f3b695e | 447 | * @arg USART_IT_ERR: Error interrupt(Frame error, noise error, overrun error) |
| EricLew | 0:80ee8f3b695e | 448 | * @retval None |
| EricLew | 0:80ee8f3b695e | 449 | */ |
| EricLew | 0:80ee8f3b695e | 450 | #define __HAL_USART_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK))): \ |
| EricLew | 0:80ee8f3b695e | 451 | ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK))): \ |
| EricLew | 0:80ee8f3b695e | 452 | ((__HANDLE__)->Instance->CR3 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK)))) |
| EricLew | 0:80ee8f3b695e | 453 | |
| EricLew | 0:80ee8f3b695e | 454 | |
| EricLew | 0:80ee8f3b695e | 455 | /** @brief Check whether the specified USART interrupt has occurred or not. |
| EricLew | 0:80ee8f3b695e | 456 | * @param __HANDLE__: specifies the USART Handle. |
| EricLew | 0:80ee8f3b695e | 457 | * @param __IT__: specifies the USART interrupt source to check. |
| EricLew | 0:80ee8f3b695e | 458 | * This parameter can be one of the following values: |
| EricLew | 0:80ee8f3b695e | 459 | * @arg USART_IT_TXE: Transmit Data Register empty interrupt |
| EricLew | 0:80ee8f3b695e | 460 | * @arg USART_IT_TC: Transmission complete interrupt |
| EricLew | 0:80ee8f3b695e | 461 | * @arg USART_IT_RXNE: Receive Data register not empty interrupt |
| EricLew | 0:80ee8f3b695e | 462 | * @arg USART_IT_IDLE: Idle line detection interrupt |
| EricLew | 0:80ee8f3b695e | 463 | * @arg USART_IT_ORE: OverRun Error interrupt |
| EricLew | 0:80ee8f3b695e | 464 | * @arg USART_IT_NE: Noise Error interrupt |
| EricLew | 0:80ee8f3b695e | 465 | * @arg USART_IT_FE: Framing Error interrupt |
| EricLew | 0:80ee8f3b695e | 466 | * @arg USART_IT_PE: Parity Error interrupt |
| EricLew | 0:80ee8f3b695e | 467 | * @retval The new state of __IT__ (TRUE or FALSE). |
| EricLew | 0:80ee8f3b695e | 468 | */ |
| EricLew | 0:80ee8f3b695e | 469 | #define __HAL_USART_GET_IT(__HANDLE__, __IT__) ((__HANDLE__)->Instance->ISR & ((uint32_t)1 << ((__IT__)>> 0x08))) |
| EricLew | 0:80ee8f3b695e | 470 | |
| EricLew | 0:80ee8f3b695e | 471 | /** @brief Check whether the specified USART interrupt source is enabled or not. |
| EricLew | 0:80ee8f3b695e | 472 | * @param __HANDLE__: specifies the USART Handle. |
| EricLew | 0:80ee8f3b695e | 473 | * @param __IT__: specifies the USART interrupt source to check. |
| EricLew | 0:80ee8f3b695e | 474 | * This parameter can be one of the following values: |
| EricLew | 0:80ee8f3b695e | 475 | * @arg USART_IT_TXE: Transmit Data Register empty interrupt |
| EricLew | 0:80ee8f3b695e | 476 | * @arg USART_IT_TC: Transmission complete interrupt |
| EricLew | 0:80ee8f3b695e | 477 | * @arg USART_IT_RXNE: Receive Data register not empty interrupt |
| EricLew | 0:80ee8f3b695e | 478 | * @arg USART_IT_IDLE: Idle line detection interrupt |
| EricLew | 0:80ee8f3b695e | 479 | * @arg USART_IT_ORE: OverRun Error interrupt |
| EricLew | 0:80ee8f3b695e | 480 | * @arg USART_IT_NE: Noise Error interrupt |
| EricLew | 0:80ee8f3b695e | 481 | * @arg USART_IT_FE: Framing Error interrupt |
| EricLew | 0:80ee8f3b695e | 482 | * @arg USART_IT_PE: Parity Error interrupt |
| EricLew | 0:80ee8f3b695e | 483 | * @retval The new state of __IT__ (TRUE or FALSE). |
| EricLew | 0:80ee8f3b695e | 484 | */ |
| EricLew | 0:80ee8f3b695e | 485 | #define __HAL_USART_GET_IT_SOURCE(__HANDLE__, __IT__) ((((((uint8_t)(__IT__)) >> 5) == 1)? (__HANDLE__)->Instance->CR1:(((((uint8_t)(__IT__)) >> 5) == 2)? \ |
| EricLew | 0:80ee8f3b695e | 486 | (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & ((uint32_t)1 << \ |
| EricLew | 0:80ee8f3b695e | 487 | (((uint16_t)(__IT__)) & USART_IT_MASK))) |
| EricLew | 0:80ee8f3b695e | 488 | |
| EricLew | 0:80ee8f3b695e | 489 | |
| EricLew | 0:80ee8f3b695e | 490 | /** @brief Clear the specified USART ISR flag, in setting the proper ICR register flag. |
| EricLew | 0:80ee8f3b695e | 491 | * @param __HANDLE__: specifies the USART Handle. |
| EricLew | 0:80ee8f3b695e | 492 | * @param __IT_CLEAR__: specifies the interrupt clear register flag that needs to be set |
| EricLew | 0:80ee8f3b695e | 493 | * to clear the corresponding interrupt. |
| EricLew | 0:80ee8f3b695e | 494 | * This parameter can be one of the following values: |
| EricLew | 0:80ee8f3b695e | 495 | * @arg USART_CLEAR_PEF: Parity Error Clear Flag |
| EricLew | 0:80ee8f3b695e | 496 | * @arg USART_CLEAR_FEF: Framing Error Clear Flag |
| EricLew | 0:80ee8f3b695e | 497 | * @arg USART_CLEAR_NEF: Noise detected Clear Flag |
| EricLew | 0:80ee8f3b695e | 498 | * @arg USART_CLEAR_OREF: OverRun Error Clear Flag |
| EricLew | 0:80ee8f3b695e | 499 | * @arg USART_CLEAR_IDLEF: IDLE line detected Clear Flag |
| EricLew | 0:80ee8f3b695e | 500 | * @arg USART_CLEAR_TCF: Transmission Complete Clear Flag |
| EricLew | 0:80ee8f3b695e | 501 | * @arg USART_CLEAR_CTSF: CTS Interrupt Clear Flag |
| EricLew | 0:80ee8f3b695e | 502 | * @retval None |
| EricLew | 0:80ee8f3b695e | 503 | */ |
| EricLew | 0:80ee8f3b695e | 504 | #define __HAL_USART_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__)) |
| EricLew | 0:80ee8f3b695e | 505 | |
| EricLew | 0:80ee8f3b695e | 506 | /** @brief Set a specific USART request flag. |
| EricLew | 0:80ee8f3b695e | 507 | * @param __HANDLE__: specifies the USART Handle. |
| EricLew | 0:80ee8f3b695e | 508 | * @param __REQ__: specifies the request flag to set. |
| EricLew | 0:80ee8f3b695e | 509 | * This parameter can be one of the following values: |
| EricLew | 0:80ee8f3b695e | 510 | * @arg USART_RXDATA_FLUSH_REQUEST: Receive Data flush Request |
| EricLew | 0:80ee8f3b695e | 511 | * @arg USART_TXDATA_FLUSH_REQUEST: Transmit data flush Request |
| EricLew | 0:80ee8f3b695e | 512 | * |
| EricLew | 0:80ee8f3b695e | 513 | * @retval None |
| EricLew | 0:80ee8f3b695e | 514 | */ |
| EricLew | 0:80ee8f3b695e | 515 | #define __HAL_USART_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (__REQ__)) |
| EricLew | 0:80ee8f3b695e | 516 | |
| EricLew | 0:80ee8f3b695e | 517 | /** @brief Enable the USART one bit sample method. |
| EricLew | 0:80ee8f3b695e | 518 | * @param __HANDLE__: specifies the USART Handle. |
| EricLew | 0:80ee8f3b695e | 519 | * @retval None |
| EricLew | 0:80ee8f3b695e | 520 | */ |
| EricLew | 0:80ee8f3b695e | 521 | #define __HAL_USART_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT) |
| EricLew | 0:80ee8f3b695e | 522 | |
| EricLew | 0:80ee8f3b695e | 523 | /** @brief Disable the USART one bit sample method. |
| EricLew | 0:80ee8f3b695e | 524 | * @param __HANDLE__: specifies the USART Handle. |
| EricLew | 0:80ee8f3b695e | 525 | * @retval None |
| EricLew | 0:80ee8f3b695e | 526 | */ |
| EricLew | 0:80ee8f3b695e | 527 | #define __HAL_USART_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint32_t)~((uint32_t)USART_CR3_ONEBIT)) |
| EricLew | 0:80ee8f3b695e | 528 | |
| EricLew | 0:80ee8f3b695e | 529 | /** @brief Enable USART. |
| EricLew | 0:80ee8f3b695e | 530 | * @param __HANDLE__: specifies the USART Handle. |
| EricLew | 0:80ee8f3b695e | 531 | * @retval None |
| EricLew | 0:80ee8f3b695e | 532 | */ |
| EricLew | 0:80ee8f3b695e | 533 | #define __HAL_USART_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE) |
| EricLew | 0:80ee8f3b695e | 534 | |
| EricLew | 0:80ee8f3b695e | 535 | /** @brief Disable USART. |
| EricLew | 0:80ee8f3b695e | 536 | * @param __HANDLE__: specifies the USART Handle. |
| EricLew | 0:80ee8f3b695e | 537 | * @retval None |
| EricLew | 0:80ee8f3b695e | 538 | */ |
| EricLew | 0:80ee8f3b695e | 539 | #define __HAL_USART_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE) |
| EricLew | 0:80ee8f3b695e | 540 | |
| EricLew | 0:80ee8f3b695e | 541 | /** |
| EricLew | 0:80ee8f3b695e | 542 | * @} |
| EricLew | 0:80ee8f3b695e | 543 | */ |
| EricLew | 0:80ee8f3b695e | 544 | |
| EricLew | 0:80ee8f3b695e | 545 | /* Private macros --------------------------------------------------------*/ |
| EricLew | 0:80ee8f3b695e | 546 | /** @defgroup USART_Private_Macros USART Private Macros |
| EricLew | 0:80ee8f3b695e | 547 | * @{ |
| EricLew | 0:80ee8f3b695e | 548 | */ |
| EricLew | 0:80ee8f3b695e | 549 | |
| EricLew | 0:80ee8f3b695e | 550 | /** @brief Report the USART clock source. |
| EricLew | 0:80ee8f3b695e | 551 | * @param __HANDLE__: specifies the USART Handle. |
| EricLew | 0:80ee8f3b695e | 552 | * @param __CLOCKSOURCE__: output variable. |
| EricLew | 0:80ee8f3b695e | 553 | * @retval the USART clocking source, written in __CLOCKSOURCE__. |
| EricLew | 0:80ee8f3b695e | 554 | */ |
| EricLew | 0:80ee8f3b695e | 555 | #define USART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \ |
| EricLew | 0:80ee8f3b695e | 556 | do { \ |
| EricLew | 0:80ee8f3b695e | 557 | if((__HANDLE__)->Instance == USART1) \ |
| EricLew | 0:80ee8f3b695e | 558 | { \ |
| EricLew | 0:80ee8f3b695e | 559 | switch(__HAL_RCC_GET_USART1_SOURCE()) \ |
| EricLew | 0:80ee8f3b695e | 560 | { \ |
| EricLew | 0:80ee8f3b695e | 561 | case RCC_USART1CLKSOURCE_PCLK2: \ |
| EricLew | 0:80ee8f3b695e | 562 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK2; \ |
| EricLew | 0:80ee8f3b695e | 563 | break; \ |
| EricLew | 0:80ee8f3b695e | 564 | case RCC_USART1CLKSOURCE_HSI: \ |
| EricLew | 0:80ee8f3b695e | 565 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \ |
| EricLew | 0:80ee8f3b695e | 566 | break; \ |
| EricLew | 0:80ee8f3b695e | 567 | case RCC_USART1CLKSOURCE_SYSCLK: \ |
| EricLew | 0:80ee8f3b695e | 568 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \ |
| EricLew | 0:80ee8f3b695e | 569 | break; \ |
| EricLew | 0:80ee8f3b695e | 570 | case RCC_USART1CLKSOURCE_LSE: \ |
| EricLew | 0:80ee8f3b695e | 571 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \ |
| EricLew | 0:80ee8f3b695e | 572 | break; \ |
| EricLew | 0:80ee8f3b695e | 573 | default: \ |
| EricLew | 0:80ee8f3b695e | 574 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \ |
| EricLew | 0:80ee8f3b695e | 575 | break; \ |
| EricLew | 0:80ee8f3b695e | 576 | } \ |
| EricLew | 0:80ee8f3b695e | 577 | } \ |
| EricLew | 0:80ee8f3b695e | 578 | else if((__HANDLE__)->Instance == USART2) \ |
| EricLew | 0:80ee8f3b695e | 579 | { \ |
| EricLew | 0:80ee8f3b695e | 580 | switch(__HAL_RCC_GET_USART2_SOURCE()) \ |
| EricLew | 0:80ee8f3b695e | 581 | { \ |
| EricLew | 0:80ee8f3b695e | 582 | case RCC_USART2CLKSOURCE_PCLK1: \ |
| EricLew | 0:80ee8f3b695e | 583 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \ |
| EricLew | 0:80ee8f3b695e | 584 | break; \ |
| EricLew | 0:80ee8f3b695e | 585 | case RCC_USART2CLKSOURCE_HSI: \ |
| EricLew | 0:80ee8f3b695e | 586 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \ |
| EricLew | 0:80ee8f3b695e | 587 | break; \ |
| EricLew | 0:80ee8f3b695e | 588 | case RCC_USART2CLKSOURCE_SYSCLK: \ |
| EricLew | 0:80ee8f3b695e | 589 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \ |
| EricLew | 0:80ee8f3b695e | 590 | break; \ |
| EricLew | 0:80ee8f3b695e | 591 | case RCC_USART2CLKSOURCE_LSE: \ |
| EricLew | 0:80ee8f3b695e | 592 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \ |
| EricLew | 0:80ee8f3b695e | 593 | break; \ |
| EricLew | 0:80ee8f3b695e | 594 | default: \ |
| EricLew | 0:80ee8f3b695e | 595 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \ |
| EricLew | 0:80ee8f3b695e | 596 | break; \ |
| EricLew | 0:80ee8f3b695e | 597 | } \ |
| EricLew | 0:80ee8f3b695e | 598 | } \ |
| EricLew | 0:80ee8f3b695e | 599 | else if((__HANDLE__)->Instance == USART3) \ |
| EricLew | 0:80ee8f3b695e | 600 | { \ |
| EricLew | 0:80ee8f3b695e | 601 | switch(__HAL_RCC_GET_USART3_SOURCE()) \ |
| EricLew | 0:80ee8f3b695e | 602 | { \ |
| EricLew | 0:80ee8f3b695e | 603 | case RCC_USART3CLKSOURCE_PCLK1: \ |
| EricLew | 0:80ee8f3b695e | 604 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \ |
| EricLew | 0:80ee8f3b695e | 605 | break; \ |
| EricLew | 0:80ee8f3b695e | 606 | case RCC_USART3CLKSOURCE_HSI: \ |
| EricLew | 0:80ee8f3b695e | 607 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \ |
| EricLew | 0:80ee8f3b695e | 608 | break; \ |
| EricLew | 0:80ee8f3b695e | 609 | case RCC_USART3CLKSOURCE_SYSCLK: \ |
| EricLew | 0:80ee8f3b695e | 610 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \ |
| EricLew | 0:80ee8f3b695e | 611 | break; \ |
| EricLew | 0:80ee8f3b695e | 612 | case RCC_USART3CLKSOURCE_LSE: \ |
| EricLew | 0:80ee8f3b695e | 613 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \ |
| EricLew | 0:80ee8f3b695e | 614 | break; \ |
| EricLew | 0:80ee8f3b695e | 615 | default: \ |
| EricLew | 0:80ee8f3b695e | 616 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \ |
| EricLew | 0:80ee8f3b695e | 617 | break; \ |
| EricLew | 0:80ee8f3b695e | 618 | } \ |
| EricLew | 0:80ee8f3b695e | 619 | } \ |
| EricLew | 0:80ee8f3b695e | 620 | } while(0) |
| EricLew | 0:80ee8f3b695e | 621 | |
| EricLew | 0:80ee8f3b695e | 622 | /** @brief Check USART Baud rate. |
| EricLew | 0:80ee8f3b695e | 623 | * @param __BAUDRATE__: Baudrate specified by the user. |
| EricLew | 0:80ee8f3b695e | 624 | * The maximum Baud Rate is derived from the maximum clock on L4 (i.e. 80 MHz) |
| EricLew | 0:80ee8f3b695e | 625 | * divided by the smallest oversampling used on the USART (i.e. 8). |
| EricLew | 0:80ee8f3b695e | 626 | * @retval Test result (TRUE or FALSE). |
| EricLew | 0:80ee8f3b695e | 627 | */ |
| EricLew | 0:80ee8f3b695e | 628 | #define IS_USART_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 10000001) |
| EricLew | 0:80ee8f3b695e | 629 | |
| EricLew | 0:80ee8f3b695e | 630 | /** |
| EricLew | 0:80ee8f3b695e | 631 | * @brief Ensure that USART frame number of stop bits is valid. |
| EricLew | 0:80ee8f3b695e | 632 | * @param __STOPBITS__: USART frame number of stop bits. |
| EricLew | 0:80ee8f3b695e | 633 | * @retval SET (__STOPBITS__ is valid) or RESET (__STOPBITS__ is invalid) |
| EricLew | 0:80ee8f3b695e | 634 | */ |
| EricLew | 0:80ee8f3b695e | 635 | #define IS_USART_STOPBITS(__STOPBITS__) (((__STOPBITS__) == USART_STOPBITS_1) || \ |
| EricLew | 0:80ee8f3b695e | 636 | ((__STOPBITS__) == USART_STOPBITS_1_5) || \ |
| EricLew | 0:80ee8f3b695e | 637 | ((__STOPBITS__) == USART_STOPBITS_2)) |
| EricLew | 0:80ee8f3b695e | 638 | |
| EricLew | 0:80ee8f3b695e | 639 | /** |
| EricLew | 0:80ee8f3b695e | 640 | * @brief Ensure that USART frame parity is valid. |
| EricLew | 0:80ee8f3b695e | 641 | * @param __PARITY__: USART frame parity. |
| EricLew | 0:80ee8f3b695e | 642 | * @retval SET (__PARITY__ is valid) or RESET (__PARITY__ is invalid) |
| EricLew | 0:80ee8f3b695e | 643 | */ |
| EricLew | 0:80ee8f3b695e | 644 | #define IS_USART_PARITY(__PARITY__) (((__PARITY__) == USART_PARITY_NONE) || \ |
| EricLew | 0:80ee8f3b695e | 645 | ((__PARITY__) == USART_PARITY_EVEN) || \ |
| EricLew | 0:80ee8f3b695e | 646 | ((__PARITY__) == USART_PARITY_ODD)) |
| EricLew | 0:80ee8f3b695e | 647 | |
| EricLew | 0:80ee8f3b695e | 648 | /** |
| EricLew | 0:80ee8f3b695e | 649 | * @brief Ensure that USART communication mode is valid. |
| EricLew | 0:80ee8f3b695e | 650 | * @param __MODE__: USART communication mode. |
| EricLew | 0:80ee8f3b695e | 651 | * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid) |
| EricLew | 0:80ee8f3b695e | 652 | */ |
| EricLew | 0:80ee8f3b695e | 653 | #define IS_USART_MODE(__MODE__) ((((__MODE__) & (uint32_t)0xFFFFFFF3) == 0x00) && ((__MODE__) != (uint32_t)0x00)) |
| EricLew | 0:80ee8f3b695e | 654 | |
| EricLew | 0:80ee8f3b695e | 655 | /** |
| EricLew | 0:80ee8f3b695e | 656 | * @brief Ensure that USART oversampling is valid. |
| EricLew | 0:80ee8f3b695e | 657 | * @param __SAMPLING__: USART oversampling. |
| EricLew | 0:80ee8f3b695e | 658 | * @retval SET (__SAMPLING__ is valid) or RESET (__SAMPLING__ is invalid) |
| EricLew | 0:80ee8f3b695e | 659 | */ |
| EricLew | 0:80ee8f3b695e | 660 | #define IS_USART_OVERSAMPLING(__SAMPLING__) (((__SAMPLING__) == USART_OVERSAMPLING_16) || \ |
| EricLew | 0:80ee8f3b695e | 661 | ((__SAMPLING__) == USART_OVERSAMPLING_8)) |
| EricLew | 0:80ee8f3b695e | 662 | |
| EricLew | 0:80ee8f3b695e | 663 | /** |
| EricLew | 0:80ee8f3b695e | 664 | * @brief Ensure that USART clock state is valid. |
| EricLew | 0:80ee8f3b695e | 665 | * @param __CLOCK__: USART clock state. |
| EricLew | 0:80ee8f3b695e | 666 | * @retval SET (__CLOCK__ is valid) or RESET (__CLOCK__ is invalid) |
| EricLew | 0:80ee8f3b695e | 667 | */ |
| EricLew | 0:80ee8f3b695e | 668 | #define IS_USART_CLOCK(__CLOCK__) (((__CLOCK__) == USART_CLOCK_DISABLE) || \ |
| EricLew | 0:80ee8f3b695e | 669 | ((__CLOCK__) == USART_CLOCK_ENABLE)) |
| EricLew | 0:80ee8f3b695e | 670 | |
| EricLew | 0:80ee8f3b695e | 671 | /** |
| EricLew | 0:80ee8f3b695e | 672 | * @brief Ensure that USART frame polarity is valid. |
| EricLew | 0:80ee8f3b695e | 673 | * @param __CPOL__: USART frame polarity. |
| EricLew | 0:80ee8f3b695e | 674 | * @retval SET (__CPOL__ is valid) or RESET (__CPOL__ is invalid) |
| EricLew | 0:80ee8f3b695e | 675 | */ |
| EricLew | 0:80ee8f3b695e | 676 | #define IS_USART_POLARITY(__CPOL__) (((__CPOL__) == USART_POLARITY_LOW) || ((__CPOL__) == USART_POLARITY_HIGH)) |
| EricLew | 0:80ee8f3b695e | 677 | |
| EricLew | 0:80ee8f3b695e | 678 | /** |
| EricLew | 0:80ee8f3b695e | 679 | * @brief Ensure that USART frame phase is valid. |
| EricLew | 0:80ee8f3b695e | 680 | * @param __CPHA__: USART frame phase. |
| EricLew | 0:80ee8f3b695e | 681 | * @retval SET (__CPHA__ is valid) or RESET (__CPHA__ is invalid) |
| EricLew | 0:80ee8f3b695e | 682 | */ |
| EricLew | 0:80ee8f3b695e | 683 | #define IS_USART_PHASE(__CPHA__) (((__CPHA__) == USART_PHASE_1EDGE) || ((__CPHA__) == USART_PHASE_2EDGE)) |
| EricLew | 0:80ee8f3b695e | 684 | |
| EricLew | 0:80ee8f3b695e | 685 | /** |
| EricLew | 0:80ee8f3b695e | 686 | * @brief Ensure that USART frame last bit clock pulse setting is valid. |
| EricLew | 0:80ee8f3b695e | 687 | * @param __LASTBIT__: USART frame last bit clock pulse setting. |
| EricLew | 0:80ee8f3b695e | 688 | * @retval SET (__LASTBIT__ is valid) or RESET (__LASTBIT__ is invalid) |
| EricLew | 0:80ee8f3b695e | 689 | */ |
| EricLew | 0:80ee8f3b695e | 690 | #define IS_USART_LASTBIT(__LASTBIT__) (((__LASTBIT__) == USART_LASTBIT_DISABLE) || \ |
| EricLew | 0:80ee8f3b695e | 691 | ((__LASTBIT__) == USART_LASTBIT_ENABLE)) |
| EricLew | 0:80ee8f3b695e | 692 | |
| EricLew | 0:80ee8f3b695e | 693 | /** |
| EricLew | 0:80ee8f3b695e | 694 | * @brief Ensure that USART request parameter is valid. |
| EricLew | 0:80ee8f3b695e | 695 | * @param __PARAM__: USART request parameter. |
| EricLew | 0:80ee8f3b695e | 696 | * @retval SET (__PARAM__ is valid) or RESET (__PARAM__ is invalid) |
| EricLew | 0:80ee8f3b695e | 697 | */ |
| EricLew | 0:80ee8f3b695e | 698 | #define IS_USART_REQUEST_PARAMETER(__PARAM__) (((__PARAM__) == USART_RXDATA_FLUSH_REQUEST) || \ |
| EricLew | 0:80ee8f3b695e | 699 | ((__PARAM__) == USART_TXDATA_FLUSH_REQUEST)) |
| EricLew | 0:80ee8f3b695e | 700 | |
| EricLew | 0:80ee8f3b695e | 701 | /** |
| EricLew | 0:80ee8f3b695e | 702 | * @} |
| EricLew | 0:80ee8f3b695e | 703 | */ |
| EricLew | 0:80ee8f3b695e | 704 | |
| EricLew | 0:80ee8f3b695e | 705 | /* Include USART HAL Extended module */ |
| EricLew | 0:80ee8f3b695e | 706 | #include "stm32l4xx_hal_usart_ex.h" |
| EricLew | 0:80ee8f3b695e | 707 | |
| EricLew | 0:80ee8f3b695e | 708 | /* Exported functions --------------------------------------------------------*/ |
| EricLew | 0:80ee8f3b695e | 709 | /** @addtogroup USART_Exported_Functions USART Exported Functions |
| EricLew | 0:80ee8f3b695e | 710 | * @{ |
| EricLew | 0:80ee8f3b695e | 711 | */ |
| EricLew | 0:80ee8f3b695e | 712 | |
| EricLew | 0:80ee8f3b695e | 713 | /** @addtogroup USART_Exported_Functions_Group1 Initialization and de-initialization functions |
| EricLew | 0:80ee8f3b695e | 714 | * @{ |
| EricLew | 0:80ee8f3b695e | 715 | */ |
| EricLew | 0:80ee8f3b695e | 716 | |
| EricLew | 0:80ee8f3b695e | 717 | /* Initialization and de-initialization functions ****************************/ |
| EricLew | 0:80ee8f3b695e | 718 | HAL_StatusTypeDef HAL_USART_Init(USART_HandleTypeDef *husart); |
| EricLew | 0:80ee8f3b695e | 719 | HAL_StatusTypeDef HAL_USART_DeInit(USART_HandleTypeDef *husart); |
| EricLew | 0:80ee8f3b695e | 720 | void HAL_USART_MspInit(USART_HandleTypeDef *husart); |
| EricLew | 0:80ee8f3b695e | 721 | void HAL_USART_MspDeInit(USART_HandleTypeDef *husart); |
| EricLew | 0:80ee8f3b695e | 722 | |
| EricLew | 0:80ee8f3b695e | 723 | /** |
| EricLew | 0:80ee8f3b695e | 724 | * @} |
| EricLew | 0:80ee8f3b695e | 725 | */ |
| EricLew | 0:80ee8f3b695e | 726 | |
| EricLew | 0:80ee8f3b695e | 727 | /** @addtogroup USART_Exported_Functions_Group2 IO operation functions |
| EricLew | 0:80ee8f3b695e | 728 | * @{ |
| EricLew | 0:80ee8f3b695e | 729 | */ |
| EricLew | 0:80ee8f3b695e | 730 | |
| EricLew | 0:80ee8f3b695e | 731 | /* IO operation functions *****************************************************/ |
| EricLew | 0:80ee8f3b695e | 732 | HAL_StatusTypeDef HAL_USART_Transmit(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size, uint32_t Timeout); |
| EricLew | 0:80ee8f3b695e | 733 | HAL_StatusTypeDef HAL_USART_Receive(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size, uint32_t Timeout); |
| EricLew | 0:80ee8f3b695e | 734 | HAL_StatusTypeDef HAL_USART_TransmitReceive(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout); |
| EricLew | 0:80ee8f3b695e | 735 | HAL_StatusTypeDef HAL_USART_Transmit_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size); |
| EricLew | 0:80ee8f3b695e | 736 | HAL_StatusTypeDef HAL_USART_Receive_IT(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size); |
| EricLew | 0:80ee8f3b695e | 737 | HAL_StatusTypeDef HAL_USART_TransmitReceive_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size); |
| EricLew | 0:80ee8f3b695e | 738 | HAL_StatusTypeDef HAL_USART_Transmit_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size); |
| EricLew | 0:80ee8f3b695e | 739 | HAL_StatusTypeDef HAL_USART_Receive_DMA(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size); |
| EricLew | 0:80ee8f3b695e | 740 | HAL_StatusTypeDef HAL_USART_TransmitReceive_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size); |
| EricLew | 0:80ee8f3b695e | 741 | HAL_StatusTypeDef HAL_USART_DMAPause(USART_HandleTypeDef *husart); |
| EricLew | 0:80ee8f3b695e | 742 | HAL_StatusTypeDef HAL_USART_DMAResume(USART_HandleTypeDef *husart); |
| EricLew | 0:80ee8f3b695e | 743 | HAL_StatusTypeDef HAL_USART_DMAStop(USART_HandleTypeDef *husart); |
| EricLew | 0:80ee8f3b695e | 744 | void HAL_USART_IRQHandler(USART_HandleTypeDef *husart); |
| EricLew | 0:80ee8f3b695e | 745 | void HAL_USART_TxHalfCpltCallback(USART_HandleTypeDef *husart); |
| EricLew | 0:80ee8f3b695e | 746 | void HAL_USART_TxCpltCallback(USART_HandleTypeDef *husart); |
| EricLew | 0:80ee8f3b695e | 747 | void HAL_USART_RxCpltCallback(USART_HandleTypeDef *husart); |
| EricLew | 0:80ee8f3b695e | 748 | void HAL_USART_RxHalfCpltCallback(USART_HandleTypeDef *husart); |
| EricLew | 0:80ee8f3b695e | 749 | void HAL_USART_TxRxCpltCallback(USART_HandleTypeDef *husart); |
| EricLew | 0:80ee8f3b695e | 750 | void HAL_USART_ErrorCallback(USART_HandleTypeDef *husart); |
| EricLew | 0:80ee8f3b695e | 751 | |
| EricLew | 0:80ee8f3b695e | 752 | /** |
| EricLew | 0:80ee8f3b695e | 753 | * @} |
| EricLew | 0:80ee8f3b695e | 754 | */ |
| EricLew | 0:80ee8f3b695e | 755 | |
| EricLew | 0:80ee8f3b695e | 756 | /* Peripheral Control functions ***********************************************/ |
| EricLew | 0:80ee8f3b695e | 757 | |
| EricLew | 0:80ee8f3b695e | 758 | /** @addtogroup USART_Exported_Functions_Group4 Peripheral State and Error functions |
| EricLew | 0:80ee8f3b695e | 759 | * @{ |
| EricLew | 0:80ee8f3b695e | 760 | */ |
| EricLew | 0:80ee8f3b695e | 761 | |
| EricLew | 0:80ee8f3b695e | 762 | /* Peripheral State and Error functions ***************************************/ |
| EricLew | 0:80ee8f3b695e | 763 | HAL_USART_StateTypeDef HAL_USART_GetState(USART_HandleTypeDef *husart); |
| EricLew | 0:80ee8f3b695e | 764 | uint32_t HAL_USART_GetError(USART_HandleTypeDef *husart); |
| EricLew | 0:80ee8f3b695e | 765 | |
| EricLew | 0:80ee8f3b695e | 766 | /** |
| EricLew | 0:80ee8f3b695e | 767 | * @} |
| EricLew | 0:80ee8f3b695e | 768 | */ |
| EricLew | 0:80ee8f3b695e | 769 | |
| EricLew | 0:80ee8f3b695e | 770 | /** |
| EricLew | 0:80ee8f3b695e | 771 | * @} |
| EricLew | 0:80ee8f3b695e | 772 | */ |
| EricLew | 0:80ee8f3b695e | 773 | |
| EricLew | 0:80ee8f3b695e | 774 | /** |
| EricLew | 0:80ee8f3b695e | 775 | * @} |
| EricLew | 0:80ee8f3b695e | 776 | */ |
| EricLew | 0:80ee8f3b695e | 777 | |
| EricLew | 0:80ee8f3b695e | 778 | /** |
| EricLew | 0:80ee8f3b695e | 779 | * @} |
| EricLew | 0:80ee8f3b695e | 780 | */ |
| EricLew | 0:80ee8f3b695e | 781 | |
| EricLew | 0:80ee8f3b695e | 782 | #ifdef __cplusplus |
| EricLew | 0:80ee8f3b695e | 783 | } |
| EricLew | 0:80ee8f3b695e | 784 | #endif |
| EricLew | 0:80ee8f3b695e | 785 | |
| EricLew | 0:80ee8f3b695e | 786 | #endif /* __STM32L4xx_HAL_USART_H */ |
| EricLew | 0:80ee8f3b695e | 787 | |
| EricLew | 0:80ee8f3b695e | 788 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
| EricLew | 0:80ee8f3b695e | 789 |
