|
Contiki 3.x
|
Files | |
| file | button-sensor.c |
| Driver for nRF52 DK buttons. | |
| file | button-sensor.h |
| Header file for the nRF52dk button driver. | |
Macros | |
| #define | DEBOUNCE_DURATION (CLOCK_SECOND >> 5) |
| Delay before button state is assumed to be stable. | |
| #define | BUTTON_SENSOR_VALUE_STATE 0 |
| Can be passed to value() function to get current button state. | |
| #define | BUTTON_SENSOR_VALUE_DURATION 1 |
| Can be passed to value() function to get low state duration. | |
Functions | |
| static void | gpiote_event_handler (nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action) |
| Button toggle handler. More... | |
| static int | config (int type, int c, nrf_drv_gpiote_pin_t pin) |
| Configuration function for the button sensor for all buttons. More... | |
| static int | config_button_1 (int type, int value) |
| Configuration function for button 1. More... | |
| static int | config_button_2 (int type, int value) |
| Configuration function for button 2. More... | |
| static int | config_button_3 (int type, int value) |
| Configuration function for button 3. More... | |
| static int | config_button_4 (int type, int value) |
| Configuration function for button 4. More... | |
| static int | value (int type, nrf_drv_gpiote_pin_t pin) |
| Return current state of a button. More... | |
| static int | value_button_1 (int type) |
| Return current state of a button 1. More... | |
| static int | value_button_2 (int type) |
| Return current state of a button 2. More... | |
| static int | value_button_3 (int type) |
| Return current state of a button 3. More... | |
| static int | value_button_4 (int type) |
| Return current state of a button 4. More... | |
| static int | status (int type, nrf_drv_gpiote_pin_t pin) |
| Get status of a given button. More... | |
| static int | status_button_1 (int type) |
| Status function for button 1. More... | |
| static int | status_button_2 (int type) |
| Status function for button 2. More... | |
| static int | status_button_3 (int type) |
| Status function for button 3. More... | |
| static int | status_button_4 (int type) |
| Status function for button 3. More... | |
|
static |
Configuration function for the button sensor for all buttons.
| type | if SENSORS_HW_INIT is passed the function will initialize given button if SENSORS_ACTIVE is passed then c parameter defines whether button should be set active or inactive |
| c | 0 to disable the button, non-zero: enable |
| pin | GPIOE pin number |
Definition at line 111 of file button-sensor.c.
References DEBOUNCE_DURATION, gpiote_event_handler(), and timer_set().
Referenced by config_button_1(), config_button_2(), config_button_3(), and config_button_4().
|
static |
|
static |
|
static |
|
static |
|
static |
Button toggle handler.
| pin | GPIO pin which has been triggered |
| action | toggle direction |
Definition at line 75 of file button-sensor.c.
References clock_time(), DEBOUNCE_DURATION, timer_expired(), and timer_set().
Referenced by config().
|
static |
Get status of a given button.
| type | SENSORS_ACTIVE or SENSORS_READY |
| pin | GPIOE pin number |
Definition at line 265 of file button-sensor.c.
Referenced by status_button_1(), status_button_2(), status_button_3(), and status_button_4().
|
static |
Status function for button 1.
| type | passed to state() as-is |
Definition at line 283 of file button-sensor.c.
References status().
|
static |
Status function for button 2.
| type | passed to state() as-is |
Definition at line 294 of file button-sensor.c.
References status().
|
static |
Status function for button 3.
| type | passed to state() as-is |
Definition at line 305 of file button-sensor.c.
References status().
|
static |
Status function for button 3.
| type | passed to state() as-is |
Definition at line 316 of file button-sensor.c.
References status().
|
static |
Return current state of a button.
| type | pass BUTTON_SENSOR_VALUE_STATE to get current button state or BUTTON_SENSOR_VALUE_DURATION to get active state duration |
| pin | GPIOE pin number |
| BUTTON_SENSOR_VALUE_PRESSED | |
| BUTTON_SENSOR_VALUE_RELEASED | when type is BUTTON_SENSOR_VALUE_STATE |
| duration | Active state duration in clock ticks |
Definition at line 201 of file button-sensor.c.
References BUTTON_SENSOR_VALUE_DURATION, and BUTTON_SENSOR_VALUE_STATE.
Referenced by value_button_1(), value_button_2(), value_button_3(), and value_button_4().
|
static |
Return current state of a button 1.
| type | passed to value() as-is |
Definition at line 220 of file button-sensor.c.
References value().
|
static |
Return current state of a button 2.
| type | passed to value() as-is |
Definition at line 231 of file button-sensor.c.
References value().
|
static |
Return current state of a button 3.
| type | passed to value() as-is |
Definition at line 242 of file button-sensor.c.
References value().
|
static |
Return current state of a button 4.
| type | passed to value() as-is |
Definition at line 253 of file button-sensor.c.
References value().
1.8.6