43 #include "dev/button-sensor.h"
44 #include "hal/micro/micro-common.h"
55 #define BUTTON_S1 PORTA_PIN(7)
56 #define BUTTON_S1_INPUT_GPIO BUTTON_INPUT_GPIO(PORTA)
57 #define BUTTON_S1_GPIO_PIN 7
58 #define BUTTON_S1_OUTPUT_GPIO GPIO_PAOUT
63 #define BUTTON_S1_SEL() do { GPIO_IRQCSEL = BUTTON_S1; } while(0)
67 #define BUTTON_S1_ISR halIrqCIsr
71 #define BUTTON_S1_INTCFG GPIO_INTCFGC
75 #define BUTTON_S1_INT_EN_BIT INT_IRQC
79 #define BUTTON_S1_FLAG_BIT INT_IRQCFLAG
83 #define BUTTON_S1_MISS_BIT INT_MISSIRQC
86 static struct timer debouncetimer;
104 BUTTON_S1_OUTPUT_GPIO |= GPIOOUT_PULLUP << BUTTON_S1_GPIO_PIN;
134 return (BUTTON_S1_INPUT_GPIO & (1<<BUTTON_S1_GPIO_PIN)) || !
timer_expired(&debouncetimer);
136 return BUTTON_S1_INPUT_GPIO & (1<<BUTTON_S1_GPIO_PIN);
141 configure(
int type,
int value)
144 case SENSORS_HW_INIT:
173 ENERGEST_ON(ENERGEST_TYPE_IRQ);
182 sensors_changed(&button_sensor);
185 sensors_changed(&button_sensor);
192 ENERGEST_OFF(ENERGEST_TYPE_IRQ);
195 SENSORS_SENSOR(button_sensor, BUTTON_SENSOR,
196 value, configure, status);