SD卡与fatfs文件系统(5)-在fatfs中使用多个SD卡分区

    fatfs是支持多个分区的,但当SD读卡器插入到windows中时却只能认出第1个分区,windows认为可移动闪存设备只有一个分区(注意,移动硬盘除外)。正好可以利用这个特性,在SD卡中使用隐藏分区。例如将SD分为两个分区,第1个分区开放给用户,第2个分区保存一些内部数据。

    要在fatfs中使用两个分区,需要配置:

#define _DRIVES		2
/* Number of logical drives to be used. This affects the size of internal table. */

#define	_MULTI_PARTITION	1
/* When _MULTI_PARTITION is set to 0, each logical drive is bound to same
/  physical drive number and can mount only 1st primaly partition. When it is
/  set to 1, each logical drive can mount a partition listed in Drives[]. */

并需要添加:

const PARTITION Drives[] = 
{
  {0, 0},
  {0, 1}
};

读写第1个分区时:

res = f_mount(0, &fs);

res = f_opendir (&dirs,“0:”);

读写第2个分区时:

res = f_mount(1, &fs);

res = f_opendir (&dirs,“1:”);


  • 2
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值