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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [ARM7_STR71x_IAR/] [Library/] [include/] [uart.h] - Blame information for rev 592

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 577 jeremybenn
/******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
2
* File Name          : uart.h
3
* Author             : MCD Application Team
4
* Date First Issued  : 16/05/2003
5
* Description        : This file contains all the functions prototypes for the
6
*                      UART software library.
7
********************************************************************************
8
* History:
9
*  30/11/2004 : V2.0
10
*  14/07/2004 : V1.3
11
*  01/01/2004 : V1.2
12
*******************************************************************************
13
 THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH
14
 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, INDIRECT
16
 OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
17
 OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
18
 CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
19
*******************************************************************************/
20
#ifndef _UART_H
21
#define _UART_H
22
 
23
#include "71x_map.h"
24
#include "rccu.h"
25
 
26
typedef enum
27
{
28
  UART_RxFIFO,
29
  UART_TxFIFO
30
} UARTFIFO_TypeDef;
31
 
32
typedef enum
33
{
34
  UART_EVEN_PARITY = 0x0000,
35
  UART_ODD_PARITY  = 0x0020,
36
  UART_NO_PARITY
37
} UARTParity_TypeDef;
38
 
39
typedef enum
40
{
41
  UART_0_5_StopBits  = 0x00,
42
  UART_1_StopBits    = 0x08,
43
  UART_1_5_StopBits  = 0x10,
44
  UART_2_StopBits    = 0x18
45
} UARTStopBits_TypeDef;
46
 
47
typedef enum
48
{
49
  UARTM_8D   = 0x01,
50
  UARTM_7D_P = 0x03,
51
  UARTM_9D   = 0x04,
52
  UARTM_8D_W = 0x05,
53
  UARTM_8D_P = 0x07
54
} UARTMode_TypeDef;
55
 
56
 
57
#define DUMMY 0
58
 
59
// UART flags definition
60
#define UART_TxFull          0x0200
61
#define UART_RxHalfFull      0x0100
62
#define UART_TimeOutIdle     0x0080
63
#define UART_TimeOutNotEmpty 0x0040
64
#define UART_OverrunError    0x0020
65
#define UART_FrameError      0x0010
66
#define UART_ParityError     0x0008
67
#define UART_TxHalfEmpty     0x0004
68
#define UART_TxEmpty         0x0002
69
#define UART_RxBufFull       0x0001
70
 
71
// CR regiter bit definition
72
#define UART_FIFOEnableBit 10
73
#define UART_RxEnableBit   8
74
#define UART_RunBit        7
75
#define UART_LoopBackBit   6
76
#define UART_ParityOddBit  5
77
#define UART_StopBits      3
78
 
79
// Stop bits definition
80
#define UART_05StopBits     0x00
81
#define UART_1StopBit       (0x01<<3)
82
#define UART_15StopBits     (0x02<<3)
83
#define UART_2StopBits      (0x03<<3)
84
 
85
// Modes definition
86
#define UART_8BitsData       0x01
87
#define UART_7BitsData       0x03
88
#define UART_9BitsData       0x04
89
#define UART_8BitsDataWakeUp 0x05
90
#define UART_8BitsDataParity 0x07
91
 
92
/*******************************************************************************
93
* Function Name  : UART_Init
94
* Description    : This function initializes the selected UART.
95
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
96
* Output         : None
97
* Return         : None
98
*******************************************************************************/
99
void UART_Init(UART_TypeDef *UARTx);
100
 
101
/*******************************************************************************
102
* Function Name  : UART_ModeConfig
103
* Description    : This function configures the mode of the selected UART.
104
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
105
* Input 2        : The UART mode
106
* Output         : None
107
* Return         : None
108
*******************************************************************************/
109
inline void UART_ModeConfig(UART_TypeDef *UARTx, UARTMode_TypeDef UART_Mode)
110
{
111
  UARTx->CR = (UARTx->CR&0xFFF8)|(u16)UART_Mode;
112
}
113
 
114
/*******************************************************************************
115
* Function Name  : UART_BaudRateConfig
116
* Description    : This function configures the baud rate of the selected UART.
117
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
118
* Input 2        : The baudrate value
119
* Output         : None
120
* Return         : None
121
*******************************************************************************/
122
void UART_BaudRateConfig(UART_TypeDef *UARTx, u32 BaudRate);
123
 
124
/*******************************************************************************
125
* Function Name  : UART_ParityConfig
126
* Description    : This function configures the data parity of the selected UART.
127
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
128
* Input 2        : The parity type
129
* Output         : None
130
* Return         : None
131
*******************************************************************************/
132
inline void UART_ParityConfig(UART_TypeDef *UARTx, UARTParity_TypeDef Parity)
133
{
134
  UARTx->CR = (UARTx->CR&0xFFDF)|(u16)Parity;
135
}
136
 
