00001 /********************************************************************* 00002 * 00003 * Microchip USB C18 Firmware Version 1.0 00004 * 00005 ********************************************************************* 00006 * FileName: typedefs.h 00007 * Dependencies: See INCLUDES section below 00008 * Processor: PIC18 00009 * Compiler: C18 2.30.01+ 00010 * Company: Microchip Technology, Inc. 00011 * 00012 * Software License Agreement 00013 * 00014 * The software supplied herewith by Microchip Technology Incorporated 00015 * (the “Company”) for its PICmicro® Microcontroller is intended and 00016 * supplied to you, the Company’s customer, for use solely and 00017 * exclusively on Microchip PICmicro Microcontroller products. The 00018 * software is owned by the Company and/or its supplier, and is 00019 * protected under applicable copyright laws. All rights are reserved. 00020 * Any use in violation of the foregoing restrictions may subject the 00021 * user to criminal sanctions under applicable laws, as well as to 00022 * civil liability for the breach of the terms and conditions of this 00023 * license. 00024 * 00025 * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, 00026 * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED 00027 * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 00028 * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, 00029 * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR 00030 * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. 00031 * 00032 * Author Date Comment 00033 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00034 * Rawin Rojvanit 7/21/04 Original. 00035 ********************************************************************/ 00036 00037 #ifndef TYPEDEFS_H 00038 #define TYPEDEFS_H 00039 00040 typedef unsigned char byte; // 8-bit 00041 typedef unsigned int word; // 16-bit 00042 typedef unsigned long dword; // 32-bit 00043 00044 typedef union _BYTE 00045 { 00046 byte _byte; 00047 struct 00048 { 00049 unsigned b0:1; 00050 unsigned b1:1; 00051 unsigned b2:1; 00052 unsigned b3:1; 00053 unsigned b4:1; 00054 unsigned b5:1; 00055 unsigned b6:1; 00056 unsigned b7:1; 00057 }; 00058 } BYTE; 00059 00060 typedef union _WORD 00061 { 00062 word _word; 00063 struct 00064 { 00065 byte byte0; 00066 byte byte1; 00067 }; 00068 struct 00069 { 00070 BYTE Byte0; 00071 BYTE Byte1; 00072 }; 00073 struct 00074 { 00075 BYTE LowB; 00076 BYTE HighB; 00077 }; 00078 struct 00079 { 00080 byte v[2]; 00081 }; 00082 } WORD; 00083 #define LSB(a) ((a).v[0]) 00084 #define MSB(a) ((a).v[1]) 00085 00086 typedef union _DWORD 00087 { 00088 dword _dword; 00089 struct 00090 { 00091 byte byte0; 00092 byte byte1; 00093 byte byte2; 00094 byte byte3; 00095 }; 00096 struct 00097 { 00098 word word0; 00099 word word1; 00100 }; 00101 struct 00102 { 00103 BYTE Byte0; 00104 BYTE Byte1; 00105 BYTE Byte2; 00106 BYTE Byte3; 00107 }; 00108 struct 00109 { 00110 WORD Word0; 00111 WORD Word1; 00112 }; 00113 struct 00114 { 00115 byte v[4]; 00116 }; 00117 } DWORD; 00118 #define LOWER_LSB(a) ((a).v[0]) 00119 #define LOWER_MSB(a) ((a).v[1]) 00120 #define UPPER_LSB(a) ((a).v[2]) 00121 #define UPPER_MSB(a) ((a).v[3]) 00122 00123 typedef void(*pFunc)(void); 00124 00125 typedef union _POINTER 00126 { 00127 struct 00128 { 00129 byte bLow; 00130 byte bHigh; 00131 //byte bUpper; 00132 }; 00133 word _word; // bLow & bHigh 00134 00135 //pFunc _pFunc; // Usage: ptr.pFunc(); Init: ptr.pFunc = &<Function>; 00136 00137 byte* bRam; // Ram byte pointer: 2 bytes pointer pointing 00138 // to 1 byte of data 00139 word* wRam; // Ram word poitner: 2 bytes poitner pointing 00140 // to 2 bytes of data 00141 00142 rom byte* bRom; // Size depends on compiler setting 00143 rom word* wRom; 00144 //rom near byte* nbRom; // Near = 2 bytes pointer 00145 //rom near word* nwRom; 00146 //rom far byte* fbRom; // Far = 3 bytes pointer 00147 //rom far word* fwRom; 00148 } POINTER; 00149 00150 typedef enum _BOOL { FALSE = 0, TRUE } BOOL; 00151 00152 #define OK TRUE 00153 #define FAIL FALSE 00154 00155 #endif //TYPEDEFS_H