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