Selector module
The selector module is used to send selector_event
that informs about the current selector state.
The module has one implementation, which uses hardware selectors (selector_hw.c
).
Module events
Source Module |
Input Event |
This Module |
Output Event |
Sink Module |
---|---|---|---|---|
|
|
|||
|
||||
|
||||
|
||||
|
Note
See the Overview: Firmware architecture for more information about the event-based communication in the nRF Desktop application and about how to read this table.
Configuration
The module implemented in selector_hw.c
uses the Zephyr GPIO driver to check the state of hardware selectors.
For this reason, you should set CONFIG_GPIO
option.
Set CONFIG_DESKTOP_SELECTOR_HW_ENABLE
option to enable the module.
The configuration for this module is an array of selector_config
pointers.
The array is written in the selector_hw_def.h
file located in the board-specific directory in the application configuration directory.
For every hardware selector, define the following parameters:
selector_config.id
- ID of the hardware selector.selector_config.pins
- Pointer to the array ofgpio_pin
.selector_config.pins_size
- Size of the array ofgpio_pin
.
Note
Each source of selector_event
must have a unique ID to properly distinguish events from different sources.
Implementation details
The selector_event
that the module sends to inform about the current hardware selector state is sent on the following occasions:
System start or wakeup (for every defined selector).
Selector state change when the application is running (only for the selector that changed state).
When the application goes to sleep, selectors are not informing about the state change (interrupts are disabled).
If a selector is placed between states, it is in unknown state and selector_event
is not sent.
Recording of selector state changes is implemented using GPIO callbacks (gpio_callback
) and work (k_work_delayable
).
Each state change triggers an interrupt (GPIO interrupt for pin level high).
Callback of an interrupt submits work, which sends selector_event
.