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:
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?

UserRevisionLine numberNew contents of line
Kojto 93:e188a91d3eaa 1 /**
Kojto 93:e188a91d3eaa 2 ******************************************************************************
Kojto 93:e188a91d3eaa 3 * @file stm32f0xx_hal_usart.h
Kojto 93:e188a91d3eaa 4 * @author MCD Application Team
Kojto 108:34e6b704fe68 5 * @version V1.3.0
Kojto 108:34e6b704fe68 6 * @date 26-June-2015
Kojto 93:e188a91d3eaa 7 * @brief Header file of USART HAL module.
Kojto 93:e188a91d3eaa 8 ******************************************************************************
Kojto 93:e188a91d3eaa 9 * @attention
Kojto 93:e188a91d3eaa 10 *
Kojto 108:34e6b704fe68 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
Kojto 93:e188a91d3eaa 12 *
Kojto 93:e188a91d3eaa 13 * Redistribution and use in source and binary forms, with or without modification,
Kojto 93:e188a91d3eaa 14 * are permitted provided that the following conditions are met:
Kojto 93:e188a91d3eaa 15 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 93:e188a91d3eaa 16 * this list of conditions and the following disclaimer.
Kojto 93:e188a91d3eaa 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 93:e188a91d3eaa 18 * this list of conditions and the following disclaimer in the documentation
Kojto 93:e188a91d3eaa 19 * and/or other materials provided with the distribution.
Kojto 93:e188a91d3eaa 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 93:e188a91d3eaa 21 * may be used to endorse or promote products derived from this software
Kojto 93:e188a91d3eaa 22 * without specific prior written permission.
Kojto 93:e188a91d3eaa 23 *
Kojto 93:e188a91d3eaa 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 93:e188a91d3eaa 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 93:e188a91d3eaa 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 93:e188a91d3eaa 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 93:e188a91d3eaa 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 93:e188a91d3eaa 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 93:e188a91d3eaa 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 93:e188a91d3eaa 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 93:e188a91d3eaa 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 93:e188a91d3eaa 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 93:e188a91d3eaa 34 *
Kojto 108:34e6b704fe68 35 ******************************************************************************
Kojto 93:e188a91d3eaa 36 */
Kojto 93:e188a91d3eaa 37
Kojto 93:e188a91d3eaa 38 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 93:e188a91d3eaa 39 #ifndef __STM32F0xx_HAL_USART_H
Kojto 93:e188a91d3eaa 40 #define __STM32F0xx_HAL_USART_H
Kojto 93:e188a91d3eaa 41
Kojto 93:e188a91d3eaa 42 #ifdef __cplusplus
Kojto 93:e188a91d3eaa 43 extern "C" {
Kojto 93:e188a91d3eaa 44 #endif
Kojto 93:e188a91d3eaa 45
Kojto 93:e188a91d3eaa 46 /* Includes ------------------------------------------------------------------*/
Kojto 93:e188a91d3eaa 47 #include "stm32f0xx_hal_def.h"
Kojto 93:e188a91d3eaa 48
Kojto 93:e188a91d3eaa 49 /** @addtogroup STM32F0xx_HAL_Driver
Kojto 93:e188a91d3eaa 50 * @{
Kojto 93:e188a91d3eaa 51 */
Kojto 93:e188a91d3eaa 52
Kojto 93:e188a91d3eaa 53 /** @addtogroup USART
Kojto 93:e188a91d3eaa 54 * @{
Kojto 108:34e6b704fe68 55 */
Kojto 93:e188a91d3eaa 56
Kojto 93:e188a91d3eaa 57 /* Exported types ------------------------------------------------------------*/
Kojto 93:e188a91d3eaa 58 /** @defgroup USART_Exported_Types USART Exported Types
Kojto 93:e188a91d3eaa 59 * @{
Kojto 108:34e6b704fe68 60 */
Kojto 93:e188a91d3eaa 61
Kojto 108:34e6b704fe68 62 /**
Kojto 108:34e6b704fe68 63 * @brief USART Init Structure definition
Kojto 108:34e6b704fe68 64 */
Kojto 93:e188a91d3eaa 65 typedef struct
Kojto 93:e188a91d3eaa 66 {
Kojto 93:e188a91d3eaa 67 uint32_t BaudRate; /*!< This member configures the Usart communication baud rate.
Kojto 93:e188a91d3eaa 68 The baud rate is computed using the following formula:
Kojto 108:34e6b704fe68 69 Baud Rate Register = ((PCLKx) / ((huart->Init.BaudRate))). */
Kojto 93:e188a91d3eaa 70
Kojto 93:e188a91d3eaa 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 93:e188a91d3eaa 73
Kojto 93:e188a91d3eaa 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 93:e188a91d3eaa 76
Kojto 93:e188a91d3eaa 77 uint32_t Parity; /*!< Specifies the parity mode.
Kojto 93:e188a91d3eaa 78 This parameter can be a value of @ref USART_Parity
Kojto 93:e188a91d3eaa 79 @note When parity is enabled, the computed parity is inserted
Kojto 93:e188a91d3eaa 80 at the MSB position of the transmitted data (9th bit when
Kojto 93:e188a91d3eaa 81 the word length is set to 9 data bits; 8th bit when the
Kojto 93:e188a91d3eaa 82 word length is set to 8 data bits). */
Kojto 108:34e6b704fe68 83
Kojto 93:e188a91d3eaa 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 93:e188a91d3eaa 86
Kojto 93:e188a91d3eaa 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 93:e188a91d3eaa 89
Kojto 93:e188a91d3eaa 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 93:e188a91d3eaa 92
Kojto 93:e188a91d3eaa 93 uint32_t CLKLastBit; /*!< Specifies whether the clock pulse corresponding to the last transmitted
Kojto 93:e188a91d3eaa 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 93:e188a91d3eaa 96 }USART_InitTypeDef;
Kojto 93:e188a91d3eaa 97
Kojto 108:34e6b704fe68 98 /**
Kojto 108:34e6b704fe68 99 * @brief HAL USART State structures definition
Kojto 108:34e6b704fe68 100 */
Kojto 93:e188a91d3eaa 101 typedef enum
Kojto 93:e188a91d3eaa 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 93:e188a91d3eaa 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 93:e188a91d3eaa 111 }HAL_USART_StateTypeDef;
Kojto 93:e188a91d3eaa 112
Kojto 108:34e6b704fe68 113 /**
Kojto 93:e188a91d3eaa 114 * @brief USART clock sources definitions
Kojto 93:e188a91d3eaa 115 */
Kojto 93:e188a91d3eaa 116 typedef enum
Kojto 93:e188a91d3eaa 117 {
Kojto 93:e188a91d3eaa 118 USART_CLOCKSOURCE_PCLK1 = 0x00, /*!< PCLK1 clock source */
Kojto 93:e188a91d3eaa 119 USART_CLOCKSOURCE_HSI = 0x02, /*!< HSI clock source */
Kojto 93:e188a91d3eaa 120 USART_CLOCKSOURCE_SYSCLK = 0x04, /*!< SYSCLK clock source */
Kojto 93:e188a91d3eaa 121 USART_CLOCKSOURCE_LSE = 0x08, /*!< LSE clock source */
Kojto 108:34e6b704fe68 122 USART_CLOCKSOURCE_UNDEFINED = 0x10 /*!< undefined clock source */
Kojto 93:e188a91d3eaa 123 }USART_ClockSourceTypeDef;
Kojto 93:e188a91d3eaa 124
Kojto 108:34e6b704fe68 125
Kojto 108:34e6b704fe68 126 /**
Kojto 108:34e6b704fe68 127 * @brief USART handle Structure definition
Kojto 108:34e6b704fe68 128 */
Kojto 93:e188a91d3eaa 129 typedef struct
Kojto 93:e188a91d3eaa 130 {
Kojto 93:e188a91d3eaa 131 USART_TypeDef *Instance; /*!< USART registers base address */
Kojto 108:34e6b704fe68 132
Kojto 93:e188a91d3eaa 133 USART_InitTypeDef Init; /*!< USART communication parameters */
Kojto 108:34e6b704fe68 134
Kojto 93:e188a91d3eaa 135 uint8_t *pTxBuffPtr; /*!< Pointer to USART Tx transfer Buffer */
Kojto 108:34e6b704fe68 136
Kojto 93:e188a91d3eaa 137 uint16_t TxXferSize; /*!< USART Tx Transfer size */
Kojto 108:34e6b704fe68 138
Kojto 93:e188a91d3eaa 139 uint16_t TxXferCount; /*!< USART Tx Transfer Counter */
Kojto 108:34e6b704fe68 140
Kojto 93:e188a91d3eaa 141 uint8_t *pRxBuffPtr; /*!< Pointer to USART Rx transfer Buffer */
Kojto 108:34e6b704fe68 142
Kojto 93:e188a91d3eaa 143 uint16_t RxXferSize; /*!< USART Rx Transfer size */
Kojto 108:34e6b704fe68 144
Kojto 93:e188a91d3eaa 145 uint16_t RxXferCount; /*!< USART Rx Transfer Counter */
Kojto 108:34e6b704fe68 146
Kojto 93:e188a91d3eaa 147 uint16_t Mask; /*!< USART Rx RDR register mask */
Kojto 108:34e6b704fe68 148
Kojto 93:e188a91d3eaa 149 DMA_HandleTypeDef *hdmatx; /*!< USART Tx DMA Handle parameters */
Kojto 108:34e6b704fe68 150
Kojto 93:e188a91d3eaa 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 93:e188a91d3eaa 159 }USART_HandleTypeDef;
Kojto 93:e188a91d3eaa 160
Kojto 93:e188a91d3eaa 161 /**
Kojto 93:e188a91d3eaa 162 * @}
Kojto 93:e188a91d3eaa 163 */
Kojto 93:e188a91d3eaa 164
Kojto 93:e188a91d3eaa 165 /* Exported constants --------------------------------------------------------*/
Kojto 108:34e6b704fe68 166 /** @defgroup USART_Exported_Constants USART Exported Constants
Kojto 93:e188a91d3eaa 167 * @{
Kojto 93:e188a91d3eaa 168 */
Kojto 93:e188a91d3eaa 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 93:e188a91d3eaa 183 /** @defgroup USART_Stop_Bits USART Number of Stop Bits
Kojto 93:e188a91d3eaa 184 * @{
Kojto 93:e188a91d3eaa 185 */
Kojto 93:e188a91d3eaa 186 #define USART_STOPBITS_1 ((uint32_t)0x0000)
Kojto 93:e188a91d3eaa 187 #define USART_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1)
Kojto 93:e188a91d3eaa 188 #define USART_STOPBITS_1_5 ((uint32_t)(USART_CR2_STOP_0 | USART_CR2_STOP_1))
Kojto 93:e188a91d3eaa 189 /**
Kojto 93:e188a91d3eaa 190 * @}
Kojto 93:e188a91d3eaa 191 */
Kojto 93:e188a91d3eaa 192
Kojto 93:e188a91d3eaa 193 /** @defgroup USART_Parity USART Parity
Kojto 93:e188a91d3eaa 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 93:e188a91d3eaa 199 /**
Kojto 93:e188a91d3eaa 200 * @}
Kojto 108:34e6b704fe68 201 */
Kojto 93:e188a91d3eaa 202
Kojto 93:e188a91d3eaa 203 /** @defgroup USART_Mode USART Mode
Kojto 93:e188a91d3eaa 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 93:e188a91d3eaa 209 /**
Kojto 93:e188a91d3eaa 210 * @}
Kojto 93:e188a91d3eaa 211 */
Kojto 108:34e6b704fe68 212
Kojto 93:e188a91d3eaa 213 /** @defgroup USART_Clock USART Clock
Kojto 93:e188a91d3eaa 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 93:e188a91d3eaa 218 /**
Kojto 93:e188a91d3eaa 219 * @}
Kojto 108:34e6b704fe68 220 */
Kojto 93:e188a91d3eaa 221
Kojto 93:e188a91d3eaa 222 /** @defgroup USART_Clock_Polarity USART Clock Polarity
Kojto 93:e188a91d3eaa 223 * @{
Kojto 93:e188a91d3eaa 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 93:e188a91d3eaa 227 /**
Kojto 93:e188a91d3eaa 228 * @}
Kojto 108:34e6b704fe68 229 */
Kojto 93:e188a91d3eaa 230
Kojto 93:e188a91d3eaa 231 /** @defgroup USART_Clock_Phase USART Clock Phase
Kojto 93:e188a91d3eaa 232 * @{
Kojto 93:e188a91d3eaa 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 93:e188a91d3eaa 236 /**
Kojto 93:e188a91d3eaa 237 * @}
Kojto 93:e188a91d3eaa 238 */
Kojto 93:e188a91d3eaa 239
Kojto 93:e188a91d3eaa 240 /** @defgroup USART_Last_Bit USART Last Bit
Kojto 93:e188a91d3eaa 241 * @{
Kojto 93:e188a91d3eaa 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 93:e188a91d3eaa 245 /**
Kojto 93:e188a91d3eaa 246 * @}
Kojto 93:e188a91d3eaa 247 */
Kojto 93:e188a91d3eaa 248
Kojto 93:e188a91d3eaa 249 /** @defgroup USART_Interrupt_definition USART Interrupts Definition
Kojto 93:e188a91d3eaa 250 * Elements values convention: 0000ZZZZ0XXYYYYYb
Kojto 93:e188a91d3eaa 251 * - YYYYY : Interrupt source position in the XX register (5bits)
Kojto 93:e188a91d3eaa 252 * - XX : Interrupt source register (2bits)
Kojto 93:e188a91d3eaa 253 * - 01: CR1 register
Kojto 93:e188a91d3eaa 254 * - 10: CR2 register
Kojto 93:e188a91d3eaa 255 * - 11: CR3 register
Kojto 93:e188a91d3eaa 256 * - ZZZZ : Flag position in the ISR register(4bits)
Kojto 93:e188a91d3eaa 257 * @{
Kojto 93:e188a91d3eaa 258 */
Kojto 93:e188a91d3eaa 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 93:e188a91d3eaa 269 /**
Kojto 93:e188a91d3eaa 270 * @}
Kojto 93:e188a91d3eaa 271 */
Kojto 93:e188a91d3eaa 272
Kojto 93:e188a91d3eaa 273 /** @defgroup USART_IT_CLEAR_Flags USART Interruption Clear Flags
Kojto 93:e188a91d3eaa 274 * @{
Kojto 93:e188a91d3eaa 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 93:e188a91d3eaa 283 /**
Kojto 93:e188a91d3eaa 284 * @}
Kojto 93:e188a91d3eaa 285 */
Kojto 93:e188a91d3eaa 286
Kojto 108:34e6b704fe68 287 /** @defgroup USART_Interruption_Mask USART Interruption Flags Mask
Kojto 93:e188a91d3eaa 288 * @{
Kojto 108:34e6b704fe68 289 */
Kojto 108:34e6b704fe68 290 #define USART_IT_MASK ((uint16_t)0x001F) /*!< USART interruptions flags mask */
Kojto 93:e188a91d3eaa 291 /**
Kojto 93:e188a91d3eaa 292 * @}
Kojto 93:e188a91d3eaa 293 */
Kojto 93:e188a91d3eaa 294
Kojto 93:e188a91d3eaa 295 /**
Kojto 93:e188a91d3eaa 296 * @}
Kojto 93:e188a91d3eaa 297 */
Kojto 108:34e6b704fe68 298
Kojto 108:34e6b704fe68 299 /* Exported macros -----------------------------------------------------------*/
Kojto 93:e188a91d3eaa 300 /** @defgroup USART_Exported_Macros USART Exported Macros
Kojto 93:e188a91d3eaa 301 * @{
Kojto 108:34e6b704fe68 302 */
Kojto 93:e188a91d3eaa 303
Kojto 108:34e6b704fe68 304 /** @brief Reset USART handle state.
Kojto 93:e188a91d3eaa 305 * @param __HANDLE__: USART handle.
Kojto 93:e188a91d3eaa 306 * @retval None
Kojto 93:e188a91d3eaa 307 */
Kojto 108:34e6b704fe68 308 #define __HAL_USART_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_USART_STATE_RESET)
Kojto 93:e188a91d3eaa 309
Kojto 108:34e6b704fe68 310 /** @brief Check whether the specified USART flag is set or not.
Kojto 93:e188a91d3eaa 311 * @param __HANDLE__: specifies the USART Handle
Kojto 93:e188a91d3eaa 312 * @param __FLAG__: specifies the flag to check.
Kojto 93:e188a91d3eaa 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 93:e188a91d3eaa 318 * @arg USART_FLAG_TXE: Transmit data register empty flag
Kojto 93:e188a91d3eaa 319 * @arg USART_FLAG_TC: Transmission Complete flag
Kojto 93:e188a91d3eaa 320 * @arg USART_FLAG_RXNE: Receive data register not empty flag
Kojto 93:e188a91d3eaa 321 * @arg USART_FLAG_IDLE: Idle Line detection flag
Kojto 93:e188a91d3eaa 322 * @arg USART_FLAG_ORE: OverRun Error flag
Kojto 93:e188a91d3eaa 323 * @arg USART_FLAG_NE: Noise Error flag
Kojto 93:e188a91d3eaa 324 * @arg USART_FLAG_FE: Framing Error flag
Kojto 93:e188a91d3eaa 325 * @arg USART_FLAG_PE: Parity Error flag
Kojto 93:e188a91d3eaa 326 * @retval The new state of __FLAG__ (TRUE or FALSE).
Kojto 93:e188a91d3eaa 327 */
Kojto 93:e188a91d3eaa 328 #define __HAL_USART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))
Kojto 93:e188a91d3eaa 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 93:e188a91d3eaa 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 93:e188a91d3eaa 381 * @param __INTERRUPT__: specifies the USART interrupt source to enable.
Kojto 93:e188a91d3eaa 382 * This parameter can be one of the following values:
Kojto 93:e188a91d3eaa 383 * @arg USART_IT_TXE: Transmit Data Register empty interrupt
Kojto 93:e188a91d3eaa 384 * @arg USART_IT_TC: Transmission complete interrupt
Kojto 93:e188a91d3eaa 385 * @arg USART_IT_RXNE: Receive Data register not empty interrupt
Kojto 93:e188a91d3eaa 386 * @arg USART_IT_IDLE: Idle line detection interrupt
Kojto 93:e188a91d3eaa 387 * @arg USART_IT_PE: Parity Error interrupt
Kojto 93:e188a91d3eaa 388 * @arg USART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
Kojto 93:e188a91d3eaa 389 * @retval None
Kojto 93:e188a91d3eaa 390 */
Kojto 93:e188a91d3eaa 391 #define __HAL_USART_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 |= (1U << ((__INTERRUPT__) & USART_IT_MASK))): \
Kojto 93:e188a91d3eaa 392 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 |= (1U << ((__INTERRUPT__) & USART_IT_MASK))): \
Kojto 93:e188a91d3eaa 393 ((__HANDLE__)->Instance->CR3 |= (1U << ((__INTERRUPT__) & USART_IT_MASK))))
Kojto 93:e188a91d3eaa 394
Kojto 108:34e6b704fe68 395 /** @brief Disable the specified USART interrupt.
Kojto 93:e188a91d3eaa 396 * @param __HANDLE__: specifies the USART Handle.
Kojto 93:e188a91d3eaa 397 * @param __INTERRUPT__: specifies the USART interrupt source to disable.
Kojto 93:e188a91d3eaa 398 * This parameter can be one of the following values:
Kojto 93:e188a91d3eaa 399 * @arg USART_IT_TXE: Transmit Data Register empty interrupt
Kojto 93:e188a91d3eaa 400 * @arg USART_IT_TC: Transmission complete interrupt
Kojto 93:e188a91d3eaa 401 * @arg USART_IT_RXNE: Receive Data register not empty interrupt
Kojto 93:e188a91d3eaa 402 * @arg USART_IT_IDLE: Idle line detection interrupt
Kojto 93:e188a91d3eaa 403 * @arg USART_IT_PE: Parity Error interrupt
Kojto 93:e188a91d3eaa 404 * @arg USART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
Kojto 93:e188a91d3eaa 405 * @retval None
Kojto 93:e188a91d3eaa 406 */
Kojto 93:e188a91d3eaa 407 #define __HAL_USART_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK))): \
Kojto 93:e188a91d3eaa 408 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK))): \
Kojto 93:e188a91d3eaa 409 ((__HANDLE__)->Instance->CR3 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK))))
Kojto 93:e188a91d3eaa 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 93:e188a91d3eaa 414 * @param __IT__: specifies the USART interrupt source to check.
Kojto 93:e188a91d3eaa 415 * This parameter can be one of the following values:
Kojto 93:e188a91d3eaa 416 * @arg USART_IT_TXE: Transmit Data Register empty interrupt
Kojto 93:e188a91d3eaa 417 * @arg USART_IT_TC: Transmission complete interrupt
Kojto 93:e188a91d3eaa 418 * @arg USART_IT_RXNE: Receive Data register not empty interrupt
Kojto 93:e188a91d3eaa 419 * @arg USART_IT_IDLE: Idle line detection interrupt
Kojto 93:e188a91d3eaa 420 * @arg USART_IT_ORE: OverRun Error interrupt
Kojto 93:e188a91d3eaa 421 * @arg USART_IT_NE: Noise Error interrupt
Kojto 93:e188a91d3eaa 422 * @arg USART_IT_FE: Framing Error interrupt
Kojto 93:e188a91d3eaa 423 * @arg USART_IT_PE: Parity Error interrupt
Kojto 93:e188a91d3eaa 424 * @retval The new state of __IT__ (TRUE or FALSE).
Kojto 93:e188a91d3eaa 425 */
Kojto 108:34e6b704fe68 426 #define __HAL_USART_GET_IT(__HANDLE__, __IT__) ((__HANDLE__)->Instance->ISR & ((uint32_t)1 << ((__IT__)>> 0x08)))
Kojto 93:e188a91d3eaa 427
Kojto 108:34e6b704fe68 428 /** @brief Check whether the specified USART interrupt source is enabled or not.
Kojto 93:e188a91d3eaa 429 * @param __HANDLE__: specifies the USART Handle.
Kojto 93:e188a91d3eaa 430 * @param __IT__: specifies the USART interrupt source to check.
Kojto 93:e188a91d3eaa 431 * This parameter can be one of the following values:
Kojto 93:e188a91d3eaa 432 * @arg USART_IT_TXE: Transmit Data Register empty interrupt
Kojto 93:e188a91d3eaa 433 * @arg USART_IT_TC: Transmission complete interrupt
Kojto 93:e188a91d3eaa 434 * @arg USART_IT_RXNE: Receive Data register not empty interrupt
Kojto 93:e188a91d3eaa 435 * @arg USART_IT_IDLE: Idle line detection interrupt
Kojto 93:e188a91d3eaa 436 * @arg USART_IT_ORE: OverRun Error interrupt
Kojto 93:e188a91d3eaa 437 * @arg USART_IT_NE: Noise Error interrupt
Kojto 93:e188a91d3eaa 438 * @arg USART_IT_FE: Framing Error interrupt
Kojto 93:e188a91d3eaa 439 * @arg USART_IT_PE: Parity Error interrupt
Kojto 93:e188a91d3eaa 440 * @retval The new state of __IT__ (TRUE or FALSE).
Kojto 93:e188a91d3eaa 441 */
Kojto 93:e188a91d3eaa 442 #define __HAL_USART_GET_IT_SOURCE(__HANDLE__, __IT__) ((((((uint8_t)(__IT__)) >> 5) == 1)? (__HANDLE__)->Instance->CR1:(((((uint8_t)(__IT__)) >> 5) == 2)? \
Kojto 93:e188a91d3eaa 443 (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & ((uint32_t)1 << \
Kojto 93:e188a91d3eaa 444 (((uint16_t)(__IT__)) & USART_IT_MASK)))
Kojto 93:e188a91d3eaa 445
Kojto 93:e188a91d3eaa 446
Kojto 108:34e6b704fe68 447 /** @brief Clear the specified USART ISR flag, in setting the proper ICR register flag.
Kojto 93:e188a91d3eaa 448 * @param __HANDLE__: specifies the USART Handle.
Kojto 93:e188a91d3eaa 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 93:e188a91d3eaa 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 93:e188a91d3eaa 459 * @retval None
Kojto 93:e188a91d3eaa 460 */
Kojto 108:34e6b704fe68 461 #define __HAL_USART_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__))
Kojto 93:e188a91d3eaa 462
Kojto 93:e188a91d3eaa 463 /** @brief Set a specific USART request flag.
Kojto 93:e188a91d3eaa 464 * @param __HANDLE__: specifies the USART Handle.
Kojto 108:34e6b704fe68 465 * @param __REQ__: specifies the request flag to set.
Kojto 93:e188a91d3eaa 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 93:e188a91d3eaa 469 *
Kojto 93:e188a91d3eaa 470 * @retval None
Kojto 108:34e6b704fe68 471 */
Kojto 108:34e6b704fe68 472 #define __HAL_USART_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (__REQ__))
Kojto 93:e188a91d3eaa 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 93:e188a91d3eaa 487 * @param __HANDLE__: specifies the USART Handle.
Kojto 93:e188a91d3eaa 488 * @retval None
Kojto 108:34e6b704fe68 489 */
Kojto 108:34e6b704fe68 490 #define __HAL_USART_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
Kojto 93:e188a91d3eaa 491
Kojto 108:34e6b704fe68 492 /** @brief Disable USART.
Kojto 93:e188a91d3eaa 493 * @param __HANDLE__: specifies the USART Handle.
Kojto 93:e188a91d3eaa 494 * @retval None
Kojto 108:34e6b704fe68 495 */
Kojto 108:34e6b704fe68 496 #define __HAL_USART_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
Kojto 93:e188a91d3eaa 497
Kojto 93:e188a91d3eaa 498 /**
Kojto 93:e188a91d3eaa 499 * @}
Kojto 108:34e6b704fe68 500 */
Kojto 93:e188a91d3eaa 501
Kojto 93:e188a91d3eaa 502 /* Private macros --------------------------------------------------------*/
Kojto 93:e188a91d3eaa 503 /** @defgroup USART_Private_Macros USART Private Macros
Kojto 93:e188a91d3eaa 504 * @{
Kojto 93:e188a91d3eaa 505 */
Kojto 93:e188a91d3eaa 506
Kojto 93:e188a91d3eaa 507 /** @brief Check USART Baud rate
Kojto 108:34e6b704fe68 508 * @param __BAUDRATE__: Baudrate specified by the user.
Kojto 93:e188a91d3eaa 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 93:e188a91d3eaa 512 */
Kojto 108:34e6b704fe68 513 #define IS_USART_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 9000001)
Kojto 108:34e6b704fe68 514
Kojto 93:e188a91d3eaa 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 93:e188a91d3eaa 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 93:e188a91d3eaa 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 93:e188a91d3eaa 559 */
Kojto 108:34e6b704fe68 560 #define IS_USART_PHASE(__CPHA__) (((__CPHA__) == USART_PHASE_1EDGE) || ((__CPHA__) == USART_PHASE_2EDGE))
Kojto 93:e188a91d3eaa 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 93:e188a91d3eaa 569
Kojto 93:e188a91d3eaa 570 /**
Kojto 93:e188a91d3eaa 571 * @}
Kojto 93:e188a91d3eaa 572 */
Kojto 93:e188a91d3eaa 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 93:e188a91d3eaa 583 * @{
Kojto 93:e188a91d3eaa 584 */
Kojto 93:e188a91d3eaa 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 93:e188a91d3eaa 601 HAL_StatusTypeDef HAL_USART_Transmit(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size, uint32_t Timeout);
Kojto 93:e188a91d3eaa 602 HAL_StatusTypeDef HAL_USART_Receive(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size, uint32_t Timeout);
Kojto 93:e188a91d3eaa 603 HAL_StatusTypeDef HAL_USART_TransmitReceive(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout);
Kojto 93:e188a91d3eaa 604 HAL_StatusTypeDef HAL_USART_Transmit_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size);
Kojto 93:e188a91d3eaa 605 HAL_StatusTypeDef HAL_USART_Receive_IT(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size);
Kojto 93:e188a91d3eaa 606 HAL_StatusTypeDef HAL_USART_TransmitReceive_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size);
Kojto 93:e188a91d3eaa 607 HAL_StatusTypeDef HAL_USART_Transmit_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size);
Kojto 93:e188a91d3eaa 608 HAL_StatusTypeDef HAL_USART_Receive_DMA(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size);
Kojto 93:e188a91d3eaa 609 HAL_StatusTypeDef HAL_USART_TransmitReceive_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size);
Kojto 93:e188a91d3eaa 610 HAL_StatusTypeDef HAL_USART_DMAPause(USART_HandleTypeDef *husart);
Kojto 93:e188a91d3eaa 611 HAL_StatusTypeDef HAL_USART_DMAResume(USART_HandleTypeDef *husart);
Kojto 93:e188a91d3eaa 612 HAL_StatusTypeDef HAL_USART_DMAStop(USART_HandleTypeDef *husart);
Kojto 93:e188a91d3eaa 613 void HAL_USART_IRQHandler(USART_HandleTypeDef *husart);
Kojto 93:e188a91d3eaa 614 void HAL_USART_TxCpltCallback(USART_HandleTypeDef *husart);
Kojto 93:e188a91d3eaa 615 void HAL_USART_RxCpltCallback(USART_HandleTypeDef *husart);
Kojto 93:e188a91d3eaa 616 void HAL_USART_TxHalfCpltCallback(USART_HandleTypeDef *husart);
Kojto 93:e188a91d3eaa 617 void HAL_USART_RxHalfCpltCallback(USART_HandleTypeDef *husart);
Kojto 93:e188a91d3eaa 618 void HAL_USART_TxRxCpltCallback(USART_HandleTypeDef *husart);
Kojto 93:e188a91d3eaa 619 void HAL_USART_ErrorCallback(USART_HandleTypeDef *husart);
Kojto 93:e188a91d3eaa 620
Kojto 93:e188a91d3eaa 621 /**
Kojto 93:e188a91d3eaa 622 * @}
Kojto 93:e188a91d3eaa 623 */
Kojto 93:e188a91d3eaa 624
Kojto 93:e188a91d3eaa 625 /* Peripheral Control functions ***********************************************/
Kojto 93:e188a91d3eaa 626
Kojto 108:34e6b704fe68 627 /** @addtogroup USART_Exported_Functions_Group3 Peripheral State and Error functions
Kojto 93:e188a91d3eaa 628 * @{
Kojto 93:e188a91d3eaa 629 */
Kojto 93:e188a91d3eaa 630
Kojto 93:e188a91d3eaa 631 /* Peripheral State and Error functions ***************************************/
Kojto 93:e188a91d3eaa 632 HAL_USART_StateTypeDef HAL_USART_GetState(USART_HandleTypeDef *husart);
Kojto 108:34e6b704fe68 633 uint32_t HAL_USART_GetError(USART_HandleTypeDef *husart);
Kojto 93:e188a91d3eaa 634
Kojto 93:e188a91d3eaa 635 /**
Kojto 93:e188a91d3eaa 636 * @}
Kojto 93:e188a91d3eaa 637 */
Kojto 108:34e6b704fe68 638
Kojto 93:e188a91d3eaa 639 /**
Kojto 93:e188a91d3eaa 640 * @}
Kojto 108:34e6b704fe68 641 */
Kojto 108:34e6b704fe68 642
Kojto 108:34e6b704fe68 643 /**
Kojto 108:34e6b704fe68 644 * @}
Kojto 108:34e6b704fe68 645 */
Kojto 93:e188a91d3eaa 646
Kojto 93:e188a91d3eaa 647 /**
Kojto 93:e188a91d3eaa 648 * @}
Kojto 93:e188a91d3eaa 649 */
Kojto 93:e188a91d3eaa 650
Kojto 93:e188a91d3eaa 651 #ifdef __cplusplus
Kojto 93:e188a91d3eaa 652 }
Kojto 93:e188a91d3eaa 653 #endif
Kojto 93:e188a91d3eaa 654
Kojto 93:e188a91d3eaa 655 #endif /* __STM32F0xx_HAL_USART_H */
Kojto 93:e188a91d3eaa 656
Kojto 93:e188a91d3eaa 657 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Kojto 93:e188a91d3eaa 658