]> git.donarmstrong.com Git - qmk_firmware.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F3XX/stm32f30x_usart.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[qmk_firmware.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_STM / TARGET_STM32F3XX / stm32f30x_usart.h
1 /**
2   ******************************************************************************
3   * @file    stm32f30x_usart.h
4   * @author  MCD Application Team
5   * @version V1.1.0
6   * @date    27-February-2014
7   * @brief   This file contains all the functions prototypes for the USART 
8   *          firmware library.
9   ******************************************************************************
10   * @attention
11   *
12   * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
13   *
14   * Redistribution and use in source and binary forms, with or without modification,
15   * are permitted provided that the following conditions are met:
16   *   1. Redistributions of source code must retain the above copyright notice,
17   *      this list of conditions and the following disclaimer.
18   *   2. Redistributions in binary form must reproduce the above copyright notice,
19   *      this list of conditions and the following disclaimer in the documentation
20   *      and/or other materials provided with the distribution.
21   *   3. Neither the name of STMicroelectronics nor the names of its contributors
22   *      may be used to endorse or promote products derived from this software
23   *      without specific prior written permission.
24   *
25   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
29   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35   *
36   ******************************************************************************
37   */
38
39 /* Define to prevent recursive inclusion -------------------------------------*/
40 #ifndef __STM32F30x_USART_H
41 #define __STM32F30x_USART_H
42
43 #ifdef __cplusplus
44  extern "C" {
45 #endif
46
47 /* Includes ------------------------------------------------------------------*/
48 #include "stm32f30x.h"
49
50 /** @addtogroup STM32F30x_StdPeriph_Driver
51   * @{
52   */
53
54 /** @addtogroup USART
55   * @{
56   */ 
57
58 /* Exported types ------------------------------------------------------------*/
59
60    
61    
62 /** 
63   * @brief  USART Init Structure definition  
64   */ 
65
66 typedef struct
67 {
68   uint32_t USART_BaudRate;            /*!< This member configures the USART communication baud rate.
69                                            The baud rate is computed using the following formula:
70                                             - IntegerDivider = ((PCLKx) / (16 * (USART_InitStruct->USART_BaudRate)))
71                                             - FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 16) + 0.5 */
72
73   uint32_t USART_WordLength;          /*!< Specifies the number of data bits transmitted or received in a frame.
74                                            This parameter can be a value of @ref USART_Word_Length */
75
76   uint32_t USART_StopBits;            /*!< Specifies the number of stop bits transmitted.
77                                            This parameter can be a value of @ref USART_Stop_Bits */
78
79   uint32_t USART_Parity;              /*!< Specifies the parity mode.
80                                            This parameter can be a value of @ref USART_Parity
81                                            @note When parity is enabled, the computed parity is inserted
82                                                  at the MSB position of the transmitted data (9th bit when
83                                                  the word length is set to 9 data bits; 8th bit when the
84                                                  word length is set to 8 data bits). */
85  
86   uint32_t USART_Mode;                /*!< Specifies wether the Receive or Transmit mode is enabled or disabled.
87                                            This parameter can be a value of @ref USART_Mode */
88
89   uint32_t USART_HardwareFlowControl; /*!< Specifies wether the hardware flow control mode is enabled
90                                            or disabled.
91                                            This parameter can be a value of @ref USART_Hardware_Flow_Control*/
92 } USART_InitTypeDef;
93
94 /** 
95   * @brief  USART Clock Init Structure definition
96   */ 
97
98 typedef struct
99 {
100   uint32_t USART_Clock;             /*!< Specifies whether the USART clock is enabled or disabled.
101                                          This parameter can be a value of @ref USART_Clock */
102
103   uint32_t USART_CPOL;              /*!< Specifies the steady state of the serial clock.
104                                          This parameter can be a value of @ref USART_Clock_Polarity */
105
106   uint32_t USART_CPHA;              /*!< Specifies the clock transition on which the bit capture is made.
107                                          This parameter can be a value of @ref USART_Clock_Phase */
108
109   uint32_t USART_LastBit;           /*!< Specifies whether the clock pulse corresponding to the last transmitted
110                                          data bit (MSB) has to be output on the SCLK pin in synchronous mode.
111                                          This parameter can be a value of @ref USART_Last_Bit */
112 } USART_ClockInitTypeDef;
113
114 /* Exported constants --------------------------------------------------------*/
115
116 /** @defgroup USART_Exported_Constants
117   * @{
118   */ 
119
120 #define IS_USART_ALL_PERIPH(PERIPH) (((PERIPH) == USART1) || \
121                                      ((PERIPH) == USART2) || \
122                                      ((PERIPH) == USART3) || \
123                                      ((PERIPH) == UART4) || \
124                                      ((PERIPH) == UART5))
125
126 #define IS_USART_123_PERIPH(PERIPH) (((PERIPH) == USART1) || \
127                                      ((PERIPH) == USART2) || \
128                                      ((PERIPH) == USART3))
129
130 #define IS_USART_1234_PERIPH(PERIPH) (((PERIPH) == USART1) || \
131                                       ((PERIPH) == USART2) || \
132                                       ((PERIPH) == USART3) || \
133                                       ((PERIPH) == UART4))
134
135
136 /** @defgroup USART_Word_Length 
137   * @{
138   */ 
139
140 #define USART_WordLength_8b                  ((uint32_t)0x00000000)
141 #define USART_WordLength_9b                  USART_CR1_M
142 #define IS_USART_WORD_LENGTH(LENGTH) (((LENGTH) == USART_WordLength_8b) || \
143                                       ((LENGTH) == USART_WordLength_9b))
144 /**
145   * @}
146   */ 
147
148 /** @defgroup USART_Stop_Bits 
149   * @{
150   */ 
151
152 #define USART_StopBits_1                     ((uint32_t)0x00000000)
153 #define USART_StopBits_2                     USART_CR2_STOP_1
154 #define USART_StopBits_1_5                   (USART_CR2_STOP_0 | USART_CR2_STOP_1)
155 #define IS_USART_STOPBITS(STOPBITS) (((STOPBITS) == USART_StopBits_1) || \
156                                      ((STOPBITS) == USART_StopBits_2) || \
157                                      ((STOPBITS) == USART_StopBits_1_5))
158 /**
159   * @}
160   */ 
161
162 /** @defgroup USART_Parity 
163   * @{
164   */ 
165
166 #define USART_Parity_No                      ((uint32_t)0x00000000)
167 #define USART_Parity_Even                    USART_CR1_PCE
168 #define USART_Parity_Odd                     (USART_CR1_PCE | USART_CR1_PS) 
169 #define IS_USART_PARITY(PARITY) (((PARITY) == USART_Parity_No) || \
170                                  ((PARITY) == USART_Parity_Even) || \
171                                  ((PARITY) == USART_Parity_Odd))
172 /**
173   * @}
174   */ 
175
176 /** @defgroup USART_Mode 
177   * @{
178   */ 
179
180 #define USART_Mode_Rx                        USART_CR1_RE
181 #define USART_Mode_Tx                        USART_CR1_TE
182 #define IS_USART_MODE(MODE) ((((MODE) & (uint32_t)0xFFFFFFF3) == 0x00) && \
183                               ((MODE) != (uint32_t)0x00))
184 /**
185   * @}
186   */ 
187
188 /** @defgroup USART_Hardware_Flow_Control 
189   * @{
190   */ 
191
192 #define USART_HardwareFlowControl_None       ((uint32_t)0x00000000)
193 #define USART_HardwareFlowControl_RTS        USART_CR3_RTSE
194 #define USART_HardwareFlowControl_CTS        USART_CR3_CTSE
195 #define USART_HardwareFlowControl_RTS_CTS    (USART_CR3_RTSE | USART_CR3_CTSE)
196 #define IS_USART_HARDWARE_FLOW_CONTROL(CONTROL)\
197                               (((CONTROL) == USART_HardwareFlowControl_None) || \
198                                ((CONTROL) == USART_HardwareFlowControl_RTS) || \
199                                ((CONTROL) == USART_HardwareFlowControl_CTS) || \
200                                ((CONTROL) == USART_HardwareFlowControl_RTS_CTS))
201 /**
202   * @}
203   */ 
204
205 /** @defgroup USART_Clock 
206   * @{
207   */ 
208   
209 #define USART_Clock_Disable                  ((uint32_t)0x00000000)
210 #define USART_Clock_Enable                   USART_CR2_CLKEN
211 #define IS_USART_CLOCK(CLOCK) (((CLOCK) == USART_Clock_Disable) || \
212                                ((CLOCK) == USART_Clock_Enable))
213 /**
214   * @}
215   */ 
216
217 /** @defgroup USART_Clock_Polarity 
218   * @{
219   */
220   
221 #define USART_CPOL_Low                       ((uint32_t)0x00000000)
222 #define USART_CPOL_High                      USART_CR2_CPOL
223 #define IS_USART_CPOL(CPOL) (((CPOL) == USART_CPOL_Low) || ((CPOL) == USART_CPOL_High))
224
225 /**
226   * @}
227   */ 
228
229 /** @defgroup USART_Clock_Phase
230   * @{
231   */
232
233 #define USART_CPHA_1Edge                     ((uint32_t)0x00000000)
234 #define USART_CPHA_2Edge                     USART_CR2_CPHA
235 #define IS_USART_CPHA(CPHA) (((CPHA) == USART_CPHA_1Edge) || ((CPHA) == USART_CPHA_2Edge))
236
237 /**
238   * @}
239   */
240
241 /** @defgroup USART_Last_Bit
242   * @{
243   */
244
245 #define USART_LastBit_Disable                ((uint32_t)0x00000000)
246 #define USART_LastBit_Enable                 USART_CR2_LBCL
247 #define IS_USART_LASTBIT(LASTBIT) (((LASTBIT) == USART_LastBit_Disable) || \
248                                    ((LASTBIT) == USART_LastBit_Enable))
249 /**
250   * @}
251   */
252   
253 /** @defgroup USART_DMA_Requests 
254   * @{
255   */
256
257 #define USART_DMAReq_Tx                      USART_CR3_DMAT
258 #define USART_DMAReq_Rx                      USART_CR3_DMAR
259 #define IS_USART_DMAREQ(DMAREQ) ((((DMAREQ) & (uint32_t)0xFFFFFF3F) == 0x00) && \
260                                   ((DMAREQ) != (uint32_t)0x00))
261
262 /**
263   * @}
264   */ 
265
266 /** @defgroup USART_DMA_Recception_Error
267   * @{
268   */
269
270 #define USART_DMAOnError_Enable              ((uint32_t)0x00000000)
271 #define USART_DMAOnError_Disable             USART_CR3_DDRE
272 #define IS_USART_DMAONERROR(DMAERROR) (((DMAERROR) == USART_DMAOnError_Disable)|| \
273                                        ((DMAERROR) == USART_DMAOnError_Enable))
274 /**
275   * @}
276   */ 
277
278 /** @defgroup USART_MuteMode_WakeUp_methods
279   * @{
280   */
281
282 #define USART_WakeUp_IdleLine                ((uint32_t)0x00000000)
283 #define USART_WakeUp_AddressMark             USART_CR1_WAKE
284 #define IS_USART_MUTEMODE_WAKEUP(WAKEUP) (((WAKEUP) == USART_WakeUp_IdleLine) || \
285                                           ((WAKEUP) == USART_WakeUp_AddressMark))
286 /**
287   * @}
288   */
289
290 /** @defgroup USART_Address_Detection
291   * @{
292   */ 
293
294 #define USART_AddressLength_4b               ((uint32_t)0x00000000)
295 #define USART_AddressLength_7b               USART_CR2_ADDM7
296 #define IS_USART_ADDRESS_DETECTION(ADDRESS) (((ADDRESS) == USART_AddressLength_4b) || \
297                                              ((ADDRESS) == USART_AddressLength_7b))
298 /**
299   * @}
300   */ 
301
302 /** @defgroup USART_StopMode_WakeUp_methods 
303   * @{
304   */ 
305
306 #define USART_WakeUpSource_AddressMatch      ((uint32_t)0x00000000)
307 #define USART_WakeUpSource_StartBit          USART_CR3_WUS_1
308 #define USART_WakeUpSource_RXNE              (uint32_t)(USART_CR3_WUS_0 | USART_CR3_WUS_1)
309 #define IS_USART_STOPMODE_WAKEUPSOURCE(SOURCE) (((SOURCE) == USART_WakeUpSource_AddressMatch) || \
310                                                 ((SOURCE) == USART_WakeUpSource_StartBit) || \
311                                                 ((SOURCE) == USART_WakeUpSource_RXNE))
312 /**
313   * @}
314   */ 
315
316 /** @defgroup USART_LIN_Break_Detection_Length 
317   * @{
318   */
319   
320 #define USART_LINBreakDetectLength_10b       ((uint32_t)0x00000000)
321 #define USART_LINBreakDetectLength_11b       USART_CR2_LBDL
322 #define IS_USART_LIN_BREAK_DETECT_LENGTH(LENGTH) \
323                                (((LENGTH) == USART_LINBreakDetectLength_10b) || \
324                                 ((LENGTH) == USART_LINBreakDetectLength_11b))
325 /**
326   * @}
327   */
328
329 /** @defgroup USART_IrDA_Low_Power 
330   * @{
331   */
332
333 #define USART_IrDAMode_LowPower              USART_CR3_IRLP
334 #define USART_IrDAMode_Normal                ((uint32_t)0x00000000)
335 #define IS_USART_IRDA_MODE(MODE) (((MODE) == USART_IrDAMode_LowPower) || \
336                                   ((MODE) == USART_IrDAMode_Normal))
337 /**
338   * @}
339   */ 
340
341 /** @defgroup USART_DE_Polarity 
342   * @{
343   */
344
345 #define USART_DEPolarity_High                ((uint32_t)0x00000000)
346 #define USART_DEPolarity_Low                 USART_CR3_DEP
347 #define IS_USART_DE_POLARITY(POLARITY) (((POLARITY) == USART_DEPolarity_Low) || \
348                                         ((POLARITY) == USART_DEPolarity_High))
349 /**
350   * @}
351   */ 
352
353 /** @defgroup USART_Inversion_Pins 
354   * @{
355   */
356
357 #define USART_InvPin_Tx                      USART_CR2_TXINV
358 #define USART_InvPin_Rx                      USART_CR2_RXINV
359 #define IS_USART_INVERSTION_PIN(PIN) ((((PIN) & (uint32_t)0xFFFCFFFF) == 0x00) && \
360                                        ((PIN) != (uint32_t)0x00))
361
362 /**
363   * @}
364   */
365
366 /** @defgroup USART_AutoBaudRate_Mode 
367   * @{
368   */
369
370 #define USART_AutoBaudRate_StartBit                 ((uint32_t)0x00000000)
371 #define USART_AutoBaudRate_FallingEdge              USART_CR2_ABRMODE_0
372 #define USART_AutoBaudRate_0x7FFrame                USART_CR2_ABRMODE_1
373 #define USART_AutoBaudRate_0x55Frame                (USART_CR2_ABRMODE_0 | USART_CR2_ABRMODE_1)
374 #define IS_USART_AUTOBAUDRATE_MODE(MODE) (((MODE) == USART_AutoBaudRate_StartBit) || \
375                                           ((MODE) == USART_AutoBaudRate_FallingEdge) || \
376                                           ((MODE) == USART_AutoBaudRate_0x7FFrame) || \
377                                           ((MODE) == USART_AutoBaudRate_0x55Frame))
378 /**
379   * @}
380   */
381
382 /** @defgroup USART_OVR_DETECTION
383   * @{
384   */
385
386 #define USART_OVRDetection_Enable            ((uint32_t)0x00000000)
387 #define USART_OVRDetection_Disable           USART_CR3_OVRDIS
388 #define IS_USART_OVRDETECTION(OVR) (((OVR) == USART_OVRDetection_Enable)|| \
389                                     ((OVR) == USART_OVRDetection_Disable))
390 /**
391   * @}
392   */ 
393 /** @defgroup USART_Request 
394   * @{
395   */
396
397 #define USART_Request_ABRRQ                  USART_RQR_ABRRQ
398 #define USART_Request_SBKRQ                  USART_RQR_SBKRQ
399 #define USART_Request_MMRQ                   USART_RQR_MMRQ
400 #define USART_Request_RXFRQ                  USART_RQR_RXFRQ
401 #define USART_Request_TXFRQ                  USART_RQR_TXFRQ
402
403 #define IS_USART_REQUEST(REQUEST) (((REQUEST) == USART_Request_TXFRQ) || \
404                                    ((REQUEST) == USART_Request_RXFRQ) || \
405                                    ((REQUEST) == USART_Request_MMRQ) || \
406                                    ((REQUEST) == USART_Request_SBKRQ) || \
407                                    ((REQUEST) == USART_Request_ABRRQ))
408 /**
409   * @}
410   */ 
411
412 /** @defgroup USART_Flags 
413   * @{
414   */
415 #define USART_FLAG_REACK                     USART_ISR_REACK
416 #define USART_FLAG_TEACK                     USART_ISR_TEACK
417 #define USART_FLAG_WU                        USART_ISR_WUF
418 #define USART_FLAG_RWU                       USART_ISR_RWU
419 #define USART_FLAG_SBK                       USART_ISR_SBKF
420 #define USART_FLAG_CM                        USART_ISR_CMF
421 #define USART_FLAG_BUSY                      USART_ISR_BUSY
422 #define USART_FLAG_ABRF                      USART_ISR_ABRF
423 #define USART_FLAG_ABRE                      USART_ISR_ABRE
424 #define USART_FLAG_EOB                       USART_ISR_EOBF
425 #define USART_FLAG_RTO                       USART_ISR_RTOF
426 #define USART_FLAG_nCTSS                     USART_ISR_CTS 
427 #define USART_FLAG_CTS                       USART_ISR_CTSIF
428 #define USART_FLAG_LBD                       USART_ISR_LBD
429 #define USART_FLAG_TXE                       USART_ISR_TXE
430 #define USART_FLAG_TC                        USART_ISR_TC
431 #define USART_FLAG_RXNE                      USART_ISR_RXNE
432 #define USART_FLAG_IDLE                      USART_ISR_IDLE
433 #define USART_FLAG_ORE                       USART_ISR_ORE
434 #define USART_FLAG_NE                        USART_ISR_NE
435 #define USART_FLAG_FE                        USART_ISR_FE
436 #define USART_FLAG_PE                        USART_ISR_PE
437 #define IS_USART_FLAG(FLAG) (((FLAG) == USART_FLAG_PE) || ((FLAG) == USART_FLAG_TXE) || \
438                              ((FLAG) == USART_FLAG_TC) || ((FLAG) == USART_FLAG_RXNE) || \
439                              ((FLAG) == USART_FLAG_IDLE) || ((FLAG) == USART_FLAG_LBD) || \
440                              ((FLAG) == USART_FLAG_CTS) || ((FLAG) == USART_FLAG_ORE) || \
441                              ((FLAG) == USART_FLAG_NE) || ((FLAG) == USART_FLAG_FE) || \
442                              ((FLAG) == USART_FLAG_nCTSS) || ((FLAG) == USART_FLAG_RTO) || \
443                              ((FLAG) == USART_FLAG_EOB) || ((FLAG) == USART_FLAG_ABRE) || \
444                              ((FLAG) == USART_FLAG_ABRF) || ((FLAG) == USART_FLAG_BUSY) || \
445                              ((FLAG) == USART_FLAG_CM) || ((FLAG) == USART_FLAG_SBK) || \
446                              ((FLAG) == USART_FLAG_RWU) || ((FLAG) == USART_FLAG_WU) || \
447                              ((FLAG) == USART_FLAG_TEACK)|| ((FLAG) == USART_FLAG_REACK))
448
449 #define IS_USART_CLEAR_FLAG(FLAG) (((FLAG) == USART_FLAG_WU) || ((FLAG) == USART_FLAG_TC) || \
450                                    ((FLAG) == USART_FLAG_IDLE) || ((FLAG) == USART_FLAG_ORE) || \
451                                    ((FLAG) == USART_FLAG_NE) || ((FLAG) == USART_FLAG_FE) || \
452                                    ((FLAG) == USART_FLAG_LBD) || ((FLAG) == USART_FLAG_CTS) || \
453                                    ((FLAG) == USART_FLAG_RTO) || ((FLAG) == USART_FLAG_EOB) || \
454                                    ((FLAG) == USART_FLAG_CM) || ((FLAG) == USART_FLAG_PE))
455 /**
456   * @}
457   */ 
458
459 /** @defgroup USART_Interrupt_definition 
460   * @brief USART Interrupt definition
461   * USART_IT possible values
462   * Elements values convention: 0xZZZZYYXX
463   *   XX: Position of the corresponding Interrupt
464   *   YY: Register index
465   *   ZZZZ: Flag position
466   * @{
467   */
468
469 #define USART_IT_WU                          ((uint32_t)0x00140316)
470 #define USART_IT_CM                          ((uint32_t)0x0011010E)
471 #define USART_IT_EOB                         ((uint32_t)0x000C011B)
472 #define USART_IT_RTO                         ((uint32_t)0x000B011A)
473 #define USART_IT_PE                          ((uint32_t)0x00000108)
474 #define USART_IT_TXE                         ((uint32_t)0x00070107)
475 #define USART_IT_TC                          ((uint32_t)0x00060106)
476 #define USART_IT_RXNE                        ((uint32_t)0x00050105)
477 #define USART_IT_IDLE                        ((uint32_t)0x00040104)
478 #define USART_IT_LBD                         ((uint32_t)0x00080206)
479 #define USART_IT_CTS                         ((uint32_t)0x0009030A) 
480 #define USART_IT_ERR                         ((uint32_t)0x00000300)
481 #define USART_IT_ORE                         ((uint32_t)0x00030300)
482 #define USART_IT_NE                          ((uint32_t)0x00020300)
483 #define USART_IT_FE                          ((uint32_t)0x00010300)
484
485 #define IS_USART_CONFIG_IT(IT) (((IT) == USART_IT_PE) || ((IT) == USART_IT_TXE) || \
486                                 ((IT) == USART_IT_TC) || ((IT) == USART_IT_RXNE) || \
487                                 ((IT) == USART_IT_IDLE) || ((IT) == USART_IT_LBD) || \
488                                 ((IT) == USART_IT_CTS) || ((IT) == USART_IT_ERR) || \
489                                 ((IT) == USART_IT_RTO) || ((IT) == USART_IT_EOB) || \
490                                 ((IT) == USART_IT_CM) || ((IT) == USART_IT_WU))
491
492 #define IS_USART_GET_IT(IT) (((IT) == USART_IT_PE) || ((IT) == USART_IT_TXE) || \
493                              ((IT) == USART_IT_TC) || ((IT) == USART_IT_RXNE) || \
494                              ((IT) == USART_IT_IDLE) || ((IT) == USART_IT_LBD) || \
495                              ((IT) == USART_IT_CTS) || ((IT) == USART_IT_ORE) || \
496                              ((IT) == USART_IT_NE) || ((IT) == USART_IT_FE) || \
497                              ((IT) == USART_IT_RTO) || ((IT) == USART_IT_EOB) || \
498                              ((IT) == USART_IT_CM) || ((IT) == USART_IT_WU))
499
500 #define IS_USART_CLEAR_IT(IT) (((IT) == USART_IT_TC) || ((IT) == USART_IT_PE) || \
501                                ((IT) == USART_IT_FE) || ((IT) == USART_IT_NE) || \
502                                ((IT) == USART_IT_ORE) || ((IT) == USART_IT_IDLE) || \
503                                ((IT) == USART_IT_LBD) || ((IT) == USART_IT_CTS) || \
504                                ((IT) == USART_IT_RTO) || ((IT) == USART_IT_EOB) || \
505                                ((IT) == USART_IT_CM) || ((IT) == USART_IT_WU))
506 /**
507   * @}
508   */
509
510 /** @defgroup USART_Global_definition 
511   * @{
512   */
513
514 #define IS_USART_BAUDRATE(BAUDRATE) (((BAUDRATE) > 0) && ((BAUDRATE) < 0x005B8D81))
515 #define IS_USART_DE_ASSERTION_DEASSERTION_TIME(TIME) ((TIME) <= 0x1F)
516 #define IS_USART_AUTO_RETRY_COUNTER(COUNTER) ((COUNTER) <= 0x7)
517 #define IS_USART_TIMEOUT(TIMEOUT) ((TIMEOUT) <= 0x00FFFFFF)
518 #define IS_USART_DATA(DATA) ((DATA) <= 0x1FF)
519
520 /**
521   * @}
522   */ 
523
524 /**
525   * @}
526   */ 
527
528 /* Exported macro ------------------------------------------------------------*/
529 /* Exported functions ------------------------------------------------------- */
530
531 /* Initialization and Configuration functions *********************************/
532 void USART_DeInit(USART_TypeDef* USARTx);
533 void USART_Init(USART_TypeDef* USARTx, USART_InitTypeDef* USART_InitStruct);
534 void USART_StructInit(USART_InitTypeDef* USART_InitStruct);
535 void USART_ClockInit(USART_TypeDef* USARTx, USART_ClockInitTypeDef* USART_ClockInitStruct);
536 void USART_ClockStructInit(USART_ClockInitTypeDef* USART_ClockInitStruct);
537 void USART_Cmd(USART_TypeDef* USARTx, FunctionalState NewState);
538 void USART_DirectionModeCmd(USART_TypeDef* USARTx, uint32_t USART_DirectionMode, FunctionalState NewState);
539 void USART_SetPrescaler(USART_TypeDef* USARTx, uint8_t USART_Prescaler);
540 void USART_OverSampling8Cmd(USART_TypeDef* USARTx, FunctionalState NewState);
541 void USART_OneBitMethodCmd(USART_TypeDef* USARTx, FunctionalState NewState);
542 void USART_MSBFirstCmd(USART_TypeDef* USARTx, FunctionalState NewState);
543 void USART_DataInvCmd(USART_TypeDef* USARTx, FunctionalState NewState);
544 void USART_InvPinCmd(USART_TypeDef* USARTx, uint32_t USART_InvPin, FunctionalState NewState);
545 void USART_SWAPPinCmd(USART_TypeDef* USARTx, FunctionalState NewState);
546 void USART_ReceiverTimeOutCmd(USART_TypeDef* USARTx, FunctionalState NewState);
547 void USART_SetReceiverTimeOut(USART_TypeDef* USARTx, uint32_t USART_ReceiverTimeOut);
548
549 /* STOP Mode functions ********************************************************/
550 void USART_STOPModeCmd(USART_TypeDef* USARTx, FunctionalState NewState);
551 void USART_StopModeWakeUpSourceConfig(USART_TypeDef* USARTx, uint32_t USART_WakeUpSource);
552
553 /* AutoBaudRate functions *****************************************************/
554 void USART_AutoBaudRateCmd(USART_TypeDef* USARTx, FunctionalState NewState);
555 void USART_AutoBaudRateConfig(USART_TypeDef* USARTx, uint32_t USART_AutoBaudRate);
556
557 /* Data transfers functions ***************************************************/
558 void USART_SendData(USART_TypeDef* USARTx, uint16_t Data);
559 uint16_t USART_ReceiveData(USART_TypeDef* USARTx);
560
561 /* Multi-Processor Communication functions ************************************/
562 void USART_SetAddress(USART_TypeDef* USARTx, uint8_t USART_Address);
563 void USART_MuteModeWakeUpConfig(USART_TypeDef* USARTx, uint32_t USART_WakeUp);
564 void USART_MuteModeCmd(USART_TypeDef* USARTx, FunctionalState NewState);
565 void USART_AddressDetectionConfig(USART_TypeDef* USARTx, uint32_t USART_AddressLength);
566 /* LIN mode functions *********************************************************/
567 void USART_LINBreakDetectLengthConfig(USART_TypeDef* USARTx, uint32_t USART_LINBreakDetectLength);
568 void USART_LINCmd(USART_TypeDef* USARTx, FunctionalState NewState);
569
570 /* Half-duplex mode function **************************************************/
571 void USART_HalfDuplexCmd(USART_TypeDef* USARTx, FunctionalState NewState);
572
573 /* Smartcard mode functions ***************************************************/
574 void USART_SmartCardCmd(USART_TypeDef* USARTx, FunctionalState NewState);
575 void USART_SmartCardNACKCmd(USART_TypeDef* USARTx, FunctionalState NewState);
576 void USART_SetGuardTime(USART_TypeDef* USARTx, uint8_t USART_GuardTime);
577 void USART_SetAutoRetryCount(USART_TypeDef* USARTx, uint8_t USART_AutoCount);
578 void USART_SetBlockLength(USART_TypeDef* USARTx, uint8_t USART_BlockLength);
579
580 /* IrDA mode functions ********************************************************/
581 void USART_IrDAConfig(USART_TypeDef* USARTx, uint32_t USART_IrDAMode);
582 void USART_IrDACmd(USART_TypeDef* USARTx, FunctionalState NewState);
583
584 /* RS485 mode functions *******************************************************/
585 void USART_DECmd(USART_TypeDef* USARTx, FunctionalState NewState);
586 void USART_DEPolarityConfig(USART_TypeDef* USARTx, uint32_t USART_DEPolarity);
587 void USART_SetDEAssertionTime(USART_TypeDef* USARTx, uint32_t USART_DEAssertionTime);
588 void USART_SetDEDeassertionTime(USART_TypeDef* USARTx, uint32_t USART_DEDeassertionTime);
589
590 /* DMA transfers management functions *****************************************/
591 void USART_DMACmd(USART_TypeDef* USARTx, uint32_t USART_DMAReq, FunctionalState NewState);
592 void USART_DMAReceptionErrorConfig(USART_TypeDef* USARTx, uint32_t USART_DMAOnError);
593
594 /* Interrupts and flags management functions **********************************/
595 void USART_ITConfig(USART_TypeDef* USARTx, uint32_t USART_IT, FunctionalState NewState);
596 void USART_RequestCmd(USART_TypeDef* USARTx, uint32_t USART_Request, FunctionalState NewState);
597 void USART_OverrunDetectionConfig(USART_TypeDef* USARTx, uint32_t USART_OVRDetection);
598 FlagStatus USART_GetFlagStatus(USART_TypeDef* USARTx, uint32_t USART_FLAG);
599 void USART_ClearFlag(USART_TypeDef* USARTx, uint32_t USART_FLAG);
600 ITStatus USART_GetITStatus(USART_TypeDef* USARTx, uint32_t USART_IT);
601 void USART_ClearITPendingBit(USART_TypeDef* USARTx, uint32_t USART_IT);
602
603 #ifdef __cplusplus
604 }
605 #endif
606
607 #endif /* __STM32F30x_USART_H */
608
609 /**
610   * @}
611   */ 
612
613 /**
614   * @}
615   */ 
616
617 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/