nvs_flash.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #ifndef nvs_flash_h
  14. #define nvs_flash_h
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #include "nvs.h"
  19. /**
  20. * @brief Initialize the default NVS partition.
  21. *
  22. * This API initialises the default NVS partition. The default NVS partition
  23. * is the one that is labelled "nvs" in the partition table.
  24. *
  25. * @return
  26. * - ESP_OK if storage was successfully initialized.
  27. * - ESP_ERR_NVS_NO_FREE_PAGES if the NVS storage contains no empty pages
  28. * (which may happen if NVS partition was truncated)
  29. * - ESP_ERR_NOT_FOUND if no partition with label "nvs" is found in the partition table
  30. * - one of the error codes from the underlying flash storage driver
  31. */
  32. esp_err_t nvs_flash_init(void);
  33. /**
  34. * @brief Initialize NVS flash storage for the specified partition.
  35. *
  36. * @param[in] partition_name Name (label) of the partition. Note that internally a reference to
  37. * passed value is kept and it should be accessible for future operations
  38. *
  39. * @return
  40. * - ESP_OK if storage was successfully initialized.
  41. * - ESP_ERR_NVS_NO_FREE_PAGES if the NVS storage contains no empty pages
  42. * (which may happen if NVS partition was truncated)
  43. * - ESP_ERR_NOT_FOUND if specified partition is not found in the partition table
  44. * - one of the error codes from the underlying flash storage driver
  45. */
  46. esp_err_t nvs_flash_init_partition(const char *partition_name);
  47. /**
  48. * @brief Erase the default NVS partition
  49. *
  50. * This function erases all contents of the default NVS partition (one with label "nvs")
  51. *
  52. * @return
  53. * - ESP_OK on success
  54. * - ESP_ERR_NOT_FOUND if there is no NVS partition labeled "nvs" in the
  55. * partition table
  56. */
  57. esp_err_t nvs_flash_erase(void);
  58. /**
  59. * @brief Erase specified NVS partition
  60. *
  61. * This function erases all contents of specified NVS partition
  62. *
  63. * @param[in] part_name Name (label) of the partition to be erased
  64. *
  65. * @return
  66. * - ESP_OK on success
  67. * - ESP_ERR_NOT_FOUND if there is no NVS partition with the specified name
  68. * in the partition table
  69. */
  70. esp_err_t nvs_flash_erase_partition(const char *part_name);
  71. #ifdef __cplusplus
  72. }
  73. #endif
  74. #endif /* nvs_flash_h */