Thank you for your answer.
Giovanni wrote:Hi,
It is like a class in C++ or Java, it is the ancestor of block device drivers, you need to extend that class in order to create your class, MMC_SPI and SDC do exactly that.
That's what I was searching for, but how is it done in C????
I understand that those methods in the MMC_SPI driver (for instance) implement the ones defined in the abstract "class" io_block.h
Code: Select all
/**
* @brief Virtual methods table.
*/
static const struct MMCDriverVMT mmc_vmt = {
(bool_t (*)(void *))mmc_lld_is_card_inserted,
(bool_t (*)(void *))mmc_lld_is_write_protected,
(bool_t (*)(void *))mmcConnect,
(bool_t (*)(void *))mmcDisconnect,
mmc_read,
mmc_write,
(bool_t (*)(void *))mmcSync,
(bool_t (*)(void *, BlockDeviceInfo *))mmcGetInfo
};
Code: Select all
/**
* @brief @p BaseBlockDevice specific methods.
*/
#define _base_block_device_methods
bool_t (*is_inserted)(void *instance); \
bool_t (*is_protected)(void *instance); \
bool_t (*connect)(void *instance); \
bool_t (*disconnect)(void *instance); \
...
But they use different method names, or prefixes. Example:
connect in the abstract "class" becomes
mmcConnect in the
MMC_SPI driver or
sdcConnect in the SDC driver
How is that possible?
(Sorry for my noob questions

)