COSA
An Object-Oriented Platform for Arduino Programming
ExternalInterrupt.hh
Go to the documentation of this file.
1 
21 #ifndef COSA_EXTERNAL_INTERRUPT_HH
22 #define COSA_EXTERNAL_INTERRUPT_HH
23 
24 #include "Cosa/Types.h"
25 #include "Cosa/Bits.h"
26 #include "Cosa/IOPin.hh"
27 #include "Cosa/Interrupt.hh"
28 
33 class ExternalInterrupt : public IOPin, public Interrupt::Handler {
34 public:
37  ON_CHANGE_MODE = _BV(ISC00),
38  ON_FALLING_MODE = _BV(ISC01),
39  ON_RISING_MODE = (_BV(ISC01) | _BV(ISC00))
40  } __attribute__((packed));
41 
51  bool pullup = false);
52 
58  virtual void on_interrupt(uint16_t arg = 0)
59  {
60  UNUSED(arg);
61  }
62 
68  virtual void enable();
69 
75  virtual void disable();
76 
82  virtual void clear();
83 
84 private:
86  static ExternalInterrupt* ext[Board::EXT_MAX];
87 
89  uint8_t m_ix;
90 
91  friend void INT0_vect(void);
92 #if defined(INT1_vect)
93  friend void INT1_vect(void);
94 #endif
95 #if defined(INT2_vect)
96  friend void INT2_vect(void);
97 #endif
98 #if defined(INT3_vect)
99  friend void INT3_vect(void);
100 #endif
101 #if defined(INT4_vect)
102  friend void INT4_vect(void);
103 #endif
104 #if defined(INT5_vect)
105  friend void INT5_vect(void);
106 #endif
107 #if defined(INT6_vect)
108  friend void INT6_vect(void);
109 #endif
110 #if defined(INT7_vect)
111  friend void INT7_vect(void);
112 #endif
113 };
114 
115 #endif
friend void INT0_vect(void)
uint8_t pin() const
Definition: Pin.hh:103
virtual void on_interrupt(uint16_t arg=0)
Mode mode() const
Definition: IOPin.hh:71
virtual void disable()
void INT4_vect(void)
void INT7_vect(void)
ExternalInterrupt(Board::ExternalInterruptPin pin, InterruptMode mode=ON_CHANGE_MODE, bool pullup=false)
void INT5_vect(void)
ExternalInterruptPin
Definition: ATmega1284P.hh:190
void INT2_vect(void)
void INT6_vect(void)
#define UNUSED(x)
Definition: ATmega328P.hh:31
void INT1_vect(void)
Definition: IOPin.hh:29
void INT3_vect(void)