NetBurner 3.5.0
PDF Version
 
sdio.h
1/*NB_REVISION*/
2
3/*NB_COPYRIGHT*/
4
5#ifndef _SDIO_H_
6#define _SDIO_H_
7#include <basictypes.h>
8#include <sys/types.h>
9
10/*
11 ******************************************************************************
12 *
13 * Reference
14 * SDIO Simplified Specification, SD Specification, Part E1, Version 2.00
15 * February 8, 2007, Technical Committee, SD Card Association
16 *
17 * Physical Layer Simplified Specification, SD Specification, Part 1,
18 * Version 2.00, September 25, 2006, Technical Committee
19 * SD Card Association
20 *
21 ******************************************************************************
22 */
23/*
24 ******************************************************************************
25 *
26 * Debugging
27 *
28 * Needs to be uncommented to support these features
29 *
30 ******************************************************************************
31 */
32/* Library debugging switch */
33/* #define SDIO_DEBUG ( 1 ) */
34
35/*
36 ******************************************************************************
37 *
38 * Runtime Library Definitions
39 *
40 ******************************************************************************
41 */
42/* Bus type */
43#define SDIO_SPI_BUS (1)
44
45/*
46 ******************************************************************************
47 *
48 * Command and Response Definitions
49 *
50 ******************************************************************************
51 */
52/* Command size in bytes */
53#define SDIO_COMMAND_SIZE (6)
54
55/* Block size */
56#define SDIO_BLOCK_SIZE (512)
57
58/* Direction */
59#define SDIO_CARD_TO_HOST (0x0)
60#define SDIO_HOST_TO_CARD (0x1)
61
62/* Command Index */
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)
68
69/* Read/Write */
70#define SDIO_READ (0)
71#define SDIO_WRITE (1)
72
73/* Function Number (I/O card dependent) */
74#define SDIO_FUNCTION_0 (0)
75#define SDIO_FUNCTION_1 (1)
76
77/* Read after write */
78#define SDIO_READ_OR_WRITE_ONLY (0)
79#define SDIO_RAW (1)
80
81/* Block Mode */
82#define SDIO_BYTE_MODE (0)
83#define SDIO_BLOCK_MODE (1)
84
85/* OP code */
86#define SDIO_FIXED_ADDRESS (FALSE)
87#define SDIO_INCREMENTING_ADDRESS (TRUE)
88
89/* Block size */
90#define SDIO_BLOCK_SIZE_NONE (0)
91
92/*
93 ******************************************************************************
94 *
95 * Common I/O Area (CIA) register addresses (Function 0)
96 *
97 ******************************************************************************
98 */
99/* Card Common Control Registers (CCCR) */
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)
119
120/*
121 ******************************************************************************
122 *
123 * Common I/O Area (CIA) register addresses (Function 1)
124 *
125 ******************************************************************************
126 */
127#define SDIO_CIA_CCCR_FN1_BLOCK_SIZE_LSB (0x00110)
128#define SDIO_CIA_CCCR_FN1_BLOCK_SIZE_MSB (0x00111)
129/*
130 ******************************************************************************
131 *
132 * Runtime Library Enumerations and Structures
133 *
134 ******************************************************************************
135 */
136/*
137 SDIO Bus type
138 Sdio - SD 4-bit mode
139 SdioSpiMode - SPI mode
140
141 */
142typedef enum _SdioBusType
143{
144 Sdio,
145 SdioSpiMode
146
147} SdioBusType;
148
149/*
150 SDIO Response type
151 R4 - IO_SEND_OP_COND Response
152 R5 - IO_RW_DIRECT Response
153
154 */
155typedef enum _SdioResponseType
156{
157 R4,
158 R5
159
160} SdioResponseType;
161
162/*
163 Bus token for user
164 butType - Bus type in use for this token
165
166 *** SPI ***
167 spiSetting - Shared SPI setting
168 spiConnectTimeout - Bus allocation timeout period in ticks
169 spiResponseTimeout - Command response timeout period in ticks
170 idleByteCount - Bytes required to idle bus
171 idleFillValue - Data to transmit that idles the bus
172
173 *** SDIO Future ***
174
175 */
176typedef struct _SdioBusToken
177{
178 SdioBusType busType;
179 int spiSetting;
180 uint32_t spiConnectTimeout;
181 uint32_t spiResponseTimeout;
182 ssize_t idleByteCount;
183 uint16_t idleFillValue;
184
185} __attribute__((packed)) SdioBusToken;
186
187/*
188 ******************************************************************************
189 *
190 * Command and Response Structures
191 *
192 ******************************************************************************
193 */
194/*
195 Start bit, direction and command
196 startBit - Start bit, always 0
197 direction - 0 card to host, 1 host to card
198 index - Command index
199
200 */
201typedef struct _CommandIndex
202{
203 uint8_t startBit : 1;
204 uint8_t direction : 1;
205 uint8_t index : 6;
206
207} __attribute__((packed)) CommandIndex;
208
209/*
210 CRC and end
211 crc7 - 7 bits of CRC data
212 endBit - End bit, always 1
213
214 */
215typedef struct _Crc
216{
217 uint8_t crc7 : 7;
218 uint8_t endBit : 1;
219
220} __attribute__((packed)) Crc;
221
222/*
223 Response Flags IAW SD Physical Specification
224 comCrcError - 1 yes else 0
225 illegalCommand - 1 yes else 0
226 ioCurrentState - Current I/O state
227 error - Unknown error
228 rfu - RFU always 0
229 functionNumberError - 1 yes else 0
230 outOfRange - 1 yes else 0
231
232 */
233typedef struct _ResponseFlags
234{
235 uint8_t comCrcError : 1;
236 uint8_t illegalCommand : 1;
237 uint8_t ioCurrentState : 2;
238 uint8_t error : 1;
239 uint8_t rfu : 1;
240 uint8_t functionNumberError : 1;
241 uint8_t outOfRange : 1;
242
243} __attribute__((packed)) ResponseFlags;
244
245/*
246 Go idle state (CMD0)
247 commandIndex - Start, direction and command index
248 stuff - MBZ
249 crc - CRC and end bit
250
251 */
252typedef struct _GoIdleStateCommand_CMD0
253{
254 CommandIndex commandIndex;
255 uint8_t stuff[4];
256 Crc crc;
257
258} __attribute__((packed)) GoIdleStateCommand_CMD0;
259
260/*
261 I/O Send Operational Condition
262 crc - CRC and end bit
263 ocr - Operations condition register
264 stuffBits - MBZ
265 commandIndex - Start, direction and command index
266
267 */
268typedef struct _IoSendOpCondCommand_CMD5
269{
270 CommandIndex commandIndex;
271 uint8_t stuffBits;
272 uint8_t ocr[3];
273 Crc crc;
274
275} __attribute__((packed)) IoSendOpCondCommand_CMD5;
276
277/*
278 CRC toggle command (CMD59)
279 crc - CRC and end bit
280 ocr - Operations condition register
281 stuffBits - MBZ
282 commandIndex - Start, direction and command index
283
284 */
285typedef struct _CrcOnOffCommand_CMD59
286{
287 CommandIndex commandIndex;
288 uint8_t stuffBits;
289 uint8_t ocr[3];
290 Crc crc;
291
292} __attribute__((packed)) CrcOnOffCommand_CMD59;
293
294/*
295 Modified R1 IAW SD Physical Specification
296 start - Start bit, always 0
297 parameterError - 1 yes else 0
298 rfu - RFU always 0
299 functionNumberError - 1 yes else 0
300 comCrcError - 1 yes else 0
301 illegalCommand - 1 yes else 0
302 rfu_1 - RFU always 0
303 idleState - Idle state, always 1
304 */
305typedef struct _ModifiedR1
306{
307 uint8_t startBit : 1;
308 uint8_t parameterError : 1;
309 uint8_t rfu : 1;
310 uint8_t functionNumberError : 1;
311 uint8_t comCrcError : 1;
312 uint8_t illegalCommand : 1;
313 uint8_t rfu_1 : 1;
314 uint8_t idleState : 1;
315
316} __attribute__((packed)) ModifiedR1;
317
318/*
319 Operate bit, number of I/O functions and memory present
320 operate - 1 card is ready to operate
321 ioFunctions - Number of I/O functions supported
322 memoryPresent - 1 SD memory else 0
323 stuffBits - MBZ
324
325 */
326typedef struct _NumberIoFunctions
327{
328 uint8_t operate : 1;
329 uint8_t ioFunctions : 3;
330 uint8_t memoryPresent : 1;
331 uint8_t stuffBits : 3;
332
333} __attribute__((packed)) NumberIoFunctions;
334
335/*
336 I/O Send Operational Condition Response in SPI mode (R4)
337 modifiedR1 - Modified R1
338 numberIoFunctions - Number of I/O functions supported
339 ocr - Operations condition register
340
341 */
342typedef struct _IoSendOpCondResponseSpiMode_R4
343{
344 ModifiedR1 modifiedR1;
345 NumberIoFunctions numberIoFunctions;
346 uint8_t ocr[3];
347
348} __attribute__((packed)) IoSendOpCondResponseSpiMode_R4;
349
350/*
351 I/O Send Operational Condition Response (R4)
352 startBit - Start bit, always 0
353 direction - 0 card to host
354 reserved_02_07 - 1s
355 numberIoFunctions - Number of I/O functions supported
356 ocr - Operations condition register
357 reserved_45_46 - 1S
358 endBit - End bit, always 1
359
360 */
361typedef struct _IoSendOpCondResponse_R4
362{
363 uint8_t startBit : 1;
364 uint8_t direction : 1;
365 uint8_t reserved_02_07 : 6;
366 NumberIoFunctions numberIoFunctions;
367 uint8_t ocr[3];
368 uint8_t reserved_45_46 : 7;
369 uint8_t endBit : 1;
370
371} __attribute__((packed)) IoSendOpCondResponse_R4;
372
373/*
374 R/W flag, function number and raw flag
375 rwFlag - 0 read, 1 write
376 functionNumber - I/O card area
377 rawFlag - Read after write, 1 yes
378 stuff - MBZ
379 registerAddress_bits_16thru15 - Register address bits 15 and 16
380
381 */
382typedef struct _Function
383{
384 uint8_t rwFlag : 1;
385 uint8_t functionNumber : 3;
386 uint8_t rawFlag : 1;
387 uint8_t stuff : 1;
388 uint8_t registerAddress_bits_16thru15 : 2;
389
390} __attribute__((packed)) Function;
391
392/*
393 Register address
394 address - Register address bits 0 through 14
395 stuff - MBZ
396
397 */
398typedef struct _RegisterAddress
399{
400 unsigned short address : 15;
401 unsigned short stuff : 1;
402
403} __attribute__((packed)) RegisterAddress;
404
405/*
406 I/O read/write direct command
407 commandIndex - Start, direction and command index
408 function - R/W flag, function number and raw flag
409 registerAddress - Register address bits 0 through 14
410 dataOrStuff - Write data byte else MBZ
411 stuffBits - MBZ
412
413 */
414typedef struct _IoRwDirectCommand_CMD52
415{
416 CommandIndex commandIndex;
417 Function function;
418 RegisterAddress registerAddress;
419 uint8_t dataOrStuff;
420 Crc crc;
421
422} __attribute__((packed)) IoRwDirectCommand_CMD52;
423
424/*
425 I/O read/write direct response
426 commandIndex - Start, direction and command index
427 stuff - MBZ
428 responseFlags - Status of SDIO card
429 readOrWriteData - RAW read else ignore
430 data - Read data
431 crc - CRC
432
433 */
434typedef struct _IoRwDirectResponse_R5
435{
436 CommandIndex commandIndex;
437 uint8_t stuff[2];
438 ResponseFlags responseFlags;
439 uint8_t readOrWriteData;
440 uint8_t data;
441 Crc crc;
442
443} __attribute__((packed)) IoRwDirectResponse_R5;
444
445/*
446 I/O read/write direct response
447 modifiedR1 - Modified R1
448 data - Read data
449
450 */
451typedef struct _IoRwDirectResponseSpiMode_R5
452{
453 ModifiedR1 modifiedR1;
454 uint8_t data;
455
456} __attribute__((packed)) IoRwDirectResponseSpiMode_R5;
457
458/*
459 R/W flag, function number and raw flag
460 rwFlag - 0 read, 1 write
461 functionNumber - I/O card area
462 blockMode - 1 block mode else bytes
463 opCode - 1 incrementing, 0 fixed location
464 registerAddress_bits_16thru15 - Register address bits 15 and 16
465
466 */
467typedef struct _FunctionBlock
468{
469 uint8_t rwFlag : 1;
470 uint8_t functionNumber : 3;
471 uint8_t blockMode : 1;
472 uint8_t opCode : 1;
473 uint8_t registerAddress_bits_16thru15 : 2;
474
475} __attribute__((packed)) FunctionBlock;
476
477/*
478 Register extended address
479 address - Register address bits 0 through 14
480 byteCount_bit_8 - Byte or block count msb
481
482 */
483typedef struct _RegisterExtended
484{
485 unsigned short address : 15;
486 unsigned short byteCount_bit_8 : 1;
487
488} __attribute__((packed)) RegisterExtended;
489
490/*
491 I/O read/write extended command
492 commandIndex - Start, direction and command index
493 functionBlock - R/W flag, function number, block and increment
494 registerExtended - Register address bits 0 through 14, msb block count
495 byteCount - Byte count bits 0 through 7
496 stuffBits - MBZ
497
498 */
499typedef struct _IoRwExtendedCommand_CMD53
500{
501 CommandIndex commandIndex;
502 FunctionBlock functionBlock;
503 RegisterExtended registerExtended;
504 uint8_t byteCount;
505 Crc crc;
506
507} __attribute__((packed)) IoRwExtendedCommand_CMD53;
508
509/*
510 Register Value ( Host order, Big Endian )
511 wValue 16bit value
512 bValue 8 bit value
513
514*/
515
516#define HIGH_BYTE (0)
517#define LOW_BYTE (1)
518
519typedef union _RegisterValue
520{
521 uint16_t wValue;
522 uint8_t bValue[2];
523
524} __attribute__((packed)) RegisterValue;
525
526/*
527 ******************************************************************************
528 *
529 * CIA CCCR Register field structures
530 *
531 ******************************************************************************
532 */
533/*
534 CCCR/SDIO Revision Register (SDIO_CIA_CCCR_CCCR_SDIO_REVISION)
535 sdio - SDIO revision
536 cccr - CCCR revision
537
538 */
539typedef struct _CccrSdioRevision
540{
541 uint8_t sdio : 4;
542 uint8_t cccr : 4;
543
544} __attribute__((packed)) CccrSdioRevision;
545
546/*
547 SDIO Specification Revision Register (SDIO_CIA_CCCR_SD_SPEC_REVISION)
548 rfu - Reserved for future use
549 sd - Revision
550
551 */
552typedef struct _SdioSpecRevision
553{
554 uint8_t rfu : 4;
555 uint8_t sd : 4;
556
557} __attribute__((packed)) SdioSpecRevision;
558
559/*
560 I/O Enable or Ready Register (SDIO_CIA_CCCR_IO_[ENABLE|READY])
561 io7 - Function 7
562 io6 - Function 6
563 io5 - Function 5
564 io4 - Function 4
565 io3 - Function 3
566 io2 - Function 2
567 io1 - Function 1
568 rfu - Reserved for future use
569
570 */
571typedef struct _IoFunctions
572{
573 uint8_t io7 : 1;
574 uint8_t io6 : 1;
575 uint8_t io5 : 1;
576 uint8_t io4 : 1;
577 uint8_t io3 : 1;
578 uint8_t io2 : 1;
579 uint8_t io1 : 1;
580 uint8_t rfu : 1;
581
582} __attribute__((packed)) IoFunctions;
583
584/*
585 Interrupt Enable or Pending Register
586 (SDIO_CIA_CCCR_INTERRUPT_[ENABLE|PENDING])
587 int7 - Interrupt for function 7
588 int6 - Interrupt for function 6
589 int5 - Interrupt for function 5
590 int4 - Interrupt for function 4
591 int3 - Interrupt for function 3
592 int2 - Interrupt for function 2
593 int1 - Interrupt for function 1
594 ienm - Master enable
595
596 */
597typedef struct _IntFunctions
598{
599 uint8_t int7 : 1;
600 uint8_t int6 : 1;
601 uint8_t int5 : 1;
602 uint8_t int4 : 1;
603 uint8_t int3 : 1;
604 uint8_t int2 : 1;
605 uint8_t int1 : 1;
606 uint8_t ienm : 1;
607
608} __attribute__((packed)) IntFunctions;
609
610/*
611 Bus Interface Control (SDIO_CIA_CCCR_BUS_INTERFACE_CONTROL)
612 cdDisable - Card detection
613 scsi - Support continuous SPI interrupt
614 ecsi - Enable continuous SPI interrupt
615 width - SDIO data bus width
616
617 */
618typedef struct _BusInterfaceControl
619{
620 uint8_t cdDisable : 1;
621 uint8_t scsi : 1;
622 uint8_t ecsi : 1;
623 uint8_t rfu : 3;
624 uint8_t width : 2;
625
626} __attribute__((packed)) BusInterfaceControl;
627
628/*
629 Card Capability (SDIO_CIA_CCCR_CARD_CAPABILITY)
630 s4bls - 4-bit support for low speed cards
631 lsc - Low speed card
632 e4mi - Enable inter-block interrupts 4 bit mode
633 s4mi - Supports inter-block interrupts 4 bit mode
634 sbs - Supports suspend/resume
635 srw - Supports read wait
636 smb - Supports multiblock
637 sdc - Supports direct commands
638
639 */
640typedef struct _CardCapability
641{
642 uint8_t s4bls : 1;
643 uint8_t lsc : 1;
644 uint8_t e4mi : 1;
645 uint8_t s4mi : 1;
646 uint8_t sbs : 1;
647 uint8_t srw : 1;
648 uint8_t smb : 1;
649 uint8_t sdc : 1;
650
651} __attribute__((packed)) CardCapability;
652
653/*
654 Power Control (SDIO_CIA_CCCR_POWER_CONTROL)
655 empc - Enable master power control
656 smpc - Supports master power control
657
658 */
659typedef struct _PowerControl
660{
661 uint8_t rfu : 6;
662 uint8_t empc : 1;
663 uint8_t smpc : 1;
664
665} __attribute__((packed)) PowerControl;
666
667/*
668 Register settings and transfer byte union
669 <lower case> - Register bits defined as structure
670 content - Transfer byte
671
672 */
673typedef union _CccrRegister
674{
675 CccrSdioRevision cccrSdioRevision;
676 SdioSpecRevision sdioSpecRevision;
677 IoFunctions ioFunctions;
678 IntFunctions intFunctions;
679 BusInterfaceControl busInterfaceControl;
680 CardCapability cardCapability;
681 PowerControl powerControl;
682 uint8_t content;
683
684} __attribute__((packed)) CccrRegister;
685
686/*
687 ******************************************************************************
688 *
689 * Classes
690 *
691 ******************************************************************************
692 */
693/*
694 ******************************************************************************
695 *
696 * SDIO Base Class (CMD0)
697 *
698 ******************************************************************************
699 */
700class SdioCommand
701{
702 public:
703 /*** Constructor ***/
704 SdioCommand(uint8_t commandIndex);
705
706 /*** Destructor ***/
707 virtual ~SdioCommand() { return; };
708
709 /*** Methods ***/
710 /* Reset command */
711 void reset(void);
712
713 /* Prepare command to send */
714 virtual void prepare(void);
715
716 /* Generate CRC 7 */
717 uint8_t generateCrc7(void);
718
719 /* Display using iprintf */
720 virtual void display(void) { return; };
721
722 /*** Accessors ***/
723 /* Get command data pointer */
724 puint8_t getPtr(void);
725
726 /* Get response size */
727 uint32_t getSize(void);
728
729 protected:
730 /* None */
731
732 private:
733 /*** Methods ***/
734 /* None */
735
736 /*** Data Members ***/
737 /* Command index */
738 uint8_t __command_index;
739
740 /* CRC 7 */
741 uint8_t __crc7;
742
743 /* Command data buffer */
744 uint8_t __commandData[SDIO_COMMAND_SIZE];
745
746 /* Command 0 pointer */
747 GoIdleStateCommand_CMD0 *__commandPtr;
748};
749
750/*
751 ******************************************************************************
752 *
753 * SDIO I/O Send Operational Condition (CMD5)
754 *
755 ******************************************************************************
756 */
757class SdioCMD5 : public SdioCommand
758{
759 public:
760 /*** Constructor ***/
761 SdioCMD5();
762
763 /*** Destructor ***/
764 ~SdioCMD5() { return; };
765
766 /*** Methods ***/
767 /* Prepare command to send */
768 void prepare(uint32_t ocr);
769
770 /*** Accessors ***/
771 /* None */
772
773 protected:
774 /* None */
775
776 private:
777 /*** Methods ***/
778 /* Reset command */
779 /* None */
780
781 /*** Data Members ***/
782 /* Command 5 pointer */
783 IoSendOpCondCommand_CMD5 *__commandPtr;
784};
785
786/*
787 ******************************************************************************
788 *
789 * SDIO I/O Read/Write Direct (CMD52)
790 *
791 ******************************************************************************
792 */
793class SdioCMD52 : public SdioCommand
794{
795 public:
796 /*** Constructor ***/
797 SdioCMD52(void);
798
799 /*** Destructor ***/
800 ~SdioCMD52() { return; };
801
802 /*** Methods ***/
803 /* Prepare command to send */
804 void prepare(int readWriteFlag, uint8_t function, int rawFlag, uint32_t registerAddress, uint8_t writeData);
805
806 /* Display using iprintf */
807 void display(void);
808
809 /*** Accessors ***/
810 /* None */
811
812 protected:
813 /* None */
814
815 private:
816 /*** Methods ***/
817 /* Reset command */
818 /* None */
819
820 /*** Data Members ***/
821 /* Command 52 pointer */
822 IoRwDirectCommand_CMD52 *__commandPtr;
823};
824
825/*
826 ******************************************************************************
827 *
828 * SDIO I/O Read/Write Extended (CMD53)
829 *
830 ******************************************************************************
831 */
832class SdioCMD53 : public SdioCommand
833{
834 public:
835 /*** Constructor ***/
836 SdioCMD53(void);
837
838 /*** Destructor ***/
839 ~SdioCMD53() { return; };
840
841 /*** Methods ***/
842 /* Prepare command to send */
843 void prepare(int readWriteFlag,
844 uint8_t function,
845 int blockMode,
846 BOOL isIncrementingAddress,
847 uint32_t registerAddress,
848 uint32_t byteCount,
849 uint16_t blockSize);
850
851 /* Display using iprintf */
852 void display(void);
853
854 /*** Accessors ***/
855 /* Get object */
856 IoRwExtendedCommand_CMD53 &getCommand(void);
857
858 protected:
859 /* None */
860
861 private:
862 /*** Methods ***/
863 /* Reset command */
864 /* None */
865
866 /*** Data Members ***/
867 /* Command 53 pointer */
868 IoRwExtendedCommand_CMD53 *__commandPtr;
869};
870
871/*
872 ******************************************************************************
873 *
874 * CRC toggle command (CMD59)
875 *
876 ******************************************************************************
877 */
878class SdioCMD59 : public SdioCommand
879{
880 public:
881 /*** Constructor ***/
882 SdioCMD59(void);
883
884 /*** Destructor ***/
885 ~SdioCMD59() { return; };
886
887 /*** Methods ***/
888 /* Prepare command to send */
889 void prepare(BOOL isOn);
890
891 /*** Accessors ***/
892 /* None */
893
894 protected:
895 /* None */
896
897 private:
898 /*** Methods ***/
899 /* Reset command */
900 /* None */
901
902 /*** Data Members ***/
903 /* Command 5 pointer */
904 CrcOnOffCommand_CMD59 *__commandPtr;
905};
906
907/*
908 ******************************************************************************
909 *
910 * SDIO Response Base Class
911 *
912 ******************************************************************************
913 */
914class SdioResponse
915{
916 public:
917 /*** Constructor ***/
918 SdioResponse(SdioBusType busType, SdioResponseType responseType);
919
920 /*** Destructor ***/
921 virtual ~SdioResponse() = 0;
922
923 /*** Methods ***/
924 /* Is response OK */
925 virtual BOOL isOk(void) = 0;
926
927 /* Display using iprintf */
928 virtual void display(void) = 0;
929
930 /*** Accessors ***/
931 /* Get response type */
932 SdioResponseType getType(void);
933
934 /* Get response type */
935 SdioBusType getBusType(void);
936
937 /* Get remaining response */
938 virtual puint8_t getPtr(void) = 0;
939
940 /* Get response size */
941 virtual uint32_t getSize(void) = 0;
942
943 protected:
944 /* None */
945
946 private:
947 /*** Methods ***/
948 /* Synchronize data */
949 virtual void synchronize(void) = 0;
950
951 /*** Data Members ***/
952 /* Type */
953 SdioResponseType __type;
954
955 SdioBusType __busType;
956};
957
958/*
959 ******************************************************************************
960 *
961 * I/O Send Operational Condition response (R4)
962 *
963 ******************************************************************************
964 */
965class SdioResponseR4 : public SdioResponse
966{
967 public:
968 /*** Constructor ***/
969 SdioResponseR4(SdioBusType busType);
970
971 /*** Destructor ***/
972 ~SdioResponseR4();
973
974 /*** Methods ***/
975 /* Is response OK */
976 BOOL isOk(void);
977
978 /* Display using iprintf */
979 void display(void);
980
981 /*** Accessors ***/
982 /* Get response pointer */
983 IoSendOpCondResponse_R4 *getResponsePtr(void);
984
985 /* Get remaining response */
986 puint8_t getPtr(void);
987
988 /* Get response size */
989 uint32_t getSize(void);
990
991 /* Get response pointer */
992 IoSendOpCondResponse_R4 &getResponse(void);
993
994 /* Get response size */
995 uint32_t getNumberIoFunctions(void);
996
997 /* Get Operations Condition Register (OCR) */
998 uint32_t getOcr(void);
999
1000 protected:
1001 /* None */
1002
1003 private:
1004 /*** Methods ***/
1005 /* Synchronize data */
1006 void synchronize(void);
1007
1008 /*** Data Members ***/
1009 /* Response pointer and size */
1010 puint8_t __responsePtr;
1011 ssize_t __responseSize;
1012
1013 /* Response */
1014 IoSendOpCondResponse_R4 __response;
1015
1016 /* Modified R1 (SPI Mode) */
1017 IoSendOpCondResponseSpiMode_R4 __responseSpiMode;
1018};
1019
1020/*
1021 ******************************************************************************
1022 *
1023 * I/O Read/Write Direct response (R5)
1024 *
1025 ******************************************************************************
1026 */
1027class SdioResponseR5 : public SdioResponse
1028{
1029 public:
1030 /*** Constructor ***/
1031 SdioResponseR5(SdioBusType busType);
1032
1033 /*** Destructor ***/
1034 ~SdioResponseR5();
1035
1036 /*** Methods ***/
1037 /* Is response OK */
1038 BOOL isOk(void);
1039
1040 /* Is card idle */
1041 BOOL isIdle(void);
1042
1043 /* Display using iprintf */
1044 void display(void);
1045
1046 /*** Accessors ***/
1047 /* Get response pointer */
1048 IoRwDirectResponse_R5 *getResponsePtr(void);
1049
1050 /* Get remaining response */
1051 puint8_t getPtr(void);
1052
1053 /* Get response size */
1054 uint32_t getSize(void);
1055
1056 /* Get response reference */
1057 IoRwDirectResponse_R5 &getResponse(void);
1058
1059 /* Get data byte */
1060 uint8_t getData(void);
1061
1062 protected:
1063 /* None */
1064
1065 private:
1066 /*** Methods ***/
1067 /* Synchronize data */
1068 void synchronize(void);
1069
1070 /*** Data Members ***/
1071 /* Response pointer and size */
1072 puint8_t __responsePtr;
1073 ssize_t __responseSize;
1074
1075 /* IO_RW_DIRECT Response */
1076 IoRwDirectResponse_R5 __response;
1077
1078 /* IO_RW_DIRECT Response (SPI Mode) */
1079 IoRwDirectResponseSpiMode_R5 __responseSpiMode;
1080};
1081
1082#endif /* _SDIO_H_ */