firmware/typedefs.h
changeset 2 2f55e5dd591d
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/firmware/typedefs.h	Tue Jan 29 22:31:52 2008 +0100
     1.3 @@ -0,0 +1,155 @@
     1.4 +/*********************************************************************
     1.5 + *
     1.6 + *                Microchip USB C18 Firmware Version 1.0
     1.7 + *
     1.8 + *********************************************************************
     1.9 + * FileName:        typedefs.h
    1.10 + * Dependencies:    See INCLUDES section below
    1.11 + * Processor:       PIC18
    1.12 + * Compiler:        C18 2.30.01+
    1.13 + * Company:         Microchip Technology, Inc.
    1.14 + *
    1.15 + * Software License Agreement
    1.16 + *
    1.17 + * The software supplied herewith by Microchip Technology Incorporated
    1.18 + * (the “Company”) for its PICmicro® Microcontroller is intended and
    1.19 + * supplied to you, the Company’s customer, for use solely and
    1.20 + * exclusively on Microchip PICmicro Microcontroller products. The
    1.21 + * software is owned by the Company and/or its supplier, and is
    1.22 + * protected under applicable copyright laws. All rights are reserved.
    1.23 + * Any use in violation of the foregoing restrictions may subject the
    1.24 + * user to criminal sanctions under applicable laws, as well as to
    1.25 + * civil liability for the breach of the terms and conditions of this
    1.26 + * license.
    1.27 + *
    1.28 + * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
    1.29 + * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
    1.30 + * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
    1.31 + * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
    1.32 + * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
    1.33 + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
    1.34 + *
    1.35 + * Author               Date        Comment
    1.36 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1.37 + * Rawin Rojvanit       7/21/04     Original.
    1.38 + ********************************************************************/
    1.39 +
    1.40 +#ifndef TYPEDEFS_H
    1.41 +#define TYPEDEFS_H
    1.42 +
    1.43 +typedef unsigned char   byte;           // 8-bit
    1.44 +typedef unsigned int    word;           // 16-bit
    1.45 +typedef unsigned long   dword;          // 32-bit
    1.46 +
    1.47 +typedef union _BYTE
    1.48 +{
    1.49 +    byte _byte;
    1.50 +    struct
    1.51 +    {
    1.52 +        unsigned b0:1;
    1.53 +        unsigned b1:1;
    1.54 +        unsigned b2:1;
    1.55 +        unsigned b3:1;
    1.56 +        unsigned b4:1;
    1.57 +        unsigned b5:1;
    1.58 +        unsigned b6:1;
    1.59 +        unsigned b7:1;
    1.60 +    };
    1.61 +} BYTE;
    1.62 +
    1.63 +typedef union _WORD
    1.64 +{
    1.65 +    word _word;
    1.66 +    struct
    1.67 +    {
    1.68 +        byte byte0;
    1.69 +        byte byte1;
    1.70 +    };
    1.71 +    struct
    1.72 +    {
    1.73 +        BYTE Byte0;
    1.74 +        BYTE Byte1;
    1.75 +    };
    1.76 +    struct
    1.77 +    {
    1.78 +        BYTE LowB;
    1.79 +        BYTE HighB;
    1.80 +    };
    1.81 +    struct
    1.82 +    {
    1.83 +        byte v[2];
    1.84 +    };
    1.85 +} WORD;
    1.86 +#define LSB(a)      ((a).v[0])
    1.87 +#define MSB(a)      ((a).v[1])
    1.88 +
    1.89 +typedef union _DWORD
    1.90 +{
    1.91 +    dword _dword;
    1.92 +    struct
    1.93 +    {
    1.94 +        byte byte0;
    1.95 +        byte byte1;
    1.96 +        byte byte2;
    1.97 +        byte byte3;
    1.98 +    };
    1.99 +    struct
   1.100 +    {
   1.101 +        word word0;
   1.102 +        word word1;
   1.103 +    };
   1.104 +    struct
   1.105 +    {
   1.106 +        BYTE Byte0;
   1.107 +        BYTE Byte1;
   1.108 +        BYTE Byte2;
   1.109 +        BYTE Byte3;
   1.110 +    };
   1.111 +    struct
   1.112 +    {
   1.113 +        WORD Word0;
   1.114 +        WORD Word1;
   1.115 +    };
   1.116 +    struct
   1.117 +    {
   1.118 +        byte v[4];
   1.119 +    };
   1.120 +} DWORD;
   1.121 +#define LOWER_LSB(a)    ((a).v[0])
   1.122 +#define LOWER_MSB(a)    ((a).v[1])
   1.123 +#define UPPER_LSB(a)    ((a).v[2])
   1.124 +#define UPPER_MSB(a)    ((a).v[3])
   1.125 +
   1.126 +typedef void(*pFunc)(void);
   1.127 +
   1.128 +typedef union _POINTER
   1.129 +{
   1.130 +    struct
   1.131 +    {
   1.132 +        byte bLow;
   1.133 +        byte bHigh;
   1.134 +        //byte bUpper;
   1.135 +    };
   1.136 +    word _word;                         // bLow & bHigh
   1.137 +    
   1.138 +    //pFunc _pFunc;                       // Usage: ptr.pFunc(); Init: ptr.pFunc = &<Function>;
   1.139 +
   1.140 +    byte* bRam;                         // Ram byte pointer: 2 bytes pointer pointing
   1.141 +                                        // to 1 byte of data
   1.142 +    word* wRam;                         // Ram word poitner: 2 bytes poitner pointing
   1.143 +                                        // to 2 bytes of data
   1.144 +
   1.145 +    rom byte* bRom;                     // Size depends on compiler setting
   1.146 +    rom word* wRom;
   1.147 +    //rom near byte* nbRom;               // Near = 2 bytes pointer
   1.148 +    //rom near word* nwRom;
   1.149 +    //rom far byte* fbRom;                // Far = 3 bytes pointer
   1.150 +    //rom far word* fwRom;
   1.151 +} POINTER;
   1.152 +
   1.153 +typedef enum _BOOL { FALSE = 0, TRUE } BOOL;
   1.154 +
   1.155 +#define OK      TRUE
   1.156 +#define FAIL    FALSE
   1.157 +
   1.158 +#endif //TYPEDEFS_H