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