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

Dependents:   1-RenBuggyTimed RenBED_RGB RenBED_RGB_PWM RenBED_RGB

Fork of mbed by mbed official

Committer:
Kojto
Date:
Wed Sep 02 14:17:43 2015 +0100
Revision:
106:ba1f97679dad
Parent:
101:7cff1c4259d7
Child:
110:165afa46840b
Release 106  of the mbed library

Changes:
- new platform - Nucleo F446RE
- STM32F4 Cube driver update v2.3.2
- ST cmsis driver v2.3.2
- nordic bugfix gcc linker start address
- lpc11u68 - bugfix for serial ports

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 101:7cff1c4259d7 1 /**
Kojto 101:7cff1c4259d7 2 ******************************************************************************
Kojto 101:7cff1c4259d7 3 * @file stm32f4xx_hal_uart.h
Kojto 101:7cff1c4259d7 4 * @author MCD Application Team
Kojto 106:ba1f97679dad 5 * @version V1.3.2
Kojto 106:ba1f97679dad 6 * @date 26-June-2015
Kojto 101:7cff1c4259d7 7 * @brief Header file of UART HAL module.
Kojto 101:7cff1c4259d7 8 ******************************************************************************
Kojto 101:7cff1c4259d7 9 * @attention
Kojto 101:7cff1c4259d7 10 *
Kojto 101:7cff1c4259d7 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
Kojto 101:7cff1c4259d7 12 *
Kojto 101:7cff1c4259d7 13 * Redistribution and use in source and binary forms, with or without modification,
Kojto 101:7cff1c4259d7 14 * are permitted provided that the following conditions are met:
Kojto 101:7cff1c4259d7 15 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 101:7cff1c4259d7 16 * this list of conditions and the following disclaimer.
Kojto 101:7cff1c4259d7 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 101:7cff1c4259d7 18 * this list of conditions and the following disclaimer in the documentation
Kojto 101:7cff1c4259d7 19 * and/or other materials provided with the distribution.
Kojto 101:7cff1c4259d7 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 101:7cff1c4259d7 21 * may be used to endorse or promote products derived from this software
Kojto 101:7cff1c4259d7 22 * without specific prior written permission.
Kojto 101:7cff1c4259d7 23 *
Kojto 101:7cff1c4259d7 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 101:7cff1c4259d7 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 101:7cff1c4259d7 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 101:7cff1c4259d7 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 101:7cff1c4259d7 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 101:7cff1c4259d7 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 101:7cff1c4259d7 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 101:7cff1c4259d7 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 101:7cff1c4259d7 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 101:7cff1c4259d7 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 101:7cff1c4259d7 34 *
Kojto 101:7cff1c4259d7 35 ******************************************************************************
Kojto 101:7cff1c4259d7 36 */
Kojto 101:7cff1c4259d7 37
Kojto 101:7cff1c4259d7 38 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 101:7cff1c4259d7 39 #ifndef __STM32F4xx_HAL_UART_H
Kojto 101:7cff1c4259d7 40 #define __STM32F4xx_HAL_UART_H
Kojto 101:7cff1c4259d7 41
Kojto 101:7cff1c4259d7 42 #ifdef __cplusplus
Kojto 101:7cff1c4259d7 43 extern "C" {
Kojto 101:7cff1c4259d7 44 #endif
Kojto 101:7cff1c4259d7 45
Kojto 101:7cff1c4259d7 46 /* Includes ------------------------------------------------------------------*/
Kojto 101:7cff1c4259d7 47 #include "stm32f4xx_hal_def.h"
Kojto 101:7cff1c4259d7 48
Kojto 101:7cff1c4259d7 49 /** @addtogroup STM32F4xx_HAL_Driver
Kojto 101:7cff1c4259d7 50 * @{
Kojto 101:7cff1c4259d7 51 */
Kojto 101:7cff1c4259d7 52
Kojto 101:7cff1c4259d7 53 /** @addtogroup UART
Kojto 101:7cff1c4259d7 54 * @{
Kojto 101:7cff1c4259d7 55 */
Kojto 101:7cff1c4259d7 56
Kojto 101:7cff1c4259d7 57 /* Exported types ------------------------------------------------------------*/
Kojto 101:7cff1c4259d7 58 /** @defgroup UART_Exported_Types UART Exported Types
Kojto 101:7cff1c4259d7 59 * @{
Kojto 101:7cff1c4259d7 60 */
Kojto 101:7cff1c4259d7 61
Kojto 101:7cff1c4259d7 62 /**
Kojto 101:7cff1c4259d7 63 * @brief UART Init Structure definition
Kojto 101:7cff1c4259d7 64 */
Kojto 101:7cff1c4259d7 65 typedef struct
Kojto 101:7cff1c4259d7 66 {
Kojto 101:7cff1c4259d7 67 uint32_t BaudRate; /*!< This member configures the UART communication baud rate.
Kojto 101:7cff1c4259d7 68 The baud rate is computed using the following formula:
Kojto 101:7cff1c4259d7 69 - IntegerDivider = ((PCLKx) / (8 * (OVR8+1) * (huart->Init.BaudRate)))
Kojto 101:7cff1c4259d7 70 - FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 8 * (OVR8+1)) + 0.5
Kojto 101:7cff1c4259d7 71 Where OVR8 is the "oversampling by 8 mode" configuration bit in the CR1 register. */
Kojto 101:7cff1c4259d7 72
Kojto 101:7cff1c4259d7 73 uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
Kojto 101:7cff1c4259d7 74 This parameter can be a value of @ref UART_Word_Length */
Kojto 101:7cff1c4259d7 75
Kojto 101:7cff1c4259d7 76 uint32_t StopBits; /*!< Specifies the number of stop bits transmitted.
Kojto 101:7cff1c4259d7 77 This parameter can be a value of @ref UART_Stop_Bits */
Kojto 101:7cff1c4259d7 78
Kojto 101:7cff1c4259d7 79 uint32_t Parity; /*!< Specifies the parity mode.
Kojto 101:7cff1c4259d7 80 This parameter can be a value of @ref UART_Parity
Kojto 101:7cff1c4259d7 81 @note When parity is enabled, the computed parity is inserted
Kojto 101:7cff1c4259d7 82 at the MSB position of the transmitted data (9th bit when
Kojto 101:7cff1c4259d7 83 the word length is set to 9 data bits; 8th bit when the
Kojto 101:7cff1c4259d7 84 word length is set to 8 data bits). */
Kojto 101:7cff1c4259d7 85
Kojto 101:7cff1c4259d7 86 uint32_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
Kojto 101:7cff1c4259d7 87 This parameter can be a value of @ref UART_Mode */
Kojto 101:7cff1c4259d7 88
Kojto 101:7cff1c4259d7 89 uint32_t HwFlowCtl; /*!< Specifies whether the hardware flow control mode is enabled
Kojto 101:7cff1c4259d7 90 or disabled.
Kojto 101:7cff1c4259d7 91 This parameter can be a value of @ref UART_Hardware_Flow_Control */
Kojto 101:7cff1c4259d7 92
Kojto 101:7cff1c4259d7 93 uint32_t OverSampling; /*!< Specifies whether the Over sampling 8 is enabled or disabled, to achieve higher speed (up to fPCLK/8).
Kojto 101:7cff1c4259d7 94 This parameter can be a value of @ref UART_Over_Sampling */
Kojto 101:7cff1c4259d7 95 }UART_InitTypeDef;
Kojto 101:7cff1c4259d7 96
Kojto 101:7cff1c4259d7 97 /**
Kojto 101:7cff1c4259d7 98 * @brief HAL UART State structures definition
Kojto 101:7cff1c4259d7 99 */
Kojto 101:7cff1c4259d7 100 typedef enum
Kojto 101:7cff1c4259d7 101 {
Kojto 101:7cff1c4259d7 102 HAL_UART_STATE_RESET = 0x00, /*!< Peripheral is not yet Initialized */
Kojto 101:7cff1c4259d7 103 HAL_UART_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */
Kojto 101:7cff1c4259d7 104 HAL_UART_STATE_BUSY = 0x02, /*!< an internal process is ongoing */
Kojto 101:7cff1c4259d7 105 HAL_UART_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */
Kojto 101:7cff1c4259d7 106 HAL_UART_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */
Kojto 101:7cff1c4259d7 107 HAL_UART_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission and Reception process is ongoing */
Kojto 101:7cff1c4259d7 108 HAL_UART_STATE_TIMEOUT = 0x03, /*!< Timeout state */
Kojto 101:7cff1c4259d7 109 HAL_UART_STATE_ERROR = 0x04 /*!< Error */
Kojto 101:7cff1c4259d7 110 }HAL_UART_StateTypeDef;
Kojto 101:7cff1c4259d7 111
Kojto 101:7cff1c4259d7 112 /**
Kojto 101:7cff1c4259d7 113 * @brief UART handle Structure definition
Kojto 101:7cff1c4259d7 114 */
Kojto 101:7cff1c4259d7 115 typedef struct
Kojto 101:7cff1c4259d7 116 {
Kojto 101:7cff1c4259d7 117 USART_TypeDef *Instance; /*!< UART registers base address */
Kojto 101:7cff1c4259d7 118
Kojto 101:7cff1c4259d7 119 UART_InitTypeDef Init; /*!< UART communication parameters */
Kojto 101:7cff1c4259d7 120
Kojto 101:7cff1c4259d7 121 uint8_t *pTxBuffPtr; /*!< Pointer to UART Tx transfer Buffer */
Kojto 101:7cff1c4259d7 122
Kojto 101:7cff1c4259d7 123 uint16_t TxXferSize; /*!< UART Tx Transfer size */
Kojto 101:7cff1c4259d7 124
Kojto 101:7cff1c4259d7 125 uint16_t TxXferCount; /*!< UART Tx Transfer Counter */
Kojto 101:7cff1c4259d7 126
Kojto 101:7cff1c4259d7 127 uint8_t *pRxBuffPtr; /*!< Pointer to UART Rx transfer Buffer */
Kojto 101:7cff1c4259d7 128
Kojto 101:7cff1c4259d7 129 uint16_t RxXferSize; /*!< UART Rx Transfer size */
Kojto 101:7cff1c4259d7 130
Kojto 101:7cff1c4259d7 131 uint16_t RxXferCount; /*!< UART Rx Transfer Counter */
Kojto 101:7cff1c4259d7 132
Kojto 101:7cff1c4259d7 133 DMA_HandleTypeDef *hdmatx; /*!< UART Tx DMA Handle parameters */
Kojto 101:7cff1c4259d7 134
Kojto 101:7cff1c4259d7 135 DMA_HandleTypeDef *hdmarx; /*!< UART Rx DMA Handle parameters */
Kojto 101:7cff1c4259d7 136
Kojto 101:7cff1c4259d7 137 HAL_LockTypeDef Lock; /*!< Locking object */
Kojto 101:7cff1c4259d7 138
Kojto 101:7cff1c4259d7 139 __IO HAL_UART_StateTypeDef State; /*!< UART communication state */
Kojto 101:7cff1c4259d7 140
Kojto 101:7cff1c4259d7 141 __IO uint32_t ErrorCode; /*!< UART Error code */
Kojto 101:7cff1c4259d7 142
Kojto 101:7cff1c4259d7 143 }UART_HandleTypeDef;
Kojto 101:7cff1c4259d7 144 /**
Kojto 101:7cff1c4259d7 145 * @}
Kojto 101:7cff1c4259d7 146 */
Kojto 101:7cff1c4259d7 147
Kojto 101:7cff1c4259d7 148 /* Exported constants --------------------------------------------------------*/
Kojto 101:7cff1c4259d7 149 /** @defgroup UART_Exported_Constants UART Exported constants
Kojto 101:7cff1c4259d7 150 * @{
Kojto 101:7cff1c4259d7 151 */
Kojto 101:7cff1c4259d7 152
Kojto 101:7cff1c4259d7 153 /** @defgroup UART_Error_Code UART Error Code
Kojto 101:7cff1c4259d7 154 * @brief UART Error Code
Kojto 101:7cff1c4259d7 155 * @{
Kojto 101:7cff1c4259d7 156 */
Kojto 101:7cff1c4259d7 157 #define HAL_UART_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */
Kojto 101:7cff1c4259d7 158 #define HAL_UART_ERROR_PE ((uint32_t)0x00000001) /*!< Parity error */
Kojto 101:7cff1c4259d7 159 #define HAL_UART_ERROR_NE ((uint32_t)0x00000002) /*!< Noise error */
Kojto 101:7cff1c4259d7 160 #define HAL_UART_ERROR_FE ((uint32_t)0x00000004) /*!< Frame error */
Kojto 101:7cff1c4259d7 161 #define HAL_UART_ERROR_ORE ((uint32_t)0x00000008) /*!< Overrun error */
Kojto 101:7cff1c4259d7 162 #define HAL_UART_ERROR_DMA ((uint32_t)0x00000010) /*!< DMA transfer error */
Kojto 101:7cff1c4259d7 163 /**
Kojto 101:7cff1c4259d7 164 * @}
Kojto 101:7cff1c4259d7 165 */
Kojto 101:7cff1c4259d7 166
Kojto 101:7cff1c4259d7 167 /** @defgroup UART_Word_Length UART Word Length
Kojto 101:7cff1c4259d7 168 * @{
Kojto 101:7cff1c4259d7 169 */
Kojto 101:7cff1c4259d7 170 #define UART_WORDLENGTH_8B ((uint32_t)0x00000000)
Kojto 101:7cff1c4259d7 171 #define UART_WORDLENGTH_9B ((uint32_t)USART_CR1_M)
Kojto 101:7cff1c4259d7 172 /**
Kojto 101:7cff1c4259d7 173 * @}
Kojto 101:7cff1c4259d7 174 */
Kojto 101:7cff1c4259d7 175
Kojto 101:7cff1c4259d7 176 /** @defgroup UART_Stop_Bits UART Number of Stop Bits
Kojto 101:7cff1c4259d7 177 * @{
Kojto 101:7cff1c4259d7 178 */
Kojto 101:7cff1c4259d7 179 #define UART_STOPBITS_1 ((uint32_t)0x00000000)
Kojto 101:7cff1c4259d7 180 #define UART_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1)
Kojto 101:7cff1c4259d7 181 /**
Kojto 101:7cff1c4259d7 182 * @}
Kojto 101:7cff1c4259d7 183 */
Kojto 101:7cff1c4259d7 184
Kojto 101:7cff1c4259d7 185 /** @defgroup UART_Parity UART Parity
Kojto 101:7cff1c4259d7 186 * @{
Kojto 101:7cff1c4259d7 187 */
Kojto 101:7cff1c4259d7 188 #define UART_PARITY_NONE ((uint32_t)0x00000000)
Kojto 101:7cff1c4259d7 189 #define UART_PARITY_EVEN ((uint32_t)USART_CR1_PCE)
Kojto 101:7cff1c4259d7 190 #define UART_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS))
Kojto 101:7cff1c4259d7 191 /**
Kojto 101:7cff1c4259d7 192 * @}
Kojto 101:7cff1c4259d7 193 */
Kojto 101:7cff1c4259d7 194
Kojto 101:7cff1c4259d7 195 /** @defgroup UART_Hardware_Flow_Control UART Hardware Flow Control
Kojto 101:7cff1c4259d7 196 * @{
Kojto 101:7cff1c4259d7 197 */
Kojto 101:7cff1c4259d7 198 #define UART_HWCONTROL_NONE ((uint32_t)0x00000000)
Kojto 101:7cff1c4259d7 199 #define UART_HWCONTROL_RTS ((uint32_t)USART_CR3_RTSE)
Kojto 101:7cff1c4259d7 200 #define UART_HWCONTROL_CTS ((uint32_t)USART_CR3_CTSE)
Kojto 101:7cff1c4259d7 201 #define UART_HWCONTROL_RTS_CTS ((uint32_t)(USART_CR3_RTSE | USART_CR3_CTSE))
Kojto 101:7cff1c4259d7 202 /**
Kojto 101:7cff1c4259d7 203 * @}
Kojto 101:7cff1c4259d7 204 */
Kojto 101:7cff1c4259d7 205
Kojto 101:7cff1c4259d7 206 /** @defgroup UART_Mode UART Transfer Mode
Kojto 101:7cff1c4259d7 207 * @{
Kojto 101:7cff1c4259d7 208 */
Kojto 101:7cff1c4259d7 209 #define UART_MODE_RX ((uint32_t)USART_CR1_RE)
Kojto 101:7cff1c4259d7 210 #define UART_MODE_TX ((uint32_t)USART_CR1_TE)
Kojto 101:7cff1c4259d7 211 #define UART_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE))
Kojto 101:7cff1c4259d7 212 /**
Kojto 101:7cff1c4259d7 213 * @}
Kojto 101:7cff1c4259d7 214 */
Kojto 101:7cff1c4259d7 215
Kojto 101:7cff1c4259d7 216 /** @defgroup UART_State UART State
Kojto 101:7cff1c4259d7 217 * @{
Kojto 101:7cff1c4259d7 218 */
Kojto 101:7cff1c4259d7 219 #define UART_STATE_DISABLE ((uint32_t)0x00000000)
Kojto 101:7cff1c4259d7 220 #define UART_STATE_ENABLE ((uint32_t)USART_CR1_UE)
Kojto 101:7cff1c4259d7 221 /**
Kojto 101:7cff1c4259d7 222 * @}
Kojto 101:7cff1c4259d7 223 */
Kojto 101:7cff1c4259d7 224
Kojto 101:7cff1c4259d7 225 /** @defgroup UART_Over_Sampling UART Over Sampling
Kojto 101:7cff1c4259d7 226 * @{
Kojto 101:7cff1c4259d7 227 */
Kojto 101:7cff1c4259d7 228 #define UART_OVERSAMPLING_16 ((uint32_t)0x00000000)
Kojto 101:7cff1c4259d7 229 #define UART_OVERSAMPLING_8 ((uint32_t)USART_CR1_OVER8)
Kojto 101:7cff1c4259d7 230 /**
Kojto 101:7cff1c4259d7 231 * @}
Kojto 101:7cff1c4259d7 232 */
Kojto 101:7cff1c4259d7 233
Kojto 101:7cff1c4259d7 234 /** @defgroup UART_LIN_Break_Detection_Length UART LIN Break Detection Length
Kojto 101:7cff1c4259d7 235 * @{
Kojto 101:7cff1c4259d7 236 */
Kojto 101:7cff1c4259d7 237 #define UART_LINBREAKDETECTLENGTH_10B ((uint32_t)0x00000000)
Kojto 101:7cff1c4259d7 238 #define UART_LINBREAKDETECTLENGTH_11B ((uint32_t)0x00000020)
Kojto 101:7cff1c4259d7 239 /**
Kojto 101:7cff1c4259d7 240 * @}
Kojto 101:7cff1c4259d7 241 */
Kojto 101:7cff1c4259d7 242
Kojto 101:7cff1c4259d7 243 /** @defgroup UART_WakeUp_functions UART Wakeup Functions
Kojto 101:7cff1c4259d7 244 * @{
Kojto 101:7cff1c4259d7 245 */
Kojto 101:7cff1c4259d7 246 #define UART_WAKEUPMETHOD_IDLELINE ((uint32_t)0x00000000)
Kojto 101:7cff1c4259d7 247 #define UART_WAKEUPMETHOD_ADDRESSMARK ((uint32_t)0x00000800)
Kojto 101:7cff1c4259d7 248 /**
Kojto 101:7cff1c4259d7 249 * @}
Kojto 101:7cff1c4259d7 250 */
Kojto 101:7cff1c4259d7 251
Kojto 101:7cff1c4259d7 252 /** @defgroup UART_Flags UART FLags
Kojto 101:7cff1c4259d7 253 * Elements values convention: 0xXXXX
Kojto 101:7cff1c4259d7 254 * - 0xXXXX : Flag mask in the SR register
Kojto 101:7cff1c4259d7 255 * @{
Kojto 101:7cff1c4259d7 256 */
Kojto 101:7cff1c4259d7 257 #define UART_FLAG_CTS ((uint32_t)USART_SR_CTS)
Kojto 101:7cff1c4259d7 258 #define UART_FLAG_LBD ((uint32_t)USART_SR_LBD)
Kojto 101:7cff1c4259d7 259 #define UART_FLAG_TXE ((uint32_t)USART_SR_TXE)
Kojto 101:7cff1c4259d7 260 #define UART_FLAG_TC ((uint32_t)USART_SR_TC)
Kojto 101:7cff1c4259d7 261 #define UART_FLAG_RXNE ((uint32_t)USART_SR_RXNE)
Kojto 101:7cff1c4259d7 262 #define UART_FLAG_IDLE ((uint32_t)USART_SR_IDLE)
Kojto 101:7cff1c4259d7 263 #define UART_FLAG_ORE ((uint32_t)USART_SR_ORE)
Kojto 101:7cff1c4259d7 264 #define UART_FLAG_NE ((uint32_t)USART_SR_NE)
Kojto 101:7cff1c4259d7 265 #define UART_FLAG_FE ((uint32_t)USART_SR_FE)
Kojto 101:7cff1c4259d7 266 #define UART_FLAG_PE ((uint32_t)USART_SR_PE)
Kojto 101:7cff1c4259d7 267 /**
Kojto 101:7cff1c4259d7 268 * @}
Kojto 101:7cff1c4259d7 269 */
Kojto 101:7cff1c4259d7 270
Kojto 101:7cff1c4259d7 271 /** @defgroup UART_Interrupt_definition UART Interrupt Definitions
Kojto 101:7cff1c4259d7 272 * Elements values convention: 0xY000XXXX
Kojto 101:7cff1c4259d7 273 * - XXXX : Interrupt mask (16 bits) in the Y register
Kojto 101:7cff1c4259d7 274 * - Y : Interrupt source register (2bits)
Kojto 101:7cff1c4259d7 275 * - 0001: CR1 register
Kojto 101:7cff1c4259d7 276 * - 0010: CR2 register
Kojto 101:7cff1c4259d7 277 * - 0011: CR3 register
Kojto 101:7cff1c4259d7 278 *
Kojto 101:7cff1c4259d7 279 * @{
Kojto 101:7cff1c4259d7 280 */
Kojto 101:7cff1c4259d7 281
Kojto 101:7cff1c4259d7 282 #define UART_IT_PE ((uint32_t)(UART_CR1_REG_INDEX << 28 | USART_CR1_PEIE))
Kojto 101:7cff1c4259d7 283 #define UART_IT_TXE ((uint32_t)(UART_CR1_REG_INDEX << 28 | USART_CR1_TXEIE))
Kojto 101:7cff1c4259d7 284 #define UART_IT_TC ((uint32_t)(UART_CR1_REG_INDEX << 28 | USART_CR1_TCIE))
Kojto 101:7cff1c4259d7 285 #define UART_IT_RXNE ((uint32_t)(UART_CR1_REG_INDEX << 28 | USART_CR1_RXNEIE))
Kojto 101:7cff1c4259d7 286 #define UART_IT_IDLE ((uint32_t)(UART_CR1_REG_INDEX << 28 | USART_CR1_IDLEIE))
Kojto 101:7cff1c4259d7 287
Kojto 101:7cff1c4259d7 288 #define UART_IT_LBD ((uint32_t)(UART_CR2_REG_INDEX << 28 | USART_CR2_LBDIE))
Kojto 101:7cff1c4259d7 289
Kojto 101:7cff1c4259d7 290 #define UART_IT_CTS ((uint32_t)(UART_CR3_REG_INDEX << 28 | USART_CR3_CTSIE))
Kojto 101:7cff1c4259d7 291 #define UART_IT_ERR ((uint32_t)(UART_CR3_REG_INDEX << 28 | USART_CR3_EIE))
Kojto 101:7cff1c4259d7 292 /**
Kojto 101:7cff1c4259d7 293 * @}
Kojto 101:7cff1c4259d7 294 */
Kojto 101:7cff1c4259d7 295
Kojto 101:7cff1c4259d7 296 /**
Kojto 101:7cff1c4259d7 297 * @}
Kojto 101:7cff1c4259d7 298 */
Kojto 101:7cff1c4259d7 299
Kojto 101:7cff1c4259d7 300 /* Exported macro ------------------------------------------------------------*/
Kojto 101:7cff1c4259d7 301 /** @defgroup UART_Exported_Macros UART Exported Macros
Kojto 101:7cff1c4259d7 302 * @{
Kojto 101:7cff1c4259d7 303 */
Kojto 101:7cff1c4259d7 304
Kojto 101:7cff1c4259d7 305 /** @brief Reset UART handle state
Kojto 101:7cff1c4259d7 306 * @param __HANDLE__: specifies the UART Handle.
Kojto 101:7cff1c4259d7 307 * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
Kojto 101:7cff1c4259d7 308 * UART peripheral.
Kojto 101:7cff1c4259d7 309 * @retval None
Kojto 101:7cff1c4259d7 310 */
Kojto 101:7cff1c4259d7 311 #define __HAL_UART_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_UART_STATE_RESET)
Kojto 101:7cff1c4259d7 312
Kojto 101:7cff1c4259d7 313 /** @brief Flushes the UART DR register
Kojto 101:7cff1c4259d7 314 * @param __HANDLE__: specifies the UART Handle.
Kojto 101:7cff1c4259d7 315 */
Kojto 101:7cff1c4259d7 316 #define __HAL_UART_FLUSH_DRREGISTER(__HANDLE__) ((__HANDLE__)->Instance->DR)
Kojto 101:7cff1c4259d7 317
Kojto 101:7cff1c4259d7 318 /** @brief Checks whether the specified UART flag is set or not.
Kojto 101:7cff1c4259d7 319 * @param __HANDLE__: specifies the UART Handle.
Kojto 101:7cff1c4259d7 320 * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
Kojto 101:7cff1c4259d7 321 * UART peripheral.
Kojto 101:7cff1c4259d7 322 * @param __FLAG__: specifies the flag to check.
Kojto 101:7cff1c4259d7 323 * This parameter can be one of the following values:
Kojto 101:7cff1c4259d7 324 * @arg UART_FLAG_CTS: CTS Change flag (not available for UART4 and UART5)
Kojto 101:7cff1c4259d7 325 * @arg UART_FLAG_LBD: LIN Break detection flag
Kojto 101:7cff1c4259d7 326 * @arg UART_FLAG_TXE: Transmit data register empty flag
Kojto 101:7cff1c4259d7 327 * @arg UART_FLAG_TC: Transmission Complete flag
Kojto 101:7cff1c4259d7 328 * @arg UART_FLAG_RXNE: Receive data register not empty flag
Kojto 101:7cff1c4259d7 329 * @arg UART_FLAG_IDLE: Idle Line detection flag
Kojto 101:7cff1c4259d7 330 * @arg UART_FLAG_ORE: Overrun Error flag
Kojto 101:7cff1c4259d7 331 * @arg UART_FLAG_NE: Noise Error flag
Kojto 101:7cff1c4259d7 332 * @arg UART_FLAG_FE: Framing Error flag
Kojto 101:7cff1c4259d7 333 * @arg UART_FLAG_PE: Parity Error flag
Kojto 101:7cff1c4259d7 334 * @retval The new state of __FLAG__ (TRUE or FALSE).
Kojto 101:7cff1c4259d7 335 */
Kojto 101:7cff1c4259d7 336
Kojto 101:7cff1c4259d7 337 #define __HAL_UART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
Kojto 101:7cff1c4259d7 338
Kojto 101:7cff1c4259d7 339 /** @brief Clears the specified UART pending flag.
Kojto 101:7cff1c4259d7 340 * @param __HANDLE__: specifies the UART Handle.
Kojto 101:7cff1c4259d7 341 * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
Kojto 101:7cff1c4259d7 342 * UART peripheral.
Kojto 101:7cff1c4259d7 343 * @param __FLAG__: specifies the flag to check.
Kojto 101:7cff1c4259d7 344 * This parameter can be any combination of the following values:
Kojto 101:7cff1c4259d7 345 * @arg UART_FLAG_CTS: CTS Change flag (not available for UART4 and UART5).
Kojto 101:7cff1c4259d7 346 * @arg UART_FLAG_LBD: LIN Break detection flag.
Kojto 101:7cff1c4259d7 347 * @arg UART_FLAG_TC: Transmission Complete flag.
Kojto 101:7cff1c4259d7 348 * @arg UART_FLAG_RXNE: Receive data register not empty flag.
Kojto 101:7cff1c4259d7 349 *
Kojto 101:7cff1c4259d7 350 * @note PE (Parity error), FE (Framing error), NE (Noise error), ORE (Overrun
Kojto 101:7cff1c4259d7 351 * error) and IDLE (Idle line detected) flags are cleared by software
Kojto 101:7cff1c4259d7 352 * sequence: a read operation to USART_SR register followed by a read
Kojto 101:7cff1c4259d7 353 * operation to USART_DR register.
Kojto 101:7cff1c4259d7 354 * @note RXNE flag can be also cleared by a read to the USART_DR register.
Kojto 101:7cff1c4259d7 355 * @note TC flag can be also cleared by software sequence: a read operation to
Kojto 101:7cff1c4259d7 356 * USART_SR register followed by a write operation to USART_DR register.
Kojto 101:7cff1c4259d7 357 * @note TXE flag is cleared only by a write to the USART_DR register.
Kojto 101:7cff1c4259d7 358 *
Kojto 101:7cff1c4259d7 359 * @retval None
Kojto 101:7cff1c4259d7 360 */
Kojto 101:7cff1c4259d7 361 #define __HAL_UART_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__))
Kojto 101:7cff1c4259d7 362
Kojto 101:7cff1c4259d7 363 /** @brief Clear the UART PE pending flag.
Kojto 101:7cff1c4259d7 364 * @param __HANDLE__: specifies the UART Handle.
Kojto 101:7cff1c4259d7 365 * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
Kojto 101:7cff1c4259d7 366 * UART peripheral.
Kojto 101:7cff1c4259d7 367 * @retval None
Kojto 101:7cff1c4259d7 368 */
Kojto 101:7cff1c4259d7 369 #define __HAL_UART_CLEAR_PEFLAG(__HANDLE__) \
Kojto 101:7cff1c4259d7 370 do{ \
Kojto 101:7cff1c4259d7 371 __IO uint32_t tmpreg; \
Kojto 101:7cff1c4259d7 372 tmpreg = (__HANDLE__)->Instance->SR; \
Kojto 101:7cff1c4259d7 373 tmpreg = (__HANDLE__)->Instance->DR; \
Kojto 101:7cff1c4259d7 374 UNUSED(tmpreg); \
Kojto 101:7cff1c4259d7 375 } while(0)
Kojto 101:7cff1c4259d7 376
Kojto 101:7cff1c4259d7 377 /** @brief Clear the UART FE pending flag.
Kojto 101:7cff1c4259d7 378 * @param __HANDLE__: specifies the UART Handle.
Kojto 101:7cff1c4259d7 379 * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
Kojto 101:7cff1c4259d7 380 * UART peripheral.
Kojto 101:7cff1c4259d7 381 * @retval None
Kojto 101:7cff1c4259d7 382 */
Kojto 101:7cff1c4259d7 383 #define __HAL_UART_CLEAR_FEFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__)
Kojto 101:7cff1c4259d7 384
Kojto 101:7cff1c4259d7 385 /** @brief Clear the UART NE pending flag.
Kojto 101:7cff1c4259d7 386 * @param __HANDLE__: specifies the UART Handle.
Kojto 101:7cff1c4259d7 387 * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
Kojto 101:7cff1c4259d7 388 * UART peripheral.
Kojto 101:7cff1c4259d7 389 * @retval None
Kojto 101:7cff1c4259d7 390 */
Kojto 101:7cff1c4259d7 391 #define __HAL_UART_CLEAR_NEFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__)
Kojto 101:7cff1c4259d7 392
Kojto 101:7cff1c4259d7 393 /** @brief Clear the UART ORE pending flag.
Kojto 101:7cff1c4259d7 394 * @param __HANDLE__: specifies the UART Handle.
Kojto 101:7cff1c4259d7 395 * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
Kojto 101:7cff1c4259d7 396 * UART peripheral.
Kojto 101:7cff1c4259d7 397 * @retval None
Kojto 101:7cff1c4259d7 398 */
Kojto 101:7cff1c4259d7 399 #define __HAL_UART_CLEAR_OREFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__)
Kojto 101:7cff1c4259d7 400
Kojto 101:7cff1c4259d7 401 /** @brief Clear the UART IDLE pending flag.
Kojto 101:7cff1c4259d7 402 * @param __HANDLE__: specifies the UART Handle.
Kojto 101:7cff1c4259d7 403 * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
Kojto 101:7cff1c4259d7 404 * UART peripheral.
Kojto 101:7cff1c4259d7 405 * @retval None
Kojto 101:7cff1c4259d7 406 */
Kojto 101:7cff1c4259d7 407 #define __HAL_UART_CLEAR_IDLEFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__)
Kojto 101:7cff1c4259d7 408
Kojto 101:7cff1c4259d7 409 /** @brief Enable the specified UART interrupt.
Kojto 101:7cff1c4259d7 410 * @param __HANDLE__: specifies the UART Handle.
Kojto 101:7cff1c4259d7 411 * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
Kojto 101:7cff1c4259d7 412 * UART peripheral.
Kojto 101:7cff1c4259d7 413 * @param __INTERRUPT__: specifies the UART interrupt source to enable.
Kojto 101:7cff1c4259d7 414 * This parameter can be one of the following values:
Kojto 101:7cff1c4259d7 415 * @arg UART_IT_CTS: CTS change interrupt
Kojto 101:7cff1c4259d7 416 * @arg UART_IT_LBD: LIN Break detection interrupt
Kojto 101:7cff1c4259d7 417 * @arg UART_IT_TXE: Transmit Data Register empty interrupt
Kojto 101:7cff1c4259d7 418 * @arg UART_IT_TC: Transmission complete interrupt
Kojto 101:7cff1c4259d7 419 * @arg UART_IT_RXNE: Receive Data register not empty interrupt
Kojto 101:7cff1c4259d7 420 * @arg UART_IT_IDLE: Idle line detection interrupt
Kojto 101:7cff1c4259d7 421 * @arg UART_IT_PE: Parity Error interrupt
Kojto 101:7cff1c4259d7 422 * @arg UART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
Kojto 101:7cff1c4259d7 423 * @retval None
Kojto 101:7cff1c4259d7 424 */
Kojto 101:7cff1c4259d7 425 #define UART_IT_MASK ((uint32_t)0x0000FFFF)
Kojto 101:7cff1c4259d7 426 #define __HAL_UART_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28) == 1)? ((__HANDLE__)->Instance->CR1 |= ((__INTERRUPT__) & UART_IT_MASK)): \
Kojto 101:7cff1c4259d7 427 (((__INTERRUPT__) >> 28) == 2)? ((__HANDLE__)->Instance->CR2 |= ((__INTERRUPT__) & UART_IT_MASK)): \
Kojto 101:7cff1c4259d7 428 ((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & UART_IT_MASK)))
Kojto 101:7cff1c4259d7 429 /** @brief Disable the specified UART interrupt.
Kojto 101:7cff1c4259d7 430 * @param __HANDLE__: specifies the UART Handle.
Kojto 101:7cff1c4259d7 431 * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
Kojto 101:7cff1c4259d7 432 * UART peripheral.
Kojto 101:7cff1c4259d7 433 * @param __INTERRUPT__: specifies the UART interrupt source to disable.
Kojto 101:7cff1c4259d7 434 * This parameter can be one of the following values:
Kojto 101:7cff1c4259d7 435 * @arg UART_IT_CTS: CTS change interrupt
Kojto 101:7cff1c4259d7 436 * @arg UART_IT_LBD: LIN Break detection interrupt
Kojto 101:7cff1c4259d7 437 * @arg UART_IT_TXE: Transmit Data Register empty interrupt
Kojto 101:7cff1c4259d7 438 * @arg UART_IT_TC: Transmission complete interrupt
Kojto 101:7cff1c4259d7 439 * @arg UART_IT_RXNE: Receive Data register not empty interrupt
Kojto 101:7cff1c4259d7 440 * @arg UART_IT_IDLE: Idle line detection interrupt
Kojto 101:7cff1c4259d7 441 * @arg UART_IT_PE: Parity Error interrupt
Kojto 101:7cff1c4259d7 442 * @arg UART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
Kojto 101:7cff1c4259d7 443 * @retval None
Kojto 101:7cff1c4259d7 444 */
Kojto 101:7cff1c4259d7 445 #define __HAL_UART_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28) == 1)? ((__HANDLE__)->Instance->CR1 &= ~((__INTERRUPT__) & UART_IT_MASK)): \
Kojto 101:7cff1c4259d7 446 (((__INTERRUPT__) >> 28) == 2)? ((__HANDLE__)->Instance->CR2 &= ~((__INTERRUPT__) & UART_IT_MASK)): \
Kojto 101:7cff1c4259d7 447 ((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & UART_IT_MASK)))
Kojto 101:7cff1c4259d7 448
Kojto 101:7cff1c4259d7 449 /** @brief Checks whether the specified UART interrupt has occurred or not.
Kojto 101:7cff1c4259d7 450 * @param __HANDLE__: specifies the UART Handle.
Kojto 101:7cff1c4259d7 451 * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
Kojto 101:7cff1c4259d7 452 * UART peripheral.
Kojto 101:7cff1c4259d7 453 * @param __IT__: specifies the UART interrupt source to check.
Kojto 101:7cff1c4259d7 454 * This parameter can be one of the following values:
Kojto 101:7cff1c4259d7 455 * @arg UART_IT_CTS: CTS change interrupt (not available for UART4 and UART5)
Kojto 101:7cff1c4259d7 456 * @arg UART_IT_LBD: LIN Break detection interrupt
Kojto 101:7cff1c4259d7 457 * @arg UART_IT_TXE: Transmit Data Register empty interrupt
Kojto 101:7cff1c4259d7 458 * @arg UART_IT_TC: Transmission complete interrupt
Kojto 101:7cff1c4259d7 459 * @arg UART_IT_RXNE: Receive Data register not empty interrupt
Kojto 101:7cff1c4259d7 460 * @arg UART_IT_IDLE: Idle line detection interrupt
Kojto 101:7cff1c4259d7 461 * @arg USART_IT_ERR: Error interrupt
Kojto 101:7cff1c4259d7 462 * @retval The new state of __IT__ (TRUE or FALSE).
Kojto 101:7cff1c4259d7 463 */
Kojto 101:7cff1c4259d7 464 #define __HAL_UART_GET_IT_SOURCE(__HANDLE__, __IT__) (((((__IT__) >> 28) == 1)? (__HANDLE__)->Instance->CR1:(((((uint32_t)(__IT__)) >> 28) == 2)? \
Kojto 101:7cff1c4259d7 465 (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & (((uint32_t)(__IT__)) & UART_IT_MASK))
Kojto 101:7cff1c4259d7 466
Kojto 101:7cff1c4259d7 467 /** @brief Enable CTS flow control
Kojto 101:7cff1c4259d7 468 * This macro allows to enable CTS hardware flow control for a given UART instance,
Kojto 101:7cff1c4259d7 469 * without need to call HAL_UART_Init() function.
Kojto 101:7cff1c4259d7 470 * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
Kojto 101:7cff1c4259d7 471 * @note As macro is expected to be used for modifying CTS Hw flow control feature activation, without need
Kojto 101:7cff1c4259d7 472 * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
Kojto 101:7cff1c4259d7 473 * - UART instance should have already been initialised (through call of HAL_UART_Init() )
Kojto 101:7cff1c4259d7 474 * - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__))
Kojto 101:7cff1c4259d7 475 * and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)).
Kojto 101:7cff1c4259d7 476 * @param __HANDLE__: specifies the UART Handle.
Kojto 101:7cff1c4259d7 477 * The Handle Instance can be USART1, USART2 or LPUART.
Kojto 101:7cff1c4259d7 478 * @retval None
Kojto 101:7cff1c4259d7 479 */
Kojto 101:7cff1c4259d7 480 #define __HAL_UART_HWCONTROL_CTS_ENABLE(__HANDLE__) \
Kojto 101:7cff1c4259d7 481 do{ \
Kojto 101:7cff1c4259d7 482 SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \
Kojto 101:7cff1c4259d7 483 (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_CTSE; \
Kojto 101:7cff1c4259d7 484 } while(0)
Kojto 101:7cff1c4259d7 485
Kojto 101:7cff1c4259d7 486 /** @brief Disable CTS flow control
Kojto 101:7cff1c4259d7 487 * This macro allows to disable CTS hardware flow control for a given UART instance,
Kojto 101:7cff1c4259d7 488 * without need to call HAL_UART_Init() function.
Kojto 101:7cff1c4259d7 489 * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
Kojto 101:7cff1c4259d7 490 * @note As macro is expected to be used for modifying CTS Hw flow control feature activation, without need
Kojto 101:7cff1c4259d7 491 * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
Kojto 101:7cff1c4259d7 492 * - UART instance should have already been initialised (through call of HAL_UART_Init() )
Kojto 101:7cff1c4259d7 493 * - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__))
Kojto 101:7cff1c4259d7 494 * and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)).
Kojto 101:7cff1c4259d7 495 * @param __HANDLE__: specifies the UART Handle.
Kojto 101:7cff1c4259d7 496 * The Handle Instance can be USART1, USART2 or LPUART.
Kojto 101:7cff1c4259d7 497 * @retval None
Kojto 101:7cff1c4259d7 498 */
Kojto 101:7cff1c4259d7 499 #define __HAL_UART_HWCONTROL_CTS_DISABLE(__HANDLE__) \
Kojto 101:7cff1c4259d7 500 do{ \
Kojto 101:7cff1c4259d7 501 CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \
Kojto 101:7cff1c4259d7 502 (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_CTSE); \
Kojto 101:7cff1c4259d7 503 } while(0)
Kojto 101:7cff1c4259d7 504
Kojto 101:7cff1c4259d7 505 /** @brief Enable RTS flow control
Kojto 101:7cff1c4259d7 506 * This macro allows to enable RTS hardware flow control for a given UART instance,
Kojto 101:7cff1c4259d7 507 * without need to call HAL_UART_Init() function.
Kojto 101:7cff1c4259d7 508 * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
Kojto 101:7cff1c4259d7 509 * @note As macro is expected to be used for modifying RTS Hw flow control feature activation, without need
Kojto 101:7cff1c4259d7 510 * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
Kojto 101:7cff1c4259d7 511 * - UART instance should have already been initialised (through call of HAL_UART_Init() )
Kojto 101:7cff1c4259d7 512 * - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__))
Kojto 101:7cff1c4259d7 513 * and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)).
Kojto 101:7cff1c4259d7 514 * @param __HANDLE__: specifies the UART Handle.
Kojto 101:7cff1c4259d7 515 * The Handle Instance can be USART1, USART2 or LPUART.
Kojto 101:7cff1c4259d7 516 * @retval None
Kojto 101:7cff1c4259d7 517 */
Kojto 101:7cff1c4259d7 518 #define __HAL_UART_HWCONTROL_RTS_ENABLE(__HANDLE__) \
Kojto 101:7cff1c4259d7 519 do{ \
Kojto 101:7cff1c4259d7 520 SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE); \
Kojto 101:7cff1c4259d7 521 (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_RTSE; \
Kojto 101:7cff1c4259d7 522 } while(0)
Kojto 101:7cff1c4259d7 523
Kojto 101:7cff1c4259d7 524 /** @brief Disable RTS flow control
Kojto 101:7cff1c4259d7 525 * This macro allows to disable RTS hardware flow control for a given UART instance,
Kojto 101:7cff1c4259d7 526 * without need to call HAL_UART_Init() function.
Kojto 101:7cff1c4259d7 527 * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
Kojto 101:7cff1c4259d7 528 * @note As macro is expected to be used for modifying RTS Hw flow control feature activation, without need
Kojto 101:7cff1c4259d7 529 * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
Kojto 101:7cff1c4259d7 530 * - UART instance should have already been initialised (through call of HAL_UART_Init() )
Kojto 101:7cff1c4259d7 531 * - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__))
Kojto 101:7cff1c4259d7 532 * and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)).
Kojto 101:7cff1c4259d7 533 * @param __HANDLE__: specifies the UART Handle.
Kojto 101:7cff1c4259d7 534 * The Handle Instance can be USART1, USART2 or LPUART.
Kojto 101:7cff1c4259d7 535 * @retval None
Kojto 101:7cff1c4259d7 536 */
Kojto 101:7cff1c4259d7 537 #define __HAL_UART_HWCONTROL_RTS_DISABLE(__HANDLE__) \
Kojto 101:7cff1c4259d7 538 do{ \
Kojto 101:7cff1c4259d7 539 CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE);\
Kojto 101:7cff1c4259d7 540 (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_RTSE); \
Kojto 101:7cff1c4259d7 541 } while(0)
Kojto 101:7cff1c4259d7 542
Kojto 101:7cff1c4259d7 543 /** @brief macros to enables the UART's one bit sample method
Kojto 101:7cff1c4259d7 544 * @param __HANDLE__: specifies the UART Handle.
Kojto 101:7cff1c4259d7 545 * @retval None
Kojto 101:7cff1c4259d7 546 */
Kojto 101:7cff1c4259d7 547 #define __HAL_UART_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
Kojto 101:7cff1c4259d7 548
Kojto 101:7cff1c4259d7 549 /** @brief macros to disables the UART's one bit sample method
Kojto 101:7cff1c4259d7 550 * @param __HANDLE__: specifies the UART Handle.
Kojto 101:7cff1c4259d7 551 * @retval None
Kojto 101:7cff1c4259d7 552 */
Kojto 101:7cff1c4259d7 553 #define __HAL_UART_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint16_t)~((uint16_t)USART_CR3_ONEBIT))
Kojto 101:7cff1c4259d7 554
Kojto 101:7cff1c4259d7 555 /** @brief Enable UART
Kojto 101:7cff1c4259d7 556 * @param __HANDLE__: specifies the UART Handle.
Kojto 101:7cff1c4259d7 557 * @retval None
Kojto 101:7cff1c4259d7 558 */
Kojto 101:7cff1c4259d7 559 #define __HAL_UART_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
Kojto 101:7cff1c4259d7 560
Kojto 101:7cff1c4259d7 561 /** @brief Disable UART
Kojto 101:7cff1c4259d7 562 * @param __HANDLE__: specifies the UART Handle.
Kojto 101:7cff1c4259d7 563 * @retval None
Kojto 101:7cff1c4259d7 564 */
Kojto 101:7cff1c4259d7 565 #define __HAL_UART_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
Kojto 101:7cff1c4259d7 566 /**
Kojto 101:7cff1c4259d7 567 * @}
Kojto 101:7cff1c4259d7 568 */
Kojto 101:7cff1c4259d7 569
Kojto 101:7cff1c4259d7 570 /* Exported functions --------------------------------------------------------*/
Kojto 101:7cff1c4259d7 571 /** @addtogroup UART_Exported_Functions
Kojto 101:7cff1c4259d7 572 * @{
Kojto 101:7cff1c4259d7 573 */
Kojto 101:7cff1c4259d7 574
Kojto 101:7cff1c4259d7 575 /** @addtogroup UART_Exported_Functions_Group1
Kojto 101:7cff1c4259d7 576 * @{
Kojto 101:7cff1c4259d7 577 */
Kojto 101:7cff1c4259d7 578 /* Initialization/de-initialization functions **********************************/
Kojto 101:7cff1c4259d7 579 HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart);
Kojto 101:7cff1c4259d7 580 HAL_StatusTypeDef HAL_HalfDuplex_Init(UART_HandleTypeDef *huart);
Kojto 101:7cff1c4259d7 581 HAL_StatusTypeDef HAL_LIN_Init(UART_HandleTypeDef *huart, uint32_t BreakDetectLength);
Kojto 101:7cff1c4259d7 582 HAL_StatusTypeDef HAL_MultiProcessor_Init(UART_HandleTypeDef *huart, uint8_t Address, uint32_t WakeUpMethod);
Kojto 101:7cff1c4259d7 583 HAL_StatusTypeDef HAL_UART_DeInit (UART_HandleTypeDef *huart);
Kojto 101:7cff1c4259d7 584 void HAL_UART_MspInit(UART_HandleTypeDef *huart);
Kojto 101:7cff1c4259d7 585 void HAL_UART_MspDeInit(UART_HandleTypeDef *huart);
Kojto 101:7cff1c4259d7 586 /**
Kojto 101:7cff1c4259d7 587 * @}
Kojto 101:7cff1c4259d7 588 */
Kojto 101:7cff1c4259d7 589
Kojto 101:7cff1c4259d7 590 /** @addtogroup UART_Exported_Functions_Group2
Kojto 101:7cff1c4259d7 591 * @{
Kojto 101:7cff1c4259d7 592 */
Kojto 101:7cff1c4259d7 593 /* IO operation functions *******************************************************/
Kojto 101:7cff1c4259d7 594 HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
Kojto 101:7cff1c4259d7 595 HAL_StatusTypeDef HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
Kojto 101:7cff1c4259d7 596 HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
Kojto 101:7cff1c4259d7 597 HAL_StatusTypeDef HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
Kojto 101:7cff1c4259d7 598 HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
Kojto 101:7cff1c4259d7 599 HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
Kojto 101:7cff1c4259d7 600 HAL_StatusTypeDef HAL_UART_DMAPause(UART_HandleTypeDef *huart);
Kojto 101:7cff1c4259d7 601 HAL_StatusTypeDef HAL_UART_DMAResume(UART_HandleTypeDef *huart);
Kojto 101:7cff1c4259d7 602 HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart);
Kojto 101:7cff1c4259d7 603 void HAL_UART_IRQHandler(UART_HandleTypeDef *huart);
Kojto 101:7cff1c4259d7 604 void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart);
Kojto 101:7cff1c4259d7 605 void HAL_UART_TxHalfCpltCallback(UART_HandleTypeDef *huart);
Kojto 101:7cff1c4259d7 606 void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart);
Kojto 101:7cff1c4259d7 607 void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart);
Kojto 101:7cff1c4259d7 608 void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart);
Kojto 101:7cff1c4259d7 609 /**
Kojto 101:7cff1c4259d7 610 * @}
Kojto 101:7cff1c4259d7 611 */
Kojto 101:7cff1c4259d7 612
Kojto 101:7cff1c4259d7 613 /** @addtogroup UART_Exported_Functions_Group3
Kojto 101:7cff1c4259d7 614 * @{
Kojto 101:7cff1c4259d7 615 */
Kojto 101:7cff1c4259d7 616 /* Peripheral Control functions ************************************************/
Kojto 101:7cff1c4259d7 617 HAL_StatusTypeDef HAL_LIN_SendBreak(UART_HandleTypeDef *huart);
Kojto 101:7cff1c4259d7 618 HAL_StatusTypeDef HAL_MultiProcessor_EnterMuteMode(UART_HandleTypeDef *huart);
Kojto 101:7cff1c4259d7 619 HAL_StatusTypeDef HAL_MultiProcessor_ExitMuteMode(UART_HandleTypeDef *huart);
Kojto 101:7cff1c4259d7 620 HAL_StatusTypeDef HAL_HalfDuplex_EnableTransmitter(UART_HandleTypeDef *huart);
Kojto 101:7cff1c4259d7 621 HAL_StatusTypeDef HAL_HalfDuplex_EnableReceiver(UART_HandleTypeDef *huart);
Kojto 101:7cff1c4259d7 622 /**
Kojto 101:7cff1c4259d7 623 * @}
Kojto 101:7cff1c4259d7 624 */
Kojto 101:7cff1c4259d7 625
Kojto 101:7cff1c4259d7 626 /** @addtogroup UART_Exported_Functions_Group4
Kojto 101:7cff1c4259d7 627 * @{
Kojto 101:7cff1c4259d7 628 */
Kojto 101:7cff1c4259d7 629 /* Peripheral State functions **************************************************/
Kojto 101:7cff1c4259d7 630 HAL_UART_StateTypeDef HAL_UART_GetState(UART_HandleTypeDef *huart);
Kojto 101:7cff1c4259d7 631 uint32_t HAL_UART_GetError(UART_HandleTypeDef *huart);
Kojto 101:7cff1c4259d7 632 /**
Kojto 101:7cff1c4259d7 633 * @}
Kojto 101:7cff1c4259d7 634 */
Kojto 101:7cff1c4259d7 635
Kojto 101:7cff1c4259d7 636 /**
Kojto 101:7cff1c4259d7 637 * @}
Kojto 101:7cff1c4259d7 638 */
Kojto 101:7cff1c4259d7 639 /* Private types -------------------------------------------------------------*/
Kojto 101:7cff1c4259d7 640 /* Private variables ---------------------------------------------------------*/
Kojto 101:7cff1c4259d7 641 /* Private constants ---------------------------------------------------------*/
Kojto 101:7cff1c4259d7 642 /** @defgroup UART_Private_Constants UART Private Constants
Kojto 101:7cff1c4259d7 643 * @{
Kojto 101:7cff1c4259d7 644 */
Kojto 101:7cff1c4259d7 645 /** @brief UART interruptions flag mask
Kojto 101:7cff1c4259d7 646 *
Kojto 101:7cff1c4259d7 647 */
Kojto 101:7cff1c4259d7 648 #define UART_CR1_REG_INDEX 1
Kojto 101:7cff1c4259d7 649 #define UART_CR2_REG_INDEX 2
Kojto 101:7cff1c4259d7 650 #define UART_CR3_REG_INDEX 3
Kojto 101:7cff1c4259d7 651 /**
Kojto 101:7cff1c4259d7 652 * @}
Kojto 101:7cff1c4259d7 653 */
Kojto 101:7cff1c4259d7 654
Kojto 101:7cff1c4259d7 655 /* Private macros ------------------------------------------------------------*/
Kojto 101:7cff1c4259d7 656 /** @defgroup UART_Private_Macros UART Private Macros
Kojto 101:7cff1c4259d7 657 * @{
Kojto 101:7cff1c4259d7 658 */
Kojto 101:7cff1c4259d7 659 #define IS_UART_WORD_LENGTH(LENGTH) (((LENGTH) == UART_WORDLENGTH_8B) || \
Kojto 101:7cff1c4259d7 660 ((LENGTH) == UART_WORDLENGTH_9B))
Kojto 101:7cff1c4259d7 661 #define IS_UART_LIN_WORD_LENGTH(LENGTH) (((LENGTH) == UART_WORDLENGTH_8B))
Kojto 101:7cff1c4259d7 662 #define IS_UART_STOPBITS(STOPBITS) (((STOPBITS) == UART_STOPBITS_1) || \
Kojto 101:7cff1c4259d7 663 ((STOPBITS) == UART_STOPBITS_2))
Kojto 101:7cff1c4259d7 664 #define IS_UART_PARITY(PARITY) (((PARITY) == UART_PARITY_NONE) || \
Kojto 101:7cff1c4259d7 665 ((PARITY) == UART_PARITY_EVEN) || \
Kojto 101:7cff1c4259d7 666 ((PARITY) == UART_PARITY_ODD))
Kojto 101:7cff1c4259d7 667 #define IS_UART_HARDWARE_FLOW_CONTROL(CONTROL)\
Kojto 101:7cff1c4259d7 668 (((CONTROL) == UART_HWCONTROL_NONE) || \
Kojto 101:7cff1c4259d7 669 ((CONTROL) == UART_HWCONTROL_RTS) || \
Kojto 101:7cff1c4259d7 670 ((CONTROL) == UART_HWCONTROL_CTS) || \
Kojto 101:7cff1c4259d7 671 ((CONTROL) == UART_HWCONTROL_RTS_CTS))
Kojto 101:7cff1c4259d7 672 #define IS_UART_MODE(MODE) ((((MODE) & (uint32_t)0x0000FFF3) == 0x00) && ((MODE) != (uint32_t)0x000000))
Kojto 101:7cff1c4259d7 673 #define IS_UART_STATE(STATE) (((STATE) == UART_STATE_DISABLE) || \
Kojto 101:7cff1c4259d7 674 ((STATE) == UART_STATE_ENABLE))
Kojto 101:7cff1c4259d7 675 #define IS_UART_OVERSAMPLING(SAMPLING) (((SAMPLING) == UART_OVERSAMPLING_16) || \
Kojto 101:7cff1c4259d7 676 ((SAMPLING) == UART_OVERSAMPLING_8))
Kojto 101:7cff1c4259d7 677 #define IS_UART_LIN_OVERSAMPLING(SAMPLING) (((SAMPLING) == UART_OVERSAMPLING_16))
Kojto 101:7cff1c4259d7 678 #define IS_UART_LIN_BREAK_DETECT_LENGTH(LENGTH) (((LENGTH) == UART_LINBREAKDETECTLENGTH_10B) || \
Kojto 101:7cff1c4259d7 679 ((LENGTH) == UART_LINBREAKDETECTLENGTH_11B))
Kojto 101:7cff1c4259d7 680 #define IS_UART_WAKEUPMETHOD(WAKEUP) (((WAKEUP) == UART_WAKEUPMETHOD_IDLELINE) || \
Kojto 101:7cff1c4259d7 681 ((WAKEUP) == UART_WAKEUPMETHOD_ADDRESSMARK))
Kojto 101:7cff1c4259d7 682 #define IS_UART_BAUDRATE(BAUDRATE) ((BAUDRATE) < 10500001)
Kojto 101:7cff1c4259d7 683 #define IS_UART_ADDRESS(ADDRESS) ((ADDRESS) <= 0xF)
Kojto 101:7cff1c4259d7 684
Kojto 101:7cff1c4259d7 685 #define UART_DIV_SAMPLING16(_PCLK_, _BAUD_) (((_PCLK_)*25)/(4*(_BAUD_)))
Kojto 101:7cff1c4259d7 686 #define UART_DIVMANT_SAMPLING16(_PCLK_, _BAUD_) (UART_DIV_SAMPLING16((_PCLK_), (_BAUD_))/100)
Kojto 101:7cff1c4259d7 687 #define UART_DIVFRAQ_SAMPLING16(_PCLK_, _BAUD_) (((UART_DIV_SAMPLING16((_PCLK_), (_BAUD_)) - (UART_DIVMANT_SAMPLING16((_PCLK_), (_BAUD_)) * 100)) * 16 + 50) / 100)
Kojto 101:7cff1c4259d7 688 #define UART_BRR_SAMPLING16(_PCLK_, _BAUD_) ((UART_DIVMANT_SAMPLING16((_PCLK_), (_BAUD_)) << 4)|(UART_DIVFRAQ_SAMPLING16((_PCLK_), (_BAUD_)) & 0x0F))
Kojto 101:7cff1c4259d7 689
Kojto 101:7cff1c4259d7 690 #define UART_DIV_SAMPLING8(_PCLK_, _BAUD_) (((_PCLK_)*25)/(2*(_BAUD_)))
Kojto 101:7cff1c4259d7 691 #define UART_DIVMANT_SAMPLING8(_PCLK_, _BAUD_) (UART_DIV_SAMPLING8((_PCLK_), (_BAUD_))/100)
Kojto 101:7cff1c4259d7 692 #define UART_DIVFRAQ_SAMPLING8(_PCLK_, _BAUD_) (((UART_DIV_SAMPLING8((_PCLK_), (_BAUD_)) - (UART_DIVMANT_SAMPLING8((_PCLK_), (_BAUD_)) * 100)) * 16 + 50) / 100)
Kojto 101:7cff1c4259d7 693 #define UART_BRR_SAMPLING8(_PCLK_, _BAUD_) ((UART_DIVMANT_SAMPLING8((_PCLK_), (_BAUD_)) << 4)|(UART_DIVFRAQ_SAMPLING8((_PCLK_), (_BAUD_)) & 0x0F))
Kojto 101:7cff1c4259d7 694
Kojto 101:7cff1c4259d7 695 /**
Kojto 101:7cff1c4259d7 696 * @}
Kojto 101:7cff1c4259d7 697 */
Kojto 101:7cff1c4259d7 698
Kojto 101:7cff1c4259d7 699 /* Private functions ---------------------------------------------------------*/
Kojto 101:7cff1c4259d7 700 /** @defgroup UART_Private_Functions UART Private Functions
Kojto 101:7cff1c4259d7 701 * @{
Kojto 101:7cff1c4259d7 702 */
Kojto 101:7cff1c4259d7 703
Kojto 101:7cff1c4259d7 704 /**
Kojto 101:7cff1c4259d7 705 * @}
Kojto 101:7cff1c4259d7 706 */
Kojto 101:7cff1c4259d7 707
Kojto 101:7cff1c4259d7 708 /**
Kojto 101:7cff1c4259d7 709 * @}
Kojto 101:7cff1c4259d7 710 */
Kojto 101:7cff1c4259d7 711
Kojto 101:7cff1c4259d7 712 /**
Kojto 101:7cff1c4259d7 713 * @}
Kojto 101:7cff1c4259d7 714 */
Kojto 101:7cff1c4259d7 715
Kojto 101:7cff1c4259d7 716 #ifdef __cplusplus
Kojto 101:7cff1c4259d7 717 }
Kojto 101:7cff1c4259d7 718 #endif
Kojto 101:7cff1c4259d7 719
Kojto 101:7cff1c4259d7 720 #endif /* __STM32F4xx_HAL_UART_H */
Kojto 101:7cff1c4259d7 721
Kojto 101:7cff1c4259d7 722 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/