Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS

Flash Circular Buffer APIs. More...

Typedefs

typedef int(* fcb_walk_cb) (struct fcb_entry_ctx *loc_ctx, void *arg)
 

Functions

int fcb_init (int f_area_id, struct fcb *fcb)
 
int fcb_append (struct fcb *fcb, uint16_t len, struct fcb_entry *loc)
 
int fcb_append_finish (struct fcb *fcb, struct fcb_entry *append_loc)
 
int fcb_walk (struct fcb *fcb, struct flash_sector *sector, fcb_walk_cb cb, void *cb_arg)
 
int fcb_getnext (struct fcb *fcb, struct fcb_entry *loc)
 
int fcb_rotate (struct fcb *fcb)
 
int fcb_append_to_scratch (struct fcb *fcb)
 
int fcb_free_sector_cnt (struct fcb *fcb)
 
int fcb_is_empty (struct fcb *fcb)
 
int fcb_offset_last_n (struct fcb *fcb, uint8_t entries, struct fcb_entry *last_n_entry)
 
int fcb_clear (struct fcb *fcb)
 

Detailed Description

Flash Circular Buffer APIs.

Typedef Documentation

◆ fcb_walk_cb

typedef int(* fcb_walk_cb) (struct fcb_entry_ctx *loc_ctx, void *arg)

#include <include/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.

Parameters
[in]loc_ctxentry location information (full context)
[in,out]argcallback context, transferred from fcb_walk.
Returns
0 continue walking, non-zero stop walking.

Function Documentation

◆ fcb_append()

int fcb_append ( struct fcb fcb,
uint16_t  len,
struct fcb_entry loc 
)

#include <include/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.

Parameters
[in]fcbFCB instance structure.
[in]lenLength of data which are expected to be written as the entry payload.
[out]locentry location information
Returns
0 on success, non-zero on failure.

◆ fcb_append_finish()

int fcb_append_finish ( struct fcb fcb,
struct fcb_entry append_loc 
)

#include <include/fs/fcb.h>

Finishes entry append operation.

Parameters
[in]fcbFCB instance structure.
[in]append_locentry location information
Returns
0 on success, non-zero on failure.

◆ fcb_append_to_scratch()

int fcb_append_to_scratch ( struct fcb fcb)

#include <include/fs/fcb.h>

◆ fcb_clear()

int fcb_clear ( struct fcb fcb)

#include <include/fs/fcb.h>

Clear fcb instance storage.

Parameters
[in]fcbFCB instance structure.
Returns
0 on success; non-zero on failure

◆ fcb_free_sector_cnt()

int fcb_free_sector_cnt ( struct fcb fcb)

#include <include/fs/fcb.h>

Get free sector count.

Parameters
[in]fcbFCB instance structure.
Returns
Number of free sectors.

◆ fcb_getnext()

int fcb_getnext ( struct fcb fcb,
struct fcb_entry loc 
)

#include <include/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.

Parameters
[in]fcbFCB instance structure.
[in,out]locentry location information
Returns
0 on success, non-zero on failure.

◆ fcb_init()

int fcb_init ( int  f_area_id,
struct fcb fcb 
)

#include <include/fs/fcb.h>

Initialize FCB instance.

Parameters
[in]f_area_idID of flash area where fcb storage resides.
[in,out]fcbFCB instance structure.
Returns
0 on success, non-zero on failure.

◆ fcb_is_empty()

int fcb_is_empty ( struct fcb fcb)

#include <include/fs/fcb.h>

Check whether FCB has any data.

Parameters
[in]fcbFCB instance structure.
Returns
Positive value if fcb is empty, otherwise 0.

◆ fcb_offset_last_n()

int fcb_offset_last_n ( struct fcb fcb,
uint8_t  entries,
struct fcb_entry last_n_entry 
)

#include <include/fs/fcb.h>

Finds the fcb entry that gives back up to n entries at the end.

Parameters
[in]fcbFCB instance structure.
[in]entriesnumber of fcb entries the user wants to get
[out]last_n_entrylast_n_entry the fcb_entry to be returned
Returns
0 on there are any fcbs available; -ENOENT otherwise

◆ fcb_rotate()

int fcb_rotate ( struct fcb fcb)

#include <include/fs/fcb.h>

◆ fcb_walk()

int fcb_walk ( struct fcb fcb,
struct flash_sector sector,
fcb_walk_cb  cb,
void cb_arg 
)

#include <include/fs/fcb.h>

Walk over all entries in the FCB sector

Parameters
[in]sectorfcb sector to be walked. If null, traverse entire storage.
[in]fcbFCB instance structure.
[in]cbpointer 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_argcallback context, transferred to the callback implementation.
Returns
0 on success, negative on failure (or transferred form callback return-value), positive transferred form callback return-value