33 #include "event-sensor.h"
39 #define DEBOUNCE_SECS (1 / 4)
42 #define EVENT_PORT RAIN_INT_PORT
43 #define EVENT_PIN RAIN_INT_PIN
44 #define EVENT_VECTOR RAIN_INT_VECTOR
46 const struct sensors_sensor event_sensor;
48 static struct timer debounce_timer;
50 static int event_count;
52 static int status(
int type);
54 static void event_isr(uint8_t port, uint8_t pin) {
58 sensors_changed(&event_sensor);
62 static int value(
int reset) {
63 int curr_event_count = event_count;
70 return curr_event_count;
73 static int configure(
int type,
int c) {
78 if (c && !status(SENSORS_ACTIVE)) {
111 static int status(
int type) {
122 SENSORS_SENSOR(event_sensor,
"Event Count", value, configure, status);
#define GPIO_TRIGGER_SINGLE_EDGE(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE to trigger an interrupt on single edge (controlled by G...
#define GPIO_ENABLE_INTERRUPT(PORT_BASE, PIN_MASK)
Enable interrupt triggering for pins with PIN_MASK of port with PORT_BASE.
#define GPIO_SET_INPUT(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE to input.
#define GPIO_PIN_MASK(PIN)
Converts a pin number to a pin mask.
Header file with definitions related to the I/O connections on the Muntjac platform, cc2538-based.
#define IOC_OVERRIDE_DIS
Override Disabled.
#define GPIO_IE
Interrupt mask.
#define GPIO_DETECT_EDGE(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE to detect edge.
void timer_set(struct timer *t, clock_time_t interval)
Set a timer.
Header file with declarations for the I/O Control module.
#define GPIO_SOFTWARE_CONTROL(PORT_BASE, PIN_MASK)
Configure the pin to be software controlled with PIN_MASK of port with PORT_BASE. ...
#define GPIO_PORT_TO_BASE(PORT)
Converts a port number to the port base address.
#define CLOCK_SECOND
A second, measured in system clock time.
#define GPIO_DETECT_RISING(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE to trigger an interrupt on rising edge.
void nvic_interrupt_enable(uint32_t intr)
Enables interrupt intr.
#define GPIO_DISABLE_INTERRUPT(PORT_BASE, PIN_MASK)
Disable interrupt triggering for pins with PIN_MASK of port with PORT_BASE.
void ioc_set_over(uint8_t port, uint8_t pin, uint8_t over)
Set Port:Pin override function.
void gpio_register_callback(gpio_callback_t f, uint8_t port, uint8_t pin)
Register GPIO callback.
int timer_expired(struct timer *t)
Check if a timer has expired.