43#define SDIO_SPI_BUS (1)
53#define SDIO_COMMAND_SIZE (6)
56#define SDIO_BLOCK_SIZE (512)
59#define SDIO_CARD_TO_HOST (0x0)
60#define SDIO_HOST_TO_CARD (0x1)
63#define SDIO_GO_IDLE (0x00)
64#define SDIO_IO_SEND_OPERATIONAL_CONDITION (0x05)
65#define SDIO_IO_RW_DIRECT (0x34)
66#define SDIO_IO_RW_EXTENDED (0x35)
67#define SDIO_CRC_ON_OFF (0x3B)
74#define SDIO_FUNCTION_0 (0)
75#define SDIO_FUNCTION_1 (1)
78#define SDIO_READ_OR_WRITE_ONLY (0)
82#define SDIO_BYTE_MODE (0)
83#define SDIO_BLOCK_MODE (1)
86#define SDIO_FIXED_ADDRESS (FALSE)
87#define SDIO_INCREMENTING_ADDRESS (TRUE)
90#define SDIO_BLOCK_SIZE_NONE (0)
100#define SDIO_CIA_CCCR_CCCR_SDIO_REVISION (0x00000)
101#define SDIO_CIA_CCCR_SD_SPEC_REVISION (0x00001)
102#define SDIO_CIA_CCCR_IO_ENABLE (0x00002)
103#define SDIO_CIA_CCCR_IO_READY (0x00003)
104#define SDIO_CIA_CCCR_INTERRUPT_ENABLE (0x00004)
105#define SDIO_CIA_CCCR_INTERRUPT_PENDING (0x00005)
106#define SDIO_CIA_CCCR_IO_ABORT (0x00006)
107#define SDIO_CIA_CCCR_BUS_INTERFACE_CONTROL (0x00007)
108#define SDIO_CIA_CCCR_CARD_CAPABILITY (0x00008)
109#define SDIO_CIA_CCCR_COMMON_CIS_POINTER_LSB (0x00009)
110#define SDIO_CIA_CCCR_COMMON_CIS_POINTER_CSB (0x0000A)
111#define SDIO_CIA_CCCR_COMMON_CIS_POINTER_MSB (0x0000B)
112#define SDIO_CIA_CCCR_BUS_SUSPEND (0x0000C)
113#define SDIO_CIA_CCCR_FUNCTION_SELECT (0x0000D)
114#define SDIO_CIA_CCCR_EXEC_FLAGS (0x0000E)
115#define SDIO_CIA_CCCR_READY_FLAGS (0x0000F)
116#define SDIO_CIA_CCCR_FN0_BLOCK_SIZE_LSB (0x00010)
117#define SDIO_CIA_CCCR_FN0_BLOCK_SIZE_MSB (0x00011)
118#define SDIO_CIA_CCCR_POWER_CONTROL (0x00012)
127#define SDIO_CIA_CCCR_FN1_BLOCK_SIZE_LSB (0x00110)
128#define SDIO_CIA_CCCR_FN1_BLOCK_SIZE_MSB (0x00111)
142typedef enum _SdioBusType
155typedef enum _SdioResponseType
176typedef struct _SdioBusToken
180 uint32_t spiConnectTimeout;
181 uint32_t spiResponseTimeout;
182 ssize_t idleByteCount;
183 uint16_t idleFillValue;
185} __attribute__((packed)) SdioBusToken;
201typedef struct _CommandIndex
203 uint8_t startBit : 1;
204 uint8_t direction : 1;
207} __attribute__((packed)) CommandIndex;
220} __attribute__((packed)) Crc;
233typedef struct _ResponseFlags
235 uint8_t comCrcError : 1;
236 uint8_t illegalCommand : 1;
237 uint8_t ioCurrentState : 2;
240 uint8_t functionNumberError : 1;
241 uint8_t outOfRange : 1;
243} __attribute__((packed)) ResponseFlags;
252typedef struct _GoIdleStateCommand_CMD0
254 CommandIndex commandIndex;
258} __attribute__((packed)) GoIdleStateCommand_CMD0;
268typedef struct _IoSendOpCondCommand_CMD5
270 CommandIndex commandIndex;
275} __attribute__((packed)) IoSendOpCondCommand_CMD5;
285typedef struct _CrcOnOffCommand_CMD59
287 CommandIndex commandIndex;
292} __attribute__((packed)) CrcOnOffCommand_CMD59;
305typedef struct _ModifiedR1
307 uint8_t startBit : 1;
308 uint8_t parameterError : 1;
310 uint8_t functionNumberError : 1;
311 uint8_t comCrcError : 1;
312 uint8_t illegalCommand : 1;
314 uint8_t idleState : 1;
316} __attribute__((packed)) ModifiedR1;
326typedef struct _NumberIoFunctions
329 uint8_t ioFunctions : 3;
330 uint8_t memoryPresent : 1;
331 uint8_t stuffBits : 3;
333} __attribute__((packed)) NumberIoFunctions;
342typedef struct _IoSendOpCondResponseSpiMode_R4
344 ModifiedR1 modifiedR1;
345 NumberIoFunctions numberIoFunctions;
348} __attribute__((packed)) IoSendOpCondResponseSpiMode_R4;
361typedef struct _IoSendOpCondResponse_R4
363 uint8_t startBit : 1;
364 uint8_t direction : 1;
365 uint8_t reserved_02_07 : 6;
366 NumberIoFunctions numberIoFunctions;
368 uint8_t reserved_45_46 : 7;
371} __attribute__((packed)) IoSendOpCondResponse_R4;
382typedef struct _Function
385 uint8_t functionNumber : 3;
388 uint8_t registerAddress_bits_16thru15 : 2;
390} __attribute__((packed)) Function;
398typedef struct _RegisterAddress
400 unsigned short address : 15;
401 unsigned short stuff : 1;
403} __attribute__((packed)) RegisterAddress;
414typedef struct _IoRwDirectCommand_CMD52
416 CommandIndex commandIndex;
418 RegisterAddress registerAddress;
422} __attribute__((packed)) IoRwDirectCommand_CMD52;
434typedef struct _IoRwDirectResponse_R5
436 CommandIndex commandIndex;
438 ResponseFlags responseFlags;
439 uint8_t readOrWriteData;
443} __attribute__((packed)) IoRwDirectResponse_R5;
451typedef struct _IoRwDirectResponseSpiMode_R5
453 ModifiedR1 modifiedR1;
456} __attribute__((packed)) IoRwDirectResponseSpiMode_R5;
467typedef struct _FunctionBlock
470 uint8_t functionNumber : 3;
471 uint8_t blockMode : 1;
473 uint8_t registerAddress_bits_16thru15 : 2;
475} __attribute__((packed)) FunctionBlock;
483typedef struct _RegisterExtended
485 unsigned short address : 15;
486 unsigned short byteCount_bit_8 : 1;
488} __attribute__((packed)) RegisterExtended;
499typedef struct _IoRwExtendedCommand_CMD53
501 CommandIndex commandIndex;
502 FunctionBlock functionBlock;
503 RegisterExtended registerExtended;
507} __attribute__((packed)) IoRwExtendedCommand_CMD53;
519typedef union _RegisterValue
524} __attribute__((packed)) RegisterValue;
539typedef struct _CccrSdioRevision
544} __attribute__((packed)) CccrSdioRevision;
552typedef struct _SdioSpecRevision
557} __attribute__((packed)) SdioSpecRevision;
571typedef struct _IoFunctions
582} __attribute__((packed)) IoFunctions;
597typedef struct _IntFunctions
608} __attribute__((packed)) IntFunctions;
618typedef struct _BusInterfaceControl
620 uint8_t cdDisable : 1;
626} __attribute__((packed)) BusInterfaceControl;
640typedef struct _CardCapability
651} __attribute__((packed)) CardCapability;
659typedef struct _PowerControl
665} __attribute__((packed)) PowerControl;
673typedef union _CccrRegister
675 CccrSdioRevision cccrSdioRevision;
676 SdioSpecRevision sdioSpecRevision;
677 IoFunctions ioFunctions;
678 IntFunctions intFunctions;
679 BusInterfaceControl busInterfaceControl;
680 CardCapability cardCapability;
681 PowerControl powerControl;
684} __attribute__((packed)) CccrRegister;
704 SdioCommand(uint8_t commandIndex);
707 virtual ~SdioCommand() {
return; };
714 virtual void prepare(
void);
717 uint8_t generateCrc7(
void);
720 virtual void display(
void) {
return; };
724 puint8_t getPtr(
void);
727 uint32_t getSize(
void);
738 uint8_t __command_index;
744 uint8_t __commandData[SDIO_COMMAND_SIZE];
747 GoIdleStateCommand_CMD0 *__commandPtr;
757class SdioCMD5 :
public SdioCommand
764 ~SdioCMD5() {
return; };
768 void prepare(uint32_t ocr);
783 IoSendOpCondCommand_CMD5 *__commandPtr;
793class SdioCMD52 :
public SdioCommand
800 ~SdioCMD52() {
return; };
804 void prepare(
int readWriteFlag, uint8_t function,
int rawFlag, uint32_t registerAddress, uint8_t writeData);
822 IoRwDirectCommand_CMD52 *__commandPtr;
832class SdioCMD53 :
public SdioCommand
839 ~SdioCMD53() {
return; };
843 void prepare(
int readWriteFlag,
846 BOOL isIncrementingAddress,
847 uint32_t registerAddress,
856 IoRwExtendedCommand_CMD53 &getCommand(
void);
868 IoRwExtendedCommand_CMD53 *__commandPtr;
878class SdioCMD59 :
public SdioCommand
885 ~SdioCMD59() {
return; };
889 void prepare(BOOL isOn);
904 CrcOnOffCommand_CMD59 *__commandPtr;
918 SdioResponse(SdioBusType busType, SdioResponseType responseType);
921 virtual ~SdioResponse() = 0;
925 virtual BOOL isOk(
void) = 0;
928 virtual void display(
void) = 0;
932 SdioResponseType getType(
void);
935 SdioBusType getBusType(
void);
938 virtual puint8_t getPtr(
void) = 0;
941 virtual uint32_t getSize(
void) = 0;
949 virtual void synchronize(
void) = 0;
953 SdioResponseType __type;
955 SdioBusType __busType;
965class SdioResponseR4 :
public SdioResponse
969 SdioResponseR4(SdioBusType busType);
983 IoSendOpCondResponse_R4 *getResponsePtr(
void);
986 puint8_t getPtr(
void);
989 uint32_t getSize(
void);
992 IoSendOpCondResponse_R4 &getResponse(
void);
995 uint32_t getNumberIoFunctions(
void);
998 uint32_t getOcr(
void);
1006 void synchronize(
void);
1010 puint8_t __responsePtr;
1011 ssize_t __responseSize;
1014 IoSendOpCondResponse_R4 __response;
1017 IoSendOpCondResponseSpiMode_R4 __responseSpiMode;
1027class SdioResponseR5 :
public SdioResponse
1031 SdioResponseR5(SdioBusType busType);
1048 IoRwDirectResponse_R5 *getResponsePtr(
void);
1051 puint8_t getPtr(
void);
1054 uint32_t getSize(
void);
1057 IoRwDirectResponse_R5 &getResponse(
void);
1060 uint8_t getData(
void);
1068 void synchronize(
void);
1072 puint8_t __responsePtr;
1073 ssize_t __responseSize;
1076 IoRwDirectResponse_R5 __response;
1079 IoRwDirectResponseSpiMode_R5 __responseSpiMode;