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 15 #pragma once 16 17 #include <stdint.h> 18 #include <stddef.h> 19 #include "freertos/FreeRTOS.h" 20 #include "freertos/task.h" 21 #include "freertos/semphr.h" 22 #include "spiffs.h" 23 #include "esp_vfs.h" 24 #include "esp_compiler.h" 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 30 /** 31 * @brief SPIFFS definition structure 32 */ 33 typedef struct { 34 spiffs *fs; /*!< Handle to the underlying SPIFFS */ 35 SemaphoreHandle_t lock; /*!< FS lock */ 36 const esp_partition_t* partition; /*!< The partition on which SPIFFS is located */ 37 char base_path[ESP_VFS_PATH_MAX+1]; /*!< Mount point */ 38 bool by_label; /*!< Partition was mounted by label */ 39 spiffs_config cfg; /*!< SPIFFS Mount configuration */ 40 uint8_t *work; /*!< Work Buffer */ 41 uint8_t *fds; /*!< File Descriptor Buffer */ 42 uint32_t fds_sz; /*!< File Descriptor Buffer Length */ 43 uint8_t *cache; /*!< Cache Buffer */ 44 uint32_t cache_sz; /*!< Cache Buffer Length */ 45 } esp_spiffs_t; 46 47 s32_t spiffs_api_read(spiffs *fs, uint32_t addr, uint32_t size, uint8_t *dst); 48 49 s32_t spiffs_api_write(spiffs *fs, uint32_t addr, uint32_t size, uint8_t *src); 50 51 s32_t spiffs_api_erase(spiffs *fs, uint32_t addr, uint32_t size); 52 53 void spiffs_api_check(spiffs *fs, spiffs_check_type type, 54 spiffs_check_report report, uint32_t arg1, uint32_t arg2); 55 56 #ifdef __cplusplus 57 } 58 #endif 59