OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [CORTEX_STM32L152_IAR/] [system_and_ST_code/] [STM32L1xx_StdPeriph_Driver/] [inc/] [stm32l1xx_usart.h] - Blame information for rev 582

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 582 jeremybenn
/**
2
  ******************************************************************************
3
  * @file    stm32l1xx_usart.h
4
  * @author  MCD Application Team
5
  * @version V1.0.0RC1
6
  * @date    07/02/2010
7
  * @brief   This file contains all the functions prototypes for the USART
8
  *          firmware library.
9
  ******************************************************************************
10
  * @copy
11
  *
12
  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
13
  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
14
  * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
15
  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
16
  * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
17
  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
18
  *
19
  * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
20
  */
21
 
22
/* Define to prevent recursive inclusion -------------------------------------*/
23
#ifndef __STM32L1xx_USART_H
24
#define __STM32L1xx_USART_H
25
 
26
#ifdef __cplusplus
27
 extern "C" {
28
#endif
29
 
30
/* Includes ------------------------------------------------------------------*/
31
#include "stm32l1xx.h"
32
 
33
/** @addtogroup STM32L1xx_StdPeriph_Driver
34
  * @{
35
  */
36
 
37
/** @addtogroup USART
38
  * @{
39
  */
40
 
41
/** @defgroup USART_Exported_Types
42
  * @{
43
  */
44
 
45
/**
46
  * @brief  USART Init Structure definition
47
  */
48
 
49
typedef struct
50
{
51
  uint32_t USART_BaudRate;            /*!< This member configures the USART communication baud rate.
52
                                           The baud rate is computed using the following formula:
53
                                            - IntegerDivider = ((PCLKx) / (16 * (USART_InitStruct->USART_BaudRate)))
54
                                            - FractionalDivider = ((IntegerDivider - ((u32) IntegerDivider)) * 16) + 0.5 */
55
 
56
  uint16_t USART_WordLength;          /*!< Specifies the number of data bits transmitted or received in a frame.
57
                                           This parameter can be a value of @ref USART_Word_Length */
58
 
59
  uint16_t USART_StopBits;            /*!< Specifies the number of stop bits transmitted.
60
                                           This parameter can be a value of @ref USART_Stop_Bits */
61
 
62
  uint16_t USART_Parity;              /*!< Specifies the parity mode.
63
                                           This parameter can be a value of @ref USART_Parity
64
                                           @note When parity is enabled, the computed parity is inserted
65
                                                 at the MSB position of the transmitted data (9th bit when
66
                                                 the word length is set to 9 data bits; 8th bit when the
67
                                                 word length is set to 8 data bits). */
68
 
69
  uint16_t USART_Mode;                /*!< Specifies wether the Receive or Transmit mode is enabled or disabled.
70
                                           This parameter can be a value of @ref USART_Mode */
71
 
72
  uint16_t USART_HardwareFlowControl; /*!< Specifies wether the hardware flow control mode is enabled
73
                                           or disabled.
74
                                           This parameter can be a value of @ref USART_Hardware_Flow_Control */
75
} USART_InitTypeDef;
76
 
77
/**
78
  * @brief  USART Clock Init Structure definition
79
  */
80
 
81
typedef struct
82
{
83
 
84
  uint16_t USART_Clock;   /*!< Specifies whether the USART clock is enabled or disabled.
85
                               This parameter can be a value of @ref USART_Clock */
86
 
87
  uint16_t USART_CPOL;    /*!< Specifies the steady state value of the serial clock.
88
                               This parameter can be a value of @ref USART_Clock_Polarity */
89
 
90
  uint16_t USART_CPHA;    /*!< Specifies the clock transition on which the bit capture is made.
91
                               This parameter can be a value of @ref USART_Clock_Phase */
92
 
93
  uint16_t USART_LastBit; /*!< Specifies whether the clock pulse corresponding to the last transmitted
94
                               data bit (MSB) has to be output on the SCLK pin in synchronous mode.
95
                               This parameter can be a value of @ref USART_Last_Bit */
96
} USART_ClockInitTypeDef;
97
 
98
/**
99
  * @}
100
  */
101
 
102
/** @defgroup USART_Exported_Constants
103
  * @{
104
  */
105
 
106
#define IS_USART_ALL_PERIPH(PERIPH) (((PERIPH) == USART1) || \
107
                                     ((PERIPH) == USART2) || \
108
                                     ((PERIPH) == USART3))
