00001 /*! \file avrlibdefs.h \brief AVRlib global defines and macros. */ 00002 //***************************************************************************** 00003 // 00004 // File Name : 'avrlibdefs.h' 00005 // Title : AVRlib global defines and macros include file 00006 // Author : Pascal Stang 00007 // Created : 7/12/2001 00008 // Revised : 9/30/2002 00009 // Version : 1.1 00010 // Target MCU : Atmel AVR series 00011 // Editor Tabs : 4 00012 // 00013 // Description : This include file is designed to contain items useful to all 00014 // code files and projects, regardless of specific implementation. 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 00022 #ifndef AVRLIBDEFS_H 00023 #define AVRLIBDEFS_H 00024 00025 // AVR-GCC compiler compatibility 00026 // avr-gcc compiler v3.1.x and older doesn't support outb() and inb() 00027 // if necessary, convert outb and inb to outp and inp 00028 #ifndef outb 00029 #define outb(addr, data) outp(data, addr) 00030 #endif 00031 #ifndef inb 00032 #define inb(addr) inp(addr) 00033 #endif 00034 00035 // support for individual port pin naming in the mega128 00036 // see port128.h for details 00037 #ifdef __AVR_ATmega128__ 00038 #include "port128.h" 00039 #endif 00040 00041 // port address helpers 00042 #define DDR(x) ((x)-1) // address of data direction register of port x 00043 #define PIN(x) ((x)-2) // address of input register of port x 00044 00045 // MIN/MAX/ABS macros 00046 #define MIN(a,b) ((a<b)?(a):(b)) 00047 #define MAX(a,b) ((a>b)?(a):(b)) 00048 #define ABS(x) ((x>0)?(x):(-x)) 00049 00050 // macro for reading 16bit words from program memory 00051 #define PRG_RDW(a) ( (PRG_RDB((unsigned char*)(a)) & 0x00FF) | ((PRG_RDB((unsigned char*)(a)+1))<<8) ) 00052 00053 // constants 00054 #define PI 3.14159265359 00055 00056 #endif
1.3-rc2