GenericTypeDefs.h

Go to the documentation of this file.
00001 // ////////////////////////////////////////////////////////////////////////////
00002 // ////////////////////////////////////////////////////////////////////////////
00017 /*********************************************************************
00018  * Software License Agreement
00019  *
00020  * The software supplied herewith by Microchip Technology Incorporated
00021  * (the "Company") is intended and supplied to you, the Company's
00022  * customer, for use solely and exclusively with products manufactured
00023  * by the Company. 
00024  *
00025  * The software is owned by the Company and/or its supplier, and is 
00026  * protected under applicable copyright laws. All rights are reserved. 
00027  * Any use in violation of the foregoing restrictions may subject the 
00028  * user to criminal sanctions under applicable laws, as well as to 
00029  * civil liability for the breach of the terms and conditions of this 
00030  * license.
00031  *
00032  * THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES, 
00033  * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED 
00034  * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 
00035  * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, 
00036  * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR 
00037  * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
00038  *
00039  *
00040  * Author                   Date        Comment
00041  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00042  * Nilesh Rajbharti         07/12/04    Rel 0.9
00043  * Nilesh Rajbharti         11/24/04    Rel 0.9.1
00044  * Rawin Rojvanit           09/17/05    Rel 0.9.2
00045  * D Flowers & H Schlunder  08/10/06    Much better now (1.0)
00046  * D Flowers & H Schlunder  09/11/06    Add base signed types (1.1)
00047  * D Flo, H Sch, et. al     02/28/07    Add QWORD, LONGLONG, QWORD_VAL (1.2)
00048  * Bud Caldwell             02/06/08    Added def's for PIC32
00049  ********************************************************************/
00050 
00051 #ifndef __GENERIC_TYPE_DEFS_H_
00052 #define __GENERIC_TYPE_DEFS_H_
00053 
00054 typedef enum _BOOL { FALSE = 0, TRUE } BOOL;    // Undefined size
00055 
00056 #ifndef NULL
00057 #define NULL    0//((void *)0)
00058 #endif
00059 
00060 #define PUBLIC                                  // Function attributes
00061 #define PROTECTED
00062 #define PRIVATE   static
00063 
00064 typedef unsigned char       BYTE;               // 8-bit unsigned
00065 typedef unsigned short int  WORD;               // 16-bit unsigned
00066 typedef unsigned long       DWORD;              // 32-bit unsigned
00067 typedef unsigned long long  QWORD;              // 64-bit unsigned
00068 typedef signed char         CHAR;               // 8-bit signed
00069 typedef signed short int    SHORT;              // 16-bit signed
00070 typedef signed long         LONG;               // 32-bit signed
00071 typedef signed long long    LONGLONG;           // 64-bit signed
00072 
00073 /* Alternate definitions */
00074 typedef void                VOID;
00075 
00076 typedef char                CHAR8;
00077 typedef unsigned char       UCHAR8;
00078 
00079 /* Processor & Compiler independent, size specific definitions */
00080 // To Do:  We need to verify the sizes on each compiler.  These
00081 //         may be compiler specific, we should either move them
00082 //         to "compiler.h" or #ifdef them for compiler type.
00083 typedef signed int          INT;
00084 typedef signed char         INT8;
00085 typedef signed short int    INT16;
00086 typedef signed long int     INT32;
00087 typedef signed long long    INT64;
00088 
00089 typedef unsigned int        UINT;
00090 typedef unsigned char       UINT8;
00091 typedef unsigned short int  UINT16;
00092 typedef unsigned long int   UINT32;  // other name for 32-bit integer
00093 typedef unsigned long long  UINT64;
00094 
00095 typedef union _BYTE_VAL
00096 {
00097     BYTE Val;
00098     struct
00099     {
00100         unsigned char b0:1;
00101         unsigned char b1:1;
00102         unsigned char b2:1;
00103         unsigned char b3:1;
00104         unsigned char b4:1;
00105         unsigned char b5:1;
00106         unsigned char b6:1;
00107         unsigned char b7:1;
00108     } bits;
00109 } BYTE_VAL, BYTE_BITS;
00110 
00111 typedef union _WORD_VAL
00112 {
00113     WORD Val;
00114     BYTE v[2];
00115     struct
00116     {
00117         BYTE LB;
00118         BYTE HB;
00119     } byte;
00120     struct
00121     {
00122         unsigned char b0:1;
00123         unsigned char b1:1;
00124         unsigned char b2:1;
00125         unsigned char b3:1;
00126         unsigned char b4:1;
00127         unsigned char b5:1;
00128         unsigned char b6:1;
00129         unsigned char b7:1;
00130         unsigned char b8:1;
00131         unsigned char b9:1;
00132         unsigned char b10:1;
00133         unsigned char b11:1;
00134         unsigned char b12:1;
00135         unsigned char b13:1;
00136         unsigned char b14:1;
00137         unsigned char b15:1;
00138     } bits;
00139 } WORD_VAL, WORD_BITS;
00140 
00141 typedef union _DWORD_VAL
00142 {
00143     DWORD Val;
00144     WORD w[2];
00145     BYTE v[4];
00146     struct
00147     {
00148         WORD LW;
00149         WORD HW;
00150     } word;
00151     struct
00152     {
00153         BYTE LB;
00154         BYTE HB;
00155         BYTE UB;
00156         BYTE MB;
00157     } byte;
00158     struct
00159     {
00160         WORD_VAL low;
00161         WORD_VAL high;
00162     }wordUnion;
00163     struct
00164     {
00165         unsigned char b0:1;
00166         unsigned char b1:1;
00167         unsigned char b2:1;
00168         unsigned char b3:1;
00169         unsigned char b4:1;
00170         unsigned char b5:1;
00171         unsigned char b6:1;
00172         unsigned char b7:1;
00173         unsigned char b8:1;
00174         unsigned char b9:1;
00175         unsigned char b10:1;
00176         unsigned char b11:1;
00177         unsigned char b12:1;
00178         unsigned char b13:1;
00179         unsigned char b14:1;
00180         unsigned char b15:1;
00181         unsigned char b16:1;
00182         unsigned char b17:1;
00183         unsigned char b18:1;
00184         unsigned char b19:1;
00185         unsigned char b20:1;
00186         unsigned char b21:1;
00187         unsigned char b22:1;
00188         unsigned char b23:1;
00189         unsigned char b24:1;
00190         unsigned char b25:1;
00191         unsigned char b26:1;
00192         unsigned char b27:1;
00193         unsigned char b28:1;
00194         unsigned char b29:1;
00195         unsigned char b30:1;
00196         unsigned char b31:1;
00197     } bits;
00198 } DWORD_VAL;
00199 
00200 #define LSB(a)          ((a).v[0])
00201 #define MSB(a)          ((a).v[1])
00202 
00203 #define LOWER_LSB(a)    ((a).v[0])
00204 #define LOWER_MSB(a)    ((a).v[1])
00205 #define UPPER_LSB(a)    ((a).v[2])
00206 #define UPPER_MSB(a)    ((a).v[3])
00207 
00208 typedef union _QWORD_VAL
00209 {
00210     QWORD Val;
00211     DWORD d[2];
00212     WORD w[4];
00213     BYTE v[8];
00214     struct
00215     {
00216         DWORD LD;
00217         DWORD HD;
00218     } dword;
00219     struct
00220     {
00221         WORD LW;
00222         WORD HW;
00223         WORD UW;
00224         WORD MW;
00225     } word;
00226     struct
00227     {
00228         unsigned char b0:1;
00229         unsigned char b1:1;
00230         unsigned char b2:1;
00231         unsigned char b3:1;
00232         unsigned char b4:1;
00233         unsigned char b5:1;
00234         unsigned char b6:1;
00235         unsigned char b7:1;
00236         unsigned char b8:1;
00237         unsigned char b9:1;
00238         unsigned char b10:1;
00239         unsigned char b11:1;
00240         unsigned char b12:1;
00241         unsigned char b13:1;
00242         unsigned char b14:1;
00243         unsigned char b15:1;
00244         unsigned char b16:1;
00245         unsigned char b17:1;
00246         unsigned char b18:1;
00247         unsigned char b19:1;
00248         unsigned char b20:1;
00249         unsigned char b21:1;
00250         unsigned char b22:1;
00251         unsigned char b23:1;
00252         unsigned char b24:1;
00253         unsigned char b25:1;
00254         unsigned char b26:1;
00255         unsigned char b27:1;
00256         unsigned char b28:1;
00257         unsigned char b29:1;
00258         unsigned char b30:1;
00259         unsigned char b31:1;
00260         unsigned char b32:1;
00261         unsigned char b33:1;
00262         unsigned char b34:1;
00263         unsigned char b35:1;
00264         unsigned char b36:1;
00265         unsigned char b37:1;
00266         unsigned char b38:1;
00267         unsigned char b39:1;
00268         unsigned char b40:1;
00269         unsigned char b41:1;
00270         unsigned char b42:1;
00271         unsigned char b43:1;
00272         unsigned char b44:1;
00273         unsigned char b45:1;
00274         unsigned char b46:1;
00275         unsigned char b47:1;
00276         unsigned char b48:1;
00277         unsigned char b49:1;
00278         unsigned char b50:1;
00279         unsigned char b51:1;
00280         unsigned char b52:1;
00281         unsigned char b53:1;
00282         unsigned char b54:1;
00283         unsigned char b55:1;
00284         unsigned char b56:1;
00285         unsigned char b57:1;
00286         unsigned char b58:1;
00287         unsigned char b59:1;
00288         unsigned char b60:1;
00289         unsigned char b61:1;
00290         unsigned char b62:1;
00291         unsigned char b63:1;
00292     } bits;
00293 } QWORD_VAL;
00294 
00295 #endif //__GENERIC_TYPE_DEFS_H_

Generated on Sun Nov 27 20:02:38 2011 for eWicht by  doxygen 1.5.5