109
 
110
/** @defgroup USART_Word_Length
111
  * @{
112
  */
113
 
114
#define USART_WordLength_8b                  ((uint16_t)0x0000)
115
#define USART_WordLength_9b                  ((uint16_t)0x1000)
116
 
117
#define IS_USART_WORD_LENGTH(LENGTH) (((LENGTH) == USART_WordLength_8b) || \
118
                                      ((LENGTH) == USART_WordLength_9b))
119
/**
120
  * @}
121
  */
122
 
123
/** @defgroup USART_Stop_Bits
124
  * @{
125
  */
126
 
127
#define USART_StopBits_1                     ((uint16_t)0x0000)
128
#define USART_StopBits_0_5                   ((uint16_t)0x1000)
129
#define USART_StopBits_2                     ((uint16_t)0x2000)
130
#define USART_StopBits_1_5                   ((uint16_t)0x3000)
131
#define IS_USART_STOPBITS(STOPBITS) (((STOPBITS) == USART_StopBits_1) || \
132
                                     ((STOPBITS) == USART_StopBits_0_5) || \
133
                                     ((STOPBITS) == USART_StopBits_2) || \
134
                                     ((STOPBITS) == USART_StopBits_1_5))
135
/**
136
  * @}
137
  */
138
 
139
/** @defgroup USART_Parity
140
  * @{
141
  */
142
 
143
#define USART_Parity_No                      ((uint16_t)0x0000)
144
#define USART_Parity_Even                    ((uint16_t)0x0400)
145
#define USART_Parity_Odd                     ((uint16_t)0x0600) 
146
#define IS_USART_PARITY(PARITY) (((PARITY) == USART_Parity_No) || \
147
                                 ((PARITY) == USART_Parity_Even) || \
148
                                 ((PARITY) == USART_Parity_Odd))
149
/**
150
  * @}
151
  */
152
 
153
/** @defgroup USART_Mode
154
  * @{
155
  */
156
 
157
#define USART_Mode_Rx                        ((uint16_t)0x0004)
158
#define USART_Mode_Tx                        ((uint16_t)0x0008)
159
#define IS_USART_MODE(MODE) ((((MODE) & (uint16_t)0xFFF3) == 0x00) && ((MODE) != (uint16_t)0x00))
160
/**
161
  * @}
162
  */
163
 
164
/** @defgroup USART_Hardware_Flow_Control
165
  * @{
166
  */
167
#define USART_HardwareFlowControl_None       ((uint16_t)0x0000)
168
#define USART_HardwareFlowControl_RTS        ((uint16_t)0x0100)
169
#define USART_HardwareFlowControl_CTS        ((uint16_t)0x0200)
170
#define USART_HardwareFlowControl_RTS_CTS    ((uint16_t)0x0300)
171
#define IS_USART_HARDWARE_FLOW_CONTROL(CONTROL)\
172
                              (((CONTROL) == USART_HardwareFlowControl_None) || \
173
                               ((CONTROL) == USART_HardwareFlowControl_RTS) || \
174
                               ((CONTROL) == USART_HardwareFlowControl_CTS) || \
175
                               ((CONTROL) == USART_HardwareFlowControl_RTS_CTS))
176
/**
177
  * @}
178
  */
179
 
180
/** @defgroup USART_Clock
181
  * @{
182
  */
