at91_sdcard源码分析(1)

程序结构中有mci.h/c和sdmmc_mci.h,这两个文件操作类型C++中父类和子类的操作,由于sdmmc_mci属于mci,所在前者是父类,后者是子类。

typedef struct {

    /// Pointer to a MCI peripheral.
	AT91S_MCI *pMciHw;
    /// MCI peripheral identifier.
    unsigned char mciId;
    /// Pointer to currently executing command.
	MciCmd *pCommand;
	/// Mutex.
	volatile char semaphore;

} Mci;

typedef struct {

    /// Pointer to a SPI peripheral.
    AT91S_MCI *pSdHw;
    /// SPI peripheral identifier.
    unsigned char spiId;
    /// Pointer to currently executing command.
    SdCmd *pCommand;
    /// Mutex.
    volatile char semaphore;

} SdDriver;

这两个结构很相似,其实在代码内部它们通过强制类型转换成需要的类型。设计的意图是SdDriver从mci继承。


你可能感兴趣的:(at91_sdcard源码分析(1))