NV component header.
Copyright (c) 2018 Microchip Technology Inc. and its subsidiaries.
#include <compiler.h>
Macros | |
#define | S_NV_APPLICATION_RANGE_MAX 0x3FFFu |
#define | S_NV_APPLICATION_RANGE_MIN 0x0900u |
The ranges of IDs that can be used by the application for storing flash data. More... | |
#define | S_NV_PLATFORM_RANGE1_MAX 0x08FFu |
#define | S_NV_PLATFORM_RANGE1_MIN 0x0800u |
First reserved range for a platform. More... | |
#define | S_NV_PLATFORM_RANGE2_MAX 0x7FFFu |
#define | S_NV_PLATFORM_RANGE2_MIN 0x7000u |
Second reserved range for a platform. More... | |
#define | S_NV_RESERVED_RANGE_MAX 0x6FFFu |
#define | S_NV_RESERVED_RANGE_MIN 0x4000u |
Reserved range for future use. More... | |
#define | S_NV_STACK_RANGE_MAX 0x07FFu |
#define | S_NV_STACK_RANGE_MIN 0x0001u |
The ranges of IDs that can be used by the stack for storing flash data. More... | |
Typedefs | |
typedef uint16_t | S_Nv_ItemId_t |
Identifier type to an item in Flash. More... | |
typedef bool(* | S_Nv_PowerSupplyCheckingFunction_t )(void) |
Function type used to check the external NV's power supply. More... | |
typedef enum S_Nv_ReturnValue_t | S_Nv_ReturnValue_t |
Return value type of most S_Nv functions. More... | |
Enumerations | |
enum | S_Nv_ReturnValue_t { S_Nv_ReturnValue_Ok, S_Nv_ReturnValue_Failure, S_Nv_ReturnValue_DidNotExist, S_Nv_ReturnValue_DoesNotExist, S_Nv_ReturnValue_BeyondEnd, S_Nv_ReturnValue_PowerSupplyTooLow } |
Return value type of most S_Nv functions. More... | |
Functions | |
S_Nv_ReturnValue_t | S_Nv_Delete (S_Nv_ItemId_t id) |
Deletes an item from non-volatile storage. More... | |
S_Nv_ReturnValue_t | S_Nv_EraseAll (bool includingPersistentItems) |
Erases all items (optionally except the persistent ones) from non-volatile storage. More... | |
bool | S_Nv_IsItemAvailable (S_Nv_ItemId_t id) |
This will check whether the item is found in the storage area. More... | |
S_Nv_ReturnValue_t | S_Nv_ItemInit (S_Nv_ItemId_t id, uint16_t itemLength, void *pDefaultData) |
Initializes an item with default data if it doesn't exist yet, or reads it when it does exist. More... | |
uint16_t | S_Nv_ItemLength (S_Nv_ItemId_t id) |
Returns the item length of an item. More... | |
S_Nv_ReturnValue_t | S_Nv_Read (S_Nv_ItemId_t id, uint16_t offset, uint16_t dataLength, void *pData) |
Reads an item. More... | |
void | S_Nv_SetPowerSupplyCheckingFunction (S_Nv_PowerSupplyCheckingFunction_t pf) |
Sets a function to check the power supply. More... | |
void | S_Nv_SetSystemIntegrityCheckFunction (void(*pf)(void)) |
S_Nv Integrity check function. More... | |
S_Nv_ReturnValue_t | S_Nv_Write (S_Nv_ItemId_t id, uint16_t offset, uint16_t dataLength, void *pData) |
Writes an item. More... | |
#define S_NV_APPLICATION_RANGE_MAX 0x3FFFu |
#define S_NV_APPLICATION_RANGE_MIN 0x0900u |
The ranges of IDs that can be used by the application for storing flash data.
#define S_NV_PLATFORM_RANGE1_MAX 0x08FFu |
#define S_NV_PLATFORM_RANGE1_MIN 0x0800u |
First reserved range for a platform.
#define S_NV_PLATFORM_RANGE2_MAX 0x7FFFu |
#define S_NV_PLATFORM_RANGE2_MIN 0x7000u |
Second reserved range for a platform.
#define S_NV_RESERVED_RANGE_MAX 0x6FFFu |
#define S_NV_RESERVED_RANGE_MIN 0x4000u |
Reserved range for future use.
#define S_NV_STACK_RANGE_MAX 0x07FFu |
#define S_NV_STACK_RANGE_MIN 0x0001u |
The ranges of IDs that can be used by the stack for storing flash data.
See wlPdsMemIds.h
typedef uint16_t S_Nv_ItemId_t |
Identifier type to an item in Flash.
Valid range is 1..32767.
typedef bool(* S_Nv_PowerSupplyCheckingFunction_t)(void) |
Function type used to check the external NV's power supply.
Should only return TRUE if the power supply is high enough to reliably perform a write or erase operation.
typedef enum S_Nv_ReturnValue_t S_Nv_ReturnValue_t |
Return value type of most S_Nv functions.
enum S_Nv_ReturnValue_t |
Return value type of most S_Nv functions.
S_Nv_ReturnValue_t S_Nv_Delete | ( | S_Nv_ItemId_t | id | ) |
Deletes an item from non-volatile storage.
id | The item to delete. |
Referenced by PDS_Delete().
S_Nv_ReturnValue_t S_Nv_EraseAll | ( | bool | includingPersistentItems | ) |
Erases all items (optionally except the persistent ones) from non-volatile storage.
includingPersistentItems | Whether to also erase the peristent items. |
The persistent items should typically never be erased in an application!
Referenced by PDS_DeleteAll().
bool S_Nv_IsItemAvailable | ( | S_Nv_ItemId_t | id | ) |
This will check whether the item is found in the storage area.
id | - Id of the item to be checked. |
Referenced by PDS_IsAbleToRestore(), and pdsStoreItemTaskHandler().
S_Nv_ReturnValue_t S_Nv_ItemInit | ( | S_Nv_ItemId_t | id, |
uint16_t | itemLength, | ||
void * | pDefaultData | ||
) |
Initializes an item with default data if it doesn't exist yet, or reads it when it does exist.
id | The item to initialize. |
itemLength | The length of the item. |
pDefaultData | Buffer to 'itemLength' bytes, or NULL. |
If the item doesn't exist, it is written with the given default data and the status code S_Nv_ReturnValue_DidNotExist is returned. Otherwise, the default data is not used, the item is kept as it was but read into pDefaultData, and S_Nv_ReturnValue_Ok is returned. If NULL is passed for pDefaultData, and the item doesn't exist all data is initialized to 0xFF.
Referenced by PDS_InitItems(), pdsRestoreItem(), and pdsStoreItemTaskHandler().
uint16_t S_Nv_ItemLength | ( | S_Nv_ItemId_t | id | ) |
Returns the item length of an item.
id | The item to get the length from. |
Referenced by pdsRestoreItem().
S_Nv_ReturnValue_t S_Nv_Read | ( | S_Nv_ItemId_t | id, |
uint16_t | offset, | ||
uint16_t | dataLength, | ||
void * | pData | ||
) |
Reads an item.
id | The item to read. |
offset | The offset in the item to start reading from. |
dataLength | The length of the data to read. |
pData | Pointer to a buffer where the read bytes are to be written to. |
If any of the bytes fall outside the item lenght as passed during S_Nv_ItemInit(), the whole read operation does not occur and S_Nv_ReturnValue_BeyondEnd is returned.
void S_Nv_SetPowerSupplyCheckingFunction | ( | S_Nv_PowerSupplyCheckingFunction_t | pf | ) |
Sets a function to check the power supply.
pf | A pointer to a function that S_Nv uses to check the power supply. |
If the power supply checking function is not set, the default is to assume that the power supply is always high enough. This is not suitable for typical applications. When this function is called again,
void S_Nv_SetSystemIntegrityCheckFunction | ( | void(*)(void) | pf | ) |
S_Nv Integrity check function.
S_Nv_ReturnValue_t S_Nv_Write | ( | S_Nv_ItemId_t | id, |
uint16_t | offset, | ||
uint16_t | dataLength, | ||
void * | pData | ||
) |
Writes an item.
id | The item to write. |
offset | The offset in the item to start writing to. |
dataLength | The length of the data to write. |
pData | Pointer to 'dataLength' bytes to write. |
If any of the bytes fall outside the item lenght as passed during S_Nv_ItemInit(), the whole write operation does not occur and S_Nv_ReturnValue_BeyondEnd is returned.
Referenced by pdsStoreItem(), updatecommnDevTable(), updateCoordHopTable(), updateCoordRouteTable(), updateCoordTable(), updateNonSleepDevTable(), and updateSleepDevTable().