183
#define USART_Clock_Disable                  ((uint16_t)0x0000)
184
#define USART_Clock_Enable                   ((uint16_t)0x0800)
185
#define IS_USART_CLOCK(CLOCK) (((CLOCK) == USART_Clock_Disable) || \
186
                               ((CLOCK) == USART_Clock_Enable))
187
/**
188
  * @}
189
  */
190
 
191
/** @defgroup USART_Clock_Polarity
192
  * @{
193
  */
194
 
195
#define USART_CPOL_Low                       ((uint16_t)0x0000)
196
#define USART_CPOL_High                      ((uint16_t)0x0400)
197
#define IS_USART_CPOL(CPOL) (((CPOL) == USART_CPOL_Low) || ((CPOL) == USART_CPOL_High))
198
 
199
/**
200
  * @}
201
  */
202
 
203
/** @defgroup USART_Clock_Phase
204
  * @{
205
  */
206
 
207
#define USART_CPHA_1Edge                     ((uint16_t)0x0000)
208
#define USART_CPHA_2Edge                     ((uint16_t)0x0200)
209
#define IS_USART_CPHA(CPHA) (((CPHA) == USART_CPHA_1Edge) || ((CPHA) == USART_CPHA_2Edge))
210
 
211
/**
212
  * @}
213
  */
214
 
215
/** @defgroup USART_Last_Bit
216
  * @{
217
  */
218
 
219
#define USART_LastBit_Disable                ((uint16_t)0x0000)
220
#define USART_LastBit_Enable                 ((uint16_t)0x0100)
221
#define IS_USART_LASTBIT(LASTBIT) (((LASTBIT) == USART_LastBit_Disable) || \
222
                                   ((LASTBIT) == USART_LastBit_Enable))
223
/**
224
  * @}
225
  */
226
 
227
/** @defgroup USART_Interrupt_definition
228
  * @{
229
  */
230
 
231
#define USART_IT_PE                          ((uint16_t)0x0028)
232
#define USART_IT_TXE                         ((uint16_t)0x0727)
233
#define USART_IT_TC                          ((uint16_t)0x0626)
234
#define USART_IT_RXNE                        ((uint16_t)0x0525)
235
#define USART_IT_IDLE                        ((uint16_t)0x0424)
236
#define USART_IT_LBD                         ((uint16_t)0x0846)
237
#define USART_IT_CTS                         ((uint16_t)0x096A)
238
#define USART_IT_ERR                         ((uint16_t)0x0060)
239
#define USART_IT_ORE                         ((uint16_t)0x0360)
240
#define USART_IT_NE                          ((uint16_t)0x0260)
241
#define USART_IT_FE                          ((uint16_t)0x0160)
242
#define IS_USART_CONFIG_IT(IT) (((IT) == USART_IT_PE) || ((IT) == USART_IT_TXE) || \
243
                                ((IT) == USART_IT_TC) || ((IT) == USART_IT_RXNE) || \
244
                                ((IT) == USART_IT_IDLE) || ((IT) == USART_IT_LBD) || \
245
                                ((IT) == USART_IT_CTS) || ((IT) == USART_IT_ERR))
246
#define IS_USART_GET_IT(IT) (((IT) == USART_IT_PE) || ((IT) == USART_IT_TXE) || \
247
                             ((IT) == USART_IT_TC) || ((IT) == USART_IT_RXNE) || \
248
                             ((IT) == USART_IT_IDLE) || ((IT) == USART_IT_LBD) || \
249
                             ((IT) == USART_IT_CTS) || ((IT) == USART_IT_ORE) || \
250
                             ((IT) == USART_IT_NE) || ((IT) == USART_IT_FE))
251
#define IS_USART_CLEAR_IT(IT) (((IT) == USART_IT_TC) || ((IT) == USART_IT_RXNE) || \
252
                               ((IT) == USART_IT_LBD) || ((IT) == USART_IT_CTS))
253
/**
254
  * @}
255
  */
256
 
257
/** @defgroup USART_DMA_Requests
258
  * @{
259
  */
