Skip to content

Commit 755ba5e

Browse files
doc: lib: add bm_buttons documentation
Add documentation for bm_buttons library. Signed-off-by: Eivind Jølsgard <[email protected]>
1 parent 8d99a4d commit 755ba5e

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

doc/nrf-bm/api/api.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ Bluetooth LE Connection State library
4848
:inner:
4949
:members:
5050

51+
.. _api_bm_buttons:
52+
5153
Bare Metal Buttons library
5254
==========================
5355

doc/nrf-bm/libraries/buttons.rst

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

doc/nrf-bm/release_notes/release_notes_changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,6 @@ No changes since the latest nRF Connect SDK Bare Metal release.
132132
Documentation
133133
=============
134134

135+
* Added documentation for the :ref:`lib_bm_buttons` library.
135136
* Added documentation for the :ref:`lib_ble_adv`.
136137
* Added documentation for the :ref:`lib_sensorsim` library.

0 commit comments

Comments
 (0)