Button handling library
The button handling library uses the GPIOTE to detect button presses.
Overview
The library initiates a timer within the GPIOTE event handler to manage debouncing. The button is only reported to the application as pressed if the corresponding pin is still active when the timer expires.
Configuration
The library is enabled using the Kconfig system.
Set the CONFIG_BM_BUTTONS Kconfig option to enable the library.
Use the CONFIG_BM_BUTTONS_NUM_PINS Kconfig option to configure the number of pins available to the library.
Initialization
Initialize the library by calling the bm_buttons_init() function.
This function requires an array of button configurations (bm_buttons_config).
You must also provide the detection delay time used for the debouncing.
Each button configuration is associated with a separate bm_buttons_handler_t function.
The event handler receives the button pin number and state during a button event.
In this way, all configurations can use the same event handler.
Usage
After initialization, enable the buttons by calling the bm_buttons_enable() function.
They can be disabled by calling the bm_buttons_disable() function.
Once a button is pressed and the debouncing process succeeds (the button state has not changed during the detection delay period), its configured event handler function is triggered.
When a button is enabled, you can call the bm_buttons_is_pressed() function to check whether it is pressed or not.
To deinitialize the library, call the bm_buttons_deinit() function.
Dependencies
This library has the following Bare Metal dependencies:
API documentation
include/bm/bm_buttons.hlib/bm_buttons/