The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
TARGET_NUCLEO_F072RB/stm32f0xx_hal_usart.h@122:f9eeca106725, 2016-07-07 (annotated)
- Committer:
- Kojto
- Date:
- Thu Jul 07 14:34:11 2016 +0100
- Revision:
- 122:f9eeca106725
- Parent:
- 108:34e6b704fe68
Release 122 of the mbed library
Changes:
- new targets - Nucleo L432KC, Beetle, Nucleo F446ZE, Nucleo L011K4
- Thread safety addition - mbed API should contain a statement about thread safety
- critical section API addition
- CAS API (core_util_atomic_incr/decr)
- DEVICE_ are generated from targets.json file, device.h deprecated
- Callback replaces FunctionPointer to provide std like interface
- mbed HAL API docs improvements
- toolchain - prexif attributes with MBED_
- add new attributes - packed, weak, forcedinline, align
- target.json - contains targets definitions
- ST - L1XX - Cube update to 1.5
- SPI clock selection fix (clock from APB domain)
- F7 - Cube update v1.4.0
- L0 - baudrate init fix
- L1 - Cube update v1.5
- F3 - baudrate init fix, 3 targets CAN support
- F4 - Cube update v1.12.0, 3 targets CAN support
- L4XX - Cube update v1.5.1
- F0 - update Cube to v1.5.0
- L4 - 2 targets (L476RG/VG) CAN support
- NXP - pwm clock fix for KSDK2 MCU
- LPC2368 - remove ARM toolchain support - due to regression
- KSDK2 - fix SPI , I2C address and repeat start
- Silabs - some fixes backported from mbed 3
- Renesas - RZ_A1H - SystemCoreClockUpdate addition
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bogdanm | 85:024bf7f99721 | 1 | /** |
bogdanm | 85:024bf7f99721 | 2 | ****************************************************************************** |
bogdanm | 85:024bf7f99721 | 3 | * @file stm32f0xx_hal_usart.h |
bogdanm | 85:024bf7f99721 | 4 | * @author MCD Application Team |
Kojto | 122:f9eeca106725 | 5 | * @version V1.4.0 |
Kojto | 122:f9eeca106725 | 6 | * @date 27-May-2016 |
bogdanm | 85:024bf7f99721 | 7 | * @brief Header file of USART HAL module. |
bogdanm | 85:024bf7f99721 | 8 | ****************************************************************************** |
bogdanm | 85:024bf7f99721 | 9 | * @attention |
bogdanm | 85:024bf7f99721 | 10 | * |
Kojto | 122:f9eeca106725 | 11 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
bogdanm | 85:024bf7f99721 | 12 | * |
bogdanm | 85:024bf7f99721 | 13 | * Redistribution and use in source and binary forms, with or without modification, |
bogdanm | 85:024bf7f99721 | 14 | * are permitted provided that the following conditions are met: |
bogdanm | 85:024bf7f99721 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
bogdanm | 85:024bf7f99721 | 16 | * this list of conditions and the following disclaimer. |
bogdanm | 85:024bf7f99721 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
bogdanm | 85:024bf7f99721 | 18 | * this list of conditions and the following disclaimer in the documentation |
bogdanm | 85:024bf7f99721 | 19 | * and/or other materials provided with the distribution. |
bogdanm | 85:024bf7f99721 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
bogdanm | 85:024bf7f99721 | 21 | * may be used to endorse or promote products derived from this software |
bogdanm | 85:024bf7f99721 | 22 | * without specific prior written permission. |
bogdanm | 85:024bf7f99721 | 23 | * |
bogdanm | 85:024bf7f99721 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
bogdanm | 85:024bf7f99721 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
bogdanm | 85:024bf7f99721 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
bogdanm | 85:024bf7f99721 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
bogdanm | 85:024bf7f99721 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
bogdanm | 85:024bf7f99721 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
bogdanm | 85:024bf7f99721 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
bogdanm | 85:024bf7f99721 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
bogdanm | 85:024bf7f99721 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
bogdanm | 85:024bf7f99721 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
bogdanm | 85:024bf7f99721 | 34 | * |
Kojto | 108:34e6b704fe68 | 35 | ****************************************************************************** |
bogdanm | 85:024bf7f99721 | 36 | */ |
bogdanm | 85:024bf7f99721 | 37 | |
bogdanm | 85:024bf7f99721 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
bogdanm | 85:024bf7f99721 | 39 | #ifndef __STM32F0xx_HAL_USART_H |
bogdanm | 85:024bf7f99721 | 40 | #define __STM32F0xx_HAL_USART_H |
bogdanm | 85:024bf7f99721 | 41 | |
bogdanm | 85:024bf7f99721 | 42 | #ifdef __cplusplus |
bogdanm | 85:024bf7f99721 | 43 | extern "C" { |
bogdanm | 85:024bf7f99721 | 44 | #endif |
bogdanm | 85:024bf7f99721 | 45 | |
bogdanm | 85:024bf7f99721 | 46 | /* Includes ------------------------------------------------------------------*/ |
bogdanm | 85:024bf7f99721 | 47 | #include "stm32f0xx_hal_def.h" |
bogdanm | 85:024bf7f99721 | 48 | |
bogdanm | 85:024bf7f99721 | 49 | /** @addtogroup STM32F0xx_HAL_Driver |
bogdanm | 85:024bf7f99721 | 50 | * @{ |
bogdanm | 85:024bf7f99721 | 51 | */ |
bogdanm | 85:024bf7f99721 | 52 | |
bogdanm | 85:024bf7f99721 | 53 | /** @addtogroup USART |
bogdanm | 85:024bf7f99721 | 54 | * @{ |
Kojto | 108:34e6b704fe68 | 55 | */ |
bogdanm | 85:024bf7f99721 | 56 | |
bogdanm | 85:024bf7f99721 | 57 | /* Exported types ------------------------------------------------------------*/ |
bogdanm | 92:4fc01daae5a5 | 58 | /** @defgroup USART_Exported_Types USART Exported Types |
bogdanm | 92:4fc01daae5a5 | 59 | * @{ |
Kojto | 108:34e6b704fe68 | 60 | */ |
bogdanm | 85:024bf7f99721 | 61 | |
Kojto | 108:34e6b704fe68 | 62 | /** |
Kojto | 108:34e6b704fe68 | 63 | * @brief USART Init Structure definition |
Kojto | 108:34e6b704fe68 | 64 | */ |
bogdanm | 85:024bf7f99721 | 65 | typedef struct |
bogdanm | 85:024bf7f99721 | 66 | { |
bogdanm | 85:024bf7f99721 | 67 | uint32_t BaudRate; /*!< This member configures the Usart communication baud rate. |
bogdanm | 85:024bf7f99721 | 68 | The baud rate is computed using the following formula: |
Kojto | 108:34e6b704fe68 | 69 | Baud Rate Register = ((PCLKx) / ((huart->Init.BaudRate))). */ |
bogdanm | 85:024bf7f99721 | 70 | |
bogdanm | 85:024bf7f99721 | 71 | uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame. |
Kojto | 108:34e6b704fe68 | 72 | This parameter can be a value of @ref USARTEx_Word_Length. */ |
bogdanm | 85:024bf7f99721 | 73 | |
bogdanm | 92:4fc01daae5a5 | 74 | uint32_t StopBits; /*!< Specifies the number of stop bits transmitted. |
Kojto | 108:34e6b704fe68 | 75 | This parameter can be a value of @ref USART_Stop_Bits. */ |
bogdanm | 85:024bf7f99721 | 76 | |
bogdanm | 92:4fc01daae5a5 | 77 | uint32_t Parity; /*!< Specifies the parity mode. |
bogdanm | 85:024bf7f99721 | 78 | This parameter can be a value of @ref USART_Parity |
bogdanm | 85:024bf7f99721 | 79 | @note When parity is enabled, the computed parity is inserted |
bogdanm | 85:024bf7f99721 | 80 | at the MSB position of the transmitted data (9th bit when |
bogdanm | 85:024bf7f99721 | 81 | the word length is set to 9 data bits; 8th bit when the |
bogdanm | 85:024bf7f99721 | 82 | word length is set to 8 data bits). */ |
Kojto | 108:34e6b704fe68 | 83 | |
bogdanm | 92:4fc01daae5a5 | 84 | uint32_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled. |
Kojto | 108:34e6b704fe68 | 85 | This parameter can be a value of @ref USART_Mode. */ |
bogdanm | 85:024bf7f99721 | 86 | |
bogdanm | 92:4fc01daae5a5 | 87 | uint32_t CLKPolarity; /*!< Specifies the steady state of the serial clock. |
Kojto | 108:34e6b704fe68 | 88 | This parameter can be a value of @ref USART_Clock_Polarity. */ |
bogdanm | 85:024bf7f99721 | 89 | |
bogdanm | 92:4fc01daae5a5 | 90 | uint32_t CLKPhase; /*!< Specifies the clock transition on which the bit capture is made. |
Kojto | 108:34e6b704fe68 | 91 | This parameter can be a value of @ref USART_Clock_Phase. */ |
bogdanm | 85:024bf7f99721 | 92 | |
bogdanm | 92:4fc01daae5a5 | 93 | uint32_t CLKLastBit; /*!< Specifies whether the clock pulse corresponding to the last transmitted |
bogdanm | 85:024bf7f99721 | 94 | data bit (MSB) has to be output on the SCLK pin in synchronous mode. |
Kojto | 108:34e6b704fe68 | 95 | This parameter can be a value of @ref USART_Last_Bit. */ |
bogdanm | 85:024bf7f99721 | 96 | }USART_InitTypeDef; |
bogdanm | 85:024bf7f99721 | 97 | |
Kojto | 108:34e6b704fe68 | 98 | /** |
Kojto | 108:34e6b704fe68 | 99 | * @brief HAL USART State structures definition |
Kojto | 108:34e6b704fe68 | 100 | */ |
bogdanm | 85:024bf7f99721 | 101 | typedef enum |
bogdanm | 85:024bf7f99721 | 102 | { |
Kojto | 108:34e6b704fe68 | 103 | HAL_USART_STATE_RESET = 0x00, /*!< Peripheral is not initialized */ |
Kojto | 108:34e6b704fe68 | 104 | HAL_USART_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */ |
Kojto | 108:34e6b704fe68 | 105 | HAL_USART_STATE_BUSY = 0x02, /*!< an internal process is ongoing */ |
Kojto | 108:34e6b704fe68 | 106 | HAL_USART_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */ |
Kojto | 108:34e6b704fe68 | 107 | HAL_USART_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */ |
bogdanm | 85:024bf7f99721 | 108 | HAL_USART_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission Reception process is ongoing */ |
Kojto | 108:34e6b704fe68 | 109 | HAL_USART_STATE_TIMEOUT = 0x03, /*!< Timeout state */ |
Kojto | 108:34e6b704fe68 | 110 | HAL_USART_STATE_ERROR = 0x04 /*!< Error */ |
bogdanm | 85:024bf7f99721 | 111 | }HAL_USART_StateTypeDef; |
bogdanm | 85:024bf7f99721 | 112 | |
Kojto | 108:34e6b704fe68 | 113 | /** |
bogdanm | 85:024bf7f99721 | 114 | * @brief USART clock sources definitions |
bogdanm | 85:024bf7f99721 | 115 | */ |
bogdanm | 85:024bf7f99721 | 116 | typedef enum |
bogdanm | 85:024bf7f99721 | 117 | { |
bogdanm | 85:024bf7f99721 | 118 | USART_CLOCKSOURCE_PCLK1 = 0x00, /*!< PCLK1 clock source */ |
bogdanm | 85:024bf7f99721 | 119 | USART_CLOCKSOURCE_HSI = 0x02, /*!< HSI clock source */ |
bogdanm | 85:024bf7f99721 | 120 | USART_CLOCKSOURCE_SYSCLK = 0x04, /*!< SYSCLK clock source */ |
bogdanm | 85:024bf7f99721 | 121 | USART_CLOCKSOURCE_LSE = 0x08, /*!< LSE clock source */ |
Kojto | 108:34e6b704fe68 | 122 | USART_CLOCKSOURCE_UNDEFINED = 0x10 /*!< undefined clock source */ |
bogdanm | 85:024bf7f99721 | 123 | }USART_ClockSourceTypeDef; |
bogdanm | 85:024bf7f99721 | 124 | |
Kojto | 108:34e6b704fe68 | 125 | |
Kojto | 108:34e6b704fe68 | 126 | /** |
Kojto | 108:34e6b704fe68 | 127 | * @brief USART handle Structure definition |
Kojto | 108:34e6b704fe68 | 128 | */ |
bogdanm | 85:024bf7f99721 | 129 | typedef struct |
bogdanm | 85:024bf7f99721 | 130 | { |
bogdanm | 92:4fc01daae5a5 | 131 | USART_TypeDef *Instance; /*!< USART registers base address */ |
Kojto | 108:34e6b704fe68 | 132 | |
bogdanm | 92:4fc01daae5a5 | 133 | USART_InitTypeDef Init; /*!< USART communication parameters */ |
Kojto | 108:34e6b704fe68 | 134 | |
bogdanm | 92:4fc01daae5a5 | 135 | uint8_t *pTxBuffPtr; /*!< Pointer to USART Tx transfer Buffer */ |
Kojto | 108:34e6b704fe68 | 136 | |
bogdanm | 92:4fc01daae5a5 | 137 | uint16_t TxXferSize; /*!< USART Tx Transfer size */ |
Kojto | 108:34e6b704fe68 | 138 | |
bogdanm | 92:4fc01daae5a5 | 139 | uint16_t TxXferCount; /*!< USART Tx Transfer Counter */ |
Kojto | 108:34e6b704fe68 | 140 | |
bogdanm | 92:4fc01daae5a5 | 141 | uint8_t *pRxBuffPtr; /*!< Pointer to USART Rx transfer Buffer */ |
Kojto | 108:34e6b704fe68 | 142 | |
bogdanm | 92:4fc01daae5a5 | 143 | uint16_t RxXferSize; /*!< USART Rx Transfer size */ |
Kojto | 108:34e6b704fe68 | 144 | |
bogdanm | 92:4fc01daae5a5 | 145 | uint16_t RxXferCount; /*!< USART Rx Transfer Counter */ |
Kojto | 108:34e6b704fe68 | 146 | |
bogdanm | 92:4fc01daae5a5 | 147 | uint16_t Mask; /*!< USART Rx RDR register mask */ |
Kojto | 108:34e6b704fe68 | 148 | |
bogdanm | 92:4fc01daae5a5 | 149 | DMA_HandleTypeDef *hdmatx; /*!< USART Tx DMA Handle parameters */ |
Kojto | 108:34e6b704fe68 | 150 | |
bogdanm | 92:4fc01daae5a5 | 151 | DMA_HandleTypeDef *hdmarx; /*!< USART Rx DMA Handle parameters */ |
Kojto | 108:34e6b704fe68 | 152 | |
Kojto | 108:34e6b704fe68 | 153 | HAL_LockTypeDef Lock; /*!< Locking object */ |
Kojto | 108:34e6b704fe68 | 154 | |
Kojto | 108:34e6b704fe68 | 155 | __IO HAL_USART_StateTypeDef State; /*!< USART communication state */ |
Kojto | 108:34e6b704fe68 | 156 | |
Kojto | 108:34e6b704fe68 | 157 | __IO uint32_t ErrorCode; /*!< USART Error code */ |
Kojto | 108:34e6b704fe68 | 158 | |
bogdanm | 85:024bf7f99721 | 159 | }USART_HandleTypeDef; |
bogdanm | 85:024bf7f99721 | 160 | |
bogdanm | 92:4fc01daae5a5 | 161 | /** |
bogdanm | 92:4fc01daae5a5 | 162 | * @} |
bogdanm | 92:4fc01daae5a5 | 163 | */ |
bogdanm | 85:024bf7f99721 | 164 | |
bogdanm | 85:024bf7f99721 | 165 | /* Exported constants --------------------------------------------------------*/ |
Kojto | 108:34e6b704fe68 | 166 | /** @defgroup USART_Exported_Constants USART Exported Constants |
bogdanm | 85:024bf7f99721 | 167 | * @{ |
bogdanm | 85:024bf7f99721 | 168 | */ |
bogdanm | 85:024bf7f99721 | 169 | |
Kojto | 93:e188a91d3eaa | 170 | /** @defgroup USART_Error USART Error |
Kojto | 93:e188a91d3eaa | 171 | * @{ |
Kojto | 93:e188a91d3eaa | 172 | */ |
Kojto | 93:e188a91d3eaa | 173 | #define HAL_USART_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */ |
Kojto | 93:e188a91d3eaa | 174 | #define HAL_USART_ERROR_PE ((uint32_t)0x00000001) /*!< Parity error */ |
Kojto | 93:e188a91d3eaa | 175 | #define HAL_USART_ERROR_NE ((uint32_t)0x00000002) /*!< Noise error */ |
Kojto | 93:e188a91d3eaa | 176 | #define HAL_USART_ERROR_FE ((uint32_t)0x00000004) /*!< frame error */ |
Kojto | 93:e188a91d3eaa | 177 | #define HAL_USART_ERROR_ORE ((uint32_t)0x00000008) /*!< Overrun error */ |
Kojto | 93:e188a91d3eaa | 178 | #define HAL_USART_ERROR_DMA ((uint32_t)0x00000010) /*!< DMA transfer error */ |
Kojto | 93:e188a91d3eaa | 179 | /** |
Kojto | 93:e188a91d3eaa | 180 | * @} |
Kojto | 93:e188a91d3eaa | 181 | */ |
Kojto | 93:e188a91d3eaa | 182 | |
bogdanm | 85:024bf7f99721 | 183 | /** @defgroup USART_Stop_Bits USART Number of Stop Bits |
bogdanm | 85:024bf7f99721 | 184 | * @{ |
bogdanm | 85:024bf7f99721 | 185 | */ |
Kojto | 122:f9eeca106725 | 186 | #ifdef USART_SMARTCARD_SUPPORT |
Kojto | 122:f9eeca106725 | 187 | #define USART_STOPBITS_0_5 ((uint32_t)USART_CR2_STOP_0) /*!< USART frame with 0.5 stop bit */ |
Kojto | 122:f9eeca106725 | 188 | #define USART_STOPBITS_1 ((uint32_t)0x00000000) /*!< USART frame with 1 stop bit */ |
Kojto | 122:f9eeca106725 | 189 | #define USART_STOPBITS_1_5 ((uint32_t)(USART_CR2_STOP_0 | USART_CR2_STOP_1)) /*!< USART frame with 1.5 stop bits */ |
Kojto | 122:f9eeca106725 | 190 | #define USART_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1) /*!< USART frame with 2 stop bits */ |
Kojto | 122:f9eeca106725 | 191 | #else |
Kojto | 122:f9eeca106725 | 192 | #define USART_STOPBITS_1 ((uint32_t)0x00000000) /*!< USART frame with 1 stop bit */ |
Kojto | 122:f9eeca106725 | 193 | #define USART_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1) /*!< USART frame with 2 stop bits */ |
Kojto | 122:f9eeca106725 | 194 | #endif |
bogdanm | 85:024bf7f99721 | 195 | /** |
bogdanm | 85:024bf7f99721 | 196 | * @} |
Kojto | 122:f9eeca106725 | 197 | */ |
bogdanm | 85:024bf7f99721 | 198 | |
bogdanm | 85:024bf7f99721 | 199 | /** @defgroup USART_Parity USART Parity |
bogdanm | 85:024bf7f99721 | 200 | * @{ |
Kojto | 108:34e6b704fe68 | 201 | */ |
Kojto | 108:34e6b704fe68 | 202 | #define USART_PARITY_NONE ((uint32_t)0x00000000) /*!< No parity */ |
Kojto | 108:34e6b704fe68 | 203 | #define USART_PARITY_EVEN ((uint32_t)USART_CR1_PCE) /*!< Even parity */ |
Kojto | 108:34e6b704fe68 | 204 | #define USART_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS)) /*!< Odd parity */ |
bogdanm | 85:024bf7f99721 | 205 | /** |
bogdanm | 85:024bf7f99721 | 206 | * @} |
Kojto | 108:34e6b704fe68 | 207 | */ |
bogdanm | 85:024bf7f99721 | 208 | |
bogdanm | 85:024bf7f99721 | 209 | /** @defgroup USART_Mode USART Mode |
bogdanm | 85:024bf7f99721 | 210 | * @{ |
Kojto | 108:34e6b704fe68 | 211 | */ |
Kojto | 108:34e6b704fe68 | 212 | #define USART_MODE_RX ((uint32_t)USART_CR1_RE) /*!< RX mode */ |
Kojto | 108:34e6b704fe68 | 213 | #define USART_MODE_TX ((uint32_t)USART_CR1_TE) /*!< TX mode */ |
Kojto | 108:34e6b704fe68 | 214 | #define USART_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE)) /*!< RX and TX mode */ |
bogdanm | 85:024bf7f99721 | 215 | /** |
bogdanm | 85:024bf7f99721 | 216 | * @} |
bogdanm | 85:024bf7f99721 | 217 | */ |
Kojto | 108:34e6b704fe68 | 218 | |
bogdanm | 85:024bf7f99721 | 219 | /** @defgroup USART_Clock USART Clock |
bogdanm | 85:024bf7f99721 | 220 | * @{ |
Kojto | 108:34e6b704fe68 | 221 | */ |
Kojto | 108:34e6b704fe68 | 222 | #define USART_CLOCK_DISABLE ((uint32_t)0x00000000) /*!< USART clock disable */ |
Kojto | 108:34e6b704fe68 | 223 | #define USART_CLOCK_ENABLE ((uint32_t)USART_CR2_CLKEN) /*!< USART clock enable */ |
bogdanm | 85:024bf7f99721 | 224 | /** |
bogdanm | 85:024bf7f99721 | 225 | * @} |
Kojto | 108:34e6b704fe68 | 226 | */ |
bogdanm | 85:024bf7f99721 | 227 | |
bogdanm | 85:024bf7f99721 | 228 | /** @defgroup USART_Clock_Polarity USART Clock Polarity |
bogdanm | 85:024bf7f99721 | 229 | * @{ |
bogdanm | 85:024bf7f99721 | 230 | */ |
Kojto | 108:34e6b704fe68 | 231 | #define USART_POLARITY_LOW ((uint32_t)0x00000000) /*!< USART Clock signal is steady Low */ |
Kojto | 108:34e6b704fe68 | 232 | #define USART_POLARITY_HIGH ((uint32_t)USART_CR2_CPOL) /*!< USART Clock signal is steady High */ |
bogdanm | 85:024bf7f99721 | 233 | /** |
bogdanm | 85:024bf7f99721 | 234 | * @} |
Kojto | 108:34e6b704fe68 | 235 | */ |
bogdanm | 85:024bf7f99721 | 236 | |
bogdanm | 85:024bf7f99721 | 237 | /** @defgroup USART_Clock_Phase USART Clock Phase |
bogdanm | 85:024bf7f99721 | 238 | * @{ |
bogdanm | 85:024bf7f99721 | 239 | */ |
Kojto | 108:34e6b704fe68 | 240 | #define USART_PHASE_1EDGE ((uint32_t)0x00000000) /*!< USART frame phase on first clock transition */ |
Kojto | 108:34e6b704fe68 | 241 | #define USART_PHASE_2EDGE ((uint32_t)USART_CR2_CPHA) /*!< USART frame phase on second clock transition */ |
bogdanm | 85:024bf7f99721 | 242 | /** |
bogdanm | 85:024bf7f99721 | 243 | * @} |
bogdanm | 85:024bf7f99721 | 244 | */ |
bogdanm | 85:024bf7f99721 | 245 | |
bogdanm | 85:024bf7f99721 | 246 | /** @defgroup USART_Last_Bit USART Last Bit |
bogdanm | 85:024bf7f99721 | 247 | * @{ |
bogdanm | 85:024bf7f99721 | 248 | */ |
Kojto | 108:34e6b704fe68 | 249 | #define USART_LASTBIT_DISABLE ((uint32_t)0x00000000) /*!< USART frame last data bit clock pulse not output to SCLK pin */ |
Kojto | 108:34e6b704fe68 | 250 | #define USART_LASTBIT_ENABLE ((uint32_t)USART_CR2_LBCL) /*!< USART frame last data bit clock pulse output to SCLK pin */ |
bogdanm | 85:024bf7f99721 | 251 | /** |
bogdanm | 85:024bf7f99721 | 252 | * @} |
bogdanm | 85:024bf7f99721 | 253 | */ |
bogdanm | 85:024bf7f99721 | 254 | |
bogdanm | 85:024bf7f99721 | 255 | /** @defgroup USART_Interrupt_definition USART Interrupts Definition |
bogdanm | 85:024bf7f99721 | 256 | * Elements values convention: 0000ZZZZ0XXYYYYYb |
bogdanm | 85:024bf7f99721 | 257 | * - YYYYY : Interrupt source position in the XX register (5bits) |
bogdanm | 85:024bf7f99721 | 258 | * - XX : Interrupt source register (2bits) |
bogdanm | 85:024bf7f99721 | 259 | * - 01: CR1 register |
bogdanm | 85:024bf7f99721 | 260 | * - 10: CR2 register |
bogdanm | 85:024bf7f99721 | 261 | * - 11: CR3 register |
bogdanm | 85:024bf7f99721 | 262 | * - ZZZZ : Flag position in the ISR register(4bits) |
bogdanm | 85:024bf7f99721 | 263 | * @{ |
bogdanm | 85:024bf7f99721 | 264 | */ |
bogdanm | 85:024bf7f99721 | 265 | |
Kojto | 108:34e6b704fe68 | 266 | #define USART_IT_PE ((uint16_t)0x0028) /*!< USART parity error interruption */ |
Kojto | 108:34e6b704fe68 | 267 | #define USART_IT_TXE ((uint16_t)0x0727) /*!< USART transmit data register empty interruption */ |
Kojto | 108:34e6b704fe68 | 268 | #define USART_IT_TC ((uint16_t)0x0626) /*!< USART transmission complete interruption */ |
Kojto | 108:34e6b704fe68 | 269 | #define USART_IT_RXNE ((uint16_t)0x0525) /*!< USART read data register not empty interruption */ |
Kojto | 108:34e6b704fe68 | 270 | #define USART_IT_IDLE ((uint16_t)0x0424) /*!< USART idle interruption */ |
Kojto | 108:34e6b704fe68 | 271 | #define USART_IT_ERR ((uint16_t)0x0060) /*!< USART error interruption */ |
Kojto | 108:34e6b704fe68 | 272 | #define USART_IT_ORE ((uint16_t)0x0300) /*!< USART overrun error interruption */ |
Kojto | 108:34e6b704fe68 | 273 | #define USART_IT_NE ((uint16_t)0x0200) /*!< USART noise error interruption */ |
Kojto | 108:34e6b704fe68 | 274 | #define USART_IT_FE ((uint16_t)0x0100) /*!< USART frame error interruption */ |
bogdanm | 85:024bf7f99721 | 275 | /** |
bogdanm | 85:024bf7f99721 | 276 | * @} |
bogdanm | 85:024bf7f99721 | 277 | */ |
bogdanm | 85:024bf7f99721 | 278 | |
bogdanm | 85:024bf7f99721 | 279 | /** @defgroup USART_IT_CLEAR_Flags USART Interruption Clear Flags |
bogdanm | 85:024bf7f99721 | 280 | * @{ |
bogdanm | 85:024bf7f99721 | 281 | */ |
Kojto | 108:34e6b704fe68 | 282 | #define USART_CLEAR_PEF USART_ICR_PECF /*!< Parity Error Clear Flag */ |
Kojto | 108:34e6b704fe68 | 283 | #define USART_CLEAR_FEF USART_ICR_FECF /*!< Framing Error Clear Flag */ |
Kojto | 108:34e6b704fe68 | 284 | #define USART_CLEAR_NEF USART_ICR_NCF /*!< Noise detected Clear Flag */ |
Kojto | 108:34e6b704fe68 | 285 | #define USART_CLEAR_OREF USART_ICR_ORECF /*!< OverRun Error Clear Flag */ |
Kojto | 108:34e6b704fe68 | 286 | #define USART_CLEAR_IDLEF USART_ICR_IDLECF /*!< IDLE line detected Clear Flag */ |
Kojto | 108:34e6b704fe68 | 287 | #define USART_CLEAR_TCF USART_ICR_TCCF /*!< Transmission Complete Clear Flag */ |
Kojto | 108:34e6b704fe68 | 288 | #define USART_CLEAR_CTSF USART_ICR_CTSCF /*!< CTS Interrupt Clear Flag */ |
bogdanm | 85:024bf7f99721 | 289 | /** |
bogdanm | 85:024bf7f99721 | 290 | * @} |
bogdanm | 85:024bf7f99721 | 291 | */ |
bogdanm | 85:024bf7f99721 | 292 | |
Kojto | 108:34e6b704fe68 | 293 | /** @defgroup USART_Interruption_Mask USART Interruption Flags Mask |
bogdanm | 85:024bf7f99721 | 294 | * @{ |
Kojto | 108:34e6b704fe68 | 295 | */ |
Kojto | 108:34e6b704fe68 | 296 | #define USART_IT_MASK ((uint16_t)0x001F) /*!< USART interruptions flags mask */ |
bogdanm | 85:024bf7f99721 | 297 | /** |
bogdanm | 85:024bf7f99721 | 298 | * @} |
bogdanm | 85:024bf7f99721 | 299 | */ |
bogdanm | 85:024bf7f99721 | 300 | |
bogdanm | 85:024bf7f99721 | 301 | /** |
bogdanm | 85:024bf7f99721 | 302 | * @} |
bogdanm | 85:024bf7f99721 | 303 | */ |
Kojto | 108:34e6b704fe68 | 304 | |
Kojto | 108:34e6b704fe68 | 305 | /* Exported macros -----------------------------------------------------------*/ |
bogdanm | 92:4fc01daae5a5 | 306 | /** @defgroup USART_Exported_Macros USART Exported Macros |
bogdanm | 85:024bf7f99721 | 307 | * @{ |
Kojto | 108:34e6b704fe68 | 308 | */ |
bogdanm | 85:024bf7f99721 | 309 | |
Kojto | 108:34e6b704fe68 | 310 | /** @brief Reset USART handle state. |
bogdanm | 85:024bf7f99721 | 311 | * @param __HANDLE__: USART handle. |
bogdanm | 85:024bf7f99721 | 312 | * @retval None |
bogdanm | 85:024bf7f99721 | 313 | */ |
Kojto | 108:34e6b704fe68 | 314 | #define __HAL_USART_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_USART_STATE_RESET) |
bogdanm | 85:024bf7f99721 | 315 | |
Kojto | 108:34e6b704fe68 | 316 | /** @brief Check whether the specified USART flag is set or not. |
bogdanm | 92:4fc01daae5a5 | 317 | * @param __HANDLE__: specifies the USART Handle |
bogdanm | 85:024bf7f99721 | 318 | * @param __FLAG__: specifies the flag to check. |
bogdanm | 85:024bf7f99721 | 319 | * This parameter can be one of the following values: |
Kojto | 108:34e6b704fe68 | 320 | * @arg USART_FLAG_REACK: Receive enable acknowledge flag |
Kojto | 108:34e6b704fe68 | 321 | * @arg USART_FLAG_TEACK: Transmit enable acknowledge flag |
Kojto | 108:34e6b704fe68 | 322 | * @arg USART_FLAG_BUSY: Busy flag |
Kojto | 108:34e6b704fe68 | 323 | * @arg USART_FLAG_CTS: CTS Change flag |
bogdanm | 85:024bf7f99721 | 324 | * @arg USART_FLAG_TXE: Transmit data register empty flag |
bogdanm | 85:024bf7f99721 | 325 | * @arg USART_FLAG_TC: Transmission Complete flag |
bogdanm | 85:024bf7f99721 | 326 | * @arg USART_FLAG_RXNE: Receive data register not empty flag |
bogdanm | 85:024bf7f99721 | 327 | * @arg USART_FLAG_IDLE: Idle Line detection flag |
bogdanm | 85:024bf7f99721 | 328 | * @arg USART_FLAG_ORE: OverRun Error flag |
bogdanm | 85:024bf7f99721 | 329 | * @arg USART_FLAG_NE: Noise Error flag |
bogdanm | 85:024bf7f99721 | 330 | * @arg USART_FLAG_FE: Framing Error flag |
bogdanm | 85:024bf7f99721 | 331 | * @arg USART_FLAG_PE: Parity Error flag |
bogdanm | 85:024bf7f99721 | 332 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
bogdanm | 85:024bf7f99721 | 333 | */ |
bogdanm | 85:024bf7f99721 | 334 | #define __HAL_USART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__)) |
bogdanm | 85:024bf7f99721 | 335 | |
Kojto | 108:34e6b704fe68 | 336 | /** @brief Clear the specified USART pending flag. |
Kojto | 108:34e6b704fe68 | 337 | * @param __HANDLE__: specifies the USART Handle. |
Kojto | 108:34e6b704fe68 | 338 | * @param __FLAG__: specifies the flag to check. |
Kojto | 108:34e6b704fe68 | 339 | * This parameter can be any combination of the following values: |
Kojto | 108:34e6b704fe68 | 340 | * @arg USART_CLEAR_PEF |
Kojto | 108:34e6b704fe68 | 341 | * @arg USART_CLEAR_FEF |
Kojto | 108:34e6b704fe68 | 342 | * @arg USART_CLEAR_NEF |
Kojto | 108:34e6b704fe68 | 343 | * @arg USART_CLEAR_OREF |
Kojto | 108:34e6b704fe68 | 344 | * @arg USART_CLEAR_IDLEF |
Kojto | 108:34e6b704fe68 | 345 | * @arg USART_CLEAR_TCF |
Kojto | 108:34e6b704fe68 | 346 | * @arg USART_CLEAR_CTSF |
Kojto | 108:34e6b704fe68 | 347 | * @arg USART_CLEAR_RTOF |
Kojto | 108:34e6b704fe68 | 348 | * @arg USART_CLEAR_EOBF |
Kojto | 108:34e6b704fe68 | 349 | * @arg USART_CLEAR_CMF |
Kojto | 108:34e6b704fe68 | 350 | * @arg USART_CLEAR_WUF |
Kojto | 108:34e6b704fe68 | 351 | * @retval None |
Kojto | 108:34e6b704fe68 | 352 | */ |
Kojto | 108:34e6b704fe68 | 353 | #define __HAL_USART_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__)) |
bogdanm | 85:024bf7f99721 | 354 | |
Kojto | 108:34e6b704fe68 | 355 | /** @brief Clear the USART PE pending flag. |
Kojto | 108:34e6b704fe68 | 356 | * @param __HANDLE__: specifies the USART Handle. |
Kojto | 108:34e6b704fe68 | 357 | * @retval None |
Kojto | 108:34e6b704fe68 | 358 | */ |
Kojto | 108:34e6b704fe68 | 359 | #define __HAL_USART_CLEAR_PEFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_PEF) |
Kojto | 108:34e6b704fe68 | 360 | |
Kojto | 108:34e6b704fe68 | 361 | /** @brief Clear the USART FE pending flag. |
Kojto | 108:34e6b704fe68 | 362 | * @param __HANDLE__: specifies the USART Handle. |
Kojto | 108:34e6b704fe68 | 363 | * @retval None |
Kojto | 108:34e6b704fe68 | 364 | */ |
Kojto | 108:34e6b704fe68 | 365 | #define __HAL_USART_CLEAR_FEFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_FEF) |
Kojto | 108:34e6b704fe68 | 366 | |
Kojto | 108:34e6b704fe68 | 367 | /** @brief Clear the USART NE pending flag. |
Kojto | 108:34e6b704fe68 | 368 | * @param __HANDLE__: specifies the USART Handle. |
Kojto | 108:34e6b704fe68 | 369 | * @retval None |
Kojto | 108:34e6b704fe68 | 370 | */ |
Kojto | 108:34e6b704fe68 | 371 | #define __HAL_USART_CLEAR_NEFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_NEF) |
Kojto | 108:34e6b704fe68 | 372 | |
Kojto | 108:34e6b704fe68 | 373 | /** @brief Clear the USART ORE pending flag. |
Kojto | 108:34e6b704fe68 | 374 | * @param __HANDLE__: specifies the USART Handle. |
Kojto | 108:34e6b704fe68 | 375 | * @retval None |
Kojto | 108:34e6b704fe68 | 376 | */ |
Kojto | 108:34e6b704fe68 | 377 | #define __HAL_USART_CLEAR_OREFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_OREF) |
Kojto | 108:34e6b704fe68 | 378 | |
Kojto | 108:34e6b704fe68 | 379 | /** @brief Clear the USART IDLE pending flag. |
Kojto | 108:34e6b704fe68 | 380 | * @param __HANDLE__: specifies the USART Handle. |
Kojto | 108:34e6b704fe68 | 381 | * @retval None |
Kojto | 108:34e6b704fe68 | 382 | */ |
Kojto | 108:34e6b704fe68 | 383 | #define __HAL_USART_CLEAR_IDLEFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_IDLEF) |
Kojto | 108:34e6b704fe68 | 384 | |
Kojto | 108:34e6b704fe68 | 385 | /** @brief Enable the specified USART interrupt. |
Kojto | 108:34e6b704fe68 | 386 | * @param __HANDLE__: specifies the USART Handle. |
bogdanm | 85:024bf7f99721 | 387 | * @param __INTERRUPT__: specifies the USART interrupt source to enable. |
bogdanm | 85:024bf7f99721 | 388 | * This parameter can be one of the following values: |
bogdanm | 85:024bf7f99721 | 389 | * @arg USART_IT_TXE: Transmit Data Register empty interrupt |
bogdanm | 85:024bf7f99721 | 390 | * @arg USART_IT_TC: Transmission complete interrupt |
bogdanm | 85:024bf7f99721 | 391 | * @arg USART_IT_RXNE: Receive Data register not empty interrupt |
bogdanm | 85:024bf7f99721 | 392 | * @arg USART_IT_IDLE: Idle line detection interrupt |
bogdanm | 85:024bf7f99721 | 393 | * @arg USART_IT_PE: Parity Error interrupt |
bogdanm | 85:024bf7f99721 | 394 | * @arg USART_IT_ERR: Error interrupt(Frame error, noise error, overrun error) |
bogdanm | 85:024bf7f99721 | 395 | * @retval None |
bogdanm | 85:024bf7f99721 | 396 | */ |
bogdanm | 85:024bf7f99721 | 397 | #define __HAL_USART_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 |= (1U << ((__INTERRUPT__) & USART_IT_MASK))): \ |
bogdanm | 85:024bf7f99721 | 398 | ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 |= (1U << ((__INTERRUPT__) & USART_IT_MASK))): \ |
bogdanm | 85:024bf7f99721 | 399 | ((__HANDLE__)->Instance->CR3 |= (1U << ((__INTERRUPT__) & USART_IT_MASK)))) |
bogdanm | 85:024bf7f99721 | 400 | |
Kojto | 108:34e6b704fe68 | 401 | /** @brief Disable the specified USART interrupt. |
bogdanm | 85:024bf7f99721 | 402 | * @param __HANDLE__: specifies the USART Handle. |
bogdanm | 85:024bf7f99721 | 403 | * @param __INTERRUPT__: specifies the USART interrupt source to disable. |
bogdanm | 85:024bf7f99721 | 404 | * This parameter can be one of the following values: |
bogdanm | 85:024bf7f99721 | 405 | * @arg USART_IT_TXE: Transmit Data Register empty interrupt |
bogdanm | 85:024bf7f99721 | 406 | * @arg USART_IT_TC: Transmission complete interrupt |
bogdanm | 85:024bf7f99721 | 407 | * @arg USART_IT_RXNE: Receive Data register not empty interrupt |
bogdanm | 85:024bf7f99721 | 408 | * @arg USART_IT_IDLE: Idle line detection interrupt |
bogdanm | 85:024bf7f99721 | 409 | * @arg USART_IT_PE: Parity Error interrupt |
bogdanm | 85:024bf7f99721 | 410 | * @arg USART_IT_ERR: Error interrupt(Frame error, noise error, overrun error) |
bogdanm | 85:024bf7f99721 | 411 | * @retval None |
bogdanm | 85:024bf7f99721 | 412 | */ |
bogdanm | 85:024bf7f99721 | 413 | #define __HAL_USART_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK))): \ |
bogdanm | 85:024bf7f99721 | 414 | ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK))): \ |
bogdanm | 85:024bf7f99721 | 415 | ((__HANDLE__)->Instance->CR3 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK)))) |
bogdanm | 85:024bf7f99721 | 416 | |
Kojto | 108:34e6b704fe68 | 417 | |
Kojto | 108:34e6b704fe68 | 418 | /** @brief Check whether the specified USART interrupt has occurred or not. |
Kojto | 108:34e6b704fe68 | 419 | * @param __HANDLE__: specifies the USART Handle. |
bogdanm | 85:024bf7f99721 | 420 | * @param __IT__: specifies the USART interrupt source to check. |
bogdanm | 85:024bf7f99721 | 421 | * This parameter can be one of the following values: |
bogdanm | 85:024bf7f99721 | 422 | * @arg USART_IT_TXE: Transmit Data Register empty interrupt |
bogdanm | 85:024bf7f99721 | 423 | * @arg USART_IT_TC: Transmission complete interrupt |
bogdanm | 85:024bf7f99721 | 424 | * @arg USART_IT_RXNE: Receive Data register not empty interrupt |
bogdanm | 85:024bf7f99721 | 425 | * @arg USART_IT_IDLE: Idle line detection interrupt |
bogdanm | 85:024bf7f99721 | 426 | * @arg USART_IT_ORE: OverRun Error interrupt |
bogdanm | 85:024bf7f99721 | 427 | * @arg USART_IT_NE: Noise Error interrupt |
bogdanm | 85:024bf7f99721 | 428 | * @arg USART_IT_FE: Framing Error interrupt |
bogdanm | 85:024bf7f99721 | 429 | * @arg USART_IT_PE: Parity Error interrupt |
bogdanm | 85:024bf7f99721 | 430 | * @retval The new state of __IT__ (TRUE or FALSE). |
bogdanm | 85:024bf7f99721 | 431 | */ |
Kojto | 108:34e6b704fe68 | 432 | #define __HAL_USART_GET_IT(__HANDLE__, __IT__) ((__HANDLE__)->Instance->ISR & ((uint32_t)1 << ((__IT__)>> 0x08))) |
bogdanm | 85:024bf7f99721 | 433 | |
Kojto | 108:34e6b704fe68 | 434 | /** @brief Check whether the specified USART interrupt source is enabled or not. |
bogdanm | 85:024bf7f99721 | 435 | * @param __HANDLE__: specifies the USART Handle. |
bogdanm | 85:024bf7f99721 | 436 | * @param __IT__: specifies the USART interrupt source to check. |
bogdanm | 85:024bf7f99721 | 437 | * This parameter can be one of the following values: |
bogdanm | 85:024bf7f99721 | 438 | * @arg USART_IT_TXE: Transmit Data Register empty interrupt |
bogdanm | 85:024bf7f99721 | 439 | * @arg USART_IT_TC: Transmission complete interrupt |
bogdanm | 85:024bf7f99721 | 440 | * @arg USART_IT_RXNE: Receive Data register not empty interrupt |
bogdanm | 85:024bf7f99721 | 441 | * @arg USART_IT_IDLE: Idle line detection interrupt |
bogdanm | 85:024bf7f99721 | 442 | * @arg USART_IT_ORE: OverRun Error interrupt |
bogdanm | 85:024bf7f99721 | 443 | * @arg USART_IT_NE: Noise Error interrupt |
bogdanm | 85:024bf7f99721 | 444 | * @arg USART_IT_FE: Framing Error interrupt |
bogdanm | 85:024bf7f99721 | 445 | * @arg USART_IT_PE: Parity Error interrupt |
bogdanm | 85:024bf7f99721 | 446 | * @retval The new state of __IT__ (TRUE or FALSE). |
bogdanm | 85:024bf7f99721 | 447 | */ |
bogdanm | 85:024bf7f99721 | 448 | #define __HAL_USART_GET_IT_SOURCE(__HANDLE__, __IT__) ((((((uint8_t)(__IT__)) >> 5) == 1)? (__HANDLE__)->Instance->CR1:(((((uint8_t)(__IT__)) >> 5) == 2)? \ |
bogdanm | 85:024bf7f99721 | 449 | (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & ((uint32_t)1 << \ |
bogdanm | 85:024bf7f99721 | 450 | (((uint16_t)(__IT__)) & USART_IT_MASK))) |
bogdanm | 85:024bf7f99721 | 451 | |
bogdanm | 85:024bf7f99721 | 452 | |
Kojto | 108:34e6b704fe68 | 453 | /** @brief Clear the specified USART ISR flag, in setting the proper ICR register flag. |
bogdanm | 85:024bf7f99721 | 454 | * @param __HANDLE__: specifies the USART Handle. |
bogdanm | 85:024bf7f99721 | 455 | * @param __IT_CLEAR__: specifies the interrupt clear register flag that needs to be set |
Kojto | 108:34e6b704fe68 | 456 | * to clear the corresponding interrupt. |
bogdanm | 85:024bf7f99721 | 457 | * This parameter can be one of the following values: |
Kojto | 108:34e6b704fe68 | 458 | * @arg USART_CLEAR_PEF: Parity Error Clear Flag |
Kojto | 108:34e6b704fe68 | 459 | * @arg USART_CLEAR_FEF: Framing Error Clear Flag |
Kojto | 108:34e6b704fe68 | 460 | * @arg USART_CLEAR_NEF: Noise detected Clear Flag |
Kojto | 108:34e6b704fe68 | 461 | * @arg USART_CLEAR_OREF: OverRun Error Clear Flag |
Kojto | 108:34e6b704fe68 | 462 | * @arg USART_CLEAR_IDLEF: IDLE line detected Clear Flag |
Kojto | 108:34e6b704fe68 | 463 | * @arg USART_CLEAR_TCF: Transmission Complete Clear Flag |
Kojto | 108:34e6b704fe68 | 464 | * @arg USART_CLEAR_CTSF: CTS Interrupt Clear Flag |
bogdanm | 85:024bf7f99721 | 465 | * @retval None |
bogdanm | 85:024bf7f99721 | 466 | */ |
Kojto | 108:34e6b704fe68 | 467 | #define __HAL_USART_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__)) |
bogdanm | 85:024bf7f99721 | 468 | |
bogdanm | 85:024bf7f99721 | 469 | /** @brief Set a specific USART request flag. |
bogdanm | 85:024bf7f99721 | 470 | * @param __HANDLE__: specifies the USART Handle. |
Kojto | 108:34e6b704fe68 | 471 | * @param __REQ__: specifies the request flag to set. |
bogdanm | 85:024bf7f99721 | 472 | * This parameter can be one of the following values: |
Kojto | 108:34e6b704fe68 | 473 | * @arg USART_RXDATA_FLUSH_REQUEST: Receive Data flush Request |
Kojto | 108:34e6b704fe68 | 474 | * @arg USART_TXDATA_FLUSH_REQUEST: Transmit data flush Request |
bogdanm | 85:024bf7f99721 | 475 | * |
bogdanm | 85:024bf7f99721 | 476 | * @retval None |
Kojto | 108:34e6b704fe68 | 477 | */ |
Kojto | 108:34e6b704fe68 | 478 | #define __HAL_USART_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (__REQ__)) |
bogdanm | 85:024bf7f99721 | 479 | |
Kojto | 108:34e6b704fe68 | 480 | /** @brief Enable the USART one bit sample method. |
Kojto | 108:34e6b704fe68 | 481 | * @param __HANDLE__: specifies the USART Handle. |
Kojto | 108:34e6b704fe68 | 482 | * @retval None |
Kojto | 108:34e6b704fe68 | 483 | */ |
Kojto | 108:34e6b704fe68 | 484 | #define __HAL_USART_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT) |
Kojto | 108:34e6b704fe68 | 485 | |
Kojto | 108:34e6b704fe68 | 486 | /** @brief Disable the USART one bit sample method. |
Kojto | 108:34e6b704fe68 | 487 | * @param __HANDLE__: specifies the USART Handle. |
Kojto | 108:34e6b704fe68 | 488 | * @retval None |
Kojto | 108:34e6b704fe68 | 489 | */ |
Kojto | 108:34e6b704fe68 | 490 | #define __HAL_USART_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint32_t)~((uint32_t)USART_CR3_ONEBIT)) |
Kojto | 108:34e6b704fe68 | 491 | |
Kojto | 108:34e6b704fe68 | 492 | /** @brief Enable USART. |
bogdanm | 85:024bf7f99721 | 493 | * @param __HANDLE__: specifies the USART Handle. |
bogdanm | 85:024bf7f99721 | 494 | * @retval None |
Kojto | 108:34e6b704fe68 | 495 | */ |
Kojto | 108:34e6b704fe68 | 496 | #define __HAL_USART_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE) |
bogdanm | 85:024bf7f99721 | 497 | |
Kojto | 108:34e6b704fe68 | 498 | /** @brief Disable USART. |
bogdanm | 85:024bf7f99721 | 499 | * @param __HANDLE__: specifies the USART Handle. |
bogdanm | 85:024bf7f99721 | 500 | * @retval None |
Kojto | 108:34e6b704fe68 | 501 | */ |
Kojto | 108:34e6b704fe68 | 502 | #define __HAL_USART_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE) |
bogdanm | 92:4fc01daae5a5 | 503 | |
bogdanm | 92:4fc01daae5a5 | 504 | /** |
bogdanm | 92:4fc01daae5a5 | 505 | * @} |
Kojto | 108:34e6b704fe68 | 506 | */ |
bogdanm | 92:4fc01daae5a5 | 507 | |
bogdanm | 92:4fc01daae5a5 | 508 | /* Private macros --------------------------------------------------------*/ |
bogdanm | 92:4fc01daae5a5 | 509 | /** @defgroup USART_Private_Macros USART Private Macros |
bogdanm | 92:4fc01daae5a5 | 510 | * @{ |
bogdanm | 92:4fc01daae5a5 | 511 | */ |
bogdanm | 85:024bf7f99721 | 512 | |
bogdanm | 85:024bf7f99721 | 513 | /** @brief Check USART Baud rate |
Kojto | 108:34e6b704fe68 | 514 | * @param __BAUDRATE__: Baudrate specified by the user. |
Kojto | 122:f9eeca106725 | 515 | * The maximum Baud Rate is derived from the maximum clock on F0 (i.e. 48 MHz) |
Kojto | 108:34e6b704fe68 | 516 | * divided by the smallest oversampling used on the USART (i.e. 8) |
Kojto | 108:34e6b704fe68 | 517 | * @retval Test result (TRUE or FALSE). |
Kojto | 122:f9eeca106725 | 518 | */ |
Kojto | 122:f9eeca106725 | 519 | #define IS_USART_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 6000001) |
Kojto | 108:34e6b704fe68 | 520 | |
bogdanm | 85:024bf7f99721 | 521 | /** |
Kojto | 108:34e6b704fe68 | 522 | * @brief Ensure that USART frame number of stop bits is valid. |
Kojto | 108:34e6b704fe68 | 523 | * @param __STOPBITS__: USART frame number of stop bits. |
Kojto | 108:34e6b704fe68 | 524 | * @retval SET (__STOPBITS__ is valid) or RESET (__STOPBITS__ is invalid) |
bogdanm | 85:024bf7f99721 | 525 | */ |
Kojto | 122:f9eeca106725 | 526 | #ifdef USART_SMARTCARD_SUPPORT |
Kojto | 122:f9eeca106725 | 527 | #define IS_USART_STOPBITS(__STOPBITS__) (((__STOPBITS__) == USART_STOPBITS_0_5) || \ |
Kojto | 122:f9eeca106725 | 528 | ((__STOPBITS__) == USART_STOPBITS_1) || \ |
Kojto | 108:34e6b704fe68 | 529 | ((__STOPBITS__) == USART_STOPBITS_1_5) || \ |
Kojto | 108:34e6b704fe68 | 530 | ((__STOPBITS__) == USART_STOPBITS_2)) |
Kojto | 122:f9eeca106725 | 531 | #else |
Kojto | 122:f9eeca106725 | 532 | #define IS_USART_STOPBITS(__STOPBITS__) (((__STOPBITS__) == USART_STOPBITS_1) || \ |
Kojto | 122:f9eeca106725 | 533 | ((__STOPBITS__) == USART_STOPBITS_2)) |
Kojto | 122:f9eeca106725 | 534 | #endif |
Kojto | 108:34e6b704fe68 | 535 | |
Kojto | 108:34e6b704fe68 | 536 | /** |
Kojto | 108:34e6b704fe68 | 537 | * @brief Ensure that USART frame parity is valid. |
Kojto | 108:34e6b704fe68 | 538 | * @param __PARITY__: USART frame parity. |
Kojto | 108:34e6b704fe68 | 539 | * @retval SET (__PARITY__ is valid) or RESET (__PARITY__ is invalid) |
Kojto | 108:34e6b704fe68 | 540 | */ |
Kojto | 108:34e6b704fe68 | 541 | #define IS_USART_PARITY(__PARITY__) (((__PARITY__) == USART_PARITY_NONE) || \ |
Kojto | 108:34e6b704fe68 | 542 | ((__PARITY__) == USART_PARITY_EVEN) || \ |
Kojto | 108:34e6b704fe68 | 543 | ((__PARITY__) == USART_PARITY_ODD)) |
bogdanm | 85:024bf7f99721 | 544 | |
Kojto | 108:34e6b704fe68 | 545 | /** |
Kojto | 108:34e6b704fe68 | 546 | * @brief Ensure that USART communication mode is valid. |
Kojto | 108:34e6b704fe68 | 547 | * @param __MODE__: USART communication mode. |
Kojto | 108:34e6b704fe68 | 548 | * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid) |
Kojto | 108:34e6b704fe68 | 549 | */ |
Kojto | 122:f9eeca106725 | 550 | #define IS_USART_MODE(__MODE__) ((((__MODE__) & (uint32_t)0xFFFFFFF3U) == 0x00) && ((__MODE__) != (uint32_t)0x00)) |
Kojto | 108:34e6b704fe68 | 551 | |
Kojto | 108:34e6b704fe68 | 552 | /** |
Kojto | 108:34e6b704fe68 | 553 | * @brief Ensure that USART clock state is valid. |
Kojto | 108:34e6b704fe68 | 554 | * @param __CLOCK__: USART clock state. |
Kojto | 108:34e6b704fe68 | 555 | * @retval SET (__CLOCK__ is valid) or RESET (__CLOCK__ is invalid) |
Kojto | 108:34e6b704fe68 | 556 | */ |
Kojto | 108:34e6b704fe68 | 557 | #define IS_USART_CLOCK(__CLOCK__) (((__CLOCK__) == USART_CLOCK_DISABLE) || \ |
Kojto | 108:34e6b704fe68 | 558 | ((__CLOCK__) == USART_CLOCK_ENABLE)) |
Kojto | 108:34e6b704fe68 | 559 | |
Kojto | 108:34e6b704fe68 | 560 | /** |
Kojto | 108:34e6b704fe68 | 561 | * @brief Ensure that USART frame polarity is valid. |
Kojto | 108:34e6b704fe68 | 562 | * @param __CPOL__: USART frame polarity. |
Kojto | 108:34e6b704fe68 | 563 | * @retval SET (__CPOL__ is valid) or RESET (__CPOL__ is invalid) |
Kojto | 108:34e6b704fe68 | 564 | */ |
Kojto | 108:34e6b704fe68 | 565 | #define IS_USART_POLARITY(__CPOL__) (((__CPOL__) == USART_POLARITY_LOW) || ((__CPOL__) == USART_POLARITY_HIGH)) |
Kojto | 108:34e6b704fe68 | 566 | |
Kojto | 108:34e6b704fe68 | 567 | /** |
Kojto | 108:34e6b704fe68 | 568 | * @brief Ensure that USART frame phase is valid. |
Kojto | 108:34e6b704fe68 | 569 | * @param __CPHA__: USART frame phase. |
Kojto | 108:34e6b704fe68 | 570 | * @retval SET (__CPHA__ is valid) or RESET (__CPHA__ is invalid) |
bogdanm | 92:4fc01daae5a5 | 571 | */ |
Kojto | 108:34e6b704fe68 | 572 | #define IS_USART_PHASE(__CPHA__) (((__CPHA__) == USART_PHASE_1EDGE) || ((__CPHA__) == USART_PHASE_2EDGE)) |
bogdanm | 92:4fc01daae5a5 | 573 | |
Kojto | 108:34e6b704fe68 | 574 | /** |
Kojto | 108:34e6b704fe68 | 575 | * @brief Ensure that USART frame last bit clock pulse setting is valid. |
Kojto | 108:34e6b704fe68 | 576 | * @param __LASTBIT__: USART frame last bit clock pulse setting. |
Kojto | 108:34e6b704fe68 | 577 | * @retval SET (__LASTBIT__ is valid) or RESET (__LASTBIT__ is invalid) |
Kojto | 108:34e6b704fe68 | 578 | */ |
Kojto | 108:34e6b704fe68 | 579 | #define IS_USART_LASTBIT(__LASTBIT__) (((__LASTBIT__) == USART_LASTBIT_DISABLE) || \ |
Kojto | 108:34e6b704fe68 | 580 | ((__LASTBIT__) == USART_LASTBIT_ENABLE)) |
bogdanm | 92:4fc01daae5a5 | 581 | |
bogdanm | 92:4fc01daae5a5 | 582 | /** |
bogdanm | 92:4fc01daae5a5 | 583 | * @} |
bogdanm | 92:4fc01daae5a5 | 584 | */ |
bogdanm | 92:4fc01daae5a5 | 585 | |
Kojto | 108:34e6b704fe68 | 586 | /* Include USART HAL Extension module */ |
Kojto | 108:34e6b704fe68 | 587 | #include "stm32f0xx_hal_usart_ex.h" |
Kojto | 108:34e6b704fe68 | 588 | |
Kojto | 108:34e6b704fe68 | 589 | /* Exported functions --------------------------------------------------------*/ |
Kojto | 108:34e6b704fe68 | 590 | /** @addtogroup USART_Exported_Functions USART Exported Functions |
Kojto | 108:34e6b704fe68 | 591 | * @{ |
Kojto | 108:34e6b704fe68 | 592 | */ |
Kojto | 108:34e6b704fe68 | 593 | |
Kojto | 108:34e6b704fe68 | 594 | /** @addtogroup USART_Exported_Functions_Group1 Initialization and de-initialization functions |
bogdanm | 92:4fc01daae5a5 | 595 | * @{ |
bogdanm | 92:4fc01daae5a5 | 596 | */ |
bogdanm | 92:4fc01daae5a5 | 597 | |
Kojto | 108:34e6b704fe68 | 598 | /* Initialization and de-initialization functions ****************************/ |
Kojto | 108:34e6b704fe68 | 599 | HAL_StatusTypeDef HAL_USART_Init(USART_HandleTypeDef *husart); |
Kojto | 108:34e6b704fe68 | 600 | HAL_StatusTypeDef HAL_USART_DeInit(USART_HandleTypeDef *husart); |
Kojto | 108:34e6b704fe68 | 601 | void HAL_USART_MspInit(USART_HandleTypeDef *husart); |
Kojto | 108:34e6b704fe68 | 602 | void HAL_USART_MspDeInit(USART_HandleTypeDef *husart); |
Kojto | 108:34e6b704fe68 | 603 | |
Kojto | 108:34e6b704fe68 | 604 | /** |
Kojto | 108:34e6b704fe68 | 605 | * @} |
Kojto | 108:34e6b704fe68 | 606 | */ |
Kojto | 108:34e6b704fe68 | 607 | |
Kojto | 108:34e6b704fe68 | 608 | /** @addtogroup USART_Exported_Functions_Group2 IO operation functions |
Kojto | 108:34e6b704fe68 | 609 | * @{ |
Kojto | 108:34e6b704fe68 | 610 | */ |
Kojto | 108:34e6b704fe68 | 611 | |
Kojto | 108:34e6b704fe68 | 612 | /* IO operation functions *****************************************************/ |
bogdanm | 85:024bf7f99721 | 613 | HAL_StatusTypeDef HAL_USART_Transmit(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size, uint32_t Timeout); |
bogdanm | 85:024bf7f99721 | 614 | HAL_StatusTypeDef HAL_USART_Receive(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size, uint32_t Timeout); |
bogdanm | 85:024bf7f99721 | 615 | HAL_StatusTypeDef HAL_USART_TransmitReceive(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout); |
bogdanm | 85:024bf7f99721 | 616 | HAL_StatusTypeDef HAL_USART_Transmit_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size); |
bogdanm | 85:024bf7f99721 | 617 | HAL_StatusTypeDef HAL_USART_Receive_IT(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size); |
bogdanm | 85:024bf7f99721 | 618 | HAL_StatusTypeDef HAL_USART_TransmitReceive_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size); |
bogdanm | 85:024bf7f99721 | 619 | HAL_StatusTypeDef HAL_USART_Transmit_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size); |
bogdanm | 85:024bf7f99721 | 620 | HAL_StatusTypeDef HAL_USART_Receive_DMA(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size); |
bogdanm | 85:024bf7f99721 | 621 | HAL_StatusTypeDef HAL_USART_TransmitReceive_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size); |
bogdanm | 85:024bf7f99721 | 622 | HAL_StatusTypeDef HAL_USART_DMAPause(USART_HandleTypeDef *husart); |
bogdanm | 85:024bf7f99721 | 623 | HAL_StatusTypeDef HAL_USART_DMAResume(USART_HandleTypeDef *husart); |
bogdanm | 85:024bf7f99721 | 624 | HAL_StatusTypeDef HAL_USART_DMAStop(USART_HandleTypeDef *husart); |
bogdanm | 85:024bf7f99721 | 625 | void HAL_USART_IRQHandler(USART_HandleTypeDef *husart); |
bogdanm | 85:024bf7f99721 | 626 | void HAL_USART_TxCpltCallback(USART_HandleTypeDef *husart); |
bogdanm | 85:024bf7f99721 | 627 | void HAL_USART_RxCpltCallback(USART_HandleTypeDef *husart); |
bogdanm | 85:024bf7f99721 | 628 | void HAL_USART_TxHalfCpltCallback(USART_HandleTypeDef *husart); |
bogdanm | 85:024bf7f99721 | 629 | void HAL_USART_RxHalfCpltCallback(USART_HandleTypeDef *husart); |
bogdanm | 85:024bf7f99721 | 630 | void HAL_USART_TxRxCpltCallback(USART_HandleTypeDef *husart); |
bogdanm | 85:024bf7f99721 | 631 | void HAL_USART_ErrorCallback(USART_HandleTypeDef *husart); |
bogdanm | 85:024bf7f99721 | 632 | |
bogdanm | 92:4fc01daae5a5 | 633 | /** |
bogdanm | 92:4fc01daae5a5 | 634 | * @} |
bogdanm | 92:4fc01daae5a5 | 635 | */ |
bogdanm | 92:4fc01daae5a5 | 636 | |
bogdanm | 85:024bf7f99721 | 637 | /* Peripheral Control functions ***********************************************/ |
bogdanm | 85:024bf7f99721 | 638 | |
Kojto | 122:f9eeca106725 | 639 | /** @addtogroup USART_Exported_Functions_Group3 Peripheral State and Error functions |
bogdanm | 92:4fc01daae5a5 | 640 | * @{ |
bogdanm | 92:4fc01daae5a5 | 641 | */ |
bogdanm | 92:4fc01daae5a5 | 642 | |
bogdanm | 85:024bf7f99721 | 643 | /* Peripheral State and Error functions ***************************************/ |
bogdanm | 85:024bf7f99721 | 644 | HAL_USART_StateTypeDef HAL_USART_GetState(USART_HandleTypeDef *husart); |
Kojto | 108:34e6b704fe68 | 645 | uint32_t HAL_USART_GetError(USART_HandleTypeDef *husart); |
bogdanm | 85:024bf7f99721 | 646 | |
bogdanm | 85:024bf7f99721 | 647 | /** |
bogdanm | 85:024bf7f99721 | 648 | * @} |
bogdanm | 85:024bf7f99721 | 649 | */ |
Kojto | 108:34e6b704fe68 | 650 | |
bogdanm | 92:4fc01daae5a5 | 651 | /** |
bogdanm | 92:4fc01daae5a5 | 652 | * @} |
Kojto | 108:34e6b704fe68 | 653 | */ |
Kojto | 108:34e6b704fe68 | 654 | |
Kojto | 108:34e6b704fe68 | 655 | /** |
Kojto | 108:34e6b704fe68 | 656 | * @} |
Kojto | 108:34e6b704fe68 | 657 | */ |
bogdanm | 92:4fc01daae5a5 | 658 | |
bogdanm | 92:4fc01daae5a5 | 659 | /** |
bogdanm | 92:4fc01daae5a5 | 660 | * @} |
bogdanm | 92:4fc01daae5a5 | 661 | */ |
bogdanm | 92:4fc01daae5a5 | 662 | |
bogdanm | 85:024bf7f99721 | 663 | #ifdef __cplusplus |
bogdanm | 85:024bf7f99721 | 664 | } |
bogdanm | 85:024bf7f99721 | 665 | #endif |
bogdanm | 85:024bf7f99721 | 666 | |
bogdanm | 85:024bf7f99721 | 667 | #endif /* __STM32F0xx_HAL_USART_H */ |
bogdanm | 85:024bf7f99721 | 668 | |
bogdanm | 85:024bf7f99721 | 669 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
bogdanm | 92:4fc01daae5a5 | 670 |