Skip to content

Commit b204d0b

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 b204d0b

2 files changed

Lines changed: 65 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
@@ -44,6 +44,8 @@ Bluetooth LE Connection State library
4444
:inner:
4545
:members:
4646

47+
.. _api_bm_buttons:
48+
4749
Bare Metal Buttons library
4850
==========================
4951

doc/nrf-bm/libraries/buttons.rst

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
.. _lib_bm_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 to detect when a button has been pushed.
15+
To handle debouncing, a timer is started 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+
18+
The button handling library uses the ``bm_timer`` module.
19+
20+
Configuration
21+
*************
22+
23+
The library is enabled using the Kconfig system.
24+
Set the :kconfig:option:`CONFIG_BM_BUTTONS` Kconfig option to enable the library.
25+
26+
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.
27+
28+
Initialization
29+
==============
30+
31+
The button handling library is initialized by calling the :c:func:`bm_buttons_init` function.
32+
The init function takes an array of button configurations as an argument, see the :c:struct:`bm_buttons_config` struct for details.
33+
It also takes, as an argument, the detection delay time used for the debouncing.
34+
Each button configuration takes a separate :c:type:`bm_buttons_handler_t` function.
35+
The button pin number and state is provided to the event handler on a button event.
36+
Thus, all configurations can use the same event handler.
37+
38+
Usage
39+
*****
40+
41+
After initialization the buttons are enabled by calling the :c:func:`bm_buttons_enable` function.
42+
Likewise, the buttons can be disabled by calling the :c:func:`bm_buttons_disable` function.
43+
44+
Once a button is pressed and the debouncing process succeeds (the button state has not changed during the detection_delay period), the button's event handler function is called.
45+
46+
When the buttons are enabled, it is possible to check if a button is pressed or not by calling the :c:func:`bm_buttons_is_pressed` function.
47+
48+
The button library can be deinitialized by calling the :c:func:`bm_buttons_deinit` function.
49+
50+
Dependencies
51+
************
52+
53+
This library uses the following |BMshort| libraries:
54+
55+
* Timer - :kconfig:option:`CONFIG_BM_TIMER`
56+
57+
API documentation
58+
*****************
59+
60+
| Header file: :file:`include/bm_buttons.h`
61+
| Source files: :file:`lib/bm_buttons/`
62+
63+
:ref:`Button handling library API reference <api_bm_buttons>`

0 commit comments

Comments
 (0)