Main Page   Compound List   File List   Compound Members   File Members  

global.h

Go to the documentation of this file.
00001 
00002 //*****************************************************************************
00003 //
00004 // File Name    : 'global.h'
00005 // Title                        : AVR project global include 
00006 // Author               : Pascal Stang
00007 // Created              : 7/12/2001
00008 // Revised              : 4/30/2002
00009 // Version              : 1.1
00010 // Target MCU   : Atmel AVR series
00011 // Editor Tabs  : 3
00012 //
00013 //      Description : This include file is designed to contain items useful to all
00014 //                                      code files and projects.
00015 //
00016 // This code is distributed under the GNU Public License
00017 //              which can be found at http://www.gnu.org/licenses/gpl.txt
00018 //
00019 //*****************************************************************************
00020 
00021 //*****Changes by MG
00022 // line 30 - commented out #ifndef outb
00023 //  this lets global.h override the #define outb outp in io.h
00024 // global.h must be included after io.h
00025 
00026 
00027 #ifndef GLOBAL_H
00028 #define GLOBAL_H
00029 
00030 // AVR-GCC compiler compatibility
00031 // avr-gcc compiler v3.1.x and older doesn't support outb() and inb()
00032 //#ifndef outb
00033         // if necessary
00034         // convert outb and inb to outp and inp
00035         #define outb(addr, data)        outp(data, addr)
00036         #define inb(addr)                       inp(addr)
00037 //#endif
00038 
00039 // port address helpers
00040 #define DDR(x) ((x)-1)    // address of data direction register of port x
00041 #define PIN(x) ((x)-2)    // address of input register of port x
00042 
00043 // min/max macros
00044 #define MIN(a,b)                        ((a<b)?(a):(b))
00045 #define MAX(a,b)                        ((a>b)?(a):(b))
00046 #define ABS(x)                          ((x>0)?(x):(-x))
00047 
00048 // macro for reading 16bit words from program memory
00049 #define PRG_RDW(a)              ( (PRG_RDB((unsigned char*)(a)) & 0x00FF) | ((PRG_RDB((unsigned char*)(a)+1))<<8) )
00050 
00051 // constants
00052 #define PI              3.14159265359
00053 
00054 #ifndef WIN32
00055         // true/false defines
00056         #define FALSE   0
00057         #define TRUE    -1
00058 #endif
00059 
00060 // datatype definitions macros
00061 typedef unsigned char  u08;
00062 typedef          char  s08;
00063 typedef unsigned short u16;
00064 typedef          short s16;
00065 typedef unsigned long  u32;
00066 typedef          long  s32;
00067 typedef unsigned long long u64;
00068 typedef          long long s64;
00069 
00070 // maximum value that can be held
00071 // by unsigned data types (8,16,32bits)
00072 #define MAX_U08 255
00073 #define MAX_U16 65535
00074 #define MAX_U32 4294967296
00075 
00076 // maximum values that can be held
00077 // by signed data types (8,16,32bits)
00078 #define MIN_S08 -128
00079 #define MAX_S08 127
00080 #define MIN_S16 -32768
00081 #define MAX_S16 32767
00082 #define MIN_S32 -2147483648
00083 #define MAX_S32 2147483647
00084 
00085 #ifndef WIN32
00086         // more type redefinitions
00087         typedef unsigned char   BOOL;
00088         typedef unsigned char   BYTE;
00089         typedef unsigned int            WORD;
00090         typedef unsigned long   DWORD;
00091 
00092         typedef unsigned char   UCHAR;
00093         typedef unsigned int            UINT;
00094         typedef unsigned short  USHORT;
00095         typedef unsigned long   ULONG;
00096 
00097         typedef char  CHAR;
00098         typedef int   INT;
00099         typedef long  LONG;
00100 #endif
00101 
00102 // system dependent defines
00103 
00104 // CPU clock speed
00105 #define F_CPU        8000000                            // 8MHz processor
00106 //#define F_CPU        7372800                          // 7.37MHz processor
00107 //#define F_CPU        4000000                          // 4MHz processor
00108 //#define F_CPU        3686400                          // 3.69MHz processor
00109 #define CYCLES_PER_US ((F_CPU+500000)/1000000)  // cpu cycles per microsecond
00110 
00111 // address space defines
00112 // internal ram
00113 #define INT_RAM_BASE                                    0x0060
00114 #define INT_RAM_END                                     0x0460
00115 
00116 #endif

Generated at Mon Oct 14 00:10:51 2002 for avrlib by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001