再次编译,发现提示一个关于get_fattime的错误,get_fattime用来获取当前时间,如果不需要,在ffconf.h中的宏定义#define _FS_NORTC改为1关闭,如果需要这个功能,需要在diskio.c里面,实现get_fattime函数,加入如下代码即可。
然后进行编译,这时错误就没有了。
至此我们已经完成FatFs文件管理系统的移植,不过功能还没有实现,需要在disk_status、disk_initialize、disk_read、disk_writ、disk_ioctl函数中加入执行代码:
设备状态获取
DSTATUS disk_status (
BYTE pdrv /* Physical drive number to identIFy the drive */
)
{
DSTATUS stat;
stat = disk.drv[pdrv]->disk_status(disk.lun[pdrv]);
return stat;
}
设备初始化
DSTATUS disk_initialize (
BYTE pdrv /* Physical drive nmuber to identify the drive */
)
{
DSTATUS stat = RES_OK;
if(disk.is_initialized[pdrv] == 0) {
disk.is_initialized[pdrv] = 1;
stat = disk.drv[pdrv]->disk_initialize(disk.lun[pdrv]);
}
return stat;
}
读取扇区
DRESULT disk_read (
BYTE pdrv, /* Physical drive nmuber to identify the drive */
BYTE* buff, /* Data buffer to store read data */
DWORD sector, /* Sector address in LBA */
UINT count /* Number of sectors to read */
)
{
DRESULT res;
res = disk.drv[pdrv]->disk_read(disk.lun[pdrv], buff, sector, count);
return res;
}
扇区写入
DRESULT disk_write (
BYTE pdrv, /* Physical drive nmuber to identify the drive */
const BYTE* buff, /* Data to be written */
DWORD sector, /* Sector address in LBA */
UINT count /* Number of sectors to write */
)
{
DRESULT res;
res = disk.drv[pdrv]->disk_write(disk.lun[pdrv], buff, sector, count);
return res;
}
其他
DRESULT disk_ioctl (
BYTE pdrv, /* Physical drive nmuber (0..) */
BYTE cmd, /* Control code */
void* buff /* Buffer to send/receive control data */
)
{
DRESULT res;
res = disk.drv[pdrv]->disk_ioctl(disk.lun[pdrv], cmd, buff);
return res;
}
关联的代码不再进行详细描述,可在MindMotion官网下载MM32F3270 lib_Samples:
https://www.mindmotion.com.cn/pr ... instream/mm32f3270/
工程路径如下:
~\MM32F3270_Lib_Samples_V0.90\Demo_app\PlayWave_Demo\SPI_I2S_SDIO_FatFs
可以看到详细的样例与功能操作。
|