Skip to content

Commit 424e74a

Browse files
doc: lib: add bm_buttons documentation
Add documentation for bm_buttons library. Signed-off-by: Eivind Jølsgard <eivind.jolsgard@nordicsemi.no>
1 parent 3033a26 commit 424e74a

2 files changed

Lines changed: 66 additions & 0 deletions

File tree

doc/nrf-bm/api/api.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ Bluetooth LE Connection State library
4747
Bare Metal Buttons library
4848
==========================
4949

50+
.. _api_bm_buttons:
51+
5052
.. doxygengroup:: bm_buttons
5153
:inner:
5254
:members:

doc/nrf-bm/libraries/buttons.rst

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
.. _lib_buttons:
2+
3+
Button handling library
4+
#######################
5+
6+
.. contents::
7+
:local:
8+
:depth: 2
9+
10+
11+
Overview
12+
********
13+
14+
The button handling library uses the GPIOTE Handler to detect when a button has been pushed.
15+
To handle debouncing, it will start a timer in the GPIOTE event handler.
16+
The button will only be reported as pushed to the application if the corresponding pin is still active when the timer expires.
17+
If there is a new GPIOTE event while the timer is running, the timer is restarted.
18+
19+
The button handling library uses the ``bm_timer`` module.
20+
The user must ensure that the queue in bm_timer is large enough to hold the :c:func:`bm_timer_stop` and :c:func:`bm_timer_start` function operations which will be executed on each event from the GPIOTE module (2 operations), as well as other ``bm_timer`` operations queued simultaneously in the application.
21+
22+
Configuration
23+
*************
24+
25+
The library is enabled using the Kconfig system.
26+
Set the :kconfig:option:`CONFIG_BM_BUTTONS` Kconfig option to enable the library.
27+
28+
The number of pins available for use by the button handling library is set by the :kconfig:option:`CONFIG_BM_BUTTONS_NUM_PINS` Kconfig option.
29+
30+
Initialization
31+
==============
32+
33+
The button handling library is initialized by calling the :c:func:`bm_buttons_init` function.
34+
The init function takes in an array of button configurations, see the :c:struct:`bm_buttons_config` struct for details.
35+
It also takes in the detection delay time used for the debouncing.
36+
Each button configuration takes a separate :c:type:`bm_buttons_handler_t` function.
37+
Though, as the button pin number and state is provided to the event handler on a button event, all configurations can use the same event handler.
38+
39+
Usage
40+
*****
41+
42+
After initialization the buttons are enabled by calling the :c:func:`bm_buttons_enable` function.
43+
Likewise the buttons can be disabled by calling the :c:func:`bm_buttons_disable` function.
44+
45+
Once a button is pressed and the debouncing process succeeds (the button state has not changed during the detection_delay period), the buttons event handler function is called.
46+
47+
While enabled it is at any time possible to test if a button is pressed by calling the :c:func:`bm_buttons_is_pressed` function.
48+
49+
The button library can be deinitialized by calling the :c:func:`bm_buttons_deinit` function.
50+
51+
Dependencies
52+
************
53+
54+
This library uses the following |BMshort| libraries:
55+
56+
* Timer - :kconfig:option:`CONFIG_BM_TIMER`
57+
58+
API documentation
59+
*****************
60+
61+
| Header file: :file:`include/bm_buttons.h`
62+
| Source files: :file:`lib/bm_buttons/`
63+
64+
:ref:`Button handling library API reference <api_bm_buttons>`

0 commit comments

Comments
 (0)