/** * @file FluxSD.h * @brief SD卡头文件 * * 用于存储测试日志 * * @author wang xiang en * @date 2025-04-18 * @version 版本号 * @copyright 版权声明((C)2025, YUWELL MEDTECH Co.ltd) */ #ifndef _FLUX_SD_H #define _FLUX_SD_H #pragma once #include #ifdef __cplusplus extern "C" { #endif #include #include #include #include #include #include #include "driver/gpio.h" #include "esp_cpu.h" #include "esp_log.h" #include "esp_vfs_fat.h" #include "sdmmc_cmd.h" #include "driver/sdmmc_host.h" /* 包含FluxProtocol头文件 */ #include "FluxProtocol.h" /* 定义块大小 */ #define EXAMPLE_MAX_CHAR_SIZE (64) /* 定义挂载点 */ #define MOUNT_POINT "/sdcard" /* 定义日志文件名 */ #define LOG_FILE_NAME "/sdcard/log.txt" /* 用于存储文件索引的文件 */ #define INDEX_FILE_NAME "/sdcard/index.txt" /* 用于存储所有测试记录 */ #define TEST_FILE_NAME "/sdcard/test.txt" #define BS_RESULT_FILE_HEADER "timestamp,timeStr,device type,stage,15BPM,20BPM,25BPM,30BPM,35BPM,40BPM\n" #define NOM_RESULT_FILE_HEADER "timestamp,timeStr,is_nom,device type,stage,rate,volume\n" /* 配置是否选择记录数据到SD卡内 */ #define LOG_RECORD_ENABLE (1) /* SD卡读写引脚编号 */ #define CONFIG_EXAMPLE_PIN_CLK (14) #define CONFIG_EXAMPLE_PIN_CMD (21) #define CONFIG_EXAMPLE_PIN_D0 (13) #define CONFIG_EXAMPLE_PIN_D1 (12) #define CONFIG_EXAMPLE_PIN_D2 (48) #define CONFIG_EXAMPLE_PIN_D3 (47) /** * @brief SD卡数据存取结构体 * * 1.存储当前SD卡空间信息 * 2.存储当前测试的数据 * */ struct SD_Data { /* 当前SD卡总空间信息 */ uint64_t total_bytes; //总空间大小 uint64_t free_bytes; //剩余空间大小 float free_percent; //剩余空间百分比 /* 用于存储的的数据 */ struct FluxTestResult { enum DeviceType current_device_type; //当前设备类型 uint8_t current_stage; //当前测试挡位 int32_t current_rate; //当前测试频率 float test_result[6]; //六个呼吸频率的测试结果15 20 25 30 35 40 float current_test_result; //当前测试结果 }flux_test_result; char log_file_dir[64]; char test_file_dir[64]; char bs_file_dir[64]; /* 每次开机启动时的开机索引 */ int file_index; //开机索引,用于新建当日数据存储及日志文件 time_t current_time; struct tm current_time_tm; char strftime_buf[64]; }; /** * @brief 选择引脚 * */ #define GPIO_INPUT_PIN_SEL(pin) (1ULL<