AnsweredAssumed Answered

stm32f103 cubx fatfs problem

Question asked by omid hamdi on Aug 4, 2017
Latest reply on Aug 4, 2017 by Clive One

hi

i used open file 

unsigned char read_file (char *filename,unsigned long address,uint8_t *data){
FIL MyFile; /* File object */
char SDPath[4]; /* SD card logical drive path */
FATFS FatFs; /* Work area (file system object) for logical drive */
FRESULT res; /* FatFs function common result code */
uint32_t bytesread=2; /* File write/read counts */

if(FATFS_LinkDriver(&USER_Driver, SDPath) == 0)
{

if(f_mount(&FatFs, (TCHAR const*)SDPath, 0) != FR_OK)
{
/* FatFs Initialization Error */
showerror ("Fat Fs Not Int");
return 1;
}
else
{

if(f_open(&MyFile, filename , FA_READ) != FR_OK)
{
/* 'STM32.TXT' file Open for read Error */
showerror ("File Not Fined");
return 2;
}
else
{

res = f_read(&MyFile, data ,sizeof(data), (UINT*)&bytesread);
if((bytesread == 0) || (res != FR_OK))
{
/* 'STM32.TXT' file Read or EOF Error */
showerror (" Read Error ");
return 3;
}
else
{

f_close(&MyFile);
return 0;
}
}
}
}

FATFS_UnLinkDriver(SDPath);

}

bout sizeof(data) is wrong number not compatible with size file please advise me how can resolved 

Outcomes