2025-04-18 18:59:53 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @file FluxSD.h
|
|
|
|
|
|
* @brief SD卡头文件
|
|
|
|
|
|
*
|
|
|
|
|
|
* 用于存储测试日志
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author wang xiang en
|
|
|
|
|
|
* @date 2025-04-18
|
|
|
|
|
|
* @version 版本号
|
|
|
|
|
|
* @copyright 版权声明((C)2025, YUWELL MEDTECH Co.ltd)
|
2025-03-07 19:07:31 +08:00
|
|
|
|
*/
|
2025-03-15 09:37:07 +08:00
|
|
|
|
#ifndef _FLUX_SD_H
|
|
|
|
|
|
#define _FLUX_SD_H
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-03-07 19:07:31 +08:00
|
|
|
|
#pragma once
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2025-04-18 18:59:53 +08:00
|
|
|
|
#include <string.h>
|
|
|
|
|
|
#include <sys/unistd.h>
|
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
#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"
|
|
|
|
|
|
|
|
|
|
|
|
/* 定义块大小 */
|
|
|
|
|
|
#define EXAMPLE_MAX_CHAR_SIZE (64)
|
|
|
|
|
|
/* 定义挂载点 */
|
2025-03-07 19:07:31 +08:00
|
|
|
|
#define MOUNT_POINT "/sdcard"
|
|
|
|
|
|
|
2025-04-18 18:59:53 +08:00
|
|
|
|
/* 选择是否进行测试数据记录 */
|
2025-03-26 18:59:32 +08:00
|
|
|
|
#define LOG_RECORD_ENABLE 1
|
|
|
|
|
|
|
2025-04-18 18:59:53 +08:00
|
|
|
|
/* 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)
|
|
|
|
|
|
|
|
|
|
|
|
/* 导出SD存储信息 */
|
2025-03-13 14:04:19 +08:00
|
|
|
|
extern uint64_t total_bytes;
|
|
|
|
|
|
extern uint64_t free_bytes;
|
|
|
|
|
|
extern float free_percent;
|
|
|
|
|
|
|
2025-04-18 18:59:53 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief 选择引脚
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
#define GPIO_INPUT_PIN_SEL(pin) (1ULL<<pin)
|
2025-03-07 19:07:31 +08:00
|
|
|
|
|
2025-04-18 18:59:53 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief SD卡Pin配置
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2025-03-07 19:07:31 +08:00
|
|
|
|
typedef struct {
|
|
|
|
|
|
const char** names;
|
|
|
|
|
|
const int* pins;
|
|
|
|
|
|
} pin_configuration_t;
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-04-18 18:59:53 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief SD卡初始化
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2025-03-07 19:07:31 +08:00
|
|
|
|
void flux_sd_init(void);
|
2025-03-15 09:37:07 +08:00
|
|
|
|
|
2025-04-18 18:59:53 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief 日志记录
|
|
|
|
|
|
*
|
|
|
|
|
|
* 用于记录测试过程日志
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2025-03-26 18:59:32 +08:00
|
|
|
|
esp_err_t s_example_write_log(char *data);
|
|
|
|
|
|
|
2025-04-19 09:30:40 +08:00
|
|
|
|
|
2025-03-07 19:07:31 +08:00
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-03-15 09:37:07 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
|