net/avrlibdefs.h

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

Erzeugt am Tue Sep 5 09:44:23 2006 für MikroEthernetBoard von  doxygen 1.4.6