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