This function utilizes two distinct sectors to retrieve the states of all system components. By using a ping-pong approach, only one sector is active at a time for updating the states. The first packet within each sector either remains empty or contains the states of all system components. If the first packet is not present, the sector is considered empty and will be promptly erased if it hasn't been already. Following the initial packet, subsequent partial data packets are used to update the system states.
for (int i = 0; i < 2; i++)
{
}
storageConfig.
clients = storageClients;
storageClients[0].
arg = (
void*)&CLIENT_DATA;
static void InitStatesFromStorage(uint32_t* data, bool isDataValid)
{
dest_data_t* src = (dest_data_t*)data;
src_data_t* dest = (src_data_t*)&srcData;
if (isDataValid)
src->value = dest->value;
else
src->value = 0;
}
static uint32_t RefreshStates(uint32_t* data, uint32_t* indexPtr)
{
uint32_t len = 0;
dest_data_t* dest = (dest_data_t*)data;
src_data_t* src = (src_data_t*)&srcData;
if (dest->value != src->value)
{
dest->value = src->value;
len = storageWordLen;
}
*indexPtr = 0;
return len;
}
{
}
Client1_ConfigStorage(&storageClients[0]);
Client2_ConfigStorage(&storageClients[1]);
void StateStorage_Init(state_storage_config_t *_config)
This function initializes the state storage according to the application requirements.
Definition state_storage_lib.c:283
Contains the entities to be defined by each storage client. The storage module uses these members to ...
Definition state_storage_lib.h:78
uint32_t dataWordLen
No of 32-bit words required for the client storage.
Definition state_storage_lib.h:80
void(* InitStatesFromStorage)(uint32_t *data, bool isDataValid)
This callback initiates the storage for the relevant client.
Definition state_storage_lib.h:81
uint32_t(* RefreshStates)(uint32_t *data, uint32_t *indexPtr)
This callback is used to refresh the states in the data buffer for the client.
Definition state_storage_lib.h:100
void * arg
Custom arguments used by the relevant client.
Definition state_storage_lib.h:79
uint32_t bank
Definition state_storage_lib.h:141
uint32_t * addr
Definition state_storage_lib.h:142
uint32_t byteCount
Definition state_storage_lib.h:140
uint32_t sectorNo
Definition state_storage_lib.h:138
Defines the state storage configuration.
Definition state_storage_lib.h:148
state_storage_client_t * clients
Definition state_storage_lib.h:151
flash_sector_config_t sectors[2]
Definition state_storage_lib.h:149
int clientCount
Definition state_storage_lib.h:150
This function utilizes two distinct sectors to retrieve the states of all system components. By using a ping-pong approach, only one sector is active at a time for updating the states. The first packet within each sector either remains empty or contains the states of all system components. If the first packet is not present, the sector is considered empty and will be promptly erased if it hasn't been already. Following the initial packet, subsequent partial data packets are used to update the system states.
for (int i = 0; i < 2; i++)
{
}
storageConfig.
clients = storageClients;
storageClients[0].
arg = (
void*)&CLIENT_DATA;
Client1_ConfigStorage(&storageClients[0]);
Client2_ConfigStorage(&storageClients[1]);