cancel
Showing results for 
Search instead for 
Did you mean: 

How does the disk_write function in diskio.c work

GreenGuy
Senior III
Posted on March 23, 2018 at 01:13

As I am debugging code I ran into a problem in f_close which leads me to the disk_write function in diskio.c.  It looks like this function calls itself?  I am stuggling to understand just what this line does:

res = disk.drv[pdrv]->disk_write(disk.lun[pdrv], buff, sector, count);

1 REPLY 1
Posted on March 23, 2018 at 01:25

Calling a function pointer in a structure, allows for multiple drives, multiple interfaces

This from sd_diskio.h, your wrapper would call SD_write()

const Diskio_drvTypeDef  SD_Driver =

{

  SD_initialize,

  SD_status,

  SD_read,

#if  _USE_WRITE == 1

  SD_write,

#endif /* _USE_WRITE == 1 */

#if  _USE_IOCTL == 1

  SD_ioctl,

#endif /* _USE_IOCTL == 1 */

};
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..