Skip to content

Commit 91d7b99

Browse files
doc: nrf-bm: lib: add event scheduler documentation
Add documentation for event scheduler. Co-authored-by: Bartosz Gentkowski <bartosz.gentkowski@nordicsemi.no> Signed-off-by: Eivind Jølsgard <eivind.jolsgard@nordicsemi.no>
1 parent 0d1ae85 commit 91d7b99

4 files changed

Lines changed: 119 additions & 1 deletion

File tree

doc/nrf-bm/api/api.rst

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

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

5456
.. doxygengroup:: bm_buttons
5557
:inner:
5658
:members:
5759

60+
.. _api_event_scheduler:
61+
5862
Bare Metal Event Scheduler library
5963
==================================
6064

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>`
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
.. _lib_event_scheduler:
2+
3+
Event Scheduler
4+
###############
5+
6+
.. contents::
7+
:local:
8+
:depth: 2
9+
10+
The event scheduler is used for transferring execution from the interrupt context to the main application context.
11+
12+
Overview
13+
********
14+
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.
16+
This shortens the time spent in the interrupt service routine (ISR).
17+
It also allows for lower priority events to be raised before the previous event is fully processed.
18+
19+
Configuration
20+
*************
21+
22+
The library is enabled using the Kconfig system.
23+
Set the :kconfig:option:`CONFIG_EVENT_SCHEDULER` Kconfig option to enable the library.
24+
25+
Use the :kconfig:option:`CONFIG_EVENT_SCHEDULER_BUF_SIZE` Kconfig option to set the size of the event scheduler buffer that the events are copied into.
26+
27+
Initialization
28+
==============
29+
30+
The library is initialized automatically on application startup.
31+
32+
Usage
33+
*****
34+
35+
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+
37+
To process these deferred events, call the :c:func:`event_scheduler_process` function regularly in the main application function.
38+
39+
Dependencies
40+
************
41+
42+
This library does not have any dependencies.
43+
44+
API documentation
45+
*****************
46+
47+
| Header file: :file:`include/bm/event_scheduler.h`
48+
| Source files: :file:`lib/event_scheduler/`
49+
50+
:ref:`Event Scheduler library API reference <api_event_scheduler>`

doc/nrf-bm/release_notes/release_notes_changelog.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +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.
138+
* Added documentation for the :ref:`lib_event_scheduler` library.
137139
* Added documentation for the :ref:`lib_sensorsim` library.

0 commit comments

Comments
 (0)