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

Source modules for module_state_event

module_state_event

selector

Power manager module

power_down_event

Buttons module

wake_up_event

HID forward module

Motion module

Power manager module

Wheel module

module_state_event

Sink modules for module_state_event

selector_event

Bluetooth LE bond 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 of gpio_pin.

  • selector_config.pins_size - Size of the array of gpio_pin.

Warning

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 wake-up (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 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_delayed_work). Each state change triggers an interrupt (GPIO interrupt for pin level high). Callback of an interrupt submits work, which sends selector_event.