优化: 优化了fatfs_port以及文件相关指令

1. fatfs_port支持设置卷标
2. 文件指令使用方式优化
This commit is contained in:
hqm 2022-08-12 15:53:44 +08:00 committed by qmfr
parent 5aade2d78c
commit 840076a741
4 changed files with 17 additions and 16 deletions

View File

@ -48,8 +48,11 @@ build/%.o:%.c
mkbuilddir:
mkdir -p build
.PHONY:clean
.PHONY:clean distclean
clean:
rm -rf build xcmder xcmder.map
distclean:
rm -rf build xcmder fatfs.img xcmder.map

View File

@ -6,7 +6,6 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include "diskio.h"
#define MMC_DISK_SECTION_SIZE (512)
#define MMC_DISK_SECTION_COUNT (1024)
@ -101,24 +100,24 @@ static DRESULT m_disk_ioctl(BYTE cmd, void *buff)
int mmc_disk_init(void)
{
FRESULT res;
disk.disk_name = "MMC Disk";
disk.disk_initialize = m_disk_initialize;
disk.disk_ioctl = m_disk_ioctl;
disk.disk_read = m_disk_read;
disk.disk_status = m_disk_status;
disk.disk_write = m_disk_write;
if(f_disk_regist(&disk, 1) == -1)
if(f_disk_regist(&disk, "MMC", 1) == -1)
{
printf("MMC disk regist ERROR!\r\n");
return FR_DISK_ERR;
}
res = f_mount(&g_fs, "1:", 1); //挂载文件系统 "1:"就是挂载的设备号为1的设备
res = f_mount(&g_fs, disk.disk_path, 1); //挂载文件系统 "1:"就是挂载的设备号为1的设备
if (res == FR_NO_FILESYSTEM) //FR_NO_FILESYSTEM值为13表示没有有效的设备
{
res = f_mkfs("1:", 0, g_work, sizeof(g_work));
res = f_mount(NULL, "1:", 1); //取消文件系统
res = f_mount(&g_fs, "1:", 1); //挂载文件系统
res = f_mkfs(disk.disk_path, 0, g_work, sizeof(g_work));
res = f_mount(NULL, disk.disk_path, 1); //取消文件系统
res = f_mount(&g_fs, disk.disk_path, 1); //挂载文件系统
}
if(res == FR_OK)

View File

@ -5,7 +5,7 @@
static DiskIo_t disk;
#define RAM_DISK_SECTION_SIZE (512)
#define RAM_DISK_SECTION_COUNT (1024)
#define RAM_DISK_SECTION_COUNT (256)
static char *ram_buf[RAM_DISK_SECTION_COUNT][RAM_DISK_SECTION_SIZE];
static FATFS g_fs;
static BYTE g_work[FF_MAX_SS];
@ -56,24 +56,23 @@ static DRESULT m_disk_ioctl(BYTE cmd, void *buff)
int ram_disk_init(void)
{
FRESULT res;
disk.disk_name = "RAM Disk";
disk.disk_initialize = m_disk_initialize;
disk.disk_ioctl = m_disk_ioctl;
disk.disk_read = m_disk_read;
disk.disk_status = m_disk_status;
disk.disk_write = m_disk_write;
if(f_disk_regist(&disk, 0) == -1)
if(f_disk_regist(&disk, "RAM", 0) == -1)
{
printf("RAM disk regist ERROR!\r\n");
return FR_DISK_ERR;
}
res = f_mount(&g_fs, "0:", 1); //挂载文件系统 "1:"就是挂载的设备号为1的设备
res = f_mount(&g_fs, disk.disk_path, 1); //挂载文件系统 "1:"就是挂载的设备号为1的设备
if (res == FR_NO_FILESYSTEM) //FR_NO_FILESYSTEM值为13表示没有有效的设备
{
res = f_mkfs("0:", 0, g_work, sizeof(g_work));
res = f_mount(NULL, "0:", 1); //取消文件系统
res = f_mount(&g_fs, "0:", 1); //挂载文件系统
res = f_mkfs(disk.disk_path, 0, g_work, sizeof(g_work));
res = f_mount(NULL, disk.disk_path, 1); //取消文件系统
res = f_mount(&g_fs, disk.disk_path, 1); //挂载文件系统
}
if(res == FR_OK)

View File

@ -17,7 +17,7 @@ extern "C" {
#define XCMD_LINE_MAX_LENGTH (128) /* 命令行支持的最大字符数 */
#define XCMD_HISTORY_MAX_NUM (16) /* 支持的历史记录个数, 这个参数对内存的影响很大建议arduino设置为00为不支持 */
#define XCMD_PARAM_MAX_NUM (8) /* 支持输入的参数个数 */
#define XCMD_PARAM_MAX_NUM (64) /* 支持输入的参数个数 */
// #define XCMD_DEFAULT_PROMPT "->" /* 提示符 */
// #define XCMD_DEFAULT_PROMPT_CLOLR TX_GREEN /* 提示符颜色 */
// #define ENABLE_XCMD_EXPORT /* 需要修改lds启用后支持XCMD_EXPORT_CMD和XCMD_EXPORT_KEY方法导出命令 */