260
 
261
#define USART_DMAReq_Tx                      ((uint16_t)0x0080)
262
#define USART_DMAReq_Rx                      ((uint16_t)0x0040)
263
#define IS_USART_DMAREQ(DMAREQ) ((((DMAREQ) & (uint16_t)0xFF3F) == 0x00) && ((DMAREQ) != (uint16_t)0x00))
264
 
265
/**
266
  * @}
267
  */
268
 
269
/** @defgroup USART_WakeUp_methods
270
  * @{
271
  */
272
 
273
#define USART_WakeUp_IdleLine                ((uint16_t)0x0000)
274
#define USART_WakeUp_AddressMark             ((uint16_t)0x0800)
275
#define IS_USART_WAKEUP(WAKEUP) (((WAKEUP) == USART_WakeUp_IdleLine) || \
276
                                 ((WAKEUP) == USART_WakeUp_AddressMark))
277
/**
278
  * @}
279
  */
280
 
281
/** @defgroup USART_LIN_Break_Detection_Length
282
  * @{
283
  */
284
 
285
#define USART_LINBreakDetectLength_10b      ((uint16_t)0x0000)
286
#define USART_LINBreakDetectLength_11b      ((uint16_t)0x0020)
287
#define IS_USART_LIN_BREAK_DETECT_LENGTH(LENGTH) \
288
                               (((LENGTH) == USART_LINBreakDetectLength_10b) || \
289
                                ((LENGTH) == USART_LINBreakDetectLength_11b))
290
/**
291
  * @}
292
  */
293
 
294
/** @defgroup USART_IrDA_Low_Power
295
  * @{
296
  */
297
 
298
#define USART_IrDAMode_LowPower              ((uint16_t)0x0004)
299
#define USART_IrDAMode_Normal                ((uint16_t)0x0000)
300
#define IS_USART_IRDA_MODE(MODE) (((MODE) == USART_IrDAMode_LowPower) || \
301
                                  ((MODE) == USART_IrDAMode_Normal))
302
/**
303
  * @}
304
  */
305
 
306
/** @defgroup USART_Flags
307
  * @{
308
  */
309
 
310
#define USART_FLAG_CTS                       ((uint16_t)0x0200)
311
#define USART_FLAG_LBD                       ((uint16_t)0x0100)
312
#define USART_FLAG_TXE                       ((uint16_t)0x0080)
313
#define USART_FLAG_TC                        ((uint16_t)0x0040)
314
#define USART_FLAG_RXNE                      ((uint16_t)0x0020)
315
#define USART_FLAG_IDLE                      ((uint16_t)0x0010)
316
#define USART_FLAG_ORE                       ((uint16_t)0x0008)
317
#define USART_FLAG_NE                        ((uint16_t)0x0004)
318
#define USART_FLAG_FE                        ((uint16_t)0x0002)
319
#define USART_FLAG_PE                        ((uint16_t)0x0001)
320
#define IS_USART_FLAG(FLAG) (((FLAG) == USART_FLAG_PE) || ((FLAG) == USART_FLAG_TXE) || \
321
                             ((FLAG) == USART_FLAG_TC) || ((FLAG) == USART_FLAG_RXNE) || \
322
                             ((FLAG) == USART_FLAG_IDLE) || ((FLAG) == USART_FLAG_LBD) || \
323
                             ((FLAG) == USART_FLAG_CTS) || ((FLAG) == USART_FLAG_ORE) || \
324
                             ((FLAG) == USART_FLAG_NE) || ((FLAG) == USART_FLAG_FE))
325
 
326
#define IS_USART_CLEAR_FLAG(FLAG) ((((FLAG) & (uint16_t)0xFC9F) == 0x00) && ((FLAG) != (uint16_t)0x00))
327
 
