nvs_flash.rst 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. .. include:: ../../components/nvs_flash/README.rst
  2. Application Example
  3. -------------------
  4. Two examples are provided in ESP-IDF examples directory:
  5. `07_nvs_rw_value <https://github.com/espressif/esp-idf/blob/master/examples/07_nvs_rw_value/main/nvs_rw_value.c>`_
  6. Demonstrates how to read and write a single integer value using NVS.
  7. The value holds the number of ESP32 module restarts. Since it is written to NVS, the value is preserved between restarts.
  8. Example also shows how to check if read / write operation was successful, or certain value is not initialized in NVS. Diagnostic is provided in plain text to help track program flow and capture any issues on the way.
  9. `08_nvs_rw_blob <https://github.com/espressif/esp-idf/blob/master/examples/08_nvs_rw_blob/main/nvs_rw_blob.c>`_
  10. Demonstrates how to read and write a single integer value and a blob (binary large object) using NVS to preserve them between ESP32 module restarts.
  11. * value - tracks number of ESP32 module soft and hard restarts.
  12. * blob - contains a table with module run times. The table is read from NVS to dynamically allocated RAM. New run time is added to the table on each manually triggered soft restart and written back to NVS. Triggering is done by pulling down GPIO0.
  13. Example also shows how to implement diagnostics if read / write operation was successful.
  14. API Reference
  15. -------------
  16. Header Files
  17. ^^^^^^^^^^^^
  18. * `nvs_flash/include/nvs_flash.h <https://github.com/espressif/esp-idf/blob/master/components/nvs_flash/include/nvs_flash.h>`_
  19. * `nvs_flash/include/nvs.h <https://github.com/espressif/esp-idf/blob/master/components/nvs_flash/include/nvs.h>`_
  20. Macros
  21. ^^^^^^
  22. .. doxygendefine:: ESP_ERR_NVS_BASE
  23. .. doxygendefine:: ESP_ERR_NVS_NOT_INITIALIZED
  24. .. doxygendefine:: ESP_ERR_NVS_NOT_FOUND
  25. .. doxygendefine:: ESP_ERR_NVS_TYPE_MISMATCH
  26. .. doxygendefine:: ESP_ERR_NVS_READ_ONLY
  27. .. doxygendefine:: ESP_ERR_NVS_NOT_ENOUGH_SPACE
  28. .. doxygendefine:: ESP_ERR_NVS_INVALID_NAME
  29. .. doxygendefine:: ESP_ERR_NVS_INVALID_HANDLE
  30. .. doxygendefine:: ESP_ERR_NVS_REMOVE_FAILED
  31. .. doxygendefine:: ESP_ERR_NVS_KEY_TOO_LONG
  32. .. doxygendefine:: ESP_ERR_NVS_PAGE_FULL
  33. .. doxygendefine:: ESP_ERR_NVS_INVALID_STATE
  34. .. doxygendefine:: ESP_ERR_NVS_INVALID_LENGTH
  35. Type Definitions
  36. ^^^^^^^^^^^^^^^^
  37. .. doxygentypedef:: nvs_handle
  38. Enumerations
  39. ^^^^^^^^^^^^
  40. .. doxygenenum:: nvs_open_mode
  41. Functions
  42. ^^^^^^^^^
  43. .. doxygenfunction:: nvs_open
  44. .. doxygenfunction:: nvs_set_i8
  45. .. doxygenfunction:: nvs_set_u8
  46. .. doxygenfunction:: nvs_set_i16
  47. .. doxygenfunction:: nvs_set_u16
  48. .. doxygenfunction:: nvs_set_i32
  49. .. doxygenfunction:: nvs_set_u32
  50. .. doxygenfunction:: nvs_set_i64
  51. .. doxygenfunction:: nvs_set_u64
  52. .. doxygenfunction:: nvs_set_str
  53. .. doxygenfunction:: nvs_set_blob
  54. .. doxygenfunction:: nvs_get_i8
  55. .. doxygenfunction:: nvs_get_u8
  56. .. doxygenfunction:: nvs_get_i16
  57. .. doxygenfunction:: nvs_get_u16
  58. .. doxygenfunction:: nvs_get_i32
  59. .. doxygenfunction:: nvs_get_u32
  60. .. doxygenfunction:: nvs_get_i64
  61. .. doxygenfunction:: nvs_get_u64
  62. .. doxygenfunction:: nvs_get_str
  63. .. doxygenfunction:: nvs_get_blob
  64. .. doxygenfunction:: nvs_erase_key
  65. .. doxygenfunction:: nvs_erase_all
  66. .. doxygenfunction:: nvs_commit
  67. .. doxygenfunction:: nvs_close
  68. .. doxygenfunction:: nvs_flash_init
  69. .. doxygenfunction:: nvs_flash_init_custom