Skip to content

Commit b54d95d

Browse files
doc: nrf-bm: lib: add event scheduler documentation
Add documentation for event scheduler. Co-authored-by: Bartosz Gentkowski <[email protected]> Signed-off-by: Eivind Jølsgard <[email protected]>
1 parent 99a0016 commit b54d95d

File tree

4 files changed

+69
-3
lines changed

4 files changed

+69
-3
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: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
.. _lib_bm_buttons:
2+
3+
Button handling library
4+
#######################
5+
6+
.. contents::
7+
:local:
8+
:depth: 2
9+
10+
The button handling library uses the GPIOTE to detect button presses.
11+
12+
Overview
13+
********
14+
15+
The library initiates a timer within the GPIOTE event handler to manage debouncing.
16+
The button is only reported to the application as pressed 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+
Use the :kconfig:option:`CONFIG_BM_BUTTONS_NUM_PINS` Kconfig option to configure the number of pins available to the library.
25+
26+
Initialization
27+
==============
28+
29+
Initialize the library by calling the :c:func:`bm_buttons_init` function.
30+
This function requires an array of button configurations (:c:struct:`bm_buttons_config`).
31+
You must also provide the detection delay time used for the debouncing.
32+
33+
Each button configuration is associated with a separate :c:type:`bm_buttons_handler_t` function.
34+
The event handler receives the button pin number and state during a button event.
35+
In this way, all configurations can use the same event handler.
36+
37+
Usage
38+
*****
39+
40+
After initialization, enable the buttons by calling the :c:func:`bm_buttons_enable` function.
41+
They can be disabled by calling the :c:func:`bm_buttons_disable` function.
42+
43+
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.
44+
45+
When a button is enabled, you can call the :c:func:`bm_buttons_is_pressed` function to check whether it is pressed or not.
46+
47+
To deinitialize the library, call the :c:func:`bm_buttons_deinit` function.
48+
49+
Dependencies
50+
************
51+
52+
This library uses the following |BMshort| libraries:
53+
54+
* Timer - :kconfig:option:`CONFIG_BM_TIMER`
55+
56+
API documentation
57+
*****************
58+
59+
| Header file: :file:`include/bm/bm_buttons.h`
60+
| Source files: :file:`lib/bm_buttons/`
61+
62+
:ref:`Button handling library API reference <api_bm_buttons>`

doc/nrf-bm/libraries/event_scheduler.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ Event Scheduler
77
:local:
88
:depth: 2
99

10-
The event scheduler is used for transferring execution from the interrupt context to the main context.
10+
The event scheduler is used for transferring execution from the interrupt context to the main application context.
1111

1212
Overview
1313
********
1414

15-
In some applications, it is beneficial to defer the execution of certain interrupts, for example some SoftDevice interrupts, to the main application function.
15+
In some applications, it is beneficial to defer the execution of certain interrupts, such as those from the SoftDevice, to the main application function.
1616
This shortens the time spent in the interrupt service routine (ISR).
1717
It also allows for lower priority events to be raised before the previous event is fully processed.
1818

@@ -33,6 +33,7 @@ Usage
3333
*****
3434

3535
The SoftDevice event handler can call the :c:func:`event_scheduler_defer` function to schedule an event for later execution in the main thread.
36+
3637
To process these deferred events, call the :c:func:`event_scheduler_process` function regularly in the main application function.
3738

3839
Dependencies

doc/nrf-bm/release_notes/release_notes_changelog.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ 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_bm_timer` library.
136-
* Added documentation for the :ref:`lib_ble_adv`.
137+
* Added documentation for the :ref:`lib_ble_adv` library.
137138
* Added documentation for the :ref:`lib_event_scheduler` library.
138139
* Added documentation for the :ref:`lib_sensorsim` library.

0 commit comments

Comments
 (0)