📄 sdcardddk.h
字号:
USHORT CardCommandClasses; // 12 bit command class support indicators
USHORT MaxReadBlockLength; // In units of bytes
BOOLEAN ReadBlockPartial; // Partial Block Read allowed ?
BOOLEAN WriteBlockMisalign; // Misaligned Block Writes allowed ?
BOOLEAN ReadBlockMisalign; // Misaligned Block Reads allowed ?
BOOLEAN DSRImplemented; // DSR Register implemented ?
ULONG DeviceSize; // Calculated device memory size in bytes
USHORT VDDReadCurrentMin; // in units of milliamps
USHORT VDDReadCurrentMax; // in units of milliamps
USHORT VDDWriteCurrentMin; // in units of milliamps
USHORT VDDWriteCurrentMax; // in units of milliamps
BOOLEAN EraseBlockEnable; // Erase in multiples of MaxWriteBlockLength ?
UCHAR EraseSectorSize; // Size of an erase sector in blocks (SECTOR_SIZE+1)
UCHAR WPGroupSize; // Size of a WP group in erase sectors (WP_GRP_SIZE+1)
UCHAR WPGroupEnable; // Group Write Protection possible ?
UCHAR WriteSpeedFactor; // Block Write time as multiple of Read access time
USHORT MaxWriteBlockLength; // In units of bytes
BOOLEAN WriteBlockPartial; // Partial block writes allowed ?
BOOLEAN CopyFlag; // Copy control flag
BOOLEAN PermanentWP; // Permanent Write Protect flag
BOOLEAN TemporaryWP; // Temporary Write Protect flag
SD_FS_TYPE FileSystem; // File System type
UCHAR RawCSDRegister[16]; // raw data
} SD_PARSED_REGISTER_CSD, *PSD_PARSED_REGISTER_CSD;
#ifdef __MMC_SPEC_4_2_SUPPORT__
typedef struct _MMC_PARSED_REGISTER_EXTCSD { // structure of Extended CSD register
UCHAR Reserved180[181];
UCHAR ErasedMemCont; // initial value after erase operation
UCHAR Reserved182;
UCHAR BusWidth; // bus width
UCHAR Reserved184;
UCHAR HSTiming; // high speed timing
UCHAR Reserved186;
UCHAR PowClass; // power class
UCHAR Reserved188;
UCHAR CmdSetRev; // command set revision
UCHAR Reserved190;
UCHAR CmdSet; // contains a binary code of the command set
UCHAR EXTCSDRev; // Extended CSD revision
UCHAR Reserved193;
UCHAR CSDStruct; // CSD structure field in CSD register
UCHAR Reserved195;
UCHAR CardType; // MMC card type
UCHAR Reserved197[3];
UCHAR PwrCl52195;
UCHAR PwrCl26195;
UCHAR PwrCl52360;
UCHAR PwrCl26360; // supported power class by the card
UCHAR Reserved204;
UCHAR MinPerfR0426; // min. read performance with 4 bit bus width & 26MHz
UCHAR MinPerfW0426; // min. write performance with 4 bit bus width & 26MHz
UCHAR MinPerfR08260452; // min. read performance with 8 bit bus width & 26MHz
// min. read performance with 4 bit bus width & 52MHz
UCHAR MinPerfW08260452; // min. write performance with 8 bit bus width & 26MHz
// min. write performance with 4 bit bus width & 26MHz
UCHAR MinPerfR0852; // min. read performance with 8 bit bus width & 52MHz
UCHAR MinPerfW0852; // min. write performance with 8 bit bus width & 52MHz
UCHAR Reserved211;
ULONG Sec_Count; // sector count
UCHAR Reserved216[288];
UCHAR sCmdSet; // command sets are supported by the card
UCHAR Reserved505[7];
} MMC_PARSED_REGISTER_EXTCSD, *PMMC_PARSED_REGISTER_EXTCSD;
#endif
#include <pshpack1.h>
typedef struct _SD_REGISTER_SCR {
DWORD ReservedForManufacturer:32;
WORD Reserverd:16;
BYTE SD_BUS_WIDTHS:4;
BYTE SD_SECURITY:3;
BYTE DATA_STAT_AFTER_ERASE:1;
BYTE SD_SPEC:4;
BYTE SCR_STRUCTURE:4;
} SD_REGISTER_SCR, *PSD_REGISTER_SCR;
#include <poppack.h>
typedef USHORT SD_CARD_RCA; // card RCA
typedef DWORD SD_CARD_STATUS; // card status
typedef struct _SLOT_POWER_DATA {
UCHAR Functions; // Number of functions for the card
BOOL fCardSupportsPowerControl; // True if card supports power control
BOOL fPowerControlEnabled; // True if power control is enabled
DWORD CurrentDrawOfSlot; // Maximum possible current draw in mA
// allocated at the slot
DWORD OperatingVoltage; // bit mask similar to OCR register
DWORD CurrentTupleVoltageRange; // bit mask similar to OCR register
UCHAR NumberOfHighPowerTuples; // For SDIO 1.1 this is 1
DWORD SizeOfFunctionRecord; // Size of data per function
} SLOT_POWER_DATA, *PSLOT_POWER_DATA;
typedef struct _SD_FUNCTION_POWER_DRAW {
//for SDIO 1.0 cards
USHORT OpMinPower; // Minimum current when this function is operating
USHORT OpAvePower; // Average current when this function is operating
USHORT OpMaxPower; // Maximum current when this function is operating
//for SDIO 1.1 cards Note: EMPC reffers to the EMPC bit of the CCCR register "Power Control"
// EPS reffers to the EPS bit of the FBR register for Power Selection
USHORT SpAvePower33; //Ave current if EMPC is not set. (Same as OpAvePower)
USHORT SpMaxPower33; //Max current if EMPC is not set. (Same as OpAvePower)
USHORT HpAvePower33; //Ave current if EMPC is set, and ESP is clear. (High Power)
USHORT HpMaxPower33; //Max current if EMPC is set, and ESP is clear. (High Power)
USHORT LpAvePower33; //Ave current if EMPC is set, and ESP is set. (Low Power)
USHORT LpMaxPower33; //Max current if EMPC is set, and ESP is set. (Low Power)
//future tuples will require six USHORTs each.
} SD_FUNCTION_POWER_DRAW, *PSD_FUNCTION_POWER_DRAW;
typedef struct _FUNCTION_POWER_STATE {
BOOL fPowerControlSupport; // Does card support Power Control
BOOL fPowerControlEnabled; // Is cards power control enabled
BOOL fFunctionEnabled; // Enable state of the Function
BOOL fSupportsPowerSelect; // Is power selection is supported for this function
BOOL fLowPower; // Function is in the Low or High power state
DWORD OperatingVoltage; // Operating voltage given as an OCR register value
USHORT CurrentDrawNow; // current draw of the function now
INT EnableDelta; // change in current if enabled state changed
INT SelectDelta; // change in current if High/Low power select state changed
} FUNCTION_POWER_STATE, *PFUNCTION_POWER_STATE;
typedef struct _FUNCTION_POWER_DATA {
TCHAR ClientName[MAX_SDCARD_CLIENT_NAME]; // client name, if the functions registered witha client
FUNCTION_POWER_STATE PowerState;
SD_FUNCTION_POWER_DRAW PowerTuples;
} FUNCTION_POWER_DATA, *PFUNCTION_POWER_DATA;
typedef struct _BUS_DRIVER_IN_SLOT_FUNCTION_POWER {
DWORD SlotIndex; // Slots start at 0
DWORD FunctionNumber; // Functions start at 1
} BUS_DRIVER_IN_SLOT_FUNCTION_POWER, *PBUS_DRIVER_IN_SLOT_FUNCTION_POWER;
// DDK api status codes
#define SD_API_STATUS_SUCCESS ((SD_API_STATUS)0x00000000L)
#define SD_API_STATUS_PENDING ((SD_API_STATUS)0x00000001L)
#define SD_API_STATUS_FAST_PATH_SUCCESS ((SD_API_STATUS)0x00000002L)
#define SD_API_STATUS_FAST_PATH_OPT_SUCCESS ((SD_API_STATUS)0x00000003L)
#define SD_API_STATUS_BUFFER_OVERFLOW ((SD_API_STATUS)0xC0000001L)
#define SD_API_STATUS_DEVICE_BUSY ((SD_API_STATUS)0xC0000002L)
#define SD_API_STATUS_UNSUCCESSFUL ((SD_API_STATUS)0xC0000003L)
#define SD_API_STATUS_NOT_IMPLEMENTED ((SD_API_STATUS)0xC0000004L)
#define SD_API_STATUS_ACCESS_VIOLATION ((SD_API_STATUS)0xC0000005L)
#define SD_API_STATUS_INVALID_HANDLE ((SD_API_STATUS)0xC0000006L)
#define SD_API_STATUS_INVALID_PARAMETER ((SD_API_STATUS)0xC0000007L)
#define SD_API_STATUS_NO_SUCH_DEVICE ((SD_API_STATUS)0xC0000008L)
#define SD_API_STATUS_INVALID_DEVICE_REQUEST ((SD_API_STATUS)0xC0000009L)
#define SD_API_STATUS_NO_MEMORY ((SD_API_STATUS)0xC000000AL)
#define SD_API_STATUS_BUS_DRIVER_NOT_READY ((SD_API_STATUS)0xC000000BL)
#define SD_API_STATUS_DATA_ERROR ((SD_API_STATUS)0xC000000CL)
#define SD_API_STATUS_CRC_ERROR ((SD_API_STATUS)0xC000000DL)
#define SD_API_STATUS_INSUFFICIENT_RESOURCES ((SD_API_STATUS)0xC000000EL)
#define SD_API_STATUS_DEVICE_NOT_CONNECTED ((SD_API_STATUS)0xC0000010L)
#define SD_API_STATUS_DEVICE_REMOVED ((SD_API_STATUS)0xC0000011L)
#define SD_API_STATUS_DEVICE_NOT_RESPONDING ((SD_API_STATUS)0xC0000012L)
#define SD_API_STATUS_CANCELED ((SD_API_STATUS)0xC0000013L)
#define SD_API_STATUS_RESPONSE_TIMEOUT ((SD_API_STATUS)0xC0000014L)
#define SD_API_STATUS_DATA_TIMEOUT ((SD_API_STATUS)0xC0000015L)
#define SD_API_STATUS_DEVICE_RESPONSE_ERROR ((SD_API_STATUS)0xC0000016L)
#define SD_API_STATUS_DEVICE_UNSUPPORTED ((SD_API_STATUS)0xC0000017L)
#define SD_API_STATUS_SHUT_DOWN ((SD_API_STATUS)0xC0000018L)
#ifdef __MMC_SPEC_4_2_SUPPORT__ // error status of bus width change
#define MMC_API_STATUS_NOT_CHANGE_BUSWIDTH ((SD_API_STATUS)0xC00000100L)
#endif
#define SD_API_STATUS_INSUFFICIENT_HOST_POWER ((SD_API_STATUS)0xC0000019L)
// macro to test for success
#define SD_API_SUCCESS(Status) ((SD_API_STATUS)(Status) >= 0)
// macro to test for success where a SD_API_STATUS_TIMEOUT is okay
#define SD_API_SUCCESS_RESPONSE_TIMEOUT_OK(Status) (((SD_API_STATUS)(Status) >= 0) || (SD_API_STATUS_RESPONSE_TIMEOUT == (SD_API_STATUS)(Status)))
// macro to test explicitly for time out
#define SD_API_RESPONSE_TIMEOUT(Status) (SD_API_STATUS_RESPONSE_TIMEOUT == (SD_API_STATUS)(Status))
// debug zone slot IDs - user assignable slots
#define SDCARD_ZONESLOT_0 0
#define SDCARD_ZONESLOT_1 1
#define SDCARD_ZONESLOT_2 2
#define SDCARD_ZONESLOT_3 3
#define SDCARD_ZONESLOT_4 4
#define SDCARD_ZONESLOT_5 5
#define SDCARD_ZONESLOT_6 6
#define SDCARD_ZONESLOT_7 7
#define SDCARD_ZONESLOT_8 8
#define SDCARD_ZONESLOT_9 9
#define SDCARD_ZONESLOT_10 10
// reserved slots
#define SDCARD_ZONESLOT_FUNC 11
#define SDCARD_ZONESLOT_INFO 12
#define SDCARD_ZONESLOT_INIT 13
#define SDCARD_ZONESLOT_WARN 14
#define SDCARD_ZONESLOT_ERROR 15
// zone enable bit definitions
#define ZONE_ENABLE_0 (1 << SDCARD_ZONESLOT_0)
#define ZONE_ENABLE_1 (1 << SDCARD_ZONESLOT_1)
#define ZONE_ENABLE_2 (1 << SDCARD_ZONESLOT_2)
#define ZONE_ENABLE_3 (1 << SDCARD_ZONESLOT_3)
#define ZONE_ENABLE_4 (1 << SDCARD_ZONESLOT_4)
#define ZONE_ENABLE_5 (1 << SDCARD_ZONESLOT_5)
#define ZONE_ENABLE_6 (1 << SDCARD_ZONESLOT_6)
#define ZONE_ENABLE_7 (1 << SDCARD_ZONESLOT_7)
#define ZONE_ENABLE_8 (1 << SDCARD_ZONESLOT_8)
#define ZONE_ENABLE_9 (1 << SDCARD_ZONESLOT_9)
#define ZONE_ENABLE_10 (1 << SDCARD_ZONESLOT_10)
#define ZONE_ENABLE_FUNC (1 << SDCARD_ZONESLOT_FUNC)
#define ZONE_ENABLE_INFO (1 << SDCARD_ZONESLOT_INFO)
#define ZONE_ENABLE_INIT (1 << SDCARD_ZONESLOT_INIT)
#define ZONE_ENABLE_WARN (1 << SDCARD_ZONESLOT_WARN)
#define ZONE_ENABLE_ERROR (1 << SDCARD_ZONESLOT_ERROR)
// debug zones masks macros
#define SDCARD_ZONE_0 DEBUGZONE(SDCARD_ZONESLOT_0)
#define SDCARD_ZONE_1 DEBUGZONE(SDCARD_ZONESLOT_1)
#define SDCARD_ZONE_2 DEBUGZONE(SDCARD_ZONESLOT_2)
#define SDCARD_ZONE_3 DEBUGZONE(SDCARD_ZONESLOT_3)
#define SDCARD_ZONE_4 DEBUGZONE(SDCARD_ZONESLOT_4)
#define SDCARD_ZONE_5 DEBUGZONE(SDCARD_ZONESLOT_5)
#define SDCARD_ZONE_6 DEBUGZONE(SDCARD_ZONESLOT_6)
#define SDCARD_ZONE_7 DEBUGZONE(SDCARD_ZONESLOT_7)
#define SDCARD_ZONE_8 DEBUGZONE(SDCARD_ZONESLOT_8)
#define SDCARD_ZONE_9 DEBUGZONE(SDCARD_ZONESLOT_9)
#define SDCARD_ZONE_10 DEBUGZONE(SDCARD_ZONESLOT_10)
#define SDCARD_ZONE_FUNC DEBUGZONE(SDCARD_ZONESLOT_FUNC)
#define SDCARD_ZONE_INFO DEBUGZONE(SDCARD_ZONESLOT_INFO)
#define SDCARD_ZONE_INIT DEBUGZONE(SDCARD_ZONESLOT_INIT)
#define SDCARD_ZONE_WARN DEBUGZONE(SDCARD_ZONESLOT_WARN)
#define SDCARD_ZONE_ERROR DEBUGZONE(SDCARD_ZONESLOT_ERROR)
#define SDCARD_WAKE_ON_SDIO_INTERRUPTS_VALNAME _T("WakeOnSDIOInterrupts")
#define SDCARD_WAKE_ON_SDIO_INTERRUPTS_VALTYPE REG_DWORD
#ifdef __cplusplus
extern "C" {
#endif //__cplusplus
// SDRegisterClient()
typedef SD_API_STATUS (*PSD_REGISTER_CLIENT) (SD_DEVICE_HANDLE,
PVOID,
PSDCARD_CLIENT_REGISTRATION_INFO);
// SDSynchronousBusRequest
typedef SD_API_STATUS (*PSD_SYNCHRONOUS_BUS_REQUEST) (SD_DEVICE_HANDLE,
UCHAR,
DWORD,
SD_TRANSFER_CLASS,
SD_RESPONSE_TYPE,
PSD_COMMAND_RESPONSE ,
ULONG,
ULONG,
PUCHAR,
DWORD);
// SDBusRequest
typedef SD_API_STATUS (*PSDBUS_REQUEST) (SD_DEVICE_HANDLE ,
UCHAR,
DWORD,
SD_TRANSFER_CLASS ,
SD_RESPONSE_TYPE ,
ULONG ,
ULONG ,
PUCHAR ,
PSD_BUS_REQUEST_CALLBACK,
DWORD,
PSD_BUS_REQUEST*,
DWORD);
// SDCancelBusRequest
typedef BOOLEAN (*PSD_CANCEL_BUS_REQUEST) (PSD_BUS_REQUEST);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -