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