Midnight Sun Firmware
Loading...
Searching...
No Matches
persist.h
1
#pragma once
2
3
/************************************************************************************************
4
* @file persist.h
5
*
6
* @brief Persist API Header file
7
*
8
* @date 2025-03-10
9
* @author Midnight Sun Team #24 - MSXVI
10
************************************************************************************************/
11
12
/* Standard library Headers */
13
#include <stdbool.h>
14
#include <stddef.h>
15
16
/* Inter-component Headers */
17
18
/* Intra-component Headers */
19
#include "flash.h"
20
#include "status.h"
21
22
// Commit data every second if dirty
23
#define PERSIST_COMMIT_TIMEOUT_MS 1000
24
25
typedef
struct
PersistStorage
{
26
void
*blob;
27
size_t
blob_size;
28
uintptr_t flash_addr;
29
uintptr_t prev_flash_addr;
30
uint32_t prev_hash;
31
uint8_t page;
32
}
PersistStorage
;
33
34
// Attempt to load stored data into the provided blob and retains the blob to
35
// commit periodically Reserves the entire flash page for the persistance layer
36
// instance Note that the blob must be a multiple of FLASH_WRITE_BYTES and must
37
// persist If |overwrite| is true, the persist layer overwrites invalid blobs.
38
// Otherwise, it fails.
39
StatusCode
persist_init(
PersistStorage
*persist, uint8_t page,
void
*blob,
size_t
blob_size,
bool
overwrite);
40
41
// Force a data commit - this should be avoided if possible.
42
StatusCode
persist_commit(
PersistStorage
*persist);
StatusCode
StatusCode
StatusCodes for various errors.
Definition:
status.h:27
PersistStorage
Definition:
persist.h:25
libraries
ms-common
inc
persist.h
Generated by
1.9.5