Zephyr API Documentation
3.7.0
A Scalable Open Source RTOS
|
Flash Circular Buffer APIs. More...
Typedefs | |
typedef int(* | fcb_walk_cb) (struct fcb_entry_ctx *loc_ctx, void *arg) |
FCB Walk callback function type. | |
Functions | |
int | fcb_init (int f_area_id, struct fcb *fcbp) |
Initialize FCB instance. | |
int | fcb_append (struct fcb *fcbp, uint16_t len, struct fcb_entry *loc) |
Appends an entry to circular buffer. | |
int | fcb_append_finish (struct fcb *fcbp, struct fcb_entry *append_loc) |
Finishes entry append operation. | |
int | fcb_walk (struct fcb *fcbp, struct flash_sector *sector, fcb_walk_cb cb, void *cb_arg) |
Walk over all entries in the FCB sector. | |
int | fcb_getnext (struct fcb *fcbp, struct fcb_entry *loc) |
Get next fcb entry location. | |
int | fcb_rotate (struct fcb *fcbp) |
Rotate fcb sectors. | |
int | fcb_append_to_scratch (struct fcb *fcbp) |
Start using the scratch block. | |
int | fcb_free_sector_cnt (struct fcb *fcbp) |
Get free sector count. | |
int | fcb_is_empty (struct fcb *fcbp) |
Check whether FCB has any data. | |
int | fcb_offset_last_n (struct fcb *fcbp, uint8_t entries, struct fcb_entry *last_n_entry) |
Finds the fcb entry that gives back up to n entries at the end. | |
int | fcb_clear (struct fcb *fcbp) |
Clear fcb instance storage. | |
Flash Circular Buffer APIs.
typedef int(* fcb_walk_cb) (struct fcb_entry_ctx *loc_ctx, void *arg) |
#include <zephyr/fs/fcb.h>
FCB Walk callback function type.
Type of function which is expected to be called while walking over fcb entries thanks to a fcb_walk call.
Entry data can be read using flash_area_read(), using loc_ctx fields as arguments. If cb wants to stop the walk, it should return non-zero value.
[in] | loc_ctx | entry location information (full context) |
[in,out] | arg | callback context, transferred from fcb_walk. |
#include <zephyr/fs/fcb.h>
Appends an entry to circular buffer.
When writing the contents for the entry, use loc->fe_sector and loc->fe_data_off with flash_area_write() to fcb flash_area. When you're finished, call fcb_append_finish() with loc as argument.
[in] | fcbp | FCB instance structure. |
[in] | len | Length of data which are expected to be written as the entry payload. |
[out] | loc | entry location information |
#include <zephyr/fs/fcb.h>
Finishes entry append operation.
[in] | fcbp | FCB instance structure. |
[in] | append_loc | entry location information |
int fcb_append_to_scratch | ( | struct fcb * | fcbp | ) |
#include <zephyr/fs/fcb.h>
Start using the scratch block.
Take one of the scratch blocks into use. So a scratch sector becomes active sector to which entries can be appended.
[in] | fcbp | FCB instance structure. |
int fcb_clear | ( | struct fcb * | fcbp | ) |
#include <zephyr/fs/fcb.h>
Clear fcb instance storage.
[in] | fcbp | FCB instance structure. |
int fcb_free_sector_cnt | ( | struct fcb * | fcbp | ) |
#include <zephyr/fs/fcb.h>
Get free sector count.
[in] | fcbp | FCB instance structure. |
#include <zephyr/fs/fcb.h>
Get next fcb entry location.
Function to obtain fcb entry location in relation to entry pointed by
loc. If loc->fe_sector is set and loc->fe_elem_off is not 0 function fetches next fcb entry location. If loc->fe_sector is NULL function fetches the oldest entry location within FCB storage. loc->fe_sector is set and loc->fe_elem_off is 0 function fetches the first entry location in the fcb sector.
[in] | fcbp | FCB instance structure. |
[in,out] | loc | entry location information |
int fcb_init | ( | int | f_area_id, |
struct fcb * | fcbp | ||
) |
#include <zephyr/fs/fcb.h>
Initialize FCB instance.
[in] | f_area_id | ID of flash area where fcb storage resides. |
[in,out] | fcbp | FCB instance structure. |
int fcb_is_empty | ( | struct fcb * | fcbp | ) |
#include <zephyr/fs/fcb.h>
Check whether FCB has any data.
[in] | fcbp | FCB instance structure. |
#include <zephyr/fs/fcb.h>
Finds the fcb entry that gives back up to n entries at the end.
[in] | fcbp | FCB instance structure. |
[in] | entries | number of fcb entries the user wants to get |
[out] | last_n_entry | last_n_entry the fcb_entry to be returned |
int fcb_rotate | ( | struct fcb * | fcbp | ) |
#include <zephyr/fs/fcb.h>
Rotate fcb sectors.
Function erases the data from oldest sector. Upon that the next sector becomes the oldest. Active sector is also switched if needed.
[in] | fcbp | FCB instance structure. |
int fcb_walk | ( | struct fcb * | fcbp, |
struct flash_sector * | sector, | ||
fcb_walk_cb | cb, | ||
void * | cb_arg | ||
) |
#include <zephyr/fs/fcb.h>
Walk over all entries in the FCB sector.
[in] | sector | fcb sector to be walked. If null, traverse entire storage. |
[in] | fcbp | FCB instance structure. |
[in] | cb | pointer to the function which gets called for every entry. If cb wants to stop the walk, it should return non-zero value. |
[in,out] | cb_arg | callback context, transferred to the callback implementation. |