mbed SDK library sources

Fork of mbed-src by mbed official

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Mon Feb 03 09:30:05 2014 +0000
Revision:
84:f54042cbc282
Parent:
70:c1fbde68b492
Synchronized with git revision bbbd8699601c42149ccf0c37bc42bb6856ccc4c6

Full URL: https://github.com/mbedmicro/mbed/commit/bbbd8699601c42149ccf0c37bc42bb6856ccc4c6/

[NUCLEO_L152RE/F030_R8] SPI, I2C, Ticker, PWM updates

Who changed what in which revision?

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