Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

avrlibdefs.h

Go to the documentation of this file.
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 // Code compatibility to new AVR-libc
00026 // outb(), inb(), inw(), outw(), BV(), sbi(), cbi(), sei(), cli()
00027 #ifndef outb
00028     #define outb(addr, data)    addr = (data)
00029 #endif
00030 #ifndef inb
00031     #define inb(addr)           (addr)
00032 #endif
00033 #ifndef outw
00034     #define outw(addr, data)    addr = (data)
00035 #endif
00036 #ifndef inw
00037     #define inw(addr)           (addr)
00038 #endif
00039 #ifndef BV
00040     #define BV(bit)         (1<<(bit))
00041 #endif
00042 #ifndef cbi
00043     #define cbi(reg,bit)    reg &= ~(BV(bit))
00044 #endif
00045 #ifndef sbi
00046     #define sbi(reg,bit)    reg |= (BV(bit))
00047 #endif
00048 #ifndef cli
00049     #define cli()           __asm__ __volatile__ ("cli" ::)
00050 #endif
00051 #ifndef sei
00052     #define sei()           __asm__ __volatile__ ("sei" ::)
00053 #endif
00054 
00055 // support for individual port pin naming in the mega128
00056 // see port128.h for details
00057 #ifdef __AVR_ATmega128__
00058 // not currently necessary due to inclusion
00059 // of these defines in newest AVR-GCC
00060 // do a quick test to see if include is needed
00061 #ifndef PD0
00062     #include "port128.h"
00063 #endif
00064 #endif
00065 
00066 // use this for packed structures
00067 // (this is seldom necessary on an 8-bit architecture like AVR,
00068 //  but can assist in code portability to AVR)
00069 #define GNUC_PACKED __attribute__((packed)) 
00070 
00071 // port address helpers
00072 #define DDR(x) ((x)-1)    // address of data direction register of port x
00073 #define PIN(x) ((x)-2)    // address of input register of port x
00074 
00075 // MIN/MAX/ABS macros
00076 #define MIN(a,b)            ((a<b)?(a):(b))
00077 #define MAX(a,b)            ((a>b)?(a):(b))
00078 #define ABS(x)              ((x>0)?(x):(-x))
00079 
00080 // constants
00081 #define PI      3.14159265359
00082 
00083 #endif

Generated on Sun Oct 29 03:41:06 2006 for Procyon AVRlib by  doxygen 1.4.2