Skip to main content
GreenGuy
Senior III
March 23, 2018
Question

How does the disk_write function in diskio.c work

  • March 23, 2018
  • 1 reply
  • 633 views
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);

    This topic has been closed for replies.

    1 reply

    Tesla DeLorean
    Guru
    March 23, 2018
    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 VenmoUp vote any posts that you find helpful, it shows what's working..