EasyManuals Logo

Espressif ESP32-S2 User Manual

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #731 background imageLoading...
Page #731 background image
Chapter 2. API Reference
[in] handle: Storage handle obtained with nvs_open. Handles that were opened read only
cannot be used.
esp_err_t nvs_commit(nvs_handle_t handle)
Write any pending changes to non-volatile storage.
After setting any values, nvs_commit() must be called to ensure changes are written to non-volatile storage.
Individual implementations may write to storage at other times, but this is not guaranteed.
Return
ESP_OK if the changes have been written successfully
ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL
other error codes from the underlying storage driver
Parameters
[in] handle: Storage handle obtained with nvs_open. Handles that were opened read only
cannot be used.
void nvs_close(nvs_handle_t handle)
Close the storage handle and free any allocated resources.
This function should be called for each handle opened with nvs_open once the handle is not in use any more.
Closing the handle may not automatically write the changes to nonvolatile storage. This has to be done explicitly
using nvs_commit function. Once this function is called on a handle, the handle should no longer be used.
Parameters
[in] handle: Storage handle to close
esp_err_t nvs_get_stats(const char *part_name, nvs_stats_t *nvs_stats)
Fill structure nvs_stats_t. It provides info about used memory the partition.
This function calculates to runtime the number of used entries, free entries, total entries, and amount namespace
in partition.
// Example of nvs_get_stats() to get the number of used entries and free
,entries:
nvs_stats_t nvs_stats;
nvs_get_stats(NULL, &nvs_stats);
printf("Count: UsedEntries = (%d), FreeEntries = (%d), AllEntries = (%d)\n",
nvs_stats.used_entries, nvs_stats.free_entries, nvs_stats.total_
,entries);
Return
ESP_OK if the changes have been written successfully. Return param nvs_stats will be filled.
ESP_ERR_NVS_PART_NOT_FOUND if the partition with label nameis not found. Return
param nvs_stats will be filled 0.
ESP_ERR_NVS_NOT_INITIALIZED if the storage driver is not initialized. Return param
nvs_stats will be filled 0.
ESP_ERR_INVALID_ARG if nvs_stats equal to NULL.
ESP_ERR_INVALID_STATE if there is page with the status of INVALID. Return param nvs_stats
will be filled not with correct values because not all pages will be counted. Counting will be inter-
rupted at the first INVALID page.
Parameters
[in] part_name: Partition name NVS in the partition table. If pass a NULL than will use
NVS_DEFAULT_PART_NAME (nvs).
[out] nvs_stats: Returns filled structure nvs_states_t. It provides info about used memory
the partition.
esp_err_t nvs_get_used_entry_count(nvs_handle_t handle, size_t *used_entries)
Calculate all entries in a namespace.
An entry represents the smallest storage unit in NVS. Strings and blobs may occupy more than one entry.
Note that to find out the total number of entries occupied by the namespace, add one to the returned value
used_entries (if err is equal to ESP_OK). Because the name space entry takes one entry.
Espressif Systems 720
Submit Document Feedback
Release v4.4

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Espressif ESP32-S2 and is the answer not in the manual?

Espressif ESP32-S2 Specifications

General IconGeneral
BrandEspressif
ModelESP32-S2
CategorySingle board computers
LanguageEnglish