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