137
/*******************************************************************************
138
* Function Name  : UART_StopBitsConfig
139
* Description    : This function configures the number of stop bits of the
140
*                  selected UART.
141
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
142
* Input 2        : The number of stop bits
143
* Output         : None
144
* Return         : None
145
*******************************************************************************/
146
inline void UART_StopBitsConfig(UART_TypeDef *UARTx, UARTStopBits_TypeDef StopBits)
147
{
148
  UARTx->CR = (UARTx->CR&0xFFE7)|(u16)StopBits;
149
}
150
 
151
/*******************************************************************************
152
* Function Name  : UART_Config
153
* Description    : This function configures the baudrate, the mode, the data
154
*                  parity and the number of stop bits of the selected UART.
155
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
156
* Input 2        : The baudrate value
157
* Input 3        : The parity type
158
* Input 4        : The number of stop bits
159
* Input 5        : The UART mode
160
* Output         : None
161
* Return         : None
162
*******************************************************************************/
163
void UART_Config(UART_TypeDef *UARTx, u32 BaudRate, UARTParity_TypeDef Parity,
164
                 UARTStopBits_TypeDef StopBits, UARTMode_TypeDef Mode);
165
 
166
/*******************************************************************************
167
* Function Name  : UART_ItConfig
168
* Description    : This function enables or disables the interrupts of the
169
*                  selected UART.
170
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
171
* Input 2        : The new interrupt flag
172
* Input 3        : ENABLE or DISABLE
173
* Output         : None
174
* Return         : None
175
*******************************************************************************/
176
void UART_ItConfig(UART_TypeDef *UARTx, u16 UART_Flag, FunctionalState NewState);
177
 
178
/*******************************************************************************
179
* Function Name  : UART_FifoConfig
180
* Description    : This function enables or disables the Rx and Tx FIFOs of
181
*                  the selected UART.
182
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
183
* Input 2        : ENABLE or DISABLE
184
* Output         : None
185
* Return         : None
186
*******************************************************************************/
187
void UART_FifoConfig(UART_TypeDef *UARTx, FunctionalState NewState);
188
 
189
/*******************************************************************************
190
* Function Name  : UART_FifoReset
191
* Description    : This function resets the Rx and the Tx FIFOs of the
192
*                  selected UART.
193
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
194
* Input 2        : RxFIFO or TxFIFO
195
* Output         : None
196
* Return         : None
197
*******************************************************************************/
198
void UART_FifoReset(UART_TypeDef *UARTx, UARTFIFO_TypeDef FIFO);
199
 
200
/*******************************************************************************
201
* Function Name  : UART_LoopBackConfig
202
* Description    : This function enables or disables the loop back mode of
203
*                  the selected UART.
204
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
205
* Input 2        : ENABLE or DISABLE
206
* Output         : None
207
* Return         : None
208
*******************************************************************************/
209
void UART_LoopBackConfig(UART_TypeDef *UARTx, FunctionalState NewState);
210
 
211
/*******************************************************************************
212
* Function Name  : UART_TimeOutPeriodConfig
213
* Description    : This function configure the Time Out Period.
214
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
215
* Input 2        : The time-out period value
216
* Output         : None
217
* Return         : None
218
*******************************************************************************/
219
inline void UART_TimeOutPeriodConfig(UART_TypeDef *UARTx, u16 TimeOutPeriod)
220
{
221
  UARTx->TOR = TimeOutPeriod;
222
}
223
 
224
/*******************************************************************************
225
* Function Name  : UART_GuardTimeConfig
226
* Description    : This function configure the Guard Time.
227
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
228
* Input 2        : The guard time value
229
* Output         : None
230
* Return         : None
231
*******************************************************************************/
232
inline void UART_GuardTimeConfig(UART_TypeDef *UARTx, u16 GuardTime)
233
{
234
  UARTx->GTR = GuardTime;
235
}
236
 
237
/*******************************************************************************
238
* Function Name  : UART_RxConfig
239
* Description    : This function enable and disable the UART data reception.
240
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
241
* Input 2        : ENABLE or DISABLE
242
* Output         : None
243
* Return         : None
244
*******************************************************************************/
245
void UART_RxConfig(UART_TypeDef *UARTx, FunctionalState NewState);
246
 
247
/*******************************************************************************
248
* Function Name  : UART_OnOffConfig
249
* Description    : This function sets On/Off the selected UART.
250
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
251
* Input 2        : ENABLE or DISABLE
252
* Output         : None
253
* Return         : None
254
*******************************************************************************/
255
void UART_OnOffConfig(UART_TypeDef *UARTx, FunctionalState NewState);
256
 
257
/*******************************************************************************
258
* Function Name  : UART_ByteSend
259
* Description    : This function sends a data byte to the selected UART.
260
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
261
* Input 2        : A pointer to the data byte to send
262
* Output         : None
263
* Return         : None
264
*******************************************************************************/
265
void UART_ByteSend(UART_TypeDef *UARTx, u8 *Data);
266
 
