学习1__STM32--FatFS之逻辑盘符与物理盘符

本文详细介绍了FatFS源代码中如何通过f_mount()函数和get_ldnumber()函数将路径转化为逻辑驱动器号。通过分析源码,解释了路径解析过程,包括查找冒号、提取数字和验证数字范围。还提供了代码示例以帮助读者更好地理解这一过程。
摘要由CSDN通过智能技术生成

FatFS源代码中的函数逻辑关系

第一  调用函数 f_mount()

result = f_mount(&fs, FS_VOLUME_NAND, 0);    /* Mount a logical drive */
FS_VOLUME_NAND 代表 “路径”

第二  进入函数 f_mount()内

 1 /*-----------------------------------------------------------------------*/
 2 /* Mount/Unmount a Logical Drive                                         */
 3 /*-----------------------------------------------------------------------*/
 4 
 5 FRESULT f_mount (
 6     FATFS* fs,            /* Pointer to the file system object (NULL:unmount)*/
 7     const TCHAR* path,    /* Logical drive number to be mounted/unmounted */
 8     BYTE opt              /* 0:Do not mount (delayed mount), 1:Mount immediately */
 9 )
10 {
11     FATFS *cfs;
12     int vol;
13     FRESULT res;
14     const TCHAR *rp = path;
15 
16 
17     vol = get_ldnumber(&rp);
18     if (vol < 0) return FR_INVALID_DRIVE;
19     cfs = FatFs[vol];                    /* Pointer to fs object */
20 
21     if (cfs) {
22 #if _FS_LOCK
23         clear_lock(cfs);
24 #endif
25 #if _FS_REENTRANT                        /* Discard sync object of the current volume */
26         if (!ff_del_syncobj(cfs->sobj)) return FR_INT_ERR;
27 #endif
28         cfs->fs_type = 0;                /*
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值