|
1 /********************************************************************* |
|
2 * |
|
3 * Microchip USB C18 Firmware Version 1.0 |
|
4 * |
|
5 ********************************************************************* |
|
6 * FileName: typedefs.h |
|
7 * Dependencies: See INCLUDES section below |
|
8 * Processor: PIC18 |
|
9 * Compiler: C18 2.30.01+ |
|
10 * Company: Microchip Technology, Inc. |
|
11 * |
|
12 * Software License Agreement |
|
13 * |
|
14 * The software supplied herewith by Microchip Technology Incorporated |
|
15 * (the “Company”) for its PICmicro® Microcontroller is intended and |
|
16 * supplied to you, the Company’s customer, for use solely and |
|
17 * exclusively on Microchip PICmicro Microcontroller products. The |
|
18 * software is owned by the Company and/or its supplier, and is |
|
19 * protected under applicable copyright laws. All rights are reserved. |
|
20 * Any use in violation of the foregoing restrictions may subject the |
|
21 * user to criminal sanctions under applicable laws, as well as to |
|
22 * civil liability for the breach of the terms and conditions of this |
|
23 * license. |
|
24 * |
|
25 * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, |
|
26 * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED |
|
27 * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
|
28 * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, |
|
29 * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR |
|
30 * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. |
|
31 * |
|
32 * Author Date Comment |
|
33 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
34 * Rawin Rojvanit 7/21/04 Original. |
|
35 ********************************************************************/ |
|
36 |
|
37 #ifndef TYPEDEFS_H |
|
38 #define TYPEDEFS_H |
|
39 |
|
40 typedef unsigned char byte; // 8-bit |
|
41 typedef unsigned int word; // 16-bit |
|
42 typedef unsigned long dword; // 32-bit |
|
43 |
|
44 typedef union _BYTE |
|
45 { |
|
46 byte _byte; |
|
47 struct |
|
48 { |
|
49 unsigned b0:1; |
|
50 unsigned b1:1; |
|
51 unsigned b2:1; |
|
52 unsigned b3:1; |
|
53 unsigned b4:1; |
|
54 unsigned b5:1; |
|
55 unsigned b6:1; |
|
56 unsigned b7:1; |
|
57 }; |
|
58 } BYTE; |
|
59 |
|
60 typedef union _WORD |
|
61 { |
|
62 word _word; |
|
63 struct |
|
64 { |
|
65 byte byte0; |
|
66 byte byte1; |
|
67 }; |
|
68 struct |
|
69 { |
|
70 BYTE Byte0; |
|
71 BYTE Byte1; |
|
72 }; |
|
73 struct |
|
74 { |
|
75 BYTE LowB; |
|
76 BYTE HighB; |
|
77 }; |
|
78 struct |
|
79 { |
|
80 byte v[2]; |
|
81 }; |
|
82 } WORD; |
|
83 #define LSB(a) ((a).v[0]) |
|
84 #define MSB(a) ((a).v[1]) |
|
85 |
|
86 typedef union _DWORD |
|
87 { |
|
88 dword _dword; |
|
89 struct |
|
90 { |
|
91 byte byte0; |
|
92 byte byte1; |
|
93 byte byte2; |
|
94 byte byte3; |
|
95 }; |
|
96 struct |
|
97 { |
|
98 word word0; |
|
99 word word1; |
|
100 }; |
|
101 struct |
|
102 { |
|
103 BYTE Byte0; |
|
104 BYTE Byte1; |
|
105 BYTE Byte2; |
|
106 BYTE Byte3; |
|
107 }; |
|
108 struct |
|
109 { |
|
110 WORD Word0; |
|
111 WORD Word1; |
|
112 }; |
|
113 struct |
|
114 { |
|
115 byte v[4]; |
|
116 }; |
|
117 } DWORD; |
|
118 #define LOWER_LSB(a) ((a).v[0]) |
|
119 #define LOWER_MSB(a) ((a).v[1]) |
|
120 #define UPPER_LSB(a) ((a).v[2]) |
|
121 #define UPPER_MSB(a) ((a).v[3]) |
|
122 |
|
123 typedef void(*pFunc)(void); |
|
124 |
|
125 typedef union _POINTER |
|
126 { |
|
127 struct |
|
128 { |
|
129 byte bLow; |
|
130 byte bHigh; |
|
131 //byte bUpper; |
|
132 }; |
|
133 word _word; // bLow & bHigh |
|
134 |
|
135 //pFunc _pFunc; // Usage: ptr.pFunc(); Init: ptr.pFunc = &<Function>; |
|
136 |
|
137 byte* bRam; // Ram byte pointer: 2 bytes pointer pointing |
|
138 // to 1 byte of data |
|
139 word* wRam; // Ram word poitner: 2 bytes poitner pointing |
|
140 // to 2 bytes of data |
|
141 |
|
142 rom byte* bRom; // Size depends on compiler setting |
|
143 rom word* wRom; |
|
144 //rom near byte* nbRom; // Near = 2 bytes pointer |
|
145 //rom near word* nwRom; |
|
146 //rom far byte* fbRom; // Far = 3 bytes pointer |
|
147 //rom far word* fwRom; |
|
148 } POINTER; |
|
149 |
|
150 typedef enum _BOOL { FALSE = 0, TRUE } BOOL; |
|
151 |
|
152 #define OK TRUE |
|
153 #define FAIL FALSE |
|
154 |
|
155 #endif //TYPEDEFS_H |