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