104 lines
1.8 KiB
C
104 lines
1.8 KiB
C
/**
|
||
* @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 <stdint.h>
|
||
|
||
#ifdef __cplusplus
|
||
extern "C" {
|
||
#endif
|
||
|
||
#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)
|
||
/* 定义挂载点 */
|
||
#define MOUNT_POINT "/sdcard"
|
||
|
||
/* 选择是否进行测试数据记录 */
|
||
#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)
|
||
|
||
/* 导出SD存储信息 */
|
||
extern uint64_t total_bytes;
|
||
extern uint64_t free_bytes;
|
||
extern float free_percent;
|
||
|
||
/**
|
||
* @brief 选择引脚
|
||
*
|
||
*/
|
||
#define GPIO_INPUT_PIN_SEL(pin) (1ULL<<pin)
|
||
|
||
/**
|
||
* @brief SD卡Pin配置
|
||
*
|
||
*/
|
||
typedef struct {
|
||
const char** names;
|
||
const int* pins;
|
||
} pin_configuration_t;
|
||
|
||
/**
|
||
* @brief SD卡引脚检查
|
||
*
|
||
* 对SD卡引脚配置进行检查,判定是否能够进行SD使用
|
||
*
|
||
* @param[out] config 引脚配置情况
|
||
* @param[in] pin_count 引脚数
|
||
*/
|
||
void check_sd_card_pins(pin_configuration_t *config, const int pin_count);
|
||
|
||
/**
|
||
* @brief SD卡初始化
|
||
*
|
||
*/
|
||
void flux_sd_init(void);
|
||
|
||
/**
|
||
* @brief 日志记录
|
||
*
|
||
* 用于记录测试过程日志
|
||
*
|
||
*/
|
||
esp_err_t s_example_write_log(char *data);
|
||
|
||
#ifdef __cplusplus
|
||
}
|
||
#endif
|
||
|
||
|
||
#endif
|
||
|