Midnight Sun Firmware
Loading...
Searching...
No Matches
Persist

persist Firmware More...

Classes

struct  PersistStorage
 

Macros

#define PERSIST_COMMIT_TIMEOUT_MS   1000
 

Functions

StatusCode persist_init (PersistStorage *persist, uint8_t page, void *blob, size_t blob_size, bool overwrite)
 Attempt to load stored data into the provided blob. More...
 
StatusCode persist_commit (PersistStorage *persist)
 Force a persist data commit. More...
 

Detailed Description

persist Firmware

Function Documentation

◆ persist_commit()

StatusCode persist_commit ( PersistStorage persist)

Force a persist data commit.

Must be called after persist_init is called

Parameters
persistPointer to the persist storage instance
Returns
STATUS_CODE_OK if committed successfully STATUS_CODE_INVALID_ARGS if invalid parameters are passed

◆ persist_init()

StatusCode persist_init ( PersistStorage persist,
uint8_t  page,
void *  blob,
size_t  blob_size,
bool  overwrite 
)

Attempt to load stored data into the provided blob.

Reserves the entire flash page for the persistance layer instance Note that the blob must be a multiple of FLASH_WRITE_BYTES and must persist If |overwrite| is true. the persist layer overwrites invalid blobs

Parameters
persistPointer to the persist storage instance
pageFlash page selection (Max: NUM_FLASH_PAGES) for persist to initialize on
blobPointer to the struct/blob you want to save or load from flash memory
blob_sizeSize of the struct/blob you want to save or load from flash memory
overwriteBoolean flag to overwrite existing blobs
Returns
STATUS_CODE_OK when persist is initialized successfully STATUS_CODE_OUT_OF_RANGE if an invalid flash page is selected STATUS_CODE_INVALID_ARGS if invalid parameters are passed

We want to exit in three scenarios:

  • If the page has been erased and there are no valid sections
    • Use the base address. Marker == 0xFFFFFFFF, Size == 0xFFFFFFFF
  • If this is an invalid section of memory
    • Increment the address by (header + blob). Marker != 0xFFFFFFFF, Size != 0xFFFFFFFF
  • If this is a valid section
    • Use the current address. Marker == 0xFFFFFFFF, Size != 0xFFFFFFFF