2016-02-24 14:37:48 +01:00
|
|
|
#ifndef INTERRUPT_H
|
|
|
|
|
#define INTERRUPT_H
|
|
|
|
|
|
2016-02-24 21:51:16 +01:00
|
|
|
|
2016-02-24 14:37:48 +01:00
|
|
|
typedef void (*InterruptFunction) ();
|
|
|
|
|
|
|
|
|
|
class Interrupt
|
|
|
|
|
{
|
|
|
|
|
public:
|
2016-05-26 16:35:22 +02:00
|
|
|
static void wakeUp() { wakeUpNow = true; };
|
2016-05-02 16:39:39 +02:00
|
|
|
static void sleep();
|
|
|
|
|
static void setupPinInterrupt(int pin);
|
2016-05-04 16:20:20 +02:00
|
|
|
static void setupWatchDogInterrupt(unsigned int milliseconds);
|
2016-05-10 13:58:07 +02:00
|
|
|
//static void setupTimerInterrupt(unsigned int milliseconds);
|
2016-05-02 16:39:39 +02:00
|
|
|
|
2016-05-26 16:35:22 +02:00
|
|
|
static void setPinCallback(InterruptFunction callback){ Interrupt::pinCallback = callback;}
|
|
|
|
|
static void setWatchDogCallback(InterruptFunction callback){ Interrupt::wdtCallback = callback;}
|
2016-02-24 14:37:48 +01:00
|
|
|
|
2016-05-26 16:35:22 +02:00
|
|
|
/* Should not be called externally, used as triggering functions */
|
|
|
|
|
static void handlePinInterrupt();
|
|
|
|
|
static void handleWatchDogInterrupt();
|
2016-02-24 14:37:48 +01:00
|
|
|
private:
|
2016-05-02 16:39:39 +02:00
|
|
|
static bool wakeUpNow;
|
|
|
|
|
|
2016-05-26 16:35:22 +02:00
|
|
|
static InterruptFunction pinCallback;
|
|
|
|
|
static InterruptFunction wdtCallback;
|
|
|
|
|
|
|
|
|
|
static void setupWatchDogInterrupt();
|
|
|
|
|
|
|
|
|
|
// Disable constructors and copy operators
|
2016-05-02 16:39:39 +02:00
|
|
|
Interrupt() {};
|
|
|
|
|
Interrupt(Interrupt const&);
|
|
|
|
|
void operator=(Interrupt const&);
|
2016-05-26 16:35:22 +02:00
|
|
|
|
2016-02-24 21:51:16 +01:00
|
|
|
};
|
2016-02-24 14:37:48 +01:00
|
|
|
|
2016-05-02 16:39:39 +02:00
|
|
|
|
2016-02-24 14:37:48 +01:00
|
|
|
#endif // INTERRUPT_H
|