OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [Common/] [drivers/] [ST/] [STM32F10xFWLib/] [inc/] [stm32f10x_usart.h] - Blame information for rev 608

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 608 jeremybenn
/******************** (C) COPYRIGHT 2007 STMicroelectronics ********************
2
* File Name          : stm32f10x_usart.h
3
* Author             : MCD Application Team
4
* Date First Issued  : 09/29/2006
5
* Description        : This file contains all the functions prototypes for the
6
*                      USART firmware library.
7
********************************************************************************
8
* History:
9
* 04/02/2007: V0.2
10
* 02/05/2007: V0.1
11
* 09/29/2006: V0.01
12
********************************************************************************
13
* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
14
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
15
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
16
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
17
* CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
18
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
19
*******************************************************************************/
20
 
21
/* Define to prevent recursive inclusion -------------------------------------*/
22
#ifndef __STM32F10x_USART_H
23
#define __STM32F10x_USART_H
24
 
25
/* Includes ------------------------------------------------------------------*/
26
#include "stm32f10x_map.h"
27
 
28
/* Exported types ------------------------------------------------------------*/
29
/* UART Init Structure definition */
30
typedef struct
31
{
32
  u32 USART_BaudRate;
33
  u16 USART_WordLength;
34
  u16 USART_StopBits;
35
  u16 USART_Parity;
36
  u16 USART_HardwareFlowControl;
37
  u16 USART_Mode;
38
  u16 USART_Clock;
39
  u16 USART_CPOL;
40
  u16 USART_CPHA;
41
  u16 USART_LastBit;
42
} USART_InitTypeDef;
43
 
44
/* Exported constants --------------------------------------------------------*/
45
/* USART Word Length ---------------------------------------------------------*/
46
#define USART_WordLength_8b                  ((u16)0x0000)
47
#define USART_WordLength_9b                  ((u16)0x1000)
48
 
49
#define IS_USART_WORD_LENGTH(LENGTH) ((LENGTH == USART_WordLength_8b) || \
50
                                      (LENGTH == USART_WordLength_9b))
51
 
52
/* USART Stop Bits -----------------------------------------------------------*/
53
#define USART_StopBits_1                     ((u16)0x0000)
54
#define USART_StopBits_0_5                   ((u16)0x1000)
55
#define USART_StopBits_2                     ((u16)0x2000)
56
#define USART_StopBits_1_5                   ((u16)0x3000)
57
 
58
#define IS_USART_STOPBITS(STOPBITS) ((STOPBITS == USART_StopBits_1) || \
59
                                     (STOPBITS == USART_StopBits_0_5) || \
60
                                     (STOPBITS == USART_StopBits_2) || \
61
                                     (STOPBITS == USART_StopBits_1_5))
62
/* USART Parity --------------------------------------------------------------*/
63
#define USART_Parity_No                      ((u16)0x0000)
64
#define USART_Parity_Even                    ((u16)0x0400)
65
#define USART_Parity_Odd                     ((u16)0x0600) 
66
 
67
#define IS_USART_PARITY(PARITY) ((PARITY == USART_Parity_No) || \
68
                                 (PARITY == USART_Parity_Even) || \
69
                                 (PARITY == USART_Parity_Odd))
70
 
71
/* USART Hardware Flow Control -----------------------------------------------*/
72
#define USART_HardwareFlowControl_None       ((u16)0x0000)
73
#define USART_HardwareFlowControl_RTS        ((u16)0x0100)
74
#define USART_HardwareFlowControl_CTS        ((u16)0x0200)
75
#define USART_HardwareFlowControl_RTS_CTS    ((u16)0x0300)
76
 
77
#define IS_USART_HARDWARE_FLOW_CONTROL(CONTROL)\
78
                              ((CONTROL == USART_HardwareFlowControl_None) || \
79
                               (CONTROL == USART_HardwareFlowControl_RTS) || \
80
                               (CONTROL == USART_HardwareFlowControl_CTS) || \
81
                               (CONTROL == USART_HardwareFlowControl_RTS_CTS))
82
 
83
/* USART Mode ----------------------------------------------------------------*/
84
#define USART_Mode_Rx                        ((u16)0x0004)
85
#define USART_Mode_Tx                        ((u16)0x0008)
86
 
87
#define IS_USART_MODE(MODE) (((MODE & (u16)0xFFF3) == 0x00) && (MODE != (u16)0x00))
88
 
89
/* USART Clock ---------------------------------------------------------------*/
90
#define USART_Clock_Disable                  ((u16)0x0000)
91
#define USART_Clock_Enable                   ((u16)0x0800)
92
 
