A simple 128x32 graphical LCD program to quickstart with LCD on ARM mbed IoT Starter Kit. This requires mbed Applciation Shield with FRDM-K64F platform.

Dependencies:   C12832

Committer:
tushki7
Date:
Sun Apr 12 15:45:52 2015 +0000
Revision:
1:eb68c94a8ee5
Parent:
0:60d829a0353a
A simple 128x32 LCD program with ARM mbed IoT Starter Kit;

Who changed what in which revision?

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