cancel
Showing results for 
Search instead for 
Did you mean: 

Wrong returned value in the library function SD_initialize()?

JSmit.18
Associate II

I am having problem with FATFS remounting with Cube IDE and STM327H50.  Tracing the program surfaced the SD_initialize() function which is defined in the ST library file  FATFS/Target/sd_diskio.c

The problem is that when BSP_SD_Init() failed, SD_initialize() returns whatever value previous functions left in the variable Stat, which can cause SD_initialize() to sometimes return OK even if BSP_SD_Init() failed.

Am I missing something?

 

 

/**
  * @brief  Initializes a Drive
  * @PAram  lun : not used
  * @retval DSTATUS: Operation status
  */
DSTATUS SD_initialize(BYTE lun)
{
#if !defined(DISABLE_SD_INIT)
  if(BSP_SD_Init() == MSD_OK)
  {
    Stat = SD_CheckStatus(lun);
  }
#else
  Stat = SD_CheckStatus(lun);
#endif
  return Stat;
}

 

 

0 REPLIES 0