328
#define IS_USART_BAUDRATE(BAUDRATE) (((BAUDRATE) > 0) && ((BAUDRATE) < 0x003D0901))
329
#define IS_USART_ADDRESS(ADDRESS) ((ADDRESS) <= 0xF)
330
#define IS_USART_DATA(DATA) ((DATA) <= 0x1FF)
331
 
332
/**
333
  * @}
334
  */
335
 
336
/**
337
  * @}
338
  */
339
 
340
/** @defgroup USART_Exported_Macros
341
  * @{
342
  */
343
 
344
/**
345
  * @}
346
  */
347
 
348
/** @defgroup USART_Exported_Functions
349
  * @{
350
  */
351
 
352
void USART_DeInit(USART_TypeDef* USARTx);
353
void USART_Init(USART_TypeDef* USARTx, USART_InitTypeDef* USART_InitStruct);
354
void USART_StructInit(USART_InitTypeDef* USART_InitStruct);
355
void USART_ClockInit(USART_TypeDef* USARTx, USART_ClockInitTypeDef* USART_ClockInitStruct);
356
void USART_ClockStructInit(USART_ClockInitTypeDef* USART_ClockInitStruct);
357
void USART_Cmd(USART_TypeDef* USARTx, FunctionalState NewState);
358
void USART_ITConfig(USART_TypeDef* USARTx, uint16_t USART_IT, FunctionalState NewState);
359
void USART_DMACmd(USART_TypeDef* USARTx, uint16_t USART_DMAReq, FunctionalState NewState);
360
void USART_SetAddress(USART_TypeDef* USARTx, uint8_t USART_Address);
361
void USART_WakeUpConfig(USART_TypeDef* USARTx, uint16_t USART_WakeUp);
362
void USART_ReceiverWakeUpCmd(USART_TypeDef* USARTx, FunctionalState NewState);
363
void USART_LINBreakDetectLengthConfig(USART_TypeDef* USARTx, uint16_t USART_LINBreakDetectLength);
364
void USART_LINCmd(USART_TypeDef* USARTx, FunctionalState NewState);
365
void USART_SendData(USART_TypeDef* USARTx, uint16_t Data);
366
uint16_t USART_ReceiveData(USART_TypeDef* USARTx);
367
void USART_SendBreak(USART_TypeDef* USARTx);
368
void USART_SetGuardTime(USART_TypeDef* USARTx, uint8_t USART_GuardTime);
369
void USART_SetPrescaler(USART_TypeDef* USARTx, uint8_t USART_Prescaler);
370
void USART_SmartCardCmd(USART_TypeDef* USARTx, FunctionalState NewState);
371
void USART_SmartCardNACKCmd(USART_TypeDef* USARTx, FunctionalState NewState);
372
void USART_HalfDuplexCmd(USART_TypeDef* USARTx, FunctionalState NewState);
373
void USART_OverSampling8Cmd(USART_TypeDef* USARTx, FunctionalState NewState);
374
void USART_OneBitMethodCmd(USART_TypeDef* USARTx, FunctionalState NewState);
375
void USART_IrDAConfig(USART_TypeDef* USARTx, uint16_t USART_IrDAMode);
376
void USART_IrDACmd(USART_TypeDef* USARTx, FunctionalState NewState);
377
FlagStatus USART_GetFlagStatus(USART_TypeDef* USARTx, uint16_t USART_FLAG);
378
void USART_ClearFlag(USART_TypeDef* USARTx, uint16_t USART_FLAG);
379
ITStatus USART_GetITStatus(USART_TypeDef* USARTx, uint16_t USART_IT);
380
void USART_ClearITPendingBit(USART_TypeDef* USARTx, uint16_t USART_IT);
381
 
382
#ifdef __cplusplus
383
}
384
#endif
385
 
386
#endif /* __STM32L1xx_USART_H */
387
/**
388
  * @}
389
  */
390
 
391
/**
392
  * @}
393
  */
394
 
395
/**
396
  * @}
397
  */
398
 
399
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/

powered by: WebSVN 2.1.0

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