Files
P4-USB-transfer/main/FLASH/flash.h
T
zhengxinandCursor 851e347cf5 初始提交卡包 USB 工程
纳入固件源码、屏幕组件、nand_xfer 工具和文档。忽略本机构建产物、sdkconfig,以及含本机路径的依赖锁。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-13 21:54:50 +08:00

46 lines
1.4 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#ifndef FLASH_H
#define FLASH_H
#pragma GCC diagnostic ignored "-Wformat-truncation"
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#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 <dirent.h>
#include <sys/stat.h>
#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