40 #include "lib/sensors.h"
41 #include "dev/button-sensor.h"
43 #include <avr/interrupt.h>
45 #define BUTTON_INT_vect INT2_vect
46 #define BUTTON_ISC ISC20
47 #define BUTTON_INT INT2
48 #define BUTTON_PORT PORTB
49 #define BUTTON_DDR DDRB
50 #define BUTION_PIN PINB
52 #define BUTTON_REG_EICR EICRA
53 #define BUTTON_REG_EIMSK EIMSK
56 #define DEBOUNCE_TIME CLOCK_SECOND / 40
61 static struct timer debouncetimer;
63 ISR(BUTTON_INT_vect) {
71 BUTTON_DDR &= ~(1 << BUTTON_P);
72 BUTTON_PORT &= ~(1 << BUTTON_P);
73 BUTTON_REG_EICR |= (0x1 << BUTTON_ISC);
78 return (1 - ((BUTION_PIN & (1 << BUTTON_P)) >> BUTTON_P))
83 configure(
int type,
int c) {
94 BUTTON_REG_EIMSK |= (1 << BUTTON_INT);
99 BUTTON_REG_EIMSK &= ~(1 << BUTTON_INT);
110 return (BUTTON_REG_EIMSK & (1 << BUTTON_INT));
112 return ~(BUTTON_DDR & (1 << BUTTON_P));
119 value, configure, status);