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