Class daisy::PersistentStorage¶
template <typename SettingStruct>
ClassList > daisy > PersistentStorage
Non Volatile storage class for persistent settings on an external flash device. More...
#include <PersistentStorage.h>
Public Types¶
Type | Name |
---|---|
enum | State |
Public Functions¶
Type | Name |
---|---|
SettingStruct & | GetSettings () |
State | GetState () const |
void | Init (const SettingStruct & defaults, uint32_t address_offset=0) |
PersistentStorage (QSPIHandle & qspi) |
|
void | RestoreDefaults () |
void | Save () |
Detailed Description¶
Author:
shensley
Storage occupied by the struct will be one word larger than the SettingStruct used. The extra word is used to store the state of the data, and whether it's been overwritten or not.
Todo
-
Make Save() non-blocking
-
Add wear leveling
Public Types Documentation¶
enum State¶
State of the storage. When created, prior to initialiation, the state will be Unknown
During initialization, the state will be changed to either FACTORY, or USER.
If this is the first time these settings are being written to the target address, the defaults will be written to that location, and the state will be set to FACTORY.
Once the first user-trigger save has been made, the state will be updated to USER to indicate that the defaults have overwritten.
Public Functions Documentation¶
function GetSettings¶
Returns a reference to the setting struct
function GetState¶
Returns the state of the Persistent Data
function Init¶
inline void daisy::PersistentStorage::Init (
const SettingStruct & defaults,
uint32_t address_offset=0
)
Initialize Storage class
The values in this class will be stored as the default for restoration to 'factory' settings.
Parameters:
defaults
should be a setting structure containing the default values. this will be updated to contain the stored data.address_offset
offset for location on the QSPI chip (offset to base address of device). This defaults to the first address on the chip, and will be masked to the nearest multiple of 256
function PersistentStorage¶
Constructor for storage class
Parameters:
qspi
reference to the hardware qspi peripheral.
function RestoreDefaults¶
Restores the settings stored in the QSPI
function Save¶
Performs the save operation, storing the storage
The documentation for this class was generated from the following file external-docs/libDaisy/src/util/PersistentStorage.h