MT7697 API Reference  LinkIt SDK v4
NVDM

This section introduces the NVDM APIs including terms and acronyms, supported features, software architecture, details on how to use the NVDM, enums, structures, typedefs and functions. More...

Overview

This section introduces the NVDM APIs including terms and acronyms, supported features, software architecture, details on how to use the NVDM, enums, structures, typedefs and functions.

Terms and acronyms

Terms Details
NVDM Non-volatile Data Management is a middleware used to store user data.

Supported features

How to use the NVDM APIs

How to adjust the NVDM region

Functions

nvdm_status_t nvdm_init (void)
 This function initializes the NVDM module to enable the NVDM services. More...
 
nvdm_status_t nvdm_write_data_item (const char *group_name, const char *data_item_name, nvdm_data_item_type_t type, const uint8_t *buffer, uint32_t size)
 This function is used to write or update a data item to flash. More...
 
nvdm_status_t nvdm_read_data_item (const char *group_name, const char *data_item_name, uint8_t *buffer, uint32_t *size)
 This function is used to read the data item from flash. More...
 
nvdm_status_t nvdm_delete_data_item (const char *group_name, const char *data_item_name)
 
nvdm_status_t nvdm_delete_group (const char *group_name)
 
nvdm_status_t nvdm_delete_all (void)
 
nvdm_status_t nvdm_query_begin (void)
 
nvdm_status_t nvdm_query_end (void)
 
nvdm_status_t nvdm_query_next_group_name (char *group_name)
 This function is used to enumerate all available group names. More...
 
nvdm_status_t nvdm_query_next_data_item_name (char *data_item_name)
 This function is used to enumerate all available data item names from the group returned by nvdm_query_next_group_name(). More...
 

Modules

 Enum
 

Function Documentation

nvdm_status_t nvdm_init ( void  )

This function initializes the NVDM module to enable the NVDM services.

User should not call nvdm_read_data_item() or nvdm_write_data_item() before nvdm_init(). Call nvdm_init() only once during the initialization.

Returns
NVDM_STATUS_OK, if the operation completed successfully.
NVDM_STATUS_ERROR, if an unknown error occurred.
nvdm_status_t nvdm_query_next_data_item_name ( char *  data_item_name)

This function is used to enumerate all available data item names from the group returned by nvdm_query_next_group_name().

The next available data item name is returned each time user calls this API. If the user calls the API after all available data item names are returned, the return value will be NVDM_STATUS_ITEM_NOT_FOUND.

Parameters
[out]data_item_namereturn the name of next data item belonging the specifc group.
Returns
NVDM_STATUS_OK, if the operation completed successfully.
NVDM_STATUS_ERROR, if an unknown error occurred.
NVDM_STATUS_INVALID_PARAMETER, if the parameter is invalid.
NVDM_STATUS_ITEM_NOT_FOUND, if the data item group is not found.
nvdm_status_t nvdm_query_next_group_name ( char *  group_name)

This function is used to enumerate all available group names.

The next available group name is returned each time user calls this API. If the user calls the API after all available group names are returned, the return value will be NVDM_STATUS_ITEM_NOT_FOUND.

Parameters
[out]group_namereturn the name of the next group available.
Returns
NVDM_STATUS_OK, if the operation completed successfully.
NVDM_STATUS_ERROR, if an unknown error occurred.
NVDM_STATUS_INVALID_PARAMETER, if the parameter is invalid.
NVDM_STATUS_ITEM_NOT_FOUND, if the data item group is not found.
nvdm_status_t nvdm_read_data_item ( const char *  group_name,
const char *  data_item_name,
uint8_t *  buffer,
uint32_t *  size 
)

This function is used to read the data item from flash.

If there is no such data item, it returns NVDM_STATUS_ITEM_NOT_FOUND. User should check the return status to verify whether the data read from the flash is correct.

Parameters
[in]group_nameis the group name of the data item, such as "Bluetooth".
[in]data_item_nameis the name of the data item, such as an "address" of "Bluetooth".
[out]bufferis a pointer to the user buffer, that stores the data item content read from the flash.
[in,out]sizeis the user buffer size when used as an input and is the size of actual data item's content read out when used as an output.
Returns
NVDM_STATUS_OK, if the operation completed successfully.
NVDM_STATUS_ERROR, if an unknown error occurred.
NVDM_STATUS_INVALID_PARAMETER, if the parameter is invalid.
NVDM_STATUS_ITEM_NOT_FOUND, if the data item is not found.
NVDM_STATUS_INCORRECT_CHECKSUM, if the checksum of data item is invalid.
Note
Call this API in tasks or function callbacks, but not in the interrupt handlers.
nvdm_status_t nvdm_write_data_item ( const char *  group_name,
const char *  data_item_name,
nvdm_data_item_type_t  type,
const uint8_t *  buffer,
uint32_t  size 
)

This function is used to write or update a data item to flash.

If there are existing data items on the flash, the NVDM invalidates old values and replaces with new ones. No other operation is performed while the data is being written to the flash. This function returns after the data is completely written to the flash. User should check the return status to verify whether the data is written to flash successfully.

Parameters
[in]typeis the data item type, which defines how the value is displayed.
[in]group_nameis the group name of the data item, such as "Bluetooth".
[in]data_item_nameis the name of the data item, such as "address" of the "Bluetooth".
[in]bufferis a pointer to the data item's content.
[in]sizeis the size of the data item's content.
Returns
NVDM_STATUS_OK, if the operation completed successfully.
NVDM_STATUS_ERROR, if an unknown error occurred.
NVDM_STATUS_INVALID_PARAMETER, if the parameter is invalid.
NVDM_STATUS_INSUFFICIENT_SPACE, if the storage space is not enough.
Note
Call this API in tasks or function callbacks, but not in the interrupt handlers.