00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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 };
00046
00047 enum AsyncEvent
00048 {
00049 ALowLevel = 0x00,
00050 AFall = 0x02,
00051 ARise = 0x03
00052
00053 };
00054
00055 enum SimpleAsyncEvent
00056 {
00057 SAFall = 0x00,
00058 SARise = 0x01
00059
00060 };
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 }
00086
00087 static inline void SetEnabledEvent(EventEnum event)
00088 {
00089 SetDisabledEvent(event);
00090 BasicInterrupt<InterruptEnableBit>::Enable();
00091
00092 }
00093
00094
00095 };
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 };
00107
00108 }
00109
00110 }
00111
00112 }
00113
00114
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__