各位,
DISKIO.c文件如下编写
#include"diskio.h"
#include"ff.h"
#include"ffconf.h"
#include"integer.h"
#include"SD.h"
DWORD get_fattime (void)
{
return ((DWORD)(2010 - 1980) << 25) /* Fixed to Jan. 1, 2010 */
|((DWORD)1 << 21)
|((DWORD)1 << 16)
|((DWORD)0 << 11)
|((DWORD)0 << 5)
|((DWORD)0 >> 1);
}
DSTATUS disk_initialize (BYTE drv)
{
while(SD_Init()!=0);// SD_Init为SD卡初始化
return 0;
}
DSTATUS disk_status (
BYTE drv /* Drive number (always 0) */
)
{
return 0;
}
DRESULT disk_ioctl (
BYTE drv, /* Physical drive nmuber (0) */
BYTE ctrl, /* Control code */
void *buff /* Buffer to send/receive control data */
)
{
return RES_OK;
}
DRESULT disk_read (
BYTE drv, /* Physical drive nmuber (0) */
BYTE *buff, /* Pointer to the data buffer to store read data */
DWORD sector, /* Start sector number (LBA) */
BYTE count /* Sector count (1..128) */
)
{
if(count>1)
SD_ReadMultiBlock(sector, buff, count);
else
SD_ReadSingleBlock(sector, buff);
return RES_OK;
}
DRESULT disk_write (
BYTE drv, /* Physical drive nmuber (0) */
const BYTE *buff, /* Pointer to the data to be written */
DWORD sector, /* Start sector number (LBA) */
BYTE count /* Sector count (1..128) */
)
{
if(count>1)
SD_WriteMultiBlock(sector, buff, count);
else
SD_WriteSingleBlock(sector, buff);
return RES_OK;
}
主函数如下编写
int main(void)
{
int i;
FRESULT res; /* Result code */
FATFS fatfs; /* File system object */
FIL fil; /* File object */
DIR dirs; /* Directory object */
FILINFO finfo; /* File information object */
UINT br;
BYTE buff[128];
char diskname[20] = {"newdir"};
RCC_Configuration();
//disk_initialize(0);
f_mount(0, &fatfs);
res = f_mkdir(diskname); // 新建文件夹,名为newdir
res = f_open(&fil, "123.txt", FA_OPEN_EXISTING | FA_READ); // 打开123.txt 文件
return(1);
}
可是用stm32操作SD卡之后放在PC上观察却始终如下
请问问题到底出在哪里啊!!
|