avr/cpp/ExternalInterrupt.h

Go to the documentation of this file.
00001 /**********************************************************************************************************************\
00002 
00003         C++ library for Atmel AVR microcontrollers
00004         Copyright (C) 2007 Lauri Kirikal, Mikk Leini, MT� TT� Robotiklubi
00005 
00006         This program is free software; you can redistribute it and/or
00007         modify it under the terms of the GNU General Public License
00008         as published by the Free Software Foundation; either version 2
00009         of the License, or (at your option) any later version.
00010 
00011         This program is distributed in the hope that it will be useful,
00012         but WITHOUT ANY WARRANTY; without even the implied warranty of
00013         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014         GNU General Public License for more details.
00015 
00016         You should have received a copy of the GNU General Public License
00017         along with this program; if not, write to the Free Software
00018         Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00019 
00020         See http://creativecommons.org/licenses/GPL/2.0/
00021 
00022         MT� TT� Robotiklubi  http://www.robotiklubi.ee robotiklubi@gmail.com
00023         Lauri Kirikal        laurikirikal@gmail.com
00024         Mikk Leini           mikk.leini@gmail.com
00025 
00026 \**********************************************************************************************************************/
00027 
00028 #ifndef __AVR_CPP_EXTERNAL_INTERRUPT_H__
00029 #define __AVR_CPP_EXTERNAL_INTERRUPT_H__
00030 
00031 #include "IO.h"
00032 
00033 
00034 namespace AVRCpp
00035 {
00036         namespace ExternalInterrupt
00037         {
00038                 enum Event
00039                 {
00040                         LowLevel                = 0x00,
00041                         LogicalChange   = 0x01,
00042                         Fall                    = 0x02,
00043                         Rise                    = 0x03
00044                         
00045                 }; // enum Event
00046                 
00047                 enum AsyncEvent
00048                 {
00049                         ALowLevel               = 0x00,
00050                         AFall                   = 0x02,
00051                         ARise                   = 0x03
00052                         
00053                 }; // enum AsyncEvent
00054         
00055                 enum SimpleAsyncEvent
00056                 {
00057                         SAFall                  = 0x00,
00058                         SARise                  = 0x01
00059                         
00060                 }; // enum SimpleAsyncEvent
00061         
00062                 namespace Internal
00063                 {
00064                         template <
00065                                         class InputPin,
00066                                         class EventEnum,
00067                                         class EventBits,
00068                                         class InterruptEnableBit,
00069                                         class InterruptFlagBit,
00070                                         uint8_t eventShift >
00071                         
00072                         struct InterruptBase : Interrupt<InterruptEnableBit, InterruptFlagBit>
00073                         {
00074                                 typedef InputPin Pin;
00075                                 
00076                                 static inline void SetEvent(EventEnum event) { EventBits::Change(event << eventShift); }
00077                                 static inline uint8_t GetEvent() { return EventBits::Select() >> eventShift; }
00078                                 
00079                                 static inline void SetDisabledEvent(EventEnum event)
00080                                 {
00081                                         BasicInterrupt<InterruptEnableBit>::Disable();
00082                                         SetEvent(event);
00083                                         Interrupt<InterruptEnableBit, InterruptFlagBit>::ClearFlag();
00084                                         
00085                                 } // SetDisabledEvent
00086                                 
00087                                 static inline void SetEnabledEvent(EventEnum event)
00088                                 {
00089                                         SetDisabledEvent(event);
00090                                         BasicInterrupt<InterruptEnableBit>::Enable();
00091                                         
00092                                 } // SetEnabledEvent
00093                                 
00094                                 
00095                         }; // struct InterruptBase
00096                         
00097                         template <
00098                                         class MaskRegister,
00099                                         class InterruptEnableBit,
00100                                         class InterruptFlagBit >
00101                         
00102                         struct PinChangeInterruptBase : Interrupt<InterruptEnableBit, InterruptFlagBit>
00103                         {
00104                                 typedef MaskRegister Mask;
00105                                 
00106                         }; // struct PinChangeInterruptBase
00107                         
00108                 } // namespace Internal
00109                 
00110         } // namespace ExternalInterrupt
00111 
00112 } // namespace AVRCpp
00113         
00114 /* Include controller specific files */
00115 #if defined(__AVR_AT90USB1287__)
00116 #include "at90usb1287/ExternalInterrupt.h"
00117 #elif defined(__AVR_ATmega128__)
00118 #include "atmega128/ExternalInterrupt.h"
00119 #elif defined(__AVR_ATmega64__)
00120 #include "atmega64/ExternalInterrupt.h"
00121 #elif defined(__AVR_ATmega88__)
00122 #include "atmega88/ExternalInterrupt.h"
00123 #elif defined(__AVR_ATmega8__)
00124 #include "atmega8/ExternalInterrupt.h"
00125 #elif defined(__AVR_ATmega8515__)
00126 #include "atmega8515/ExternalInterrupt.h"
00127 #elif defined(__AVR_ATmega48__)
00128 #include "atmega48/ExternalInterrupt.h"
00129 #elif defined(__AVR_ATmega168__)
00130 #include "atmega168/ExternalInterrupt.h"
00131 #elif defined(__AVR_ATmega164P__)
00132 #include "atmega164p/ExternalInterrupt.h"
00133 #elif defined(__AVR_ATmega324P__)
00134 #include "atmega324p/ExternalInterrupt.h"
00135 #elif defined(__AVR_ATmega644P__)
00136 #include "atmega644p/ExternalInterrupt.h"
00137 #elif defined(__AVR_ATmega644__)
00138 #include "atmega644/ExternalInterrupt.h"
00139 #else
00140 #error "Device is not selected or selected device is not supported."
00141 #endif
00142 
00143 #endif // ifndef __AVR_CPP_EXTERNAL_INTERRUPT_H__

Generated on Sat Sep 15 23:41:40 2007 for AVR C++ Lib for ATmega88 by  doxygen 1.5.2
SourceForge.net Logo MTÜ TTÜ Robotiklubi