93
#define IS_USART_CLOCK(CLOCK) ((CLOCK == USART_Clock_Disable) || \
94
                               (CLOCK == USART_Clock_Enable))
95
 
96
/* USART Clock Polarity ------------------------------------------------------*/
97
#define USART_CPOL_Low                       ((u16)0x0000)
98
#define USART_CPOL_High                      ((u16)0x0400)
99
 
100
#define IS_USART_CPOL(CPOL) ((CPOL == USART_CPOL_Low) || (CPOL == USART_CPOL_High))
101
 
102
/* USART Clock Phase ---------------------------------------------------------*/
103
#define USART_CPHA_1Edge                     ((u16)0x0000)
104
#define USART_CPHA_2Edge                     ((u16)0x0200)
105
#define IS_USART_CPHA(CPHA) ((CPHA == USART_CPHA_1Edge) || (CPHA == USART_CPHA_2Edge))
106
 
107
/* USART Last Bit ------------------------------------------------------------*/
108
#define USART_LastBit_Disable                ((u16)0x0000)
109
#define USART_LastBit_Enable                 ((u16)0x0100)
110
 
111
#define IS_USART_LASTBIT(LASTBIT) ((LASTBIT == USART_LastBit_Disable) || \
112
                                   (LASTBIT == USART_LastBit_Enable))
113
 
114
/* USART Interrupt definition ------------------------------------------------*/
115
#define USART_IT_PE                          ((u16)0x0028)
116
#define USART_IT_TXE                         ((u16)0x0727)
117
#define USART_IT_TC                          ((u16)0x0626)
118
#define USART_IT_RXNE                        ((u16)0x0525)
119
#define USART_IT_IDLE                        ((u16)0x0424)
120
#define USART_IT_LBD                         ((u16)0x0846)
121
#define USART_IT_CTS                         ((u16)0x096A)
122
#define USART_IT_ERR                         ((u16)0x0060)
123
#define USART_IT_ORE                         ((u16)0x0360)
124
#define USART_IT_NE                          ((u16)0x0260)
125
#define USART_IT_FE                          ((u16)0x0160)
126
 
127
#define IS_USART_CONFIG_IT(IT) ((IT == USART_IT_PE) || (IT == USART_IT_TXE) || \
128
                               (IT == USART_IT_TC) || (IT == USART_IT_RXNE) || \
129
                               (IT == USART_IT_IDLE) || (IT == USART_IT_LBD) || \
130
                               (IT == USART_IT_CTS) || (IT == USART_IT_ERR))
131
 
132
#define IS_USART_IT(IT) ((IT == USART_IT_PE) || (IT == USART_IT_TXE) || \
133
                         (IT == USART_IT_TC) || (IT == USART_IT_RXNE) || \
134
                         (IT == USART_IT_IDLE) || (IT == USART_IT_LBD) || \
135
                         (IT == USART_IT_CTS) || (IT == USART_IT_ORE) || \
136
                         (IT == USART_IT_NE) || (IT == USART_IT_FE))
137
 
138
/* USART DMA Requests --------------------------------------------------------*/
139
#define USART_DMAReq_Tx                      ((u16)0x0080)
140
#define USART_DMAReq_Rx                      ((u16)0x0040)
141
 
142
#define IS_USART_DMAREQ(DMAREQ) (((DMAREQ & (u16)0xFF3F) == 0x00) && (DMAREQ != (u16)0x00))
143
 
144
/* USART WakeUp methods ------------------------------------------------------*/
145
#define USART_WakeUp_IdleLine                ((u16)0x0000)
146
#define USART_WakeUp_AddressMark             ((u16)0x0800)
147
 
148
#define IS_USART_WAKEUP(WAKEUP) ((WAKEUP == USART_WakeUp_IdleLine) || \
149
                                 (WAKEUP == USART_WakeUp_AddressMark))
150
 
151
/* USART LIN Break Detection Length ------------------------------------------*/
152
#define USART_LINBreakDetectLength_10b      ((u16)0x0000)
153
#define USART_LINBreakDetectLength_11b      ((u16)0x0020)
154
 
155
#define IS_USART_LIN_BREAK_DETECT_LENGTH(LENGTH) \
156
                               ((LENGTH == USART_LINBreakDetectLength_10b) || \
157
                                (LENGTH == USART_LINBreakDetectLength_11b))
158
 
159
/* USART IrDA Low Power ------------------------------------------------------*/
160
#define USART_IrDAMode_LowPower              ((u16)0x0004)
161
#define USART_IrDAMode_Normal                ((u16)0x0000)
162
 
