Fork of the official mbed C/C SDK provides the software platform and libraries to build your applications for RenBED.

Dependents:   1-RenBuggyTimed RenBED_RGB RenBED_RGB_PWM RenBED_RGB

Fork of mbed by mbed official

Committer:
elijahorr
Date:
Thu Apr 14 07:28:54 2016 +0000
Revision:
121:672067c3ada4
Parent:
99:dbbf35b96557
.

Who changed what in which revision?

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