#ifndef FLASH_H #define FLASH_H #pragma GCC diagnostic ignored "-Wformat-truncation" #include #include #include #include #include #include "esp_flash.h" #include "esp_flash_spi_init.h" #include "esp_partition.h" #include "esp_vfs.h" #include "esp_vfs_fat.h" #include "esp_system.h" #include "soc/spi_pins.h" #include #include #define HOST_ID SPI3_HOST // 使用SPI3主机(VSPI) #define PIN_MOSI 39 #define PIN_MISO 41 #define PIN_CLK 40 #define PIN_CS 42 #define PIN_WP -1 #define PIN_HD -1 #define SPI_DMA_CHAN SPI_DMA_CH_AUTO // DMA通道:自动选择 /* extflash 访问互斥:所有对 /extflash 的 fopen/fread/fwrite/stat/opendir 等操作需在持锁期间进行 */ void extflash_lock(void); void extflash_unlock(void); /* 解压进行中标志:动画切换应延后,避免与解压写操作竞争 */ void extflash_extraction_started(void); void extflash_extraction_finished(void); bool extflash_is_extracting(void); void list_files_in_directory(const char *path); static bool copy_file(const char *source_path, const char *dest_path); static void extract_task(void *pvParameters); static bool example_mount_fatfs(void); void flash_main(void); esp_err_t download_file(char *firmware_url, char *filename); static esp_err_t read_chip_id(spi_device_handle_t handle, uint8_t *id_data, size_t len); #endif // FLASH_H