42 #include "dev/button-sensor.h"
48 #define BUTTON_SELECT_PORT_BASE GPIO_PORT_TO_BASE(BUTTON_SELECT_PORT)
49 #define BUTTON_SELECT_PIN_MASK GPIO_PIN_MASK(BUTTON_SELECT_PIN)
51 #define BUTTON_LEFT_PORT_BASE GPIO_PORT_TO_BASE(BUTTON_LEFT_PORT)
52 #define BUTTON_LEFT_PIN_MASK GPIO_PIN_MASK(BUTTON_LEFT_PIN)
54 #define BUTTON_RIGHT_PORT_BASE GPIO_PORT_TO_BASE(BUTTON_RIGHT_PORT)
55 #define BUTTON_RIGHT_PIN_MASK GPIO_PIN_MASK(BUTTON_RIGHT_PIN)
57 #define BUTTON_UP_PORT_BASE GPIO_PORT_TO_BASE(BUTTON_UP_PORT)
58 #define BUTTON_UP_PIN_MASK GPIO_PIN_MASK(BUTTON_UP_PIN)
60 #define BUTTON_DOWN_PORT_BASE GPIO_PORT_TO_BASE(BUTTON_DOWN_PORT)
61 #define BUTTON_DOWN_PIN_MASK GPIO_PIN_MASK(BUTTON_DOWN_PIN)
63 static struct timer debouncetimer;
71 config(uint32_t port_base, uint32_t pin_mask)
112 sensors_changed(&button_right_sensor);
114 sensors_changed(&button_up_sensor);
116 sensors_changed(&button_down_sensor);
134 config(BUTTON_SELECT_PORT_BASE, BUTTON_SELECT_PIN_MASK);
158 config(BUTTON_LEFT_PORT_BASE, BUTTON_LEFT_PIN_MASK);
182 config(BUTTON_RIGHT_PORT_BASE, BUTTON_RIGHT_PIN_MASK);
206 config(BUTTON_UP_PORT_BASE, BUTTON_UP_PIN_MASK);
230 config(BUTTON_DOWN_PORT_BASE, BUTTON_DOWN_PIN_MASK);
#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.
static int config_down(int type, int value)
Init function for the down button.
#define GPIO_SET_INPUT(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE to input.
#define BUTTON_RIGHT_PORT
BUTTON_RIGHT -> PC5.
static void btn_callback(uint8_t port, uint8_t pin)
Callback registered with the GPIO module.
static int config_up(int type, int value)
Init function for the up button.
#define IOC_OVERRIDE_PUE
Pull Up Enable.
const struct sensors_sensor button_left_sensor
Exports a global symbol to be used by the sensor API.
#define GPIO_DETECT_EDGE(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE to detect edge.
Timer library header file.
void timer_set(struct timer *t, clock_time_t interval)
Set a timer.
#define BUTTON_LEFT_PORT
BUTTON_LEFT -> PC4.
Header file for the ARM Nested Vectored Interrupt Controller.
#define BUTTON_UP_PORT
BUTTON_UP -> PC6.
#define BUTTON_SELECT_PORT
BUTTON_SELECT -> PA3.
static int config_select(int type, int value)
Init function for the select button.
static int config_right(int type, int value)
Init function for the right button.
#define BUTTON_DOWN_PORT
BUTTON_DOWN -> PC7.
#define NULL
The null pointer.
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. ...
static void config(uint32_t port_base, uint32_t pin_mask)
Common initialiser for all buttons.
#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.
const struct sensors_sensor button_select_sensor
Exports a global symbol to be used by the sensor API.
void nvic_interrupt_enable(uint32_t intr)
Enables interrupt intr.
static int config_left(int type, int value)
Init function for the left button.
void ioc_set_over(uint8_t port, uint8_t pin, uint8_t over)
Set Port:Pin override function.
static int value(int type, nrf_drv_gpiote_pin_t pin)
Return current state of a button.
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.
void button_sensor_init()
Common initialiser for all SmartRF Buttons.