41 #define SDIO_SPI_BUS (1) 51 #define SDIO_COMMAND_SIZE (6) 54 #define SDIO_BLOCK_SIZE (512) 57 #define SDIO_CARD_TO_HOST (0x0) 58 #define SDIO_HOST_TO_CARD (0x1) 61 #define SDIO_GO_IDLE (0x00) 62 #define SDIO_IO_SEND_OPERATIONAL_CONDITION (0x05) 63 #define SDIO_IO_RW_DIRECT (0x34) 64 #define SDIO_IO_RW_EXTENDED (0x35) 65 #define SDIO_CRC_ON_OFF (0x3B) 69 #define SDIO_WRITE (1) 72 #define SDIO_FUNCTION_0 (0) 73 #define SDIO_FUNCTION_1 (1) 76 #define SDIO_READ_OR_WRITE_ONLY (0) 80 #define SDIO_BYTE_MODE (0) 81 #define SDIO_BLOCK_MODE (1) 84 #define SDIO_FIXED_ADDRESS (FALSE) 85 #define SDIO_INCREMENTING_ADDRESS (TRUE) 88 #define SDIO_BLOCK_SIZE_NONE (0) 98 #define SDIO_CIA_CCCR_CCCR_SDIO_REVISION (0x00000) 99 #define SDIO_CIA_CCCR_SD_SPEC_REVISION (0x00001) 100 #define SDIO_CIA_CCCR_IO_ENABLE (0x00002) 101 #define SDIO_CIA_CCCR_IO_READY (0x00003) 102 #define SDIO_CIA_CCCR_INTERRUPT_ENABLE (0x00004) 103 #define SDIO_CIA_CCCR_INTERRUPT_PENDING (0x00005) 104 #define SDIO_CIA_CCCR_IO_ABORT (0x00006) 105 #define SDIO_CIA_CCCR_BUS_INTERFACE_CONTROL (0x00007) 106 #define SDIO_CIA_CCCR_CARD_CAPABILITY (0x00008) 107 #define SDIO_CIA_CCCR_COMMON_CIS_POINTER_LSB (0x00009) 108 #define SDIO_CIA_CCCR_COMMON_CIS_POINTER_CSB (0x0000A) 109 #define SDIO_CIA_CCCR_COMMON_CIS_POINTER_MSB (0x0000B) 110 #define SDIO_CIA_CCCR_BUS_SUSPEND (0x0000C) 111 #define SDIO_CIA_CCCR_FUNCTION_SELECT (0x0000D) 112 #define SDIO_CIA_CCCR_EXEC_FLAGS (0x0000E) 113 #define SDIO_CIA_CCCR_READY_FLAGS (0x0000F) 114 #define SDIO_CIA_CCCR_FN0_BLOCK_SIZE_LSB (0x00010) 115 #define SDIO_CIA_CCCR_FN0_BLOCK_SIZE_MSB (0x00011) 116 #define SDIO_CIA_CCCR_POWER_CONTROL (0x00012) 125 #define SDIO_CIA_CCCR_FN1_BLOCK_SIZE_LSB (0x00110) 126 #define SDIO_CIA_CCCR_FN1_BLOCK_SIZE_MSB (0x00111) 140 typedef enum _SdioBusType
153 typedef enum _SdioResponseType
174 typedef struct _SdioBusToken
178 uint32_t spiConnectTimeout;
179 uint32_t spiResponseTimeout;
180 ssize_t idleByteCount;
181 uint16_t idleFillValue;
183 } __attribute__((packed)) SdioBusToken;
199 typedef struct _CommandIndex
201 uint8_t startBit : 1;
202 uint8_t direction : 1;
205 } __attribute__((packed)) CommandIndex;
218 } __attribute__((packed)) Crc;
231 typedef struct _ResponseFlags
233 uint8_t comCrcError : 1;
234 uint8_t illegalCommand : 1;
235 uint8_t ioCurrentState : 2;
238 uint8_t functionNumberError : 1;
239 uint8_t outOfRange : 1;
241 } __attribute__((packed)) ResponseFlags;
250 typedef struct _GoIdleStateCommand_CMD0
252 CommandIndex commandIndex;
256 } __attribute__((packed)) GoIdleStateCommand_CMD0;
266 typedef struct _IoSendOpCondCommand_CMD5
268 CommandIndex commandIndex;
273 } __attribute__((packed)) IoSendOpCondCommand_CMD5;
283 typedef struct _CrcOnOffCommand_CMD59
285 CommandIndex commandIndex;
290 } __attribute__((packed)) CrcOnOffCommand_CMD59;
303 typedef struct _ModifiedR1
305 uint8_t startBit : 1;
306 uint8_t parameterError : 1;
308 uint8_t functionNumberError : 1;
309 uint8_t comCrcError : 1;
310 uint8_t illegalCommand : 1;
312 uint8_t idleState : 1;
314 } __attribute__((packed)) ModifiedR1;
324 typedef struct _NumberIoFunctions
327 uint8_t ioFunctions : 3;
328 uint8_t memoryPresent : 1;
329 uint8_t stuffBits : 3;
331 } __attribute__((packed)) NumberIoFunctions;
340 typedef struct _IoSendOpCondResponseSpiMode_R4
342 ModifiedR1 modifiedR1;
343 NumberIoFunctions numberIoFunctions;
346 } __attribute__((packed)) IoSendOpCondResponseSpiMode_R4;
359 typedef struct _IoSendOpCondResponse_R4
361 uint8_t startBit : 1;
362 uint8_t direction : 1;
363 uint8_t reserved_02_07 : 6;
364 NumberIoFunctions numberIoFunctions;
366 uint8_t reserved_45_46 : 7;
369 } __attribute__((packed)) IoSendOpCondResponse_R4;
380 typedef struct _Function
383 uint8_t functionNumber : 3;
386 uint8_t registerAddress_bits_16thru15 : 2;
388 } __attribute__((packed)) Function;
396 typedef struct _RegisterAddress
398 unsigned short address : 15;
399 unsigned short stuff : 1;
401 } __attribute__((packed)) RegisterAddress;
412 typedef struct _IoRwDirectCommand_CMD52
414 CommandIndex commandIndex;
416 RegisterAddress registerAddress;
420 } __attribute__((packed)) IoRwDirectCommand_CMD52;
432 typedef struct _IoRwDirectResponse_R5
434 CommandIndex commandIndex;
436 ResponseFlags responseFlags;
437 uint8_t readOrWriteData;
441 } __attribute__((packed)) IoRwDirectResponse_R5;
449 typedef struct _IoRwDirectResponseSpiMode_R5
451 ModifiedR1 modifiedR1;
454 } __attribute__((packed)) IoRwDirectResponseSpiMode_R5;
465 typedef struct _FunctionBlock
468 uint8_t functionNumber : 3;
469 uint8_t blockMode : 1;
471 uint8_t registerAddress_bits_16thru15 : 2;
473 } __attribute__((packed)) FunctionBlock;
481 typedef struct _RegisterExtended
483 unsigned short address : 15;
484 unsigned short byteCount_bit_8 : 1;
486 } __attribute__((packed)) RegisterExtended;
497 typedef struct _IoRwExtendedCommand_CMD53
499 CommandIndex commandIndex;
500 FunctionBlock functionBlock;
501 RegisterExtended registerExtended;
505 } __attribute__((packed)) IoRwExtendedCommand_CMD53;
514 #define HIGH_BYTE (0) 517 typedef union _RegisterValue {
521 } __attribute__((packed)) RegisterValue;
536 typedef struct _CccrSdioRevision
541 } __attribute__((packed)) CccrSdioRevision;
549 typedef struct _SdioSpecRevision
554 } __attribute__((packed)) SdioSpecRevision;
568 typedef struct _IoFunctions
579 } __attribute__((packed)) IoFunctions;
594 typedef struct _IntFunctions
605 } __attribute__((packed)) IntFunctions;
615 typedef struct _BusInterfaceControl
617 uint8_t cdDisable : 1;
623 } __attribute__((packed)) BusInterfaceControl;
637 typedef struct _CardCapability
648 } __attribute__((packed)) CardCapability;
656 typedef struct _PowerControl
662 } __attribute__((packed)) PowerControl;
670 typedef union _CccrRegister {
671 CccrSdioRevision cccrSdioRevision;
672 SdioSpecRevision sdioSpecRevision;
673 IoFunctions ioFunctions;
674 IntFunctions intFunctions;
675 BusInterfaceControl busInterfaceControl;
676 CardCapability cardCapability;
677 PowerControl powerControl;
680 } __attribute__((packed)) CccrRegister;
700 SdioCommand(uint8_t commandIndex);
703 virtual ~SdioCommand() {
return; };
710 virtual void prepare(
void);
713 uint8_t generateCrc7(
void);
716 virtual void display(
void) {
return; };
720 puint8_t getPtr(
void);
723 uint32_t getSize(
void);
734 uint8_t __command_index;
740 uint8_t __commandData[SDIO_COMMAND_SIZE];
743 GoIdleStateCommand_CMD0 *__commandPtr;
753 class SdioCMD5 :
public SdioCommand
760 ~SdioCMD5() {
return; };
764 void prepare(uint32_t ocr);
779 IoSendOpCondCommand_CMD5 *__commandPtr;
789 class SdioCMD52 :
public SdioCommand
796 ~SdioCMD52() {
return; };
800 void prepare(
int readWriteFlag, uint8_t
function,
int rawFlag, uint32_t registerAddress, uint8_t writeData);
818 IoRwDirectCommand_CMD52 *__commandPtr;
828 class SdioCMD53 :
public SdioCommand
835 ~SdioCMD53() {
return; };
839 void prepare(
int readWriteFlag,
842 BOOL isIncrementingAddress,
843 uint32_t registerAddress,
852 IoRwExtendedCommand_CMD53 &getCommand(
void);
864 IoRwExtendedCommand_CMD53 *__commandPtr;
874 class SdioCMD59 :
public SdioCommand
881 ~SdioCMD59() {
return; };
885 void prepare(BOOL isOn);
900 CrcOnOffCommand_CMD59 *__commandPtr;
914 SdioResponse(SdioBusType busType, SdioResponseType responseType);
917 virtual ~SdioResponse() = 0;
921 virtual BOOL isOk(
void) = 0;
924 virtual void display(
void) = 0;
928 SdioResponseType getType(
void);
931 SdioBusType getBusType(
void);
934 virtual puint8_t getPtr(
void) = 0;
937 virtual uint32_t getSize(
void) = 0;
945 virtual void synchronize(
void) = 0;
949 SdioResponseType __type;
951 SdioBusType __busType;
961 class SdioResponseR4 :
public SdioResponse
965 SdioResponseR4(SdioBusType busType);
979 IoSendOpCondResponse_R4 *getResponsePtr(
void);
982 puint8_t getPtr(
void);
985 uint32_t getSize(
void);
988 IoSendOpCondResponse_R4 &getResponse(
void);
991 uint32_t getNumberIoFunctions(
void);
994 uint32_t getOcr(
void);
1002 void synchronize(
void);
1006 puint8_t __responsePtr;
1007 ssize_t __responseSize;
1010 IoSendOpCondResponse_R4 __response;
1013 IoSendOpCondResponseSpiMode_R4 __responseSpiMode;
1023 class SdioResponseR5 :
public SdioResponse
1027 SdioResponseR5(SdioBusType busType);
1044 IoRwDirectResponse_R5 *getResponsePtr(
void);
1047 puint8_t getPtr(
void);
1050 uint32_t getSize(
void);
1053 IoRwDirectResponse_R5 &getResponse(
void);
1056 uint8_t getData(
void);
1064 void synchronize(
void);
1068 puint8_t __responsePtr;
1069 ssize_t __responseSize;
1072 IoRwDirectResponse_R5 __response;
1075 IoRwDirectResponseSpiMode_R5 __responseSpiMode;