-
Notifications
You must be signed in to change notification settings - Fork 0
/
GenericTypeDefs.h
549 lines (518 loc) · 15.2 KB
/
GenericTypeDefs.h
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
/*******************************************************************
Generic Type Definitions
********************************************************************
FileName: GenericTypeDefs.h
Dependencies: None
Processor: PIC10, PIC12, PIC16, PIC18, PIC24, dsPIC, PIC32
Compiler: MPLAB C Compilers for PIC18, PIC24, dsPIC, & PIC32
Hi-Tech PICC PRO, Hi-Tech PICC18 PRO
Company: Microchip Technology Inc.
Software License Agreement
The software supplied herewith by Microchip Technology Incorporated
(the "Company") is intended and supplied to you, the Company's
customer, for use solely and exclusively with products manufactured
by the Company.
The software is owned by the Company and/or its supplier, and is
protected under applicable copyright laws. All rights are reserved.
Any use in violation of the foregoing restrictions may subject the
user to criminal sanctions under applicable laws, as well as to
civil liability for the breach of the terms and conditions of this
license.
THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES,
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
********************************************************************
File Description:
Change History:
Rev Date Description
1.1 09/11/06 Add base signed types
1.2 02/28/07 Add QWORD, LONGLONG, QWORD_VAL
1.3 02/06/08 Add def's for PIC32
1.4 08/08/08 Remove LSB/MSB Macros, adopted by Peripheral lib
1.5 08/14/08 Simplify file header
2.0 07/13/09 Updated for new release of coding standards
3.1 05/28/10 MiWi DE 3.1
*******************************************************************/
#ifndef __GENERIC_TYPE_DEFS_H_
#define __GENERIC_TYPE_DEFS_H_
/* Specify an extension for GCC based compilers */
#if defined(__GNUC__)
#define __EXTENSION __extension__
#else
#define __EXTENSION
#endif
#if !defined(__PACKED)
#define __PACKED
#endif
/* get compiler defined type definitions (NULL, size_t, etc) */
#include <stddef.h>
typedef enum _BOOL { FALSE = 0, TRUE } BOOL; /* Undefined size */
typedef enum _BIT { CLEAR = 0, SET } BIT;
#define PUBLIC /* Function attributes */
#define PROTECTED
#define PRIVATE static
/* INT is processor specific in length may vary in size */
typedef signed int INT;
typedef signed char INT8;
typedef signed short int INT16;
typedef signed long int INT32;
/* MPLAB C Compiler for PIC18 does not support 64-bit integers */
#if !defined(__18CXX)
__EXTENSION typedef signed long long INT64;
#endif
/* UINT is processor specific in length may vary in size */
typedef unsigned int UINT;
typedef unsigned char UINT8;
typedef unsigned short int UINT16;
/* 24-bit type only available on C18 */
#if defined(__18CXX)
typedef unsigned short long UINT24;
#endif
typedef unsigned long int UINT32; /* other name for 32-bit integer */
/* MPLAB C Compiler for PIC18 does not support 64-bit integers */
#if !defined(__18CXX)
__EXTENSION typedef unsigned long long UINT64;
#endif
typedef union
{
UINT8 Val;
struct
{
__EXTENSION UINT8 b0:1;
__EXTENSION UINT8 b1:1;
__EXTENSION UINT8 b2:1;
__EXTENSION UINT8 b3:1;
__EXTENSION UINT8 b4:1;
__EXTENSION UINT8 b5:1;
__EXTENSION UINT8 b6:1;
__EXTENSION UINT8 b7:1;
} bits;
} UINT8_VAL, UINT8_BITS;
typedef union
{
UINT16 Val;
UINT8 v[2] __PACKED;
struct __PACKED
{
UINT8 LB;
UINT8 HB;
} byte;
struct __PACKED
{
__EXTENSION UINT8 b0:1;
__EXTENSION UINT8 b1:1;
__EXTENSION UINT8 b2:1;
__EXTENSION UINT8 b3:1;
__EXTENSION UINT8 b4:1;
__EXTENSION UINT8 b5:1;
__EXTENSION UINT8 b6:1;
__EXTENSION UINT8 b7:1;
__EXTENSION UINT8 b8:1;
__EXTENSION UINT8 b9:1;
__EXTENSION UINT8 b10:1;
__EXTENSION UINT8 b11:1;
__EXTENSION UINT8 b12:1;
__EXTENSION UINT8 b13:1;
__EXTENSION UINT8 b14:1;
__EXTENSION UINT8 b15:1;
} bits;
} UINT16_VAL, UINT16_BITS;
/* 24-bit type only available on C18 */
#if defined(__18CXX)
typedef union
{
UINT24 Val;
UINT8 v[3] __PACKED;
struct __PACKED
{
UINT8 LB;
UINT8 HB;
UINT8 UB;
} byte;
struct __PACKED
{
__EXTENSION UINT8 b0:1;
__EXTENSION UINT8 b1:1;
__EXTENSION UINT8 b2:1;
__EXTENSION UINT8 b3:1;
__EXTENSION UINT8 b4:1;
__EXTENSION UINT8 b5:1;
__EXTENSION UINT8 b6:1;
__EXTENSION UINT8 b7:1;
__EXTENSION UINT8 b8:1;
__EXTENSION UINT8 b9:1;
__EXTENSION UINT8 b10:1;
__EXTENSION UINT8 b11:1;
__EXTENSION UINT8 b12:1;
__EXTENSION UINT8 b13:1;
__EXTENSION UINT8 b14:1;
__EXTENSION UINT8 b15:1;
__EXTENSION UINT8 b16:1;
__EXTENSION UINT8 b17:1;
__EXTENSION UINT8 b18:1;
__EXTENSION UINT8 b19:1;
__EXTENSION UINT8 b20:1;
__EXTENSION UINT8 b21:1;
__EXTENSION UINT8 b22:1;
__EXTENSION UINT8 b23:1;
} bits;
} UINT24_VAL, UINT24_BITS;
#endif
typedef union
{
UINT32 Val;
UINT16 w[2] __PACKED;
UINT8 v[4] __PACKED;
struct __PACKED
{
UINT16 LW;
UINT16 HW;
} word;
struct __PACKED
{
UINT8 LB;
UINT8 HB;
UINT8 UB;
UINT8 MB;
} byte;
struct __PACKED
{
UINT16_VAL low;
UINT16_VAL high;
}wordUnion;
struct __PACKED
{
__EXTENSION UINT8 b0:1;
__EXTENSION UINT8 b1:1;
__EXTENSION UINT8 b2:1;
__EXTENSION UINT8 b3:1;
__EXTENSION UINT8 b4:1;
__EXTENSION UINT8 b5:1;
__EXTENSION UINT8 b6:1;
__EXTENSION UINT8 b7:1;
__EXTENSION UINT8 b8:1;
__EXTENSION UINT8 b9:1;
__EXTENSION UINT8 b10:1;
__EXTENSION UINT8 b11:1;
__EXTENSION UINT8 b12:1;
__EXTENSION UINT8 b13:1;
__EXTENSION UINT8 b14:1;
__EXTENSION UINT8 b15:1;
__EXTENSION UINT8 b16:1;
__EXTENSION UINT8 b17:1;
__EXTENSION UINT8 b18:1;
__EXTENSION UINT8 b19:1;
__EXTENSION UINT8 b20:1;
__EXTENSION UINT8 b21:1;
__EXTENSION UINT8 b22:1;
__EXTENSION UINT8 b23:1;
__EXTENSION UINT8 b24:1;
__EXTENSION UINT8 b25:1;
__EXTENSION UINT8 b26:1;
__EXTENSION UINT8 b27:1;
__EXTENSION UINT8 b28:1;
__EXTENSION UINT8 b29:1;
__EXTENSION UINT8 b30:1;
__EXTENSION UINT8 b31:1;
} bits;
} UINT32_VAL;
/* MPLAB C Compiler for PIC18 does not support 64-bit integers */
#if !defined(__18CXX)
typedef union
{
UINT64 Val;
UINT32 d[2] __PACKED;
UINT16 w[4] __PACKED;
UINT8 v[8] __PACKED;
struct __PACKED
{
UINT32 LD;
UINT32 HD;
} dword;
struct __PACKED
{
UINT16 LW;
UINT16 HW;
UINT16 UW;
UINT16 MW;
} word;
struct __PACKED
{
__EXTENSION UINT8 b0:1;
__EXTENSION UINT8 b1:1;
__EXTENSION UINT8 b2:1;
__EXTENSION UINT8 b3:1;
__EXTENSION UINT8 b4:1;
__EXTENSION UINT8 b5:1;
__EXTENSION UINT8 b6:1;
__EXTENSION UINT8 b7:1;
__EXTENSION UINT8 b8:1;
__EXTENSION UINT8 b9:1;
__EXTENSION UINT8 b10:1;
__EXTENSION UINT8 b11:1;
__EXTENSION UINT8 b12:1;
__EXTENSION UINT8 b13:1;
__EXTENSION UINT8 b14:1;
__EXTENSION UINT8 b15:1;
__EXTENSION UINT8 b16:1;
__EXTENSION UINT8 b17:1;
__EXTENSION UINT8 b18:1;
__EXTENSION UINT8 b19:1;
__EXTENSION UINT8 b20:1;
__EXTENSION UINT8 b21:1;
__EXTENSION UINT8 b22:1;
__EXTENSION UINT8 b23:1;
__EXTENSION UINT8 b24:1;
__EXTENSION UINT8 b25:1;
__EXTENSION UINT8 b26:1;
__EXTENSION UINT8 b27:1;
__EXTENSION UINT8 b28:1;
__EXTENSION UINT8 b29:1;
__EXTENSION UINT8 b30:1;
__EXTENSION UINT8 b31:1;
__EXTENSION UINT8 b32:1;
__EXTENSION UINT8 b33:1;
__EXTENSION UINT8 b34:1;
__EXTENSION UINT8 b35:1;
__EXTENSION UINT8 b36:1;
__EXTENSION UINT8 b37:1;
__EXTENSION UINT8 b38:1;
__EXTENSION UINT8 b39:1;
__EXTENSION UINT8 b40:1;
__EXTENSION UINT8 b41:1;
__EXTENSION UINT8 b42:1;
__EXTENSION UINT8 b43:1;
__EXTENSION UINT8 b44:1;
__EXTENSION UINT8 b45:1;
__EXTENSION UINT8 b46:1;
__EXTENSION UINT8 b47:1;
__EXTENSION UINT8 b48:1;
__EXTENSION UINT8 b49:1;
__EXTENSION UINT8 b50:1;
__EXTENSION UINT8 b51:1;
__EXTENSION UINT8 b52:1;
__EXTENSION UINT8 b53:1;
__EXTENSION UINT8 b54:1;
__EXTENSION UINT8 b55:1;
__EXTENSION UINT8 b56:1;
__EXTENSION UINT8 b57:1;
__EXTENSION UINT8 b58:1;
__EXTENSION UINT8 b59:1;
__EXTENSION UINT8 b60:1;
__EXTENSION UINT8 b61:1;
__EXTENSION UINT8 b62:1;
__EXTENSION UINT8 b63:1;
} bits;
} UINT64_VAL;
#endif /* __18CXX */
/***********************************************************************************/
/* Alternate definitions */
typedef void VOID;
typedef char CHAR8;
typedef unsigned char UCHAR8;
typedef unsigned char BYTE; /* 8-bit unsigned */
typedef unsigned short int WORD; /* 16-bit unsigned */
typedef unsigned long DWORD; /* 32-bit unsigned */
/* MPLAB C Compiler for PIC18 does not support 64-bit integers */
__EXTENSION
typedef unsigned long long QWORD; /* 64-bit unsigned */
typedef signed char CHAR; /* 8-bit signed */
typedef signed short int SHORT; /* 16-bit signed */
typedef signed long LONG; /* 32-bit signed */
/* MPLAB C Compiler for PIC18 does not support 64-bit integers */
__EXTENSION
typedef signed long long LONGLONG; /* 64-bit signed */
typedef union
{
BYTE Val;
struct __PACKED
{
__EXTENSION BYTE b0:1;
__EXTENSION BYTE b1:1;
__EXTENSION BYTE b2:1;
__EXTENSION BYTE b3:1;
__EXTENSION BYTE b4:1;
__EXTENSION BYTE b5:1;
__EXTENSION BYTE b6:1;
__EXTENSION BYTE b7:1;
} bits;
} BYTE_VAL, BYTE_BITS;
typedef union
{
WORD Val;
BYTE v[2] __PACKED;
struct __PACKED
{
BYTE LB;
BYTE HB;
} byte;
struct __PACKED
{
__EXTENSION BYTE b0:1;
__EXTENSION BYTE b1:1;
__EXTENSION BYTE b2:1;
__EXTENSION BYTE b3:1;
__EXTENSION BYTE b4:1;
__EXTENSION BYTE b5:1;
__EXTENSION BYTE b6:1;
__EXTENSION BYTE b7:1;
__EXTENSION BYTE b8:1;
__EXTENSION BYTE b9:1;
__EXTENSION BYTE b10:1;
__EXTENSION BYTE b11:1;
__EXTENSION BYTE b12:1;
__EXTENSION BYTE b13:1;
__EXTENSION BYTE b14:1;
__EXTENSION BYTE b15:1;
} bits;
} WORD_VAL, WORD_BITS;
typedef union
{
DWORD Val;
WORD w[2] __PACKED;
BYTE v[4] __PACKED;
struct __PACKED
{
WORD LW;
WORD HW;
} word;
struct __PACKED
{
BYTE LB;
BYTE HB;
BYTE UB;
BYTE MB;
} byte;
struct __PACKED
{
WORD_VAL low;
WORD_VAL high;
}wordUnion;
struct __PACKED
{
__EXTENSION BYTE b0:1;
__EXTENSION BYTE b1:1;
__EXTENSION BYTE b2:1;
__EXTENSION BYTE b3:1;
__EXTENSION BYTE b4:1;
__EXTENSION BYTE b5:1;
__EXTENSION BYTE b6:1;
__EXTENSION BYTE b7:1;
__EXTENSION BYTE b8:1;
__EXTENSION BYTE b9:1;
__EXTENSION BYTE b10:1;
__EXTENSION BYTE b11:1;
__EXTENSION BYTE b12:1;
__EXTENSION BYTE b13:1;
__EXTENSION BYTE b14:1;
__EXTENSION BYTE b15:1;
__EXTENSION BYTE b16:1;
__EXTENSION BYTE b17:1;
__EXTENSION BYTE b18:1;
__EXTENSION BYTE b19:1;
__EXTENSION BYTE b20:1;
__EXTENSION BYTE b21:1;
__EXTENSION BYTE b22:1;
__EXTENSION BYTE b23:1;
__EXTENSION BYTE b24:1;
__EXTENSION BYTE b25:1;
__EXTENSION BYTE b26:1;
__EXTENSION BYTE b27:1;
__EXTENSION BYTE b28:1;
__EXTENSION BYTE b29:1;
__EXTENSION BYTE b30:1;
__EXTENSION BYTE b31:1;
} bits;
} DWORD_VAL;
/* MPLAB C Compiler for PIC18 does not support 64-bit integers */
typedef union
{
QWORD Val;
DWORD d[2] __PACKED;
WORD w[4] __PACKED;
BYTE v[8] __PACKED;
struct __PACKED
{
DWORD LD;
DWORD HD;
} dword;
struct __PACKED
{
WORD LW;
WORD HW;
WORD UW;
WORD MW;
} word;
struct __PACKED
{
__EXTENSION BYTE b0:1;
__EXTENSION BYTE b1:1;
__EXTENSION BYTE b2:1;
__EXTENSION BYTE b3:1;
__EXTENSION BYTE b4:1;
__EXTENSION BYTE b5:1;
__EXTENSION BYTE b6:1;
__EXTENSION BYTE b7:1;
__EXTENSION BYTE b8:1;
__EXTENSION BYTE b9:1;
__EXTENSION BYTE b10:1;
__EXTENSION BYTE b11:1;
__EXTENSION BYTE b12:1;
__EXTENSION BYTE b13:1;
__EXTENSION BYTE b14:1;
__EXTENSION BYTE b15:1;
__EXTENSION BYTE b16:1;
__EXTENSION BYTE b17:1;
__EXTENSION BYTE b18:1;
__EXTENSION BYTE b19:1;
__EXTENSION BYTE b20:1;
__EXTENSION BYTE b21:1;
__EXTENSION BYTE b22:1;
__EXTENSION BYTE b23:1;
__EXTENSION BYTE b24:1;
__EXTENSION BYTE b25:1;
__EXTENSION BYTE b26:1;
__EXTENSION BYTE b27:1;
__EXTENSION BYTE b28:1;
__EXTENSION BYTE b29:1;
__EXTENSION BYTE b30:1;
__EXTENSION BYTE b31:1;
__EXTENSION BYTE b32:1;
__EXTENSION BYTE b33:1;
__EXTENSION BYTE b34:1;
__EXTENSION BYTE b35:1;
__EXTENSION BYTE b36:1;
__EXTENSION BYTE b37:1;
__EXTENSION BYTE b38:1;
__EXTENSION BYTE b39:1;
__EXTENSION BYTE b40:1;
__EXTENSION BYTE b41:1;
__EXTENSION BYTE b42:1;
__EXTENSION BYTE b43:1;
__EXTENSION BYTE b44:1;
__EXTENSION BYTE b45:1;
__EXTENSION BYTE b46:1;
__EXTENSION BYTE b47:1;
__EXTENSION BYTE b48:1;
__EXTENSION BYTE b49:1;
__EXTENSION BYTE b50:1;
__EXTENSION BYTE b51:1;
__EXTENSION BYTE b52:1;
__EXTENSION BYTE b53:1;
__EXTENSION BYTE b54:1;
__EXTENSION BYTE b55:1;
__EXTENSION BYTE b56:1;
__EXTENSION BYTE b57:1;
__EXTENSION BYTE b58:1;
__EXTENSION BYTE b59:1;
__EXTENSION BYTE b60:1;
__EXTENSION BYTE b61:1;
__EXTENSION BYTE b62:1;
__EXTENSION BYTE b63:1;
} bits;
} QWORD_VAL;
#undef __EXTENSION
#endif /* __GENERIC_TYPE_DEFS_H_ */