163
#define IS_USART_IRDA_MODE(MODE) ((MODE == USART_IrDAMode_LowPower) || \
164
                                  (MODE == USART_IrDAMode_Normal))
165
 
166
/* USART Flags ---------------------------------------------------------------*/
167
#define USART_FLAG_CTS                       ((u16)0x0200)
168
#define USART_FLAG_LBD                       ((u16)0x0100)
169
#define USART_FLAG_TXE                       ((u16)0x0080)
170
#define USART_FLAG_TC                        ((u16)0x0040)
171
#define USART_FLAG_RXNE                      ((u16)0x0020)
172
#define USART_FLAG_IDLE                      ((u16)0x0010)
173
#define USART_FLAG_ORE                       ((u16)0x0008)
174
#define USART_FLAG_NE                        ((u16)0x0004)
175
#define USART_FLAG_FE                        ((u16)0x0002)
176
#define USART_FLAG_PE                        ((u16)0x0001)
177
 
178
#define IS_USART_FLAG(FLAG) ((FLAG == USART_FLAG_PE) || (FLAG == USART_FLAG_TXE) || \
179
                             (FLAG == USART_FLAG_TC) || (FLAG == USART_FLAG_RXNE) || \
180
                             (FLAG == USART_FLAG_IDLE) || (FLAG == USART_FLAG_LBD) || \
181
                             (FLAG == USART_FLAG_CTS) || (FLAG == USART_FLAG_ORE) || \
182
                             (FLAG == USART_FLAG_NE) || (FLAG == USART_FLAG_FE))
183
 
184
#define IS_USART_CLEAR_FLAG(FLAG) (((FLAG & (u16)0xFC00) == 0x00) && (FLAG != (u16)0x00))
185
 
186
#define IS_USART_ADDRESS(ADDRESS) (ADDRESS <= 0xF)
187
#define IS_USART_DATA(DATA) (DATA <= 0x1FF)
188
 
189
/* Exported macro ------------------------------------------------------------*/
190
/* Exported functions ------------------------------------------------------- */
191
void USART_DeInit(USART_TypeDef* USARTx);
192
void USART_Init(USART_TypeDef* USARTx, USART_InitTypeDef* USART_InitStruct);
193
void USART_StructInit(USART_InitTypeDef* USART_InitStruct);
194
void USART_Cmd(USART_TypeDef* USARTx, FunctionalState NewState);
195
void USART_ITConfig(USART_TypeDef* USARTx, u16 USART_IT, FunctionalState NewState);
196
void USART_DMACmd(USART_TypeDef* USARTx, u16 USART_DMAReq, FunctionalState NewState);
197
void USART_SetAddress(USART_TypeDef* USARTx, u8 USART_Address);
198
void USART_WakeUpConfig(USART_TypeDef* USARTx, u16 USART_WakeUp);
199
void USART_ReceiverWakeUpCmd(USART_TypeDef* USARTx, FunctionalState NewState);
200
void USART_LINBreakDetectLengthConfig(USART_TypeDef* USARTx, u16 USART_LINBreakDetectLength);
201
void USART_LINCmd(USART_TypeDef* USARTx, FunctionalState NewState);
202
void USART_SendData(USART_TypeDef* USARTx, u16 Data);
203
u16 USART_ReceiveData(USART_TypeDef* USARTx);
204
void USART_SendBreak(USART_TypeDef* USARTx);
205
void USART_SetGuardTime(USART_TypeDef* USARTx, u8 USART_GuardTime);
206
void USART_SetPrescaler(USART_TypeDef* USARTx, u8 USART_Prescaler);
207
void USART_SmartCardCmd(USART_TypeDef* USARTx, FunctionalState NewState);
208
void USART_SmartCardNACKCmd(USART_TypeDef* USARTx, FunctionalState NewState);
209
void USART_HalfDuplexCmd(USART_TypeDef* USARTx, FunctionalState NewState);
210
void USART_IrDAConfig(USART_TypeDef* USARTx, u16 USART_IrDAMode);
211
void USART_IrDACmd(USART_TypeDef* USARTx, FunctionalState NewState);
212
FlagStatus USART_GetFlagStatus(USART_TypeDef* USARTx, u16 USART_FLAG);
213
void USART_ClearFlag(USART_TypeDef* USARTx, u16 USART_FLAG);
214
ITStatus USART_GetITStatus(USART_TypeDef* USARTx, u16 USART_IT);
215
void USART_ClearITPendingBit(USART_TypeDef* USARTx, u16 USART_IT);
216
 
217
#endif /* __STM32F10x_USART_H */
218
 
219
/******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.