serial_buf.h
5.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
*********************************************************************************************************
* SERIAL (BYTE) COMMUNICATION
*
* (c) Copyright 2007-2009; Micrium, Inc.; Weston, FL
*
* All rights reserved. Protected by international copyright laws.
* Knowledge of the source code may NOT be used to develop a similar product.
* Please help us continue to provide the Embedded community with the finest
* software available. Your honesty is greatly appreciated.
*********************************************************************************************************
*/
/*
*********************************************************************************************************
*
* SERIAL (BYTE) COMMUNICATION
*
* Filename : serial.h
* Version : V2.00
* Programmer(s) : FGK
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* MODULE
*
* Note(s) : (1) This header file is protected from multiple pre-processor inclusion through use of the
* SERIAL_BUF present pre-processor macro definition.
*********************************************************************************************************
*/
#ifndef SERIAL_BUF_PRESENT
#define SERIAL_BUF_PRESENT
/*
*********************************************************************************************************
* EXTERNS
*********************************************************************************************************
*/
#ifdef SERIAL_BUF_MODULE
#define SERIAL_BUF_EXT
#else
#define SERIAL_BUF_EXT extern
#endif
/*
*********************************************************************************************************
* SERIAL BUFFER DATA TYPE
*********************************************************************************************************
*/
typedef struct serial_buf {
CPU_SIZE_T Len; /* Buf len. */
CPU_SIZE_T EmptyCnt; /* Empty entries cnt. */
CPU_SIZE_T IxRd; /* Next rd ix. */
CPU_SIZE_T IxWr; /* Next wr ix. */
CPU_INT08U *DataPtr; /* Ptr to buf data area. */
} SERIAL_BUF;
/*
*********************************************************************************************************
* FUNCTION PROTOTYPES
*********************************************************************************************************
*/
void SerialBuf_Init (SERIAL_BUF *pbuf, /* Init buf. */
CPU_INT08U *pdata,
CPU_SIZE_T len,
CPU_BOOLEAN full);
void SerialBuf_Clr (SERIAL_BUF *pbuf); /* Clr buf. */
CPU_SIZE_T SerialBuf_Rd (SERIAL_BUF *pbuf, /* Rd from buf. */
CPU_INT08U *psrc,
CPU_SIZE_T len);
CPU_BOOLEAN SerialBuf_RdOctet(SERIAL_BUF *pbuf, /* Rd octet from buf. */
CPU_INT08U *pdatum);
CPU_BOOLEAN SerialBuf_WrOctet(SERIAL_BUF *pbuf, /* Wr octet to buf. */
CPU_INT08U datum);
CPU_BOOLEAN SerialBuf_Cmp (SERIAL_BUF *pbuf, /* Cmp incoming octets to buf. */
CPU_INT08U datum);
CPU_BOOLEAN SerialBuf_IsEmpty(SERIAL_BUF *pbuf); /* Determine whether buf is empty. */
CPU_BOOLEAN SerialBuf_IsFull (SERIAL_BUF *pbuf); /* Determine whether buf is full. */
CPU_SIZE_T SerialBuf_Size (SERIAL_BUF *pbuf); /* Retrieve buf size. */
CPU_SIZE_T SerialBuf_DataLen(SERIAL_BUF *pbuf); /* Determine buf data area len. */
/*
*********************************************************************************************************
* MODULE END
*********************************************************************************************************
*/
#endif /* End of SERIAL_BUF module include. */