KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
blockstore.h File Reference

Allows for storage of persistent information in flash. More...

#include <stdbool.h>
#include <stddef.h>
#include "kernel/err.h"
#include "errorcode.h"

Go to the source code of this file.

Macros

#define E_BS_INVALID   (E_BLOCK + 0x01)
 Block storage is not valid. Must erase.
 
#define E_BS_INVALID_DESCR   "Can not load blockdata, invalid"
 
#define E_BS_LEN_MISMATCH   (E_BLOCK + 0x02)
 Buffer does not match the size of the allocated area.
 
#define E_BS_LEN_MISMATCH_DESCR   "Length of block not equal to provided buffer"
 

Functions

bool bsSave (unsigned int block, void *data, size_t len)
 Saves a block of data on the internal flash. More...
 
bool bsLoad (unsigned int block, void *data, size_t len)
 Loads a block of data from the flash. More...
 
bool bsCheck (unsigned int block, size_t len, bool *hasValidData)
 Checks the contents of a block. More...
 
bool bsErase (unsigned int block)
 Erases all data. More...
 

Detailed Description

Allows for storage of persistent information in flash.

Definition in file blockstore.h.

Function Documentation

bool bsCheck ( unsigned int  block,
size_t  len,
bool *  hasValidData 
)

Checks the contents of a block.

Parameters
blockThe block to check
lenLength to check (optional, 0 - don't check).
hasValidDataPointer to result to fill.
Return values
trueCheck successful.
falseCheck failed, please check error module for error.

Definition at line 63 of file blockstore.c.

bool bsErase ( unsigned int  block)

Erases all data.

Parameters
blockBlock number
Return values
trueErase successful.
falseErase failed, please check error module for error.

Definition at line 91 of file blockstore.c.

bool bsLoad ( unsigned int  block,
void *  data,
size_t  len 
)

Loads a block of data from the flash.

Parameters
blockThe block number.
dataThe data
lenThe length
Return values
trueLoading successful.
falseLoading failed, please check error module for error.

Definition at line 79 of file blockstore.c.

bool bsSave ( unsigned int  block,
void *  data,
size_t  len 
)

Saves a block of data on the internal flash.

If there is already data in the flash, and its not the same, the block will be erased, and new data written.

Parameters
blockThe block number
dataThe data to write
lenThe length of the data
Return values
trueSaving successful.
falseSaving failed, please check error module for error.

Definition at line 46 of file blockstore.c.