34 #include "lib/sensors.h"
35 #include "dev/hwconf.h"
36 #include "dev/button-sensor.h"
37 #include "isr_compat.h"
39 const struct sensors_sensor event_sensor;
42 static struct timer debouncetimer;
43 static struct timer debouncetimer_event;
44 static int status(
int type);
46 static int eventcount;
49 HWCONF_PIN(BUTTON, 2, 5);
50 HWCONF_IRQ(BUTTON, 2, 5);
52 HWCONF_PIN(EVENT_SENSOR,2,0);
53 HWCONF_IRQ(EVENT_SENSOR,2,0);
65 ENERGEST_ON(ENERGEST_TYPE_IRQ);
67 if(BUTTON_CHECK_IRQ()) {
75 if(EVENT_SENSOR_CHECK_IRQ()) {
79 sensors_changed(&event_sensor);
84 ENERGEST_OFF(ENERGEST_TYPE_IRQ);
94 value_event(
int reset)
109 configure(
int type,
int c)
114 if(!status(SENSORS_ACTIVE)) {
116 BUTTON_IRQ_EDGE_SELECTD();
124 BUTTON_DISABLE_IRQ();
131 configure_event(
int type,
int c)
136 if(!status(SENSORS_ACTIVE)) {
139 EVENT_SENSOR_IRQ_EDGE_SELECTU();
141 EVENT_SENSOR_SELECT();
142 EVENT_SENSOR_MAKE_INPUT();
144 EVENT_SENSOR_ENABLE_IRQ();
147 EVENT_SENSOR_DISABLE_IRQ();
160 return BUTTON_IRQ_ENABLED();
165 status_event(
int type)
170 return EVENT_SENSOR_IRQ_ENABLED();
176 value, configure, status);
177 SENSORS_SENSOR(event_sensor,
"Event Count", value_event,configure_event,status_event);
void timer_set(struct timer *t, clock_time_t interval)
Set a timer.
const struct sensors_sensor button_sensor
Copyright (c) 2014, Analog Devices, Inc.
#define CLOCK_SECOND
A second, measured in system clock time.
int timer_expired(struct timer *t)
Check if a timer has expired.