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:
Thu Jan 30 12:15:05 2014 +0000
Revision:
80:66393a7b209d
Parent:
76:aeb1df146756
Synchronized with git revision dba523f83fe09b7fce11fc1299dd1216e9776359

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

Update of I2C, SPI, SLEEP for NUCLEO_F103RB and L152RE

Who changed what in which revision?

UserRevisionLine numberNew 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 80:66393a7b209d 12 * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
mbed_official 76:aeb1df146756 13 *
mbed_official 76:aeb1df146756 14 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
mbed_official 76:aeb1df146756 15 * You may not use this file except in compliance with the License.
mbed_official 76:aeb1df146756 16 * You may obtain a copy of the License at:
mbed_official 76:aeb1df146756 17 *
mbed_official 76:aeb1df146756 18 * http://www.st.com/software_license_agreement_liberty_v2
mbed_official 76:aeb1df146756 19 *
mbed_official 76:aeb1df146756 20 * Unless required by applicable law or agreed to in writing, software
mbed_official 76:aeb1df146756 21 * distributed under the License is distributed on an "AS IS" BASIS,
mbed_official 76:aeb1df146756 22 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbed_official 76:aeb1df146756 23 * See the License for the specific language governing permissions and
mbed_official 76:aeb1df146756 24 * limitations under the License.
mbed_official 76:aeb1df146756 25 *
mbed_official 76:aeb1df146756 26 ******************************************************************************
mbed_official 76:aeb1df146756 27 */
mbed_official 76:aeb1df146756 28
mbed_official 76:aeb1df146756 29 /* Define to prevent recursive inclusion -------------------------------------*/
mbed_official 76:aeb1df146756 30 #ifndef __STM32L1xx_USART_H
mbed_official 76:aeb1df146756 31 #define __STM32L1xx_USART_H
mbed_official 76:aeb1df146756 32
mbed_official 76:aeb1df146756 33 #ifdef __cplusplus
mbed_official 76:aeb1df146756 34 extern "C" {
mbed_official 76:aeb1df146756 35 #endif
mbed_official 76:aeb1df146756 36
mbed_official 76:aeb1df146756 37 /* Includes ------------------------------------------------------------------*/
mbed_official 76:aeb1df146756 38 #include "stm32l1xx.h"
mbed_official 76:aeb1df146756 39
mbed_official 76:aeb1df146756 40 /** @addtogroup STM32L1xx_StdPeriph_Driver
mbed_official 76:aeb1df146756 41 * @{
mbed_official 76:aeb1df146756 42 */
mbed_official 76:aeb1df146756 43
mbed_official 76:aeb1df146756 44 /** @addtogroup USART
mbed_official 76:aeb1df146756 45 * @{
mbed_official 76:aeb1df146756 46 */
mbed_official 76:aeb1df146756 47
mbed_official 76:aeb1df146756 48 /* Exported types ------------------------------------------------------------*/
mbed_official 76:aeb1df146756 49
mbed_official 76:aeb1df146756 50 /**
mbed_official 76:aeb1df146756 51 * @brief USART Init Structure definition
mbed_official 76:aeb1df146756 52 */
mbed_official 76:aeb1df146756 53
mbed_official 76:aeb1df146756 54 typedef struct
mbed_official 76:aeb1df146756 55 {
mbed_official 76:aeb1df146756 56 uint32_t USART_BaudRate; /*!< This member configures the USART communication baud rate.
mbed_official 76:aeb1df146756 57 The baud rate is computed using the following formula:
mbed_official 76:aeb1df146756 58 - IntegerDivider = ((PCLKx) / (8 * (OVR8+1) * (USART_InitStruct->USART_BaudRate)))
mbed_official 76:aeb1df146756 59 - FractionalDivider = ((IntegerDivider - ((u32) IntegerDivider)) * 8 * (OVR8+1)) + 0.5
mbed_official 76:aeb1df146756 60 Where OVR8 is the "oversampling by 8 mode" configuration bit in the CR1 register. */
mbed_official 76:aeb1df146756 61
mbed_official 76:aeb1df146756 62 uint16_t USART_WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
mbed_official 76:aeb1df146756 63 This parameter can be a value of @ref USART_Word_Length */
mbed_official 76:aeb1df146756 64
mbed_official 76:aeb1df146756 65 uint16_t USART_StopBits; /*!< Specifies the number of stop bits transmitted.
mbed_official 76:aeb1df146756 66 This parameter can be a value of @ref USART_Stop_Bits */
mbed_official 76:aeb1df146756 67
mbed_official 76:aeb1df146756 68 uint16_t USART_Parity; /*!< Specifies the parity mode.
mbed_official 76:aeb1df146756 69 This parameter can be a value of @ref USART_Parity
mbed_official 76:aeb1df146756 70 @note When parity is enabled, the computed parity is inserted
mbed_official 76:aeb1df146756 71 at the MSB position of the transmitted data (9th bit when
mbed_official 76:aeb1df146756 72 the word length is set to 9 data bits; 8th bit when the
mbed_official 76:aeb1df146756 73 word length is set to 8 data bits). */
mbed_official 76:aeb1df146756 74
mbed_official 76:aeb1df146756 75 uint16_t USART_Mode; /*!< Specifies wether the Receive or Transmit mode is enabled or disabled.
mbed_official 76:aeb1df146756 76 This parameter can be a value of @ref USART_Mode */
mbed_official 76:aeb1df146756 77
mbed_official 76:aeb1df146756 78 uint16_t USART_HardwareFlowControl; /*!< Specifies wether the hardware flow control mode is enabled
mbed_official 76:aeb1df146756 79 or disabled.
mbed_official 76:aeb1df146756 80 This parameter can be a value of @ref USART_Hardware_Flow_Control */
mbed_official 76:aeb1df146756 81 } USART_InitTypeDef;
mbed_official 76:aeb1df146756 82
mbed_official 76:aeb1df146756 83 /**
mbed_official 76:aeb1df146756 84 * @brief USART Clock Init Structure definition
mbed_official 76:aeb1df146756 85 */
mbed_official 76:aeb1df146756 86
mbed_official 76:aeb1df146756 87 typedef struct
mbed_official 76:aeb1df146756 88 {
mbed_official 76:aeb1df146756 89
mbed_official 76:aeb1df146756 90 uint16_t USART_Clock; /*!< Specifies whether the USART clock is enabled or disabled.
mbed_official 76:aeb1df146756 91 This parameter can be a value of @ref USART_Clock */
mbed_official 76:aeb1df146756 92
mbed_official 76:aeb1df146756 93 uint16_t USART_CPOL; /*!< Specifies the steady state of the serial clock.
mbed_official 76:aeb1df146756 94 This parameter can be a value of @ref USART_Clock_Polarity */
mbed_official 76:aeb1df146756 95
mbed_official 76:aeb1df146756 96 uint16_t USART_CPHA; /*!< Specifies the clock transition on which the bit capture is made.
mbed_official 76:aeb1df146756 97 This parameter can be a value of @ref USART_Clock_Phase */
mbed_official 76:aeb1df146756 98
mbed_official 76:aeb1df146756 99 uint16_t USART_LastBit; /*!< Specifies whether the clock pulse corresponding to the last transmitted
mbed_official 76:aeb1df146756 100 data bit (MSB) has to be output on the SCLK pin in synchronous mode.
mbed_official 76:aeb1df146756 101 This parameter can be a value of @ref USART_Last_Bit */
mbed_official 76:aeb1df146756 102 } USART_ClockInitTypeDef;
mbed_official 76:aeb1df146756 103
mbed_official 76:aeb1df146756 104 /* Exported constants --------------------------------------------------------*/
mbed_official 76:aeb1df146756 105
mbed_official 76:aeb1df146756 106 /** @defgroup USART_Exported_Constants
mbed_official 76:aeb1df146756 107 * @{
mbed_official 76:aeb1df146756 108 */
mbed_official 76:aeb1df146756 109
mbed_official 76:aeb1df146756 110 #define IS_USART_ALL_PERIPH(PERIPH) (((PERIPH) == USART1) || \
mbed_official 76:aeb1df146756 111 ((PERIPH) == USART2) || \
mbed_official 76:aeb1df146756 112 ((PERIPH) == USART3) || \
mbed_official 76:aeb1df146756 113 ((PERIPH) == UART4) || \
mbed_official 76:aeb1df146756 114 ((PERIPH) == UART5))
mbed_official 76:aeb1df146756 115
mbed_official 76:aeb1df146756 116 #define IS_USART_123_PERIPH(PERIPH) (((PERIPH) == USART1) || \
mbed_official 76:aeb1df146756 117 ((PERIPH) == USART2) || \
mbed_official 76:aeb1df146756 118 ((PERIPH) == USART3))
mbed_official 76:aeb1df146756 119
mbed_official 76:aeb1df146756 120 /** @defgroup USART_Word_Length
mbed_official 76:aeb1df146756 121 * @{
mbed_official 76:aeb1df146756 122 */
mbed_official 76:aeb1df146756 123
mbed_official 76:aeb1df146756 124 #define USART_WordLength_8b ((uint16_t)0x0000)
mbed_official 76:aeb1df146756 125 #define USART_WordLength_9b ((uint16_t)0x1000)
mbed_official 76:aeb1df146756 126
mbed_official 76:aeb1df146756 127 #define IS_USART_WORD_LENGTH(LENGTH) (((LENGTH) == USART_WordLength_8b) || \
mbed_official 76:aeb1df146756 128 ((LENGTH) == USART_WordLength_9b))
mbed_official 76:aeb1df146756 129 /**
mbed_official 76:aeb1df146756 130 * @}
mbed_official 76:aeb1df146756 131 */
mbed_official 76:aeb1df146756 132
mbed_official 76:aeb1df146756 133 /** @defgroup USART_Stop_Bits
mbed_official 76:aeb1df146756 134 * @{
mbed_official 76:aeb1df146756 135 */
mbed_official 76:aeb1df146756 136
mbed_official 76:aeb1df146756 137 #define USART_StopBits_1 ((uint16_t)0x0000)
mbed_official 76:aeb1df146756 138 #define USART_StopBits_0_5 ((uint16_t)0x1000)
mbed_official 76:aeb1df146756 139 #define USART_StopBits_2 ((uint16_t)0x2000)
mbed_official 76:aeb1df146756 140 #define USART_StopBits_1_5 ((uint16_t)0x3000)
mbed_official 76:aeb1df146756 141 #define IS_USART_STOPBITS(STOPBITS) (((STOPBITS) == USART_StopBits_1) || \
mbed_official 76:aeb1df146756 142 ((STOPBITS) == USART_StopBits_0_5) || \
mbed_official 76:aeb1df146756 143 ((STOPBITS) == USART_StopBits_2) || \
mbed_official 76:aeb1df146756 144 ((STOPBITS) == USART_StopBits_1_5))
mbed_official 76:aeb1df146756 145 /**
mbed_official 76:aeb1df146756 146 * @}
mbed_official 76:aeb1df146756 147 */
mbed_official 76:aeb1df146756 148
mbed_official 76:aeb1df146756 149 /** @defgroup USART_Parity
mbed_official 76:aeb1df146756 150 * @{
mbed_official 76:aeb1df146756 151 */
mbed_official 76:aeb1df146756 152
mbed_official 76:aeb1df146756 153 #define USART_Parity_No ((uint16_t)0x0000)
mbed_official 76:aeb1df146756 154 #define USART_Parity_Even ((uint16_t)0x0400)
mbed_official 76:aeb1df146756 155 #define USART_Parity_Odd ((uint16_t)0x0600)
mbed_official 76:aeb1df146756 156 #define IS_USART_PARITY(PARITY) (((PARITY) == USART_Parity_No) || \
mbed_official 76:aeb1df146756 157 ((PARITY) == USART_Parity_Even) || \
mbed_official 76:aeb1df146756 158 ((PARITY) == USART_Parity_Odd))
mbed_official 76:aeb1df146756 159 /**
mbed_official 76:aeb1df146756 160 * @}
mbed_official 76:aeb1df146756 161 */
mbed_official 76:aeb1df146756 162
mbed_official 76:aeb1df146756 163 /** @defgroup USART_Mode
mbed_official 76:aeb1df146756 164 * @{
mbed_official 76:aeb1df146756 165 */
mbed_official 76:aeb1df146756 166
mbed_official 76:aeb1df146756 167 #define USART_Mode_Rx ((uint16_t)0x0004)
mbed_official 76:aeb1df146756 168 #define USART_Mode_Tx ((uint16_t)0x0008)
mbed_official 76:aeb1df146756 169 #define IS_USART_MODE(MODE) ((((MODE) & (uint16_t)0xFFF3) == 0x00) && ((MODE) != (uint16_t)0x00))
mbed_official 76:aeb1df146756 170 /**
mbed_official 76:aeb1df146756 171 * @}
mbed_official 76:aeb1df146756 172 */
mbed_official 76:aeb1df146756 173
mbed_official 76:aeb1df146756 174 /** @defgroup USART_Hardware_Flow_Control
mbed_official 76:aeb1df146756 175 * @{
mbed_official 76:aeb1df146756 176 */
mbed_official 76:aeb1df146756 177 #define USART_HardwareFlowControl_None ((uint16_t)0x0000)
mbed_official 76:aeb1df146756 178 #define USART_HardwareFlowControl_RTS ((uint16_t)0x0100)
mbed_official 76:aeb1df146756 179 #define USART_HardwareFlowControl_CTS ((uint16_t)0x0200)
mbed_official 76:aeb1df146756 180 #define USART_HardwareFlowControl_RTS_CTS ((uint16_t)0x0300)
mbed_official 76:aeb1df146756 181 #define IS_USART_HARDWARE_FLOW_CONTROL(CONTROL)\
mbed_official 76:aeb1df146756 182 (((CONTROL) == USART_HardwareFlowControl_None) || \
mbed_official 76:aeb1df146756 183 ((CONTROL) == USART_HardwareFlowControl_RTS) || \
mbed_official 76:aeb1df146756 184 ((CONTROL) == USART_HardwareFlowControl_CTS) || \
mbed_official 76:aeb1df146756 185 ((CONTROL) == USART_HardwareFlowControl_RTS_CTS))
mbed_official 76:aeb1df146756 186 /**
mbed_official 76:aeb1df146756 187 * @}
mbed_official 76:aeb1df146756 188 */
mbed_official 76:aeb1df146756 189
mbed_official 76:aeb1df146756 190 /** @defgroup USART_Clock
mbed_official 76:aeb1df146756 191 * @{
mbed_official 76:aeb1df146756 192 */
mbed_official 76:aeb1df146756 193 #define USART_Clock_Disable ((uint16_t)0x0000)
mbed_official 76:aeb1df146756 194 #define USART_Clock_Enable ((uint16_t)0x0800)
mbed_official 76:aeb1df146756 195 #define IS_USART_CLOCK(CLOCK) (((CLOCK) == USART_Clock_Disable) || \
mbed_official 76:aeb1df146756 196 ((CLOCK) == USART_Clock_Enable))
mbed_official 76:aeb1df146756 197 /**
mbed_official 76:aeb1df146756 198 * @}
mbed_official 76:aeb1df146756 199 */
mbed_official 76:aeb1df146756 200
mbed_official 76:aeb1df146756 201 /** @defgroup USART_Clock_Polarity
mbed_official 76:aeb1df146756 202 * @{
mbed_official 76:aeb1df146756 203 */
mbed_official 76:aeb1df146756 204
mbed_official 76:aeb1df146756 205 #define USART_CPOL_Low ((uint16_t)0x0000)
mbed_official 76:aeb1df146756 206 #define USART_CPOL_High ((uint16_t)0x0400)
mbed_official 76:aeb1df146756 207 #define IS_USART_CPOL(CPOL) (((CPOL) == USART_CPOL_Low) || ((CPOL) == USART_CPOL_High))
mbed_official 76:aeb1df146756 208
mbed_official 76:aeb1df146756 209 /**
mbed_official 76:aeb1df146756 210 * @}
mbed_official 76:aeb1df146756 211 */
mbed_official 76:aeb1df146756 212
mbed_official 76:aeb1df146756 213 /** @defgroup USART_Clock_Phase
mbed_official 76:aeb1df146756 214 * @{
mbed_official 76:aeb1df146756 215 */
mbed_official 76:aeb1df146756 216
mbed_official 76:aeb1df146756 217 #define USART_CPHA_1Edge ((uint16_t)0x0000)
mbed_official 76:aeb1df146756 218 #define USART_CPHA_2Edge ((uint16_t)0x0200)
mbed_official 76:aeb1df146756 219 #define IS_USART_CPHA(CPHA) (((CPHA) == USART_CPHA_1Edge) || ((CPHA) == USART_CPHA_2Edge))
mbed_official 76:aeb1df146756 220
mbed_official 76:aeb1df146756 221 /**
mbed_official 76:aeb1df146756 222 * @}
mbed_official 76:aeb1df146756 223 */
mbed_official 76:aeb1df146756 224
mbed_official 76:aeb1df146756 225 /** @defgroup USART_Last_Bit
mbed_official 76:aeb1df146756 226 * @{
mbed_official 76:aeb1df146756 227 */
mbed_official 76:aeb1df146756 228
mbed_official 76:aeb1df146756 229 #define USART_LastBit_Disable ((uint16_t)0x0000)
mbed_official 76:aeb1df146756 230 #define USART_LastBit_Enable ((uint16_t)0x0100)
mbed_official 76:aeb1df146756 231 #define IS_USART_LASTBIT(LASTBIT) (((LASTBIT) == USART_LastBit_Disable) || \
mbed_official 76:aeb1df146756 232 ((LASTBIT) == USART_LastBit_Enable))
mbed_official 76:aeb1df146756 233 /**
mbed_official 76:aeb1df146756 234 * @}
mbed_official 76:aeb1df146756 235 */
mbed_official 76:aeb1df146756 236
mbed_official 76:aeb1df146756 237 /** @defgroup USART_Interrupt_definition
mbed_official 76:aeb1df146756 238 * @{
mbed_official 76:aeb1df146756 239 */
mbed_official 76:aeb1df146756 240
mbed_official 76:aeb1df146756 241 #define USART_IT_PE ((uint16_t)0x0028)
mbed_official 76:aeb1df146756 242 #define USART_IT_TXE ((uint16_t)0x0727)
mbed_official 76:aeb1df146756 243 #define USART_IT_TC ((uint16_t)0x0626)
mbed_official 76:aeb1df146756 244 #define USART_IT_RXNE ((uint16_t)0x0525)
mbed_official 76:aeb1df146756 245 #define USART_IT_IDLE ((uint16_t)0x0424)
mbed_official 76:aeb1df146756 246 #define USART_IT_LBD ((uint16_t)0x0846)
mbed_official 76:aeb1df146756 247 #define USART_IT_ORE_RX ((uint16_t)0x0325) /* In case interrupt is generated if the RXNEIE bit is set */
mbed_official 76:aeb1df146756 248 #define USART_IT_CTS ((uint16_t)0x096A)
mbed_official 76:aeb1df146756 249 #define USART_IT_ERR ((uint16_t)0x0060)
mbed_official 76:aeb1df146756 250 #define USART_IT_ORE_ER ((uint16_t)0x0360) /* In case interrupt is generated if the EIE bit is set */
mbed_official 76:aeb1df146756 251 #define USART_IT_NE ((uint16_t)0x0260)
mbed_official 76:aeb1df146756 252 #define USART_IT_FE ((uint16_t)0x0160)
mbed_official 76:aeb1df146756 253
mbed_official 76:aeb1df146756 254 /** @defgroup USART_Legacy
mbed_official 76:aeb1df146756 255 * @{
mbed_official 76:aeb1df146756 256 */
mbed_official 76:aeb1df146756 257 #define USART_IT_ORE USART_IT_ORE_ER
mbed_official 76:aeb1df146756 258 /**
mbed_official 76:aeb1df146756 259 * @}
mbed_official 76:aeb1df146756 260 */
mbed_official 76:aeb1df146756 261
mbed_official 76:aeb1df146756 262 #define IS_USART_CONFIG_IT(IT) (((IT) == USART_IT_PE) || ((IT) == USART_IT_TXE) || \
mbed_official 76:aeb1df146756 263 ((IT) == USART_IT_TC) || ((IT) == USART_IT_RXNE) || \
mbed_official 76:aeb1df146756 264 ((IT) == USART_IT_IDLE) || ((IT) == USART_IT_LBD) || \
mbed_official 76:aeb1df146756 265 ((IT) == USART_IT_CTS) || ((IT) == USART_IT_ERR))
mbed_official 76:aeb1df146756 266 #define IS_USART_GET_IT(IT) (((IT) == USART_IT_PE) || ((IT) == USART_IT_TXE) || \
mbed_official 76:aeb1df146756 267 ((IT) == USART_IT_TC) || ((IT) == USART_IT_RXNE) || \
mbed_official 76:aeb1df146756 268 ((IT) == USART_IT_IDLE) || ((IT) == USART_IT_LBD) || \
mbed_official 76:aeb1df146756 269 ((IT) == USART_IT_CTS) || ((IT) == USART_IT_ORE_RX) || \
mbed_official 76:aeb1df146756 270 ((IT) == USART_IT_ORE_ER) || ((IT) == USART_IT_NE) || \
mbed_official 76:aeb1df146756 271 ((IT) == USART_IT_FE))
mbed_official 76:aeb1df146756 272 #define IS_USART_CLEAR_IT(IT) (((IT) == USART_IT_TC) || ((IT) == USART_IT_RXNE) || \
mbed_official 76:aeb1df146756 273 ((IT) == USART_IT_LBD) || ((IT) == USART_IT_CTS))
mbed_official 76:aeb1df146756 274 /**
mbed_official 76:aeb1df146756 275 * @}
mbed_official 76:aeb1df146756 276 */
mbed_official 76:aeb1df146756 277
mbed_official 76:aeb1df146756 278 /** @defgroup USART_DMA_Requests
mbed_official 76:aeb1df146756 279 * @{
mbed_official 76:aeb1df146756 280 */
mbed_official 76:aeb1df146756 281
mbed_official 76:aeb1df146756 282 #define USART_DMAReq_Tx ((uint16_t)0x0080)
mbed_official 76:aeb1df146756 283 #define USART_DMAReq_Rx ((uint16_t)0x0040)
mbed_official 76:aeb1df146756 284 #define IS_USART_DMAREQ(DMAREQ) ((((DMAREQ) & (uint16_t)0xFF3F) == 0x00) && ((DMAREQ) != (uint16_t)0x00))
mbed_official 76:aeb1df146756 285
mbed_official 76:aeb1df146756 286 /**
mbed_official 76:aeb1df146756 287 * @}
mbed_official 76:aeb1df146756 288 */
mbed_official 76:aeb1df146756 289
mbed_official 76:aeb1df146756 290 /** @defgroup USART_WakeUp_methods
mbed_official 76:aeb1df146756 291 * @{
mbed_official 76:aeb1df146756 292 */
mbed_official 76:aeb1df146756 293
mbed_official 76:aeb1df146756 294 #define USART_WakeUp_IdleLine ((uint16_t)0x0000)
mbed_official 76:aeb1df146756 295 #define USART_WakeUp_AddressMark ((uint16_t)0x0800)
mbed_official 76:aeb1df146756 296 #define IS_USART_WAKEUP(WAKEUP) (((WAKEUP) == USART_WakeUp_IdleLine) || \
mbed_official 76:aeb1df146756 297 ((WAKEUP) == USART_WakeUp_AddressMark))
mbed_official 76:aeb1df146756 298 /**
mbed_official 76:aeb1df146756 299 * @}
mbed_official 76:aeb1df146756 300 */
mbed_official 76:aeb1df146756 301
mbed_official 76:aeb1df146756 302 /** @defgroup USART_LIN_Break_Detection_Length
mbed_official 76:aeb1df146756 303 * @{
mbed_official 76:aeb1df146756 304 */
mbed_official 76:aeb1df146756 305
mbed_official 76:aeb1df146756 306 #define USART_LINBreakDetectLength_10b ((uint16_t)0x0000)
mbed_official 76:aeb1df146756 307 #define USART_LINBreakDetectLength_11b ((uint16_t)0x0020)
mbed_official 76:aeb1df146756 308 #define IS_USART_LIN_BREAK_DETECT_LENGTH(LENGTH) \
mbed_official 76:aeb1df146756 309 (((LENGTH) == USART_LINBreakDetectLength_10b) || \
mbed_official 76:aeb1df146756 310 ((LENGTH) == USART_LINBreakDetectLength_11b))
mbed_official 76:aeb1df146756 311 /**
mbed_official 76:aeb1df146756 312 * @}
mbed_official 76:aeb1df146756 313 */
mbed_official 76:aeb1df146756 314
mbed_official 76:aeb1df146756 315 /** @defgroup USART_IrDA_Low_Power
mbed_official 76:aeb1df146756 316 * @{
mbed_official 76:aeb1df146756 317 */
mbed_official 76:aeb1df146756 318
mbed_official 76:aeb1df146756 319 #define USART_IrDAMode_LowPower ((uint16_t)0x0004)
mbed_official 76:aeb1df146756 320 #define USART_IrDAMode_Normal ((uint16_t)0x0000)
mbed_official 76:aeb1df146756 321 #define IS_USART_IRDA_MODE(MODE) (((MODE) == USART_IrDAMode_LowPower) || \
mbed_official 76:aeb1df146756 322 ((MODE) == USART_IrDAMode_Normal))
mbed_official 76:aeb1df146756 323 /**
mbed_official 76:aeb1df146756 324 * @}
mbed_official 76:aeb1df146756 325 */
mbed_official 76:aeb1df146756 326
mbed_official 76:aeb1df146756 327 /** @defgroup USART_Flags
mbed_official 76:aeb1df146756 328 * @{
mbed_official 76:aeb1df146756 329 */
mbed_official 76:aeb1df146756 330
mbed_official 76:aeb1df146756 331 #define USART_FLAG_CTS ((uint16_t)0x0200)
mbed_official 76:aeb1df146756 332 #define USART_FLAG_LBD ((uint16_t)0x0100)
mbed_official 76:aeb1df146756 333 #define USART_FLAG_TXE ((uint16_t)0x0080)
mbed_official 76:aeb1df146756 334 #define USART_FLAG_TC ((uint16_t)0x0040)
mbed_official 76:aeb1df146756 335 #define USART_FLAG_RXNE ((uint16_t)0x0020)
mbed_official 76:aeb1df146756 336 #define USART_FLAG_IDLE ((uint16_t)0x0010)
mbed_official 76:aeb1df146756 337 #define USART_FLAG_ORE ((uint16_t)0x0008)
mbed_official 76:aeb1df146756 338 #define USART_FLAG_NE ((uint16_t)0x0004)
mbed_official 76:aeb1df146756 339 #define USART_FLAG_FE ((uint16_t)0x0002)
mbed_official 76:aeb1df146756 340 #define USART_FLAG_PE ((uint16_t)0x0001)
mbed_official 76:aeb1df146756 341 #define IS_USART_FLAG(FLAG) (((FLAG) == USART_FLAG_PE) || ((FLAG) == USART_FLAG_TXE) || \
mbed_official 76:aeb1df146756 342 ((FLAG) == USART_FLAG_TC) || ((FLAG) == USART_FLAG_RXNE) || \
mbed_official 76:aeb1df146756 343 ((FLAG) == USART_FLAG_IDLE) || ((FLAG) == USART_FLAG_LBD) || \
mbed_official 76:aeb1df146756 344 ((FLAG) == USART_FLAG_CTS) || ((FLAG) == USART_FLAG_ORE) || \
mbed_official 76:aeb1df146756 345 ((FLAG) == USART_FLAG_NE) || ((FLAG) == USART_FLAG_FE))
mbed_official 76:aeb1df146756 346
mbed_official 76:aeb1df146756 347 #define IS_USART_CLEAR_FLAG(FLAG) ((((FLAG) & (uint16_t)0xFC9F) == 0x00) && ((FLAG) != (uint16_t)0x00))
mbed_official 76:aeb1df146756 348
mbed_official 76:aeb1df146756 349 #define IS_USART_BAUDRATE(BAUDRATE) (((BAUDRATE) > 0) && ((BAUDRATE) < 0x003D0901))
mbed_official 76:aeb1df146756 350 #define IS_USART_ADDRESS(ADDRESS) ((ADDRESS) <= 0xF)
mbed_official 76:aeb1df146756 351 #define IS_USART_DATA(DATA) ((DATA) <= 0x1FF)
mbed_official 76:aeb1df146756 352
mbed_official 76:aeb1df146756 353 /**
mbed_official 76:aeb1df146756 354 * @}
mbed_official 76:aeb1df146756 355 */
mbed_official 76:aeb1df146756 356
mbed_official 76:aeb1df146756 357 /**
mbed_official 76:aeb1df146756 358 * @}
mbed_official 76:aeb1df146756 359 */
mbed_official 76:aeb1df146756 360
mbed_official 76:aeb1df146756 361 /* Exported macro ------------------------------------------------------------*/
mbed_official 76:aeb1df146756 362 /* Exported functions ------------------------------------------------------- */
mbed_official 76:aeb1df146756 363
mbed_official 76:aeb1df146756 364 /* Function used to set the USART configuration to the default reset state ***/
mbed_official 76:aeb1df146756 365 void USART_DeInit(USART_TypeDef* USARTx);
mbed_official 76:aeb1df146756 366
mbed_official 76:aeb1df146756 367 /* Initialization and Configuration functions *********************************/
mbed_official 76:aeb1df146756 368 void USART_Init(USART_TypeDef* USARTx, USART_InitTypeDef* USART_InitStruct);
mbed_official 76:aeb1df146756 369 void USART_StructInit(USART_InitTypeDef* USART_InitStruct);
mbed_official 76:aeb1df146756 370 void USART_ClockInit(USART_TypeDef* USARTx, USART_ClockInitTypeDef* USART_ClockInitStruct);
mbed_official 76:aeb1df146756 371 void USART_ClockStructInit(USART_ClockInitTypeDef* USART_ClockInitStruct);
mbed_official 76:aeb1df146756 372 void USART_Cmd(USART_TypeDef* USARTx, FunctionalState NewState);
mbed_official 76:aeb1df146756 373 void USART_SetPrescaler(USART_TypeDef* USARTx, uint8_t USART_Prescaler);
mbed_official 76:aeb1df146756 374 void USART_OverSampling8Cmd(USART_TypeDef* USARTx, FunctionalState NewState);
mbed_official 76:aeb1df146756 375 void USART_OneBitMethodCmd(USART_TypeDef* USARTx, FunctionalState NewState);
mbed_official 76:aeb1df146756 376
mbed_official 76:aeb1df146756 377 /* Data transfers functions ***************************************************/
mbed_official 76:aeb1df146756 378 void USART_SendData(USART_TypeDef* USARTx, uint16_t Data);
mbed_official 76:aeb1df146756 379 uint16_t USART_ReceiveData(USART_TypeDef* USARTx);
mbed_official 76:aeb1df146756 380
mbed_official 76:aeb1df146756 381 /* Multi-Processor Communication functions ************************************/
mbed_official 76:aeb1df146756 382 void USART_SetAddress(USART_TypeDef* USARTx, uint8_t USART_Address);
mbed_official 76:aeb1df146756 383 void USART_WakeUpConfig(USART_TypeDef* USARTx, uint16_t USART_WakeUp);
mbed_official 76:aeb1df146756 384 void USART_ReceiverWakeUpCmd(USART_TypeDef* USARTx, FunctionalState NewState);
mbed_official 76:aeb1df146756 385
mbed_official 76:aeb1df146756 386 /* LIN mode functions *********************************************************/
mbed_official 76:aeb1df146756 387 void USART_LINBreakDetectLengthConfig(USART_TypeDef* USARTx, uint16_t USART_LINBreakDetectLength);
mbed_official 76:aeb1df146756 388 void USART_LINCmd(USART_TypeDef* USARTx, FunctionalState NewState);
mbed_official 76:aeb1df146756 389 void USART_SendBreak(USART_TypeDef* USARTx);
mbed_official 76:aeb1df146756 390
mbed_official 76:aeb1df146756 391 /* Half-duplex mode function **************************************************/
mbed_official 76:aeb1df146756 392 void USART_HalfDuplexCmd(USART_TypeDef* USARTx, FunctionalState NewState);
mbed_official 76:aeb1df146756 393
mbed_official 76:aeb1df146756 394 /* Smartcard mode functions ***************************************************/
mbed_official 76:aeb1df146756 395 void USART_SmartCardCmd(USART_TypeDef* USARTx, FunctionalState NewState);
mbed_official 76:aeb1df146756 396 void USART_SmartCardNACKCmd(USART_TypeDef* USARTx, FunctionalState NewState);
mbed_official 76:aeb1df146756 397 void USART_SetGuardTime(USART_TypeDef* USARTx, uint8_t USART_GuardTime);
mbed_official 76:aeb1df146756 398
mbed_official 76:aeb1df146756 399 /* IrDA mode functions ********************************************************/
mbed_official 76:aeb1df146756 400 void USART_IrDAConfig(USART_TypeDef* USARTx, uint16_t USART_IrDAMode);
mbed_official 76:aeb1df146756 401 void USART_IrDACmd(USART_TypeDef* USARTx, FunctionalState NewState);
mbed_official 76:aeb1df146756 402
mbed_official 76:aeb1df146756 403 /* DMA transfers management functions *****************************************/
mbed_official 76:aeb1df146756 404 void USART_DMACmd(USART_TypeDef* USARTx, uint16_t USART_DMAReq, FunctionalState NewState);
mbed_official 76:aeb1df146756 405
mbed_official 76:aeb1df146756 406 /* Interrupts and flags management functions **********************************/
mbed_official 76:aeb1df146756 407 void USART_ITConfig(USART_TypeDef* USARTx, uint16_t USART_IT, FunctionalState NewState);
mbed_official 76:aeb1df146756 408 FlagStatus USART_GetFlagStatus(USART_TypeDef* USARTx, uint16_t USART_FLAG);
mbed_official 76:aeb1df146756 409 void USART_ClearFlag(USART_TypeDef* USARTx, uint16_t USART_FLAG);
mbed_official 76:aeb1df146756 410 ITStatus USART_GetITStatus(USART_TypeDef* USARTx, uint16_t USART_IT);
mbed_official 76:aeb1df146756 411 void USART_ClearITPendingBit(USART_TypeDef* USARTx, uint16_t USART_IT);
mbed_official 76:aeb1df146756 412
mbed_official 76:aeb1df146756 413 #ifdef __cplusplus
mbed_official 76:aeb1df146756 414 }
mbed_official 76:aeb1df146756 415 #endif
mbed_official 76:aeb1df146756 416
mbed_official 76:aeb1df146756 417 #endif /* __STM32L1xx_USART_H */
mbed_official 76:aeb1df146756 418
mbed_official 76:aeb1df146756 419 /**
mbed_official 76:aeb1df146756 420 * @}
mbed_official 76:aeb1df146756 421 */
mbed_official 76:aeb1df146756 422
mbed_official 76:aeb1df146756 423 /**
mbed_official 76:aeb1df146756 424 * @}
mbed_official 76:aeb1df146756 425 */
mbed_official 76:aeb1df146756 426
mbed_official 76:aeb1df146756 427 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/