Skip to content

Commit d314076

Browse files
committed
doc: nrf-bm: libraries: add bm_storage documentation
Adds `bm_storage` library documentation. Signed-off-by: Mirko Covizzi <[email protected]>
1 parent fe98516 commit d314076

File tree

2 files changed

+107
-0
lines changed

2 files changed

+107
-0
lines changed

doc/nrf-bm/api/api.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ Bare Metal Low Power UART with EasyDMA driver
6868
Bare Metal Storage library
6969
==========================
7070

71+
.. _api_storage:
72+
7173
.. doxygengroup:: bm_storage
7274
:inner:
7375
:members:
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
.. _lib_storage:
2+
3+
Storage Library
4+
###############
5+
6+
.. contents::
7+
:local:
8+
:depth: 2
9+
10+
Overview
11+
********
12+
13+
The Storage library provides abstractions for reading, writing, and erasing non-volatile memory (NVM).
14+
It supports multiple storage instances, each bound to a specific memory region, and reports operation results through user-defined event handlers.
15+
Depending on the backend and runtime state, operations may be synchronous or asynchronous.
16+
17+
Configuration
18+
*************
19+
20+
The library is enabled and configured entirely using the Kconfig system.
21+
Set the :kconfig:option:`CONFIG_BM_STORAGE` Kconfig option to enable the library.
22+
23+
Select a backend using :kconfig:option:`CONFIG_BM_STORAGE_BACKEND`:
24+
25+
* :kconfig:option:`CONFIG_BM_STORAGE_BACKEND_RRAM` – RRAM backend. The events reported are synchronous.
26+
* :kconfig:option:`CONFIG_BM_STORAGE_BACKEND_SD` – SoftDevice backend. The events reported are asynchronous.
27+
28+
SoftDevice backend options:
29+
30+
* :kconfig:option:`CONFIG_BM_STORAGE_BACKEND_SD_QUEUE_SIZE` – Queue size for pending operations.
31+
* :kconfig:option:`CONFIG_BM_STORAGE_BACKEND_SD_MAX_RETRIES` – Maximum retries if the SoftDevice is busy.
32+
33+
Initialization
34+
==============
35+
36+
Each storage instance is represented by a :c:struct:`bm_storage` structure.
37+
38+
Initialize an instance with the :c:func:`bm_storage_init` function, providing:
39+
40+
* :c:member:`bm_storage.evt_handler` – Event callback.
41+
* :c:member:`bm_storage.start_addr` and :c:member:`bm_storage.end_addr` – Accessible address range.
42+
43+
Uninitialize with the :c:func:`bm_storage_uninit` function.
44+
45+
Usage
46+
*****
47+
48+
Read
49+
====
50+
51+
Use the :c:func:`bm_storage_read` function to copy data from NVM into RAM.
52+
The data length must be a multiple of the backend’s program unit and within the configured region.
53+
54+
Write
55+
=====
56+
57+
Use the :c:func:`bm_storage_write` function to write data to NVM.
58+
Writes are validated against alignment and range, and completion is reported through :c:member:`bm_storage.evt_handler`.
59+
60+
Erase
61+
=====
62+
63+
Use the :c:func:`bm_storage_erase` function to erase a region in NVM.
64+
``len`` must be a multiple of the erase unit. If not supported by the backend, the call may return ``NRF_ERROR_NOT_SUPPORTED``.
65+
This means that the backend does not require the region to be erased before another write operation.
66+
67+
Busy state
68+
==========
69+
70+
Use the :c:func:`bm_storage_is_busy` function to check whether a backend is executing an operation.
71+
72+
Events
73+
======
74+
75+
The following events may be reported to the user callback:
76+
77+
* :c:enum:`BM_STORAGE_EVT_WRITE_RESULT` – Write operation completed.
78+
* :c:enum:`BM_STORAGE_EVT_ERASE_RESULT` – Erase operation completed.
79+
80+
Each event includes the result code, information about the address range of the associated operation, and if the operation is synchronous or asynchronous.
81+
82+
Dependencies
83+
************
84+
85+
* :kconfig:option:`CONFIG_BM_STORAGE_BACKEND_RRAM`:
86+
87+
This backend requires the following Kconfig options to be disabled:
88+
89+
* :kconfig:option:`CONFIG_SOFTDEVICE`
90+
91+
* :kconfig:option:`CONFIG_BM_STORAGE_BACKEND_SD`:
92+
93+
This backend requires the following Kconfig options to be enabled:
94+
95+
* :kconfig:option:`CONFIG_SOFTDEVICE`
96+
* :kconfig:option:`CONFIG_NRF_SDH`
97+
* :kconfig:option:`CONFIG_RING_BUFFER`
98+
99+
API documentation
100+
*****************
101+
102+
| Header file: :file:`include/bm_storage.h`
103+
| Source files: :file:`lib/bm_storage/`
104+
105+
:ref:`Storage library API reference <api_storage>`

0 commit comments

Comments
 (0)