diff --git a/doc/nrf-bm/api/api.rst b/doc/nrf-bm/api/api.rst index d7b36f2271..15f8111beb 100644 --- a/doc/nrf-bm/api/api.rst +++ b/doc/nrf-bm/api/api.rst @@ -48,6 +48,8 @@ Bluetooth LE Connection State library :inner: :members: +.. _api_bm_buttons: + Bare Metal Buttons library ========================== diff --git a/doc/nrf-bm/libraries/buttons.rst b/doc/nrf-bm/libraries/buttons.rst new file mode 100644 index 0000000000..4a0eafbc3d --- /dev/null +++ b/doc/nrf-bm/libraries/buttons.rst @@ -0,0 +1,62 @@ +.. _lib_bm_buttons: + +Button handling library +####################### + +.. contents:: + :local: + :depth: 2 + +The button handling library uses the GPIOTE to detect button presses. + +Overview +******** + +The library initiates a timer within the GPIOTE event handler to manage debouncing. +The button is only reported to the application as pressed if the corresponding pin is still active when the timer expires. + +Configuration +************* + +The library is enabled using the Kconfig system. +Set the :kconfig:option:`CONFIG_BM_BUTTONS` Kconfig option to enable the library. + +Use the :kconfig:option:`CONFIG_BM_BUTTONS_NUM_PINS` Kconfig option to configure the number of pins available to the library. + +Initialization +============== + +Initialize the library by calling the :c:func:`bm_buttons_init` function. +This function requires an array of button configurations (:c:struct:`bm_buttons_config`). +You must also provide the detection delay time used for the debouncing. + +Each button configuration is associated with a separate :c:type:`bm_buttons_handler_t` function. +The event handler receives the button pin number and state during a button event. +In this way, all configurations can use the same event handler. + +Usage +***** + +After initialization, enable the buttons by calling the :c:func:`bm_buttons_enable` function. +They can be disabled by calling the :c:func:`bm_buttons_disable` function. + +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. + +When a button is enabled, you can call the :c:func:`bm_buttons_is_pressed` function to check whether it is pressed or not. + +To deinitialize the library, call the :c:func:`bm_buttons_deinit` function. + +Dependencies +************ + +This library uses the following |BMshort| libraries: + +* Timer - :kconfig:option:`CONFIG_BM_TIMER` + +API documentation +***************** + +| Header file: :file:`include/bm/bm_buttons.h` +| Source files: :file:`lib/bm_buttons/` + +:ref:`Button handling library API reference ` diff --git a/doc/nrf-bm/libraries/event_scheduler.rst b/doc/nrf-bm/libraries/event_scheduler.rst index 21547956b0..d054cc4717 100644 --- a/doc/nrf-bm/libraries/event_scheduler.rst +++ b/doc/nrf-bm/libraries/event_scheduler.rst @@ -7,12 +7,12 @@ Event Scheduler :local: :depth: 2 -The event scheduler is used for transferring execution from the interrupt context to the main context. +The event scheduler is used for transferring execution from the interrupt context to the main application context. Overview ******** -In some applications, it is beneficial to defer the execution of certain interrupts, for example some SoftDevice interrupts, to the main application function. +In some applications, it is beneficial to defer the execution of certain interrupts, such as those from the SoftDevice, to the main application function. This shortens the time spent in the interrupt service routine (ISR). It also allows for lower priority events to be raised before the previous event is fully processed. @@ -33,6 +33,7 @@ Usage ***** The SoftDevice event handler can call the :c:func:`event_scheduler_defer` function to schedule an event for later execution in the main thread. + To process these deferred events, call the :c:func:`event_scheduler_process` function regularly in the main application function. Dependencies diff --git a/doc/nrf-bm/release_notes/release_notes_changelog.rst b/doc/nrf-bm/release_notes/release_notes_changelog.rst index 5b522fa2b4..ba19a74771 100644 --- a/doc/nrf-bm/release_notes/release_notes_changelog.rst +++ b/doc/nrf-bm/release_notes/release_notes_changelog.rst @@ -132,7 +132,8 @@ No changes since the latest nRF Connect SDK Bare Metal release. Documentation ============= +* Added documentation for the :ref:`lib_bm_buttons` library. * Added documentation for the :ref:`lib_bm_timer` library. -* Added documentation for the :ref:`lib_ble_adv`. +* Added documentation for the :ref:`lib_ble_adv` library. * Added documentation for the :ref:`lib_event_scheduler` library. * Added documentation for the :ref:`lib_sensorsim` library.