version_2.0
Dependents: cc3000_ping_demo_try_2
Fork of mbed by
TARGET_NUCLEO_L152RE/stm32l1xx_usart.h@86:4f9a848d74c7, 2014-06-25 (annotated)
- Committer:
- erezi
- Date:
- Wed Jun 25 06:08:49 2014 +0000
- Revision:
- 86:4f9a848d74c7
- Parent:
- 81:7d30d6019079
version_2.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emilmont | 77:869cf507173a | 1 | /** |
emilmont | 77:869cf507173a | 2 | ****************************************************************************** |
emilmont | 77:869cf507173a | 3 | * @file stm32l1xx_usart.h |
emilmont | 77:869cf507173a | 4 | * @author MCD Application Team |
emilmont | 77:869cf507173a | 5 | * @version V1.3.0 |
emilmont | 77:869cf507173a | 6 | * @date 31-January-2014 |
emilmont | 77:869cf507173a | 7 | * @brief This file contains all the functions prototypes for the USART |
emilmont | 77:869cf507173a | 8 | * firmware library. |
emilmont | 77:869cf507173a | 9 | ****************************************************************************** |
emilmont | 77:869cf507173a | 10 | * @attention |
emilmont | 77:869cf507173a | 11 | * |
bogdanm | 81:7d30d6019079 | 12 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
emilmont | 77:869cf507173a | 13 | * |
bogdanm | 81:7d30d6019079 | 14 | * Redistribution and use in source and binary forms, with or without modification, |
bogdanm | 81:7d30d6019079 | 15 | * are permitted provided that the following conditions are met: |
bogdanm | 81:7d30d6019079 | 16 | * 1. Redistributions of source code must retain the above copyright notice, |
bogdanm | 81:7d30d6019079 | 17 | * this list of conditions and the following disclaimer. |
bogdanm | 81:7d30d6019079 | 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
bogdanm | 81:7d30d6019079 | 19 | * this list of conditions and the following disclaimer in the documentation |
bogdanm | 81:7d30d6019079 | 20 | * and/or other materials provided with the distribution. |
bogdanm | 81:7d30d6019079 | 21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
bogdanm | 81:7d30d6019079 | 22 | * may be used to endorse or promote products derived from this software |
bogdanm | 81:7d30d6019079 | 23 | * without specific prior written permission. |
emilmont | 77:869cf507173a | 24 | * |
bogdanm | 81:7d30d6019079 | 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
bogdanm | 81:7d30d6019079 | 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
bogdanm | 81:7d30d6019079 | 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
bogdanm | 81:7d30d6019079 | 28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
bogdanm | 81:7d30d6019079 | 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
bogdanm | 81:7d30d6019079 | 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
bogdanm | 81:7d30d6019079 | 31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
bogdanm | 81:7d30d6019079 | 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
bogdanm | 81:7d30d6019079 | 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
bogdanm | 81:7d30d6019079 | 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
emilmont | 77:869cf507173a | 35 | * |
emilmont | 77:869cf507173a | 36 | ****************************************************************************** |
emilmont | 77:869cf507173a | 37 | */ |
emilmont | 77:869cf507173a | 38 | |
emilmont | 77:869cf507173a | 39 | /* Define to prevent recursive inclusion -------------------------------------*/ |
emilmont | 77:869cf507173a | 40 | #ifndef __STM32L1xx_USART_H |
emilmont | 77:869cf507173a | 41 | #define __STM32L1xx_USART_H |
emilmont | 77:869cf507173a | 42 | |
emilmont | 77:869cf507173a | 43 | #ifdef __cplusplus |
emilmont | 77:869cf507173a | 44 | extern "C" { |
emilmont | 77:869cf507173a | 45 | #endif |
emilmont | 77:869cf507173a | 46 | |
emilmont | 77:869cf507173a | 47 | /* Includes ------------------------------------------------------------------*/ |
emilmont | 77:869cf507173a | 48 | #include "stm32l1xx.h" |
emilmont | 77:869cf507173a | 49 | |
emilmont | 77:869cf507173a | 50 | /** @addtogroup STM32L1xx_StdPeriph_Driver |
emilmont | 77:869cf507173a | 51 | * @{ |
emilmont | 77:869cf507173a | 52 | */ |
emilmont | 77:869cf507173a | 53 | |
emilmont | 77:869cf507173a | 54 | /** @addtogroup USART |
emilmont | 77:869cf507173a | 55 | * @{ |
emilmont | 77:869cf507173a | 56 | */ |
emilmont | 77:869cf507173a | 57 | |
emilmont | 77:869cf507173a | 58 | /* Exported types ------------------------------------------------------------*/ |
emilmont | 77:869cf507173a | 59 | |
emilmont | 77:869cf507173a | 60 | /** |
emilmont | 77:869cf507173a | 61 | * @brief USART Init Structure definition |
emilmont | 77:869cf507173a | 62 | */ |
emilmont | 77:869cf507173a | 63 | |
emilmont | 77:869cf507173a | 64 | typedef struct |
emilmont | 77:869cf507173a | 65 | { |
emilmont | 77:869cf507173a | 66 | uint32_t USART_BaudRate; /*!< This member configures the USART communication baud rate. |
emilmont | 77:869cf507173a | 67 | The baud rate is computed using the following formula: |
emilmont | 77:869cf507173a | 68 | - IntegerDivider = ((PCLKx) / (8 * (OVR8+1) * (USART_InitStruct->USART_BaudRate))) |
emilmont | 77:869cf507173a | 69 | - FractionalDivider = ((IntegerDivider - ((u32) IntegerDivider)) * 8 * (OVR8+1)) + 0.5 |
emilmont | 77:869cf507173a | 70 | Where OVR8 is the "oversampling by 8 mode" configuration bit in the CR1 register. */ |
emilmont | 77:869cf507173a | 71 | |
emilmont | 77:869cf507173a | 72 | uint16_t USART_WordLength; /*!< Specifies the number of data bits transmitted or received in a frame. |
emilmont | 77:869cf507173a | 73 | This parameter can be a value of @ref USART_Word_Length */ |
emilmont | 77:869cf507173a | 74 | |
emilmont | 77:869cf507173a | 75 | uint16_t USART_StopBits; /*!< Specifies the number of stop bits transmitted. |
emilmont | 77:869cf507173a | 76 | This parameter can be a value of @ref USART_Stop_Bits */ |
emilmont | 77:869cf507173a | 77 | |
emilmont | 77:869cf507173a | 78 | uint16_t USART_Parity; /*!< Specifies the parity mode. |
emilmont | 77:869cf507173a | 79 | This parameter can be a value of @ref USART_Parity |
emilmont | 77:869cf507173a | 80 | @note When parity is enabled, the computed parity is inserted |
emilmont | 77:869cf507173a | 81 | at the MSB position of the transmitted data (9th bit when |
emilmont | 77:869cf507173a | 82 | the word length is set to 9 data bits; 8th bit when the |
emilmont | 77:869cf507173a | 83 | word length is set to 8 data bits). */ |
emilmont | 77:869cf507173a | 84 | |
emilmont | 77:869cf507173a | 85 | uint16_t USART_Mode; /*!< Specifies wether the Receive or Transmit mode is enabled or disabled. |
emilmont | 77:869cf507173a | 86 | This parameter can be a value of @ref USART_Mode */ |
emilmont | 77:869cf507173a | 87 | |
emilmont | 77:869cf507173a | 88 | uint16_t USART_HardwareFlowControl; /*!< Specifies wether the hardware flow control mode is enabled |
emilmont | 77:869cf507173a | 89 | or disabled. |
emilmont | 77:869cf507173a | 90 | This parameter can be a value of @ref USART_Hardware_Flow_Control */ |
emilmont | 77:869cf507173a | 91 | } USART_InitTypeDef; |
emilmont | 77:869cf507173a | 92 | |
emilmont | 77:869cf507173a | 93 | /** |
emilmont | 77:869cf507173a | 94 | * @brief USART Clock Init Structure definition |
emilmont | 77:869cf507173a | 95 | */ |
emilmont | 77:869cf507173a | 96 | |
emilmont | 77:869cf507173a | 97 | typedef struct |
emilmont | 77:869cf507173a | 98 | { |
emilmont | 77:869cf507173a | 99 | |
emilmont | 77:869cf507173a | 100 | uint16_t USART_Clock; /*!< Specifies whether the USART clock is enabled or disabled. |
emilmont | 77:869cf507173a | 101 | This parameter can be a value of @ref USART_Clock */ |
emilmont | 77:869cf507173a | 102 | |
emilmont | 77:869cf507173a | 103 | uint16_t USART_CPOL; /*!< Specifies the steady state of the serial clock. |
emilmont | 77:869cf507173a | 104 | This parameter can be a value of @ref USART_Clock_Polarity */ |
emilmont | 77:869cf507173a | 105 | |
emilmont | 77:869cf507173a | 106 | uint16_t USART_CPHA; /*!< Specifies the clock transition on which the bit capture is made. |
emilmont | 77:869cf507173a | 107 | This parameter can be a value of @ref USART_Clock_Phase */ |
emilmont | 77:869cf507173a | 108 | |
emilmont | 77:869cf507173a | 109 | uint16_t USART_LastBit; /*!< Specifies whether the clock pulse corresponding to the last transmitted |
emilmont | 77:869cf507173a | 110 | data bit (MSB) has to be output on the SCLK pin in synchronous mode. |
emilmont | 77:869cf507173a | 111 | This parameter can be a value of @ref USART_Last_Bit */ |
emilmont | 77:869cf507173a | 112 | } USART_ClockInitTypeDef; |
emilmont | 77:869cf507173a | 113 | |
emilmont | 77:869cf507173a | 114 | /* Exported constants --------------------------------------------------------*/ |
emilmont | 77:869cf507173a | 115 | |
emilmont | 77:869cf507173a | 116 | /** @defgroup USART_Exported_Constants |
emilmont | 77:869cf507173a | 117 | * @{ |
emilmont | 77:869cf507173a | 118 | */ |
emilmont | 77:869cf507173a | 119 | |
emilmont | 77:869cf507173a | 120 | #define IS_USART_ALL_PERIPH(PERIPH) (((PERIPH) == USART1) || \ |
emilmont | 77:869cf507173a | 121 | ((PERIPH) == USART2) || \ |
emilmont | 77:869cf507173a | 122 | ((PERIPH) == USART3) || \ |
emilmont | 77:869cf507173a | 123 | ((PERIPH) == UART4) || \ |
emilmont | 77:869cf507173a | 124 | ((PERIPH) == UART5)) |
emilmont | 77:869cf507173a | 125 | |
emilmont | 77:869cf507173a | 126 | #define IS_USART_123_PERIPH(PERIPH) (((PERIPH) == USART1) || \ |
emilmont | 77:869cf507173a | 127 | ((PERIPH) == USART2) || \ |
emilmont | 77:869cf507173a | 128 | ((PERIPH) == USART3)) |
emilmont | 77:869cf507173a | 129 | |
emilmont | 77:869cf507173a | 130 | /** @defgroup USART_Word_Length |
emilmont | 77:869cf507173a | 131 | * @{ |
emilmont | 77:869cf507173a | 132 | */ |
emilmont | 77:869cf507173a | 133 | |
emilmont | 77:869cf507173a | 134 | #define USART_WordLength_8b ((uint16_t)0x0000) |
emilmont | 77:869cf507173a | 135 | #define USART_WordLength_9b ((uint16_t)0x1000) |
emilmont | 77:869cf507173a | 136 | |
emilmont | 77:869cf507173a | 137 | #define IS_USART_WORD_LENGTH(LENGTH) (((LENGTH) == USART_WordLength_8b) || \ |
emilmont | 77:869cf507173a | 138 | ((LENGTH) == USART_WordLength_9b)) |
emilmont | 77:869cf507173a | 139 | /** |
emilmont | 77:869cf507173a | 140 | * @} |
emilmont | 77:869cf507173a | 141 | */ |
emilmont | 77:869cf507173a | 142 | |
emilmont | 77:869cf507173a | 143 | /** @defgroup USART_Stop_Bits |
emilmont | 77:869cf507173a | 144 | * @{ |
emilmont | 77:869cf507173a | 145 | */ |
emilmont | 77:869cf507173a | 146 | |
emilmont | 77:869cf507173a | 147 | #define USART_StopBits_1 ((uint16_t)0x0000) |
emilmont | 77:869cf507173a | 148 | #define USART_StopBits_0_5 ((uint16_t)0x1000) |
emilmont | 77:869cf507173a | 149 | #define USART_StopBits_2 ((uint16_t)0x2000) |
emilmont | 77:869cf507173a | 150 | #define USART_StopBits_1_5 ((uint16_t)0x3000) |
emilmont | 77:869cf507173a | 151 | #define IS_USART_STOPBITS(STOPBITS) (((STOPBITS) == USART_StopBits_1) || \ |
emilmont | 77:869cf507173a | 152 | ((STOPBITS) == USART_StopBits_0_5) || \ |
emilmont | 77:869cf507173a | 153 | ((STOPBITS) == USART_StopBits_2) || \ |
emilmont | 77:869cf507173a | 154 | ((STOPBITS) == USART_StopBits_1_5)) |
emilmont | 77:869cf507173a | 155 | /** |
emilmont | 77:869cf507173a | 156 | * @} |
emilmont | 77:869cf507173a | 157 | */ |
emilmont | 77:869cf507173a | 158 | |
emilmont | 77:869cf507173a | 159 | /** @defgroup USART_Parity |
emilmont | 77:869cf507173a | 160 | * @{ |
emilmont | 77:869cf507173a | 161 | */ |
emilmont | 77:869cf507173a | 162 | |
emilmont | 77:869cf507173a | 163 | #define USART_Parity_No ((uint16_t)0x0000) |
emilmont | 77:869cf507173a | 164 | #define USART_Parity_Even ((uint16_t)0x0400) |
emilmont | 77:869cf507173a | 165 | #define USART_Parity_Odd ((uint16_t)0x0600) |
emilmont | 77:869cf507173a | 166 | #define IS_USART_PARITY(PARITY) (((PARITY) == USART_Parity_No) || \ |
emilmont | 77:869cf507173a | 167 | ((PARITY) == USART_Parity_Even) || \ |
emilmont | 77:869cf507173a | 168 | ((PARITY) == USART_Parity_Odd)) |
emilmont | 77:869cf507173a | 169 | /** |
emilmont | 77:869cf507173a | 170 | * @} |
emilmont | 77:869cf507173a | 171 | */ |
emilmont | 77:869cf507173a | 172 | |
emilmont | 77:869cf507173a | 173 | /** @defgroup USART_Mode |
emilmont | 77:869cf507173a | 174 | * @{ |
emilmont | 77:869cf507173a | 175 | */ |
emilmont | 77:869cf507173a | 176 | |
emilmont | 77:869cf507173a | 177 | #define USART_Mode_Rx ((uint16_t)0x0004) |
emilmont | 77:869cf507173a | 178 | #define USART_Mode_Tx ((uint16_t)0x0008) |
emilmont | 77:869cf507173a | 179 | #define IS_USART_MODE(MODE) ((((MODE) & (uint16_t)0xFFF3) == 0x00) && ((MODE) != (uint16_t)0x00)) |
emilmont | 77:869cf507173a | 180 | /** |
emilmont | 77:869cf507173a | 181 | * @} |
emilmont | 77:869cf507173a | 182 | */ |
emilmont | 77:869cf507173a | 183 | |
emilmont | 77:869cf507173a | 184 | /** @defgroup USART_Hardware_Flow_Control |
emilmont | 77:869cf507173a | 185 | * @{ |
emilmont | 77:869cf507173a | 186 | */ |
emilmont | 77:869cf507173a | 187 | #define USART_HardwareFlowControl_None ((uint16_t)0x0000) |
emilmont | 77:869cf507173a | 188 | #define USART_HardwareFlowControl_RTS ((uint16_t)0x0100) |
emilmont | 77:869cf507173a | 189 | #define USART_HardwareFlowControl_CTS ((uint16_t)0x0200) |
emilmont | 77:869cf507173a | 190 | #define USART_HardwareFlowControl_RTS_CTS ((uint16_t)0x0300) |
emilmont | 77:869cf507173a | 191 | #define IS_USART_HARDWARE_FLOW_CONTROL(CONTROL)\ |
emilmont | 77:869cf507173a | 192 | (((CONTROL) == USART_HardwareFlowControl_None) || \ |
emilmont | 77:869cf507173a | 193 | ((CONTROL) == USART_HardwareFlowControl_RTS) || \ |
emilmont | 77:869cf507173a | 194 | ((CONTROL) == USART_HardwareFlowControl_CTS) || \ |
emilmont | 77:869cf507173a | 195 | ((CONTROL) == USART_HardwareFlowControl_RTS_CTS)) |
emilmont | 77:869cf507173a | 196 | /** |
emilmont | 77:869cf507173a | 197 | * @} |
emilmont | 77:869cf507173a | 198 | */ |
emilmont | 77:869cf507173a | 199 | |
emilmont | 77:869cf507173a | 200 | /** @defgroup USART_Clock |
emilmont | 77:869cf507173a | 201 | * @{ |
emilmont | 77:869cf507173a | 202 | */ |
emilmont | 77:869cf507173a | 203 | #define USART_Clock_Disable ((uint16_t)0x0000) |
emilmont | 77:869cf507173a | 204 | #define USART_Clock_Enable ((uint16_t)0x0800) |
emilmont | 77:869cf507173a | 205 | #define IS_USART_CLOCK(CLOCK) (((CLOCK) == USART_Clock_Disable) || \ |
emilmont | 77:869cf507173a | 206 | ((CLOCK) == USART_Clock_Enable)) |
emilmont | 77:869cf507173a | 207 | /** |
emilmont | 77:869cf507173a | 208 | * @} |
emilmont | 77:869cf507173a | 209 | */ |
emilmont | 77:869cf507173a | 210 | |
emilmont | 77:869cf507173a | 211 | /** @defgroup USART_Clock_Polarity |
emilmont | 77:869cf507173a | 212 | * @{ |
emilmont | 77:869cf507173a | 213 | */ |
emilmont | 77:869cf507173a | 214 | |
emilmont | 77:869cf507173a | 215 | #define USART_CPOL_Low ((uint16_t)0x0000) |
emilmont | 77:869cf507173a | 216 | #define USART_CPOL_High ((uint16_t)0x0400) |
emilmont | 77:869cf507173a | 217 | #define IS_USART_CPOL(CPOL) (((CPOL) == USART_CPOL_Low) || ((CPOL) == USART_CPOL_High)) |
emilmont | 77:869cf507173a | 218 | |
emilmont | 77:869cf507173a | 219 | /** |
emilmont | 77:869cf507173a | 220 | * @} |
emilmont | 77:869cf507173a | 221 | */ |
emilmont | 77:869cf507173a | 222 | |
emilmont | 77:869cf507173a | 223 | /** @defgroup USART_Clock_Phase |
emilmont | 77:869cf507173a | 224 | * @{ |
emilmont | 77:869cf507173a | 225 | */ |
emilmont | 77:869cf507173a | 226 | |
emilmont | 77:869cf507173a | 227 | #define USART_CPHA_1Edge ((uint16_t)0x0000) |
emilmont | 77:869cf507173a | 228 | #define USART_CPHA_2Edge ((uint16_t)0x0200) |
emilmont | 77:869cf507173a | 229 | #define IS_USART_CPHA(CPHA) (((CPHA) == USART_CPHA_1Edge) || ((CPHA) == USART_CPHA_2Edge)) |
emilmont | 77:869cf507173a | 230 | |
emilmont | 77:869cf507173a | 231 | /** |
emilmont | 77:869cf507173a | 232 | * @} |
emilmont | 77:869cf507173a | 233 | */ |
emilmont | 77:869cf507173a | 234 | |
emilmont | 77:869cf507173a | 235 | /** @defgroup USART_Last_Bit |
emilmont | 77:869cf507173a | 236 | * @{ |
emilmont | 77:869cf507173a | 237 | */ |
emilmont | 77:869cf507173a | 238 | |
emilmont | 77:869cf507173a | 239 | #define USART_LastBit_Disable ((uint16_t)0x0000) |
emilmont | 77:869cf507173a | 240 | #define USART_LastBit_Enable ((uint16_t)0x0100) |
emilmont | 77:869cf507173a | 241 | #define IS_USART_LASTBIT(LASTBIT) (((LASTBIT) == USART_LastBit_Disable) || \ |
emilmont | 77:869cf507173a | 242 | ((LASTBIT) == USART_LastBit_Enable)) |
emilmont | 77:869cf507173a | 243 | /** |
emilmont | 77:869cf507173a | 244 | * @} |
emilmont | 77:869cf507173a | 245 | */ |
emilmont | 77:869cf507173a | 246 | |
emilmont | 77:869cf507173a | 247 | /** @defgroup USART_Interrupt_definition |
emilmont | 77:869cf507173a | 248 | * @{ |
emilmont | 77:869cf507173a | 249 | */ |
emilmont | 77:869cf507173a | 250 | |
emilmont | 77:869cf507173a | 251 | #define USART_IT_PE ((uint16_t)0x0028) |
emilmont | 77:869cf507173a | 252 | #define USART_IT_TXE ((uint16_t)0x0727) |
emilmont | 77:869cf507173a | 253 | #define USART_IT_TC ((uint16_t)0x0626) |
emilmont | 77:869cf507173a | 254 | #define USART_IT_RXNE ((uint16_t)0x0525) |
emilmont | 77:869cf507173a | 255 | #define USART_IT_IDLE ((uint16_t)0x0424) |
emilmont | 77:869cf507173a | 256 | #define USART_IT_LBD ((uint16_t)0x0846) |
emilmont | 77:869cf507173a | 257 | #define USART_IT_ORE_RX ((uint16_t)0x0325) /* In case interrupt is generated if the RXNEIE bit is set */ |
emilmont | 77:869cf507173a | 258 | #define USART_IT_CTS ((uint16_t)0x096A) |
emilmont | 77:869cf507173a | 259 | #define USART_IT_ERR ((uint16_t)0x0060) |
emilmont | 77:869cf507173a | 260 | #define USART_IT_ORE_ER ((uint16_t)0x0360) /* In case interrupt is generated if the EIE bit is set */ |
emilmont | 77:869cf507173a | 261 | #define USART_IT_NE ((uint16_t)0x0260) |
emilmont | 77:869cf507173a | 262 | #define USART_IT_FE ((uint16_t)0x0160) |
emilmont | 77:869cf507173a | 263 | |
emilmont | 77:869cf507173a | 264 | /** @defgroup USART_Legacy |
emilmont | 77:869cf507173a | 265 | * @{ |
emilmont | 77:869cf507173a | 266 | */ |
emilmont | 77:869cf507173a | 267 | #define USART_IT_ORE USART_IT_ORE_ER |
emilmont | 77:869cf507173a | 268 | /** |
emilmont | 77:869cf507173a | 269 | * @} |
emilmont | 77:869cf507173a | 270 | */ |
emilmont | 77:869cf507173a | 271 | |
emilmont | 77:869cf507173a | 272 | #define IS_USART_CONFIG_IT(IT) (((IT) == USART_IT_PE) || ((IT) == USART_IT_TXE) || \ |
emilmont | 77:869cf507173a | 273 | ((IT) == USART_IT_TC) || ((IT) == USART_IT_RXNE) || \ |
emilmont | 77:869cf507173a | 274 | ((IT) == USART_IT_IDLE) || ((IT) == USART_IT_LBD) || \ |
emilmont | 77:869cf507173a | 275 | ((IT) == USART_IT_CTS) || ((IT) == USART_IT_ERR)) |
emilmont | 77:869cf507173a | 276 | #define IS_USART_GET_IT(IT) (((IT) == USART_IT_PE) || ((IT) == USART_IT_TXE) || \ |
emilmont | 77:869cf507173a | 277 | ((IT) == USART_IT_TC) || ((IT) == USART_IT_RXNE) || \ |
emilmont | 77:869cf507173a | 278 | ((IT) == USART_IT_IDLE) || ((IT) == USART_IT_LBD) || \ |
emilmont | 77:869cf507173a | 279 | ((IT) == USART_IT_CTS) || ((IT) == USART_IT_ORE_RX) || \ |
emilmont | 77:869cf507173a | 280 | ((IT) == USART_IT_ORE_ER) || ((IT) == USART_IT_NE) || \ |
emilmont | 77:869cf507173a | 281 | ((IT) == USART_IT_FE)) |
emilmont | 77:869cf507173a | 282 | #define IS_USART_CLEAR_IT(IT) (((IT) == USART_IT_TC) || ((IT) == USART_IT_RXNE) || \ |
emilmont | 77:869cf507173a | 283 | ((IT) == USART_IT_LBD) || ((IT) == USART_IT_CTS)) |
emilmont | 77:869cf507173a | 284 | /** |
emilmont | 77:869cf507173a | 285 | * @} |
emilmont | 77:869cf507173a | 286 | */ |
emilmont | 77:869cf507173a | 287 | |
emilmont | 77:869cf507173a | 288 | /** @defgroup USART_DMA_Requests |
emilmont | 77:869cf507173a | 289 | * @{ |
emilmont | 77:869cf507173a | 290 | */ |
emilmont | 77:869cf507173a | 291 | |
emilmont | 77:869cf507173a | 292 | #define USART_DMAReq_Tx ((uint16_t)0x0080) |
emilmont | 77:869cf507173a | 293 | #define USART_DMAReq_Rx ((uint16_t)0x0040) |
emilmont | 77:869cf507173a | 294 | #define IS_USART_DMAREQ(DMAREQ) ((((DMAREQ) & (uint16_t)0xFF3F) == 0x00) && ((DMAREQ) != (uint16_t)0x00)) |
emilmont | 77:869cf507173a | 295 | |
emilmont | 77:869cf507173a | 296 | /** |
emilmont | 77:869cf507173a | 297 | * @} |
emilmont | 77:869cf507173a | 298 | */ |
emilmont | 77:869cf507173a | 299 | |
emilmont | 77:869cf507173a | 300 | /** @defgroup USART_WakeUp_methods |
emilmont | 77:869cf507173a | 301 | * @{ |
emilmont | 77:869cf507173a | 302 | */ |
emilmont | 77:869cf507173a | 303 | |
emilmont | 77:869cf507173a | 304 | #define USART_WakeUp_IdleLine ((uint16_t)0x0000) |
emilmont | 77:869cf507173a | 305 | #define USART_WakeUp_AddressMark ((uint16_t)0x0800) |
emilmont | 77:869cf507173a | 306 | #define IS_USART_WAKEUP(WAKEUP) (((WAKEUP) == USART_WakeUp_IdleLine) || \ |
emilmont | 77:869cf507173a | 307 | ((WAKEUP) == USART_WakeUp_AddressMark)) |
emilmont | 77:869cf507173a | 308 | /** |
emilmont | 77:869cf507173a | 309 | * @} |
emilmont | 77:869cf507173a | 310 | */ |
emilmont | 77:869cf507173a | 311 | |
emilmont | 77:869cf507173a | 312 | /** @defgroup USART_LIN_Break_Detection_Length |
emilmont | 77:869cf507173a | 313 | * @{ |
emilmont | 77:869cf507173a | 314 | */ |
emilmont | 77:869cf507173a | 315 | |
emilmont | 77:869cf507173a | 316 | #define USART_LINBreakDetectLength_10b ((uint16_t)0x0000) |
emilmont | 77:869cf507173a | 317 | #define USART_LINBreakDetectLength_11b ((uint16_t)0x0020) |
emilmont | 77:869cf507173a | 318 | #define IS_USART_LIN_BREAK_DETECT_LENGTH(LENGTH) \ |
emilmont | 77:869cf507173a | 319 | (((LENGTH) == USART_LINBreakDetectLength_10b) || \ |
emilmont | 77:869cf507173a | 320 | ((LENGTH) == USART_LINBreakDetectLength_11b)) |
emilmont | 77:869cf507173a | 321 | /** |
emilmont | 77:869cf507173a | 322 | * @} |
emilmont | 77:869cf507173a | 323 | */ |
emilmont | 77:869cf507173a | 324 | |
emilmont | 77:869cf507173a | 325 | /** @defgroup USART_IrDA_Low_Power |
emilmont | 77:869cf507173a | 326 | * @{ |
emilmont | 77:869cf507173a | 327 | */ |
emilmont | 77:869cf507173a | 328 | |
emilmont | 77:869cf507173a | 329 | #define USART_IrDAMode_LowPower ((uint16_t)0x0004) |
emilmont | 77:869cf507173a | 330 | #define USART_IrDAMode_Normal ((uint16_t)0x0000) |
emilmont | 77:869cf507173a | 331 | #define IS_USART_IRDA_MODE(MODE) (((MODE) == USART_IrDAMode_LowPower) || \ |
emilmont | 77:869cf507173a | 332 | ((MODE) == USART_IrDAMode_Normal)) |
emilmont | 77:869cf507173a | 333 | /** |
emilmont | 77:869cf507173a | 334 | * @} |
emilmont | 77:869cf507173a | 335 | */ |
emilmont | 77:869cf507173a | 336 | |
emilmont | 77:869cf507173a | 337 | /** @defgroup USART_Flags |
emilmont | 77:869cf507173a | 338 | * @{ |
emilmont | 77:869cf507173a | 339 | */ |
emilmont | 77:869cf507173a | 340 | |
emilmont | 77:869cf507173a | 341 | #define USART_FLAG_CTS ((uint16_t)0x0200) |
emilmont | 77:869cf507173a | 342 | #define USART_FLAG_LBD ((uint16_t)0x0100) |
emilmont | 77:869cf507173a | 343 | #define USART_FLAG_TXE ((uint16_t)0x0080) |
emilmont | 77:869cf507173a | 344 | #define USART_FLAG_TC ((uint16_t)0x0040) |
emilmont | 77:869cf507173a | 345 | #define USART_FLAG_RXNE ((uint16_t)0x0020) |
emilmont | 77:869cf507173a | 346 | #define USART_FLAG_IDLE ((uint16_t)0x0010) |
emilmont | 77:869cf507173a | 347 | #define USART_FLAG_ORE ((uint16_t)0x0008) |
emilmont | 77:869cf507173a | 348 | #define USART_FLAG_NE ((uint16_t)0x0004) |
emilmont | 77:869cf507173a | 349 | #define USART_FLAG_FE ((uint16_t)0x0002) |
emilmont | 77:869cf507173a | 350 | #define USART_FLAG_PE ((uint16_t)0x0001) |
emilmont | 77:869cf507173a | 351 | #define IS_USART_FLAG(FLAG) (((FLAG) == USART_FLAG_PE) || ((FLAG) == USART_FLAG_TXE) || \ |
emilmont | 77:869cf507173a | 352 | ((FLAG) == USART_FLAG_TC) || ((FLAG) == USART_FLAG_RXNE) || \ |
emilmont | 77:869cf507173a | 353 | ((FLAG) == USART_FLAG_IDLE) || ((FLAG) == USART_FLAG_LBD) || \ |
emilmont | 77:869cf507173a | 354 | ((FLAG) == USART_FLAG_CTS) || ((FLAG) == USART_FLAG_ORE) || \ |
emilmont | 77:869cf507173a | 355 | ((FLAG) == USART_FLAG_NE) || ((FLAG) == USART_FLAG_FE)) |
emilmont | 77:869cf507173a | 356 | |
emilmont | 77:869cf507173a | 357 | #define IS_USART_CLEAR_FLAG(FLAG) ((((FLAG) & (uint16_t)0xFC9F) == 0x00) && ((FLAG) != (uint16_t)0x00)) |
emilmont | 77:869cf507173a | 358 | |
emilmont | 77:869cf507173a | 359 | #define IS_USART_BAUDRATE(BAUDRATE) (((BAUDRATE) > 0) && ((BAUDRATE) < 0x003D0901)) |
emilmont | 77:869cf507173a | 360 | #define IS_USART_ADDRESS(ADDRESS) ((ADDRESS) <= 0xF) |
emilmont | 77:869cf507173a | 361 | #define IS_USART_DATA(DATA) ((DATA) <= 0x1FF) |
emilmont | 77:869cf507173a | 362 | |
emilmont | 77:869cf507173a | 363 | /** |
emilmont | 77:869cf507173a | 364 | * @} |
emilmont | 77:869cf507173a | 365 | */ |
emilmont | 77:869cf507173a | 366 | |
emilmont | 77:869cf507173a | 367 | /** |
emilmont | 77:869cf507173a | 368 | * @} |
emilmont | 77:869cf507173a | 369 | */ |
emilmont | 77:869cf507173a | 370 | |
emilmont | 77:869cf507173a | 371 | /* Exported macro ------------------------------------------------------------*/ |
emilmont | 77:869cf507173a | 372 | /* Exported functions ------------------------------------------------------- */ |
emilmont | 77:869cf507173a | 373 | |
emilmont | 77:869cf507173a | 374 | /* Function used to set the USART configuration to the default reset state ***/ |
emilmont | 77:869cf507173a | 375 | void USART_DeInit(USART_TypeDef* USARTx); |
emilmont | 77:869cf507173a | 376 | |
emilmont | 77:869cf507173a | 377 | /* Initialization and Configuration functions *********************************/ |
emilmont | 77:869cf507173a | 378 | void USART_Init(USART_TypeDef* USARTx, USART_InitTypeDef* USART_InitStruct); |
emilmont | 77:869cf507173a | 379 | void USART_StructInit(USART_InitTypeDef* USART_InitStruct); |
emilmont | 77:869cf507173a | 380 | void USART_ClockInit(USART_TypeDef* USARTx, USART_ClockInitTypeDef* USART_ClockInitStruct); |
emilmont | 77:869cf507173a | 381 | void USART_ClockStructInit(USART_ClockInitTypeDef* USART_ClockInitStruct); |
emilmont | 77:869cf507173a | 382 | void USART_Cmd(USART_TypeDef* USARTx, FunctionalState NewState); |
emilmont | 77:869cf507173a | 383 | void USART_SetPrescaler(USART_TypeDef* USARTx, uint8_t USART_Prescaler); |
emilmont | 77:869cf507173a | 384 | void USART_OverSampling8Cmd(USART_TypeDef* USARTx, FunctionalState NewState); |
emilmont | 77:869cf507173a | 385 | void USART_OneBitMethodCmd(USART_TypeDef* USARTx, FunctionalState NewState); |
emilmont | 77:869cf507173a | 386 | |
emilmont | 77:869cf507173a | 387 | /* Data transfers functions ***************************************************/ |
emilmont | 77:869cf507173a | 388 | void USART_SendData(USART_TypeDef* USARTx, uint16_t Data); |
emilmont | 77:869cf507173a | 389 | uint16_t USART_ReceiveData(USART_TypeDef* USARTx); |
emilmont | 77:869cf507173a | 390 | |
emilmont | 77:869cf507173a | 391 | /* Multi-Processor Communication functions ************************************/ |
emilmont | 77:869cf507173a | 392 | void USART_SetAddress(USART_TypeDef* USARTx, uint8_t USART_Address); |
emilmont | 77:869cf507173a | 393 | void USART_WakeUpConfig(USART_TypeDef* USARTx, uint16_t USART_WakeUp); |
emilmont | 77:869cf507173a | 394 | void USART_ReceiverWakeUpCmd(USART_TypeDef* USARTx, FunctionalState NewState); |
emilmont | 77:869cf507173a | 395 | |
emilmont | 77:869cf507173a | 396 | /* LIN mode functions *********************************************************/ |
emilmont | 77:869cf507173a | 397 | void USART_LINBreakDetectLengthConfig(USART_TypeDef* USARTx, uint16_t USART_LINBreakDetectLength); |
emilmont | 77:869cf507173a | 398 | void USART_LINCmd(USART_TypeDef* USARTx, FunctionalState NewState); |
emilmont | 77:869cf507173a | 399 | void USART_SendBreak(USART_TypeDef* USARTx); |
emilmont | 77:869cf507173a | 400 | |
emilmont | 77:869cf507173a | 401 | /* Half-duplex mode function **************************************************/ |
emilmont | 77:869cf507173a | 402 | void USART_HalfDuplexCmd(USART_TypeDef* USARTx, FunctionalState NewState); |
emilmont | 77:869cf507173a | 403 | |
emilmont | 77:869cf507173a | 404 | /* Smartcard mode functions ***************************************************/ |
emilmont | 77:869cf507173a | 405 | void USART_SmartCardCmd(USART_TypeDef* USARTx, FunctionalState NewState); |
emilmont | 77:869cf507173a | 406 | void USART_SmartCardNACKCmd(USART_TypeDef* USARTx, FunctionalState NewState); |
emilmont | 77:869cf507173a | 407 | void USART_SetGuardTime(USART_TypeDef* USARTx, uint8_t USART_GuardTime); |
emilmont | 77:869cf507173a | 408 | |
emilmont | 77:869cf507173a | 409 | /* IrDA mode functions ********************************************************/ |
emilmont | 77:869cf507173a | 410 | void USART_IrDAConfig(USART_TypeDef* USARTx, uint16_t USART_IrDAMode); |
emilmont | 77:869cf507173a | 411 | void USART_IrDACmd(USART_TypeDef* USARTx, FunctionalState NewState); |
emilmont | 77:869cf507173a | 412 | |
emilmont | 77:869cf507173a | 413 | /* DMA transfers management functions *****************************************/ |
emilmont | 77:869cf507173a | 414 | void USART_DMACmd(USART_TypeDef* USARTx, uint16_t USART_DMAReq, FunctionalState NewState); |
emilmont | 77:869cf507173a | 415 | |
emilmont | 77:869cf507173a | 416 | /* Interrupts and flags management functions **********************************/ |
emilmont | 77:869cf507173a | 417 | void USART_ITConfig(USART_TypeDef* USARTx, uint16_t USART_IT, FunctionalState NewState); |
emilmont | 77:869cf507173a | 418 | FlagStatus USART_GetFlagStatus(USART_TypeDef* USARTx, uint16_t USART_FLAG); |
emilmont | 77:869cf507173a | 419 | void USART_ClearFlag(USART_TypeDef* USARTx, uint16_t USART_FLAG); |
emilmont | 77:869cf507173a | 420 | ITStatus USART_GetITStatus(USART_TypeDef* USARTx, uint16_t USART_IT); |
emilmont | 77:869cf507173a | 421 | void USART_ClearITPendingBit(USART_TypeDef* USARTx, uint16_t USART_IT); |
emilmont | 77:869cf507173a | 422 | |
emilmont | 77:869cf507173a | 423 | #ifdef __cplusplus |
emilmont | 77:869cf507173a | 424 | } |
emilmont | 77:869cf507173a | 425 | #endif |
emilmont | 77:869cf507173a | 426 | |
emilmont | 77:869cf507173a | 427 | #endif /* __STM32L1xx_USART_H */ |
emilmont | 77:869cf507173a | 428 | |
emilmont | 77:869cf507173a | 429 | /** |
emilmont | 77:869cf507173a | 430 | * @} |
emilmont | 77:869cf507173a | 431 | */ |
emilmont | 77:869cf507173a | 432 | |
emilmont | 77:869cf507173a | 433 | /** |
emilmont | 77:869cf507173a | 434 | * @} |
emilmont | 77:869cf507173a | 435 | */ |
emilmont | 77:869cf507173a | 436 | |
emilmont | 77:869cf507173a | 437 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |