spiffs_api.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright 2015-2017 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. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #pragma once
  15. #include <stdint.h>
  16. #include <stddef.h>
  17. #include "freertos/FreeRTOS.h"
  18. #include "freertos/task.h"
  19. #include "freertos/semphr.h"
  20. #include "spiffs.h"
  21. #include "esp_vfs.h"
  22. #include "esp_compiler.h"
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /**
  27. * @brief SPIFFS definition structure
  28. */
  29. typedef struct {
  30. spiffs *fs; /*!< Handle to the underlying SPIFFS */
  31. SemaphoreHandle_t lock; /*!< FS lock */
  32. const esp_partition_t* partition; /*!< The partition on which SPIFFS is located */
  33. char base_path[ESP_VFS_PATH_MAX+1]; /*!< Mount point */
  34. bool by_label; /*!< Partition was mounted by label */
  35. spiffs_config cfg; /*!< SPIFFS Mount configuration */
  36. uint8_t *work; /*!< Work Buffer */
  37. uint8_t *fds; /*!< File Descriptor Buffer */
  38. uint32_t fds_sz; /*!< File Descriptor Buffer Length */
  39. uint8_t *cache; /*!< Cache Buffer */
  40. uint32_t cache_sz; /*!< Cache Buffer Length */
  41. } esp_spiffs_t;
  42. s32_t spiffs_api_read(spiffs *fs, uint32_t addr, uint32_t size, uint8_t *dst);
  43. s32_t spiffs_api_write(spiffs *fs, uint32_t addr, uint32_t size, uint8_t *src);
  44. s32_t spiffs_api_erase(spiffs *fs, uint32_t addr, uint32_t size);
  45. void spiffs_api_check(spiffs *fs, spiffs_check_type type,
  46. spiffs_check_report report, uint32_t arg1, uint32_t arg2);
  47. #ifdef __cplusplus
  48. }
  49. #endif