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)
99 btn_callback(uint8_t port, uint8_t pin)
110 case BUTTON_LEFT_PIN:
111 sensors_changed(&button_left_sensor);
113 case BUTTON_RIGHT_PIN:
114 sensors_changed(&button_right_sensor);
117 sensors_changed(&button_up_sensor);
119 case BUTTON_DOWN_PIN:
120 sensors_changed(&button_down_sensor);
140 config_select(
int type,
int value)
142 config(BUTTON_SELECT_PORT_BASE, BUTTON_SELECT_PIN_MASK);
164 config_left(
int type,
int value)
166 config(BUTTON_LEFT_PORT_BASE, BUTTON_LEFT_PIN_MASK);
188 config_right(
int type,
int value)
190 config(BUTTON_RIGHT_PORT_BASE, BUTTON_RIGHT_PIN_MASK);
212 config_up(
int type,
int value)
214 config(BUTTON_UP_PORT_BASE, BUTTON_UP_PIN_MASK);
236 config_down(
int type,
int value)
238 config(BUTTON_DOWN_PORT_BASE, BUTTON_DOWN_PIN_MASK);
255 SENSORS_SENSOR(button_left_sensor, BUTTON_SENSOR,
NULL, config_left,
NULL);
256 SENSORS_SENSOR(button_right_sensor, BUTTON_SENSOR,
NULL, config_right,
NULL);
257 SENSORS_SENSOR(button_up_sensor, BUTTON_SENSOR,
NULL, config_up,
NULL);
258 SENSORS_SENSOR(button_down_sensor, BUTTON_SENSOR,
NULL, config_down,
NULL);
#define GPIO_A_NUM
GPIO_A: 0.
#define BUTTON_DOWN_PORT
BUTTON_DOWN -> PC7.
#define BUTTON_LEFT_PORT
BUTTON_LEFT -> PC4.
Header file for the ARM Nested Vectored Interrupt Controller.
#define BUTTON_UP_PORT
BUTTON_UP -> PC6.
#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.
Header file with register and macro declarations for the cc2538 GPIO module.
void timer_set(struct timer *t, clock_time_t interval)
Set a timer.
void ioc_set_over(uint8_t port, uint8_t pin, uint8_t over)
Set Port:Pin override function.
#define NULL
The null pointer.
#define GPIO_SET_INPUT(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE to input.
#define GPIO_DETECT_EDGE(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE to detect edge.
Header file with declarations for the I/O Control module.
void nvic_interrupt_enable(uint32_t intr)
Enables interrupt intr.
#define BUTTON_RIGHT_PORT
BUTTON_RIGHT -> PC5.
void button_sensor_init()
Common initialiser for all SmartRF Buttons.
#define GPIO_SOFTWARE_CONTROL(PORT_BASE, PIN_MASK)
Configure the pin to be software controlled with PIN_MASK of port with PORT_BASE. ...
#define IOC_OVERRIDE_PUE
Pull Up Enable.
struct sensors_sensor button_select_sensor
Exports a global symbol to be used by the sensor API.
void gpio_register_callback(gpio_callback_t f, uint8_t port, uint8_t pin)
Register GPIO callback.
#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.
Timer library header file.
#define GPIO_C_NUM
GPIO_C: 2.
#define BUTTON_SELECT_PORT
BUTTON_SELECT -> PA3.
int timer_expired(struct timer *t)
Check if a timer has expired.
#define CLOCK_SECOND
A second, measured in system clock time.