void LCD_OD_Test(void)
{ /*!<Flash picture number initial value*/
uint8_t KeyInfoTmp; /*!<KeyInfo temporary data*/
uint8_t *ptr1=0;
uint8_t *ptr2=0;
uint8_t ptraddr[18];
uint16_t i=0;
uint8_t usage=0;
uint32_t total=0,free=0;
uint8_t status1=0;
uint8_t status2=0;
LCD_Init();/*!<LCM&SSD282X Init*/
MemoryInit();
while(SD_Init()!=SD_OK)
{
StringDisplay(5,52,"SD_Init Fail",RED);
StringDisplay(5,69,"pleas check",RED);
Delay_ms(500);
LED_Toggle(LED2);
}
ShowSDCardInfo();
sprintf((char*)ptraddr,"SD_Size:%dMB",SDCardInfo.CardCapacity>>20);
StringDisplay(5,52,"SD Successful",GREEN);
StringDisplay(5,69,ptraddr,GREEN);
while(extraFunctionInit())
{
printf("
please check.....");
Delay_ms(500);
}
printf("
after malloc (3)fs1=%p",fs1);
printf("
after malloc (3)&fs1%d",&fs1);
status1=f_mount(0,fs1);
printf("
Result from f_mount is:%d",status1);
status2=capacityGet(0,&total,&free);
printf("
Result from FATFS is:%d",status2);
while(status2)
{
StringDisplay(5,86,"SD FATFS FAIL",RED);
StringDisplay(5,103,"Check!!",RED);
}
StringDisplay(5,120,"By FATFAS READ",GREEN);
StringDisplay(5,137,"Total:",GREEN);
ValueDisplay(102,137,total,GREEN);
StringDisplay(5,154,"Free:",GREEN);
ValueDisplay(102,154,free,GREEN);
while(1);
通过串口信息追踪,直接操作SD读取容量,读取里面文件信息也是成功的;
调用malloc分配供FATFS使用的空间也是OK的;
使用f_mount()注册磁盘,返回也是OK的;
然后在通过FATFS获取容量是,返回 FR_NO_FILESYSTEM;
然后通过不停的插入printf,capacityGet()调用f_getfree(),然后f_getfree调用chk_mounted(),
错误发生在chk_mounted()中。如下加粗斜体文字部分,fmt返回值为2,然后就返回了 FR_NO_FILESYSTEM;
串口信息如图片,请教下各位是哪里出问题了、、、、。完全懵逼了。
fmt = check_fs(fs, bsect = 0); /* Load sector 0 and check if it is an FAT-VBR (in SFD) */
printf("
Error test: check_fs(fs, bsect = 0)=fmt =%d",fmt);
if (LD2PT(vol) && !fmt) fmt = 1; /* Force non-SFD if the volume is forced partition */
printf("
(2)fmt =%d",fmt);
if (fmt == 1) { /* Not an FAT-VBR, the physical drive can be partitioned */
/* Check the partition listed in the partition table */
pi = LD2PT(vol);
if (pi) pi--;
tbl = &fs->win[MBR_Table + pi * SZ_PTE];/* Partition table */
if (tbl[4]) { /* Is the partition existing? */
bsect = LD_DWORD(&tbl[8]); /* Partition offset in LBA */
fmt = check_fs(fs, bsect); /* Check the partition */
}
}
printf("
(3)fmt =%d",fmt); if (fmt == 3) return FR_DISK_ERR;
if (fmt) return FR_NO_FILESYSTEM; /* No FAT volume is found */
格式化就可以了,搞死我了。。。。
一周热门 更多>