267
/*******************************************************************************
268
* Function Name  : UART_9BitByteSend
269
* Description    : This function sends a 9 bits data byte to the selected UART.
270
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
271
* Input 2        : A pointer to the data to send
272
* Output         : None
273
* Return         : None
274
*******************************************************************************/
275
void UART_9BitByteSend(UART_TypeDef *UARTx, u16 *Data);
276
 
277
/*******************************************************************************
278
* Function Name  : UART_DataSend
279
* Description    : This function sends several data bytes to the selected UART.
280
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
281
* Input 2        : A pointer to the data to send
282
* Input 3        : The data length in bytes
283
* Output         : None
284
* Return         : None
285
*******************************************************************************/
286
void UART_DataSend(UART_TypeDef *UARTx, u8 *Data, u8 DataLength);
287
 
288
/*******************************************************************************
289
* Function Name  : UART_9BitDataSend
290
* Description    : This function sends several 9 bits data bytes to the selected UART.
291
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
292
* Input 2        : A pointer to the data to send
293
* Input 3        : The data length
294
* Output         : None
295
* Return         : None
296
*******************************************************************************/
297
void UART_9BitDataSend(UART_TypeDef *UARTx, u16 *Data, u8 DataLength);
298
 
299
/*******************************************************************************
300
* Function Name  : UART_StringSend
301
* Description    : This function sends a string to the selected UART.
302
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
303
* Input 2        : A pointer to the string to send
304
* Output         : None
305
* Return         : None
306
*******************************************************************************/
307
void UART_StringSend(UART_TypeDef *UARTx, u8 *String);
308
 
309
/*******************************************************************************
310
* Function Name  : UART_ByteReceive
311
* Description    : This function gets a data byte from the selected UART.
312
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
313
* Input 2        : A pointer to the buffer where the data will be stored
314
* Input 3        : The time-out period
315
* Output         : The received data
316
* Return         : The UARTx.SR register contents
317
*******************************************************************************/
318
u16 UART_ByteReceive(UART_TypeDef *UARTx, u8 *Data, u8 TimeOut);
319
 
320
/*******************************************************************************
321
* Function Name  : UART_9BitByteReceive
322
* Description    : This function gets a 9 bits data byte from the selected UART.
323
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
324
* Input 2        : A pointer to the buffer where the data will be stored
325
* Input 3        : The time-out period value
326
* Output         : The received data
327
* Return         : The UARTx.SR register contents
328
*******************************************************************************/
329
u16 UART_9BitByteReceive(UART_TypeDef *UARTx, u16 *Data, u8 TimeOut);
330
 
331
/*******************************************************************************
332
* Function Name  : UART_DataReceive
333
* Description    : This function gets 8 bits data bytes from the selected UART.
334
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
335
* Input 2        : A pointer to the buffer where the data will be stored
336
* Input 3        : The data length
337
* Input 4        : The time-out period value
338
* Output         : The received data
339
* Return         : The UARTx.SR register contents
340
*******************************************************************************/
341
u16 UART_DataReceive(UART_TypeDef *UARTx, u8 *Data, u8 DataLength, u8 TimeOut);
342
 
343
/*******************************************************************************
344
* Function Name  : UART_9BitDataReceive
345
* Description    : This function gets 9 bits data bytes from the selected UART.
346
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
347
* Input 2        : A pointer to the buffer where the data will be stored
348
* Input 3        : The data length
349
* Input 4        : The time-out value
350
* Output         : The received data
351
* Return         : The UARTx.SR register contents
352
*******************************************************************************/
353
u16 UART_9BitDataReceive(UART_TypeDef *UARTx, u16 *Data, u8 DataLength, u8 TimeOut);
354
 
355
/*******************************************************************************
356
* Function Name  : UART_StringReceive
357
* Description    : This function gets 8 bits data bytes from the selected UART.
358
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
359
* Input 2        : A pointer to the buffer where the string will be stored
360
* Output         : None
361
* Return         : None
362
*******************************************************************************/
363
u16 UART_StringReceive(UART_TypeDef *UARTx, u8 *Data);
364
 
365
/*******************************************************************************
366
* Function Name  : UART_FlagStatus
367
* Description    : This function gets the flags status of the selected UART.
368
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
369
* Output         : None
370
* Return         : None
371
*******************************************************************************/
372
inline u16 UART_FlagStatus(UART_TypeDef *UARTx)
373
{
374
  return UARTx->SR;
375
}
376
 
377
#ifdef USE_SERIAL_PORT
378
/*******************************************************************************
379
* Function Name  : sendchar
380
* Description    : This function sends a character to the selected UART.
381
* Input 1        : A pointer to the character to send.
382
* Output         : None
383
* Return         : None
384
*******************************************************************************/
385
void sendchar( char *ch );
386
#endif /* USE_SERIAL_PORT */
387
 
388
#endif /* _UART_H */
389
 
390
/******************* (C) COPYRIGHT 2003 STMicroelectronics *****END OF FILE****/

powered by: WebSVN 2.1.0

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