Mangue Baja Box

Dependencies:   mbed

Committer:
einsteingustavo
Date:
Mon Jul 29 20:38:00 2019 +0000
Revision:
0:0dee8840a1c0
Mangue Baja Box

Who changed what in which revision?

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