COSA
An Object-Oriented Platform for Arduino Programming
PinChangeInterrupt.hh
Go to the documentation of this file.
1 
21 #ifndef COSA_PIN_CHANGE_INTERRUPT_HH
22 #define COSA_PIN_CHANGE_INTERRUPT_HH
23 
24 #include "Cosa/Types.h"
25 #include "Cosa/Event.hh"
26 #include "Cosa/IOPin.hh"
27 #include "Cosa/Interrupt.hh"
28 
34 public:
38  static void begin();
39 
43  static void end();
44 
50  } __attribute__((packed));
51 
61  bool pullup = false) :
62  IOPin((Board::DigitalPin) pin, INPUT_MODE, pullup),
63  m_mode(mode),
64  m_next(NULL)
65  {}
66 
72  virtual void enable();
73 
79  virtual void disable();
80 
86  virtual void on_interrupt(uint16_t arg = 0) = 0;
87 
88 private:
89  static PinChangeInterrupt* s_pin[Board::PCMSK_MAX];
90  static uint8_t s_state[Board::PCMSK_MAX];
91 
93  InterruptMode m_mode;
94 
96  PinChangeInterrupt* m_next;
97 
106  static void on_interrupt(uint8_t ix, uint8_t mask, uint8_t base);
107 
108  friend void PCINT0_vect(void);
109 #if defined(PCINT1_vect)
110  friend void PCINT1_vect(void);
111 #if defined(PCINT2_vect)
112  friend void PCINT2_vect(void);
113 #if defined(PCINT3_vect)
114  friend void PCINT3_vect(void);
115 #endif
116 #endif
117 #endif
118 };
119 #endif
void PCINT2_vect(void)
uint8_t pin() const
Definition: Pin.hh:103
PinChangeInterrupt(Board::InterruptPin pin, InterruptMode mode=ON_CHANGE_MODE, bool pullup=false)
void PCINT1_vect(void)
#define NULL
Definition: Types.h:101
Mode mode() const
Definition: IOPin.hh:71
void PCINT3_vect(void)
friend void PCINT0_vect(void)
Definition: IOPin.hh:29
virtual void on_interrupt(uint16_t arg=0)=0