nRF Connect SDK Bare Metal API 2.0.99
Loading...
Searching...
No Matches
bm_storage.h
1
16#ifndef BM_STORAGE_H__
17#define BM_STORAGE_H__
18
19#include <stdint.h>
20#include <stddef.h>
21#include <stdbool.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
36
54 int result;
58 uint32_t addr;
64 const void *src;
68 size_t len;
72 void *ctx;
73};
74
78typedef void (*bm_storage_evt_handler_t)(struct bm_storage_evt *evt);
79
87 uint32_t program_unit;
91 uint32_t erase_unit;
95 uint32_t wear_unit;
99 uint8_t erase_value;
104};
105
106struct bm_storage;
107struct bm_storage_config;
108
119 int (*init)(struct bm_storage *storage, const struct bm_storage_config *config);
120 int (*uninit)(struct bm_storage *storage);
121 int (*read)(const struct bm_storage *storage, uint32_t src, void *dest, uint32_t len);
122 int (*write)(const struct bm_storage *storage, uint32_t dest, const void *src, uint32_t len,
123 void *ctx);
124 int (*erase)(const struct bm_storage *storage, uint32_t addr, uint32_t len, void *ctx);
125 bool (*is_busy)(const struct bm_storage *storage);
126};
127
137 const struct bm_storage_api *api;
150 uint32_t addr;
154 uint32_t size;
158 struct {
172};
173
187 const struct bm_storage_api *api;
191 uint32_t addr;
195 uint32_t size;
199 struct {
218};
219
232int bm_storage_init(struct bm_storage *storage, const struct bm_storage_config *config);
233
251int bm_storage_uninit(struct bm_storage *storage);
252
266int bm_storage_read(const struct bm_storage *storage, uint32_t src, void *dest, uint32_t len);
267
289int bm_storage_write(const struct bm_storage *storage, uint32_t dest, const void *src,
290 uint32_t len, void *ctx);
291
315int bm_storage_erase(const struct bm_storage *storage, uint32_t addr, uint32_t len, void *ctx);
316
325bool bm_storage_is_busy(const struct bm_storage *storage);
326
335const struct bm_storage_info *bm_storage_nvm_info_get(const struct bm_storage *storage);
336
349void bm_storage_evt_dispatch(const struct bm_storage *storage, struct bm_storage_evt *evt);
350
351#ifdef __cplusplus
352}
353#endif
354
355#include <bm/storage/bm_storage_backends.h>
356
357#endif /* BM_STORAGE_H__ */
358
void(* bm_storage_evt_handler_t)(struct bm_storage_evt *evt)
Storage event handler type.
Definition bm_storage.h:78
const struct bm_storage_info * bm_storage_nvm_info_get(const struct bm_storage *storage)
Retrieve NVM storage information.
int bm_storage_uninit(struct bm_storage *storage)
Uninitialize a storage instance.
bool bm_storage_is_busy(const struct bm_storage *storage)
Query the status of a storage instance.
bm_storage_evt_type
Event IDs.
Definition bm_storage.h:30
@ BM_STORAGE_EVT_WRITE_RESULT
Definition bm_storage.h:32
@ BM_STORAGE_EVT_ERASE_RESULT
Definition bm_storage.h:34
int bm_storage_write(const struct bm_storage *storage, uint32_t dest, const void *src, uint32_t len, void *ctx)
Write data to storage.
int bm_storage_erase(const struct bm_storage *storage, uint32_t addr, uint32_t len, void *ctx)
Erase data from storage.
void bm_storage_evt_dispatch(const struct bm_storage *storage, struct bm_storage_evt *evt)
Dispatch a storage event to the application's event handler.
int bm_storage_init(struct bm_storage *storage, const struct bm_storage_config *config)
Initialize a storage instance.
int bm_storage_read(const struct bm_storage *storage, uint32_t src, void *dest, uint32_t len)
Read data from storage.
int(* init)(struct bm_storage *storage, const struct bm_storage_config *config)
Definition bm_storage.h:119
bool(* is_busy)(const struct bm_storage *storage)
Definition bm_storage.h:125
int(* write)(const struct bm_storage *storage, uint32_t dest, const void *src, uint32_t len, void *ctx)
Definition bm_storage.h:122
int(* read)(const struct bm_storage *storage, uint32_t src, void *dest, uint32_t len)
Definition bm_storage.h:121
int(* erase)(const struct bm_storage *storage, uint32_t addr, uint32_t len, void *ctx)
Definition bm_storage.h:124
int(* uninit)(struct bm_storage *storage)
Definition bm_storage.h:120
Backend API.
Definition bm_storage.h:118
uint32_t size
The size of this instance's partition, in bytes.
Definition bm_storage.h:195
bm_storage_evt_handler_t evt_handler
The event handler function.
Definition bm_storage.h:183
bool is_wear_aligned
Enforce wear unit alignment on operations that cause wear.
Definition bm_storage.h:209
bool is_write_padded
Automatically pad write operations up to the alignment unit.
Definition bm_storage.h:216
const struct bm_storage_api * api
API implementation.
Definition bm_storage.h:187
struct bm_storage_config::@126 flags
Configuration flags.
uint32_t addr
The starting address of this instance's partition.
Definition bm_storage.h:191
Configuration for storage instance initialization.
Definition bm_storage.h:177
void * ctx
User-defined context.
Definition bm_storage.h:72
uint32_t addr
Address in memory where the operation was performed.
Definition bm_storage.h:58
enum bm_storage_evt_type id
Event identifier.
Definition bm_storage.h:44
size_t len
Length of the operation.
Definition bm_storage.h:68
const void * src
Pointer to the data written to memory.
Definition bm_storage.h:64
bool is_async
Whether the event was dispatched asynchronously.
Definition bm_storage.h:48
int result
Result of the operation.
Definition bm_storage.h:54
Storage event.
Definition bm_storage.h:40
uint32_t wear_unit
Size of the memory unit towards which wear is counted, in bytes.
Definition bm_storage.h:95
uint8_t erase_value
Value used to represent erased memory.
Definition bm_storage.h:99
uint32_t program_unit
Size of the smallest unit of memory that can be programmed, in bytes.
Definition bm_storage.h:87
uint32_t erase_unit
Size of the smallest unit of memory that can be erased, in bytes.
Definition bm_storage.h:91
bool is_erase_before_write
Whether the memory must be erased before it can be written to.
Definition bm_storage.h:103
Information about the non-volatile memory.
Definition bm_storage.h:83
struct bm_storage::@125 flags
Instance flags.
bm_storage_evt_handler_t evt_handler
The event handler function.
Definition bm_storage.h:146
const struct bm_storage_api * api
API implementation.
Definition bm_storage.h:137
bool is_initialized
The instance has been initialized.
Definition bm_storage.h:162
uint32_t addr
The starting address of this instance's partition.
Definition bm_storage.h:150
uint32_t size
The size of this instance's partition, in bytes.
Definition bm_storage.h:154
bool is_write_padded
Automatically pad write operations.
Definition bm_storage.h:170
const struct bm_storage_info * nvm_info
Information about the implementation-specific functionality and the non-volatile memory peripheral.
Definition bm_storage.h:142
bool is_wear_aligned
Enforce wear unit alignment on operations that cause wear.
Definition bm_storage.h:166
Storage instance.
Definition bm_storage.h:133