问题描述:

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

I am not sure what the above statement means.

This is from FATFS open source driver and i am trying to udnerstand how it works. I am using STM32 SPI interface.

网友答案:

Your learning experience might be greater if you ask a question about which specific part of this confuses you... but lets break it down:

disk.drv means "get the member (a pointer that points into an array, in this case) that corresponds to the drv member of disk".

disk.drv[pdrv] means "get the element of that array indexed by pdrv".

disk.drv[pdrv]->disk_read means "get the member (a function pointer) that corresponds to the disk_read of disk.drv[pdrv][0]".

disk.drv[pdrv]->disk_read(buff, sector, count); means "call that function with buff, sector and count as arguments".

res = disk.drv[pdrv]->disk_read(buff, sector, count); means "assign the return value of that function call to res".

It seems as though the aim of the whole statement is to read a chunk of data from a drive.

Any questions?

相关阅读:
Top