Selector module
The selector module is used to send a selector_event that informs about the current selector state.
The module uses hardware selectors (selector_hw.c).
Module events
Source Module |
Input Event |
This Module |
Output Event |
Sink Module |
|---|---|---|---|---|
|
|
|||
|
||||
|
||||
|
||||
|
Note
See the Application overview 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 General-Purpose Input/Output (GPIO) driver to check the state of hardware selectors.
For this reason, you must set the CONFIG_GPIO Kconfig option.
To enable the module, use the CONFIG_DESKTOP_SELECTOR_HW_ENABLE option.
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 a 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 an unknown state and selector_event is not sent.
Recording of selector state changes is implemented using GPIO callbacks (gpio_callback) and a work (k_work_delayable).
Each state change triggers an interrupt (GPIO interrupt for pin level high).
The callback of an interrupt submits a work that sends the selector_event.