Keys on GPIOs, reported as Input key events.
More...
Keys on GPIOs, reported as Input key events.
Each edge of a key restarts its debounce timer; when the timer expires the key is read and, if it changed, reported. A key must therefore be stable for its debounce interval to be reported. Keys held at initialization are reported once their debounce interval has elapsed.
The configuration follows the devicetree gpio-keys binding, one key per child node:
...);
#define NRF5_GPIO_P0
Port P0.
Definition nrf5.h:40
#define PBL_GPIO_ACTIVE_LOW
The pin is active when low.
Definition gpio.h:50
#define PBL_GPIO(_port, _pin, _flags)
Initializer for a struct pbl_gpio.
Definition gpio.h:148
#define PBL_GPIO_PULL_UP
Enable the pull-up.
Definition gpio.h:52
◆ pbl_gpio_keys_key
| Data Fields |
|
uint16_t |
code |
PBL_INPUT_EV_KEY code, linux,code. |
|
uint16_t |
debounce_interval_ms |
Time the key must be stable to be reported, in ms, debounce-interval. |
|
struct pbl_gpio |
gpio |
GPIO, gpios; reads active while pressed. |
|
const char * |
label |
Name, label. |
◆ pbl_gpio_keys
| Data Fields |
|
struct pbl_device |
dev |
Device. |
|
const struct pbl_gpio_keys_key * |
keys |
Keys. |
|
uint8_t |
num_keys |
Number of keys. |
|
struct pbl_gpio_keys_key_state * |
state |
Runtime state of each key. |
◆ PBL_GPIO_KEYS_DEFINE
| #define PBL_GPIO_KEYS_DEFINE |
( |
|
sym, |
|
|
|
_name, |
|
|
|
... |
|
) |
| |
Value:
static struct pbl_gpio_keys_key_state sym##_key_state[
ARRAY_LENGTH(sym##_keys)]; \
PBL_DEVICE_STATE_DEFINE(sym); \
.keys = sym##_keys, \
.state = sym##_key_state, \
}; \
PBL_DEVICE_REGISTER(sym, &sym.
dev)
#define PBL_DEVICE_INIT(sym, _name, _init, _parent, _deps)
Initializer for the struct pbl_device of device instance sym.
Definition device.h:142
#define ARRAY_LENGTH(array)
Calculate the length of an array, based on the size of the element type.
Definition size.h:18
Define and register a set of keys.
- Parameters
-
◆ PBL_GPIO_KEYS_KEY
| #define PBL_GPIO_KEYS_KEY |
( |
|
_label, |
|
|
|
_gpio, |
|
|
|
_code, |
|
|
|
_debounce_interval_ms |
|
) |
| |
Value: { \
.label = (_label), \
.gpio = _gpio, \
.code = (_code), \
.debounce_interval_ms = (_debounce_interval_ms), \
}
Initializer for a key.
- Parameters
-