47 #include "dev/button-sensor.h"
68 #define BUTTON_S1 PORTx_PIN(boardDescription->io->buttons[0].gpioPort, boardDescription->io->buttons[0].gpioPin)
69 #define BUTTON_S1_INPUT_GPIO BUTTON_INPUT_GPIO(boardDescription->io->buttons[0].gpioPort)
70 #define BUTTON_S1_GPIO_PIN boardDescription->io->buttons[0].gpioPin
71 #define BUTTON_S1_OUTPUT_GPIO GPIO_PAOUT
76 #define BUTTON_S1_SEL() do { GPIO_IRQCSEL = BUTTON_S1; } while(0)
80 #define BUTTON_S1_ISR halIrqCIsr
84 #define BUTTON_S1_INTCFG GPIO_INTCFGC
88 #define BUTTON_S1_INT_EN_BIT INT_IRQC
92 #define BUTTON_S1_FLAG_BIT INT_IRQCFLAG
96 #define BUTTON_S1_MISS_BIT INT_MISSIRQC
99 static struct timer debouncetimer;
117 BUTTON_S1_OUTPUT_GPIO |= GPIOOUT_PULLUP << BUTTON_S1_GPIO_PIN;
147 return (BUTTON_S1_INPUT_GPIO & (1<<BUTTON_S1_GPIO_PIN)) || !
timer_expired(&debouncetimer);
149 return BUTTON_S1_INPUT_GPIO & (1<<BUTTON_S1_GPIO_PIN);
154 configure(
int type,
int value)
157 case SENSORS_HW_INIT:
186 ENERGEST_ON(ENERGEST_TYPE_IRQ);
195 sensors_changed(&button_sensor);
198 sensors_changed(&button_sensor);
205 ENERGEST_OFF(ENERGEST_TYPE_IRQ);
208 SENSORS_SENSOR(button_sensor, BUTTON_SENSOR,
209 value, configure, status);
#define BUTTON_S1_FLAG_BIT
The interrupt bit for BUTTON_S1.
#define BUTTON_S1_INTCFG
The interrupt configuration register for BUTTON_S1.
void timer_set(struct timer *t, clock_time_t interval)
Set a timer.
Utility and convenience functions for STM32W108 microcontroller, common to both the full and minimal ...
#define BUTTON_S1_SEL()
Point the proper IRQ at the desired pin for BUTTON0.
#define BUTTON_S1
Port and pin for BUTTON0.
#define TRUE
An alias for one, used for clarity.
Minimal Hal functions common across all microcontroller-specific files.
#define FALSE
An alias for zero, used for clarity.
void halGpioConfig(uint32_t io, uint32_t config)
Configure an IO pin's operating mode.
int timer_expired(struct timer *t)
Check if a timer has expired.
#define BUTTON_S1_INT_EN_BIT
The interrupt bit for BUTTON_S1.
#define BUTTON_S1_ISR
The interrupt service routine for BUTTON_S1.
#define CLOCK_SECOND
A second, measured in system clock time.