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

extint.h

Go to the documentation of this file.
00001 /*! \file extint.h \brief External-Interrupt function library. */
00002 //*****************************************************************************
00003 //
00004 // File Name    : 'extint.h'
00005 // Title        : External-Interrupt function library
00006 // Author       : Pascal Stang - Copyright (C) 2002-2004
00007 // Created      : 5/10/2002
00008 // Revised      : 11/16/2004
00009 // Version      : 1.0
00010 // Target MCU   : Atmel AVR Series
00011 // Editor Tabs  : 4
00012 //
00013 // Notes:   This library provides convenient standardized configuration and
00014 //          access to external interrupts.  The library is designed to make
00015 //          it possible to write code that uses external interrupts without
00016 //          digging into the processor datasheets to find register names and
00017 //          bit-defines.  The library also strives to allow code which uses
00018 //          external interrupts to more easily cross-compile between different
00019 //          microcontrollers.
00020 //
00021 //          NOTE: Using this library has certain advantages, but also adds
00022 //          overhead and latency to interrupt servicing.  If the smallest
00023 //          code size or fastest possible latency is needed, do NOT use this
00024 //          library; link your interrupts directly.
00025 //
00026 //*****************************************************************************
00027 
00028 #ifndef EXTINT_H
00029 #define EXTINT_H
00030 
00031 #include "global.h"
00032 
00033 // constants/macros/typdefs
00034 
00035 // interrupt macros for attaching user functions to external interrupts
00036 // use these with extintAttach( intNum, function )
00037 #define EXTINT0                 0x00    ///< External Interrupt 0
00038 #define EXTINT1                 0x01    ///< External Interrupt 1
00039 #define EXTINT2                 0x02    ///< External Interrupt 2
00040 #define EXTINT3                 0x03    ///< External Interrupt 3
00041 #define EXTINT4                 0x04    ///< External Interrupt 4
00042 #define EXTINT5                 0x05    ///< External Interrupt 5
00043 #define EXTINT6                 0x06    ///< External Interrupt 6
00044 #define EXTINT7                 0x07    ///< External Interrupt 7
00045 
00046 #define EXTINT_LEVEL_LOW        0x00    ///< Trigger on low level
00047 #define EXTINT_EDGE_ANY         0x01    ///< Trigger on any edge
00048 #define EXTINT_EDGE_FALLING     0x02    ///< Trigger on falling edge
00049 #define EXTINT_EDGE_RISING      0x03    ///< Trigger on rising edge
00050 
00051 // type of interrupt handler to use
00052 // *do not change unless you know what you're doing
00053 // Value may be SIGNAL or INTERRUPT
00054 #ifndef EXTINT_INTERRUPT_HANDLER
00055 #define EXTINT_INTERRUPT_HANDLER    SIGNAL
00056 #endif
00057 
00058 // processor-adaptive defines
00059 // mainstream AVR processors generally have 1,2,3, or 8 external interrupts
00060 // (if someone has a better idea of how to manage this, let me know)
00061 #ifdef SIG_INTERRUPT7
00062     #define EXTINT_NUM_INTERRUPTS   8
00063 #else
00064 #ifdef SIG_INTERRUPT2
00065     #define EXTINT_NUM_INTERRUPTS   3
00066 #else
00067 #ifdef SIG_INTERRUPT1
00068     #define EXTINT_NUM_INTERRUPTS   2
00069 #else
00070     #define EXTINT_NUM_INTERRUPTS   1
00071 #endif
00072 #endif
00073 #endif
00074 
00075 // functions
00076 
00077 //! initializes extint library
00078 void extintInit(void);
00079 
00080 //! Configure external interrupt trigger
00081 void extintConfigure(u08 interruptNum, u08 configuration);
00082 
00083 // extintAttach and extintDetach commands
00084 //      These functions allow the attachment (or detachment) of any user
00085 //      function to an external interrupt.  "Attaching" one of your own
00086 //      functions to an interrupt means that it will be called whenever
00087 //      that interrupt is triggered.  Example usage:
00088 //
00089 //      extintAttach(EXTINT0, myInterruptHandler);
00090 //      extintDetach(EXTINT0);
00091 //
00092 //      extintAttach causes the myInterruptHandler() to be attached, and therefore
00093 //      execute, whenever the corresponding interrupt occurs.  extintDetach removes
00094 //      the association and executes no user function when the interrupt occurs.
00095 //      myInterruptFunction must be defined with no return value and no arguments:
00096 //
00097 //      void myInterruptHandler(void) { ... }
00098 
00099 //! Attach a user function to an external interrupt
00100 void extintAttach(u08 interruptNum, void (*userHandler)(void) );
00101 //! Detach a user function from an external interrupt
00102 void extintDetach(u08 interruptNum);
00103 
00104 #endif

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