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
28
// Commit data every second if dirty
29
#define PERSIST_COMMIT_TIMEOUT_MS 1000
30
31
typedef
struct
PersistStorage
{
32
void
*blob;
33
size_t
blob_size;
34
uintptr_t flash_addr;
35
uintptr_t prev_flash_addr;
36
uint32_t prev_hash;
37
uint8_t page;
38
}
PersistStorage
;
39
40
// Attempt to load stored data into the provided blob and retains the blob to
41
// commit periodically Reserves the entire flash page for the persistance layer
42
// instance Note that the blob must be a multiple of FLASH_WRITE_BYTES and must
43
// persist If |overwrite| is true, the persist layer overwrites invalid blobs.
44
// Otherwise, it fails.
45
StatusCode
persist_init(
PersistStorage
*persist, uint8_t page,
void
*blob,
size_t
blob_size,
bool
overwrite);
46
47
// Force a data commit - this should be avoided if possible.
48
StatusCode
persist_commit(
PersistStorage
*persist);
49
StatusCode
StatusCode
StatusCodes for various errors.
Definition:
status.h:27
PersistStorage
Definition:
persist.h:31
libraries
ms-common
inc
persist.h
Generated by
1.9.5