42 lines
871 B
C++
42 lines
871 B
C++
/*
|
|
* Interrupt.hpp
|
|
*
|
|
* Created: 18.11.2014 00:27:52
|
|
* Author: netz
|
|
*/
|
|
|
|
|
|
#ifndef INTERRUPT_H_
|
|
#define INTERRUPT_H_
|
|
|
|
template <typename Port, int pin_int>
|
|
class Interrupt {
|
|
public:
|
|
Interrupt() {
|
|
init();
|
|
}
|
|
uint8_t is_active() {
|
|
return intpin::read();
|
|
}
|
|
private:
|
|
void init() {
|
|
intpin::make_input();
|
|
intpin::pullup();
|
|
init_int();
|
|
}
|
|
void init_int() {
|
|
// External Interrupt(s) initialization
|
|
// INT0: On
|
|
// INT0 Mode: Rising Edge
|
|
// INT1: Off
|
|
// Interrupt on any change on pins PCINT0-7: Off
|
|
// Interrupt on any change on pins PCINT8-14: Off
|
|
// Interrupt on any change on pins PCINT16-23: Off
|
|
EICRA=(0<<ISC11) | (0<<ISC10) | (0<<ISC01) | (1<<ISC00);
|
|
EIMSK=(0<<INT1) | (1<<INT0);
|
|
EIFR=(0<<INTF1) | (1<<INTF0);
|
|
}
|
|
const typedef avrlib::pin<Port, pin_int> intpin;
|
|
};
|
|
|
|
#endif /* INTERRUPT_H_ */ |