6 #ifndef FS_DRIVE_SPI_HPP_
7 #define FS_DRIVE_SPI_HPP_
10 #include "RtosInclude.hpp"
13 class FsDriveSdSpi:
public FsDrive {
14 friend class RtosInterrupt;
25 }__attribute__((packed)) CMD_RESP;
30 uint8_t eraseReset :1;
31 uint8_t illeagalCmd :1;
33 uint8_t eraseSeqError :1;
34 uint8_t addressError :1;
35 uint8_t parameterError :1;
39 }__attribute__((packed)) RESP_R1;
43 uint8_t cmdVersion :4;
45 uint8_t voltageAccepted :4;
48 }__attribute__((packed)) RESP_R7;
51 uint8_t switchTo1_8Accepted;
52 }__attribute__((packed)) OCR;
56 START_SINGLE_BLOCK_WRITE = 0xFE,
57 START_MULTIPLE_BLOCK_WRITE = 0xFC,
58 STOP_TRANSMISSION = 0xFD,
61 const static uint8_t RESP_R1_IDLE_VALUE = 0x01;
64 FsDriveSdSpi(DrvSpi* spi);
68 static FsDriveSdSpi* sInstances[];
71 RESP_R1 sendCmd(uint8_t cmd, uint32_t arg);
74 bool readDataBlock(uint8_t* buffer,
unsigned int size);
75 bool writeDataBlock(
const uint8_t* buffer,
unsigned int size,
bool isMultipleBlock);
77 bool internalReadBlocks(FsDefs::SECTOR* buffer,
unsigned int blockNumber,
unsigned int blockCount);
78 bool internalWriteBlocks(
const FsDefs::SECTOR* buffer,
unsigned int blockNumber,
unsigned int blockCount);
81 virtual bool readBlocks(FsDefs::SECTOR* buffer,
unsigned int blockNumber,
unsigned int blockCount);
82 virtual bool writeBlocks(
const FsDefs::SECTOR* buffer,
unsigned int blockNumber,
unsigned int blockCount);
85 const static uint8_t CMD0_GO_IDLE_STATE = 0;
86 const static uint8_t CMD1_SEND_OP_COND = 1;
87 const static uint8_t CMD6_SWITCH_FUNC = 6;
88 const static uint8_t CMD8_SEND_IF_COND = 8;
89 const static uint8_t CMD9_SEND_CSD = 9;
90 const static uint8_t CMD10_SEND_CID = 10;
91 const static uint8_t CMD12_STOP_TRANSMISSION = 12;
92 const static uint8_t CMD13_SEND_STATUS = 13;
93 const static uint8_t CMD16_SET_BLOCKLEN = 16;
94 const static uint8_t CMD17_READ_SINGLE_BLOCK = 17;
95 const static uint8_t CMD18_READ_MULTIPLE_BLOCK = 18;
96 const static uint8_t CMD24_WRITE_BLOCK = 24;
97 const static uint8_t CMD25_WRITE_MULTIPLE_BLOCK = 25;
98 const static uint8_t CMD27_PROGRAM_CSD = 27;
99 const static uint8_t CMD28_SET_WRITE_PROT = 28;
100 const static uint8_t CMD29_CLR_WRITE_PROT = 29;
101 const static uint8_t CMD30_SEND_WRITE_PROT = 30;
102 const static uint8_t CMD32_ERASE_WR_BLK_START_ADDR = 32;
103 const static uint8_t CMD33_ERASE_WR_BLK_END_ADDR = 33;
104 const static uint8_t CMD38_ERASE = 38;
105 const static uint8_t CMD42_LOCK_UNLOCK = 42;
106 const static uint8_t CMD55_APP_CMD = 55;
107 const static uint8_t CMD56_GEN_CMD = 56;
108 const static uint8_t CMD58_READ_OCR = 58;
109 const static uint8_t CMD59_CRC_ON_OFF = 59;
110 const static uint8_t ACMD13_SD_STATUS = 13;
111 const static uint8_t ACMD22_SEND_NUM_WR_BLOCKS = 22;
112 const static uint8_t ACMD23_SET_WR_BLK_ERASE_COUNT = 23;
113 const static uint8_t ACMD41_SD_SEND_OP_COND = 41;
114 const static uint8_t ACMD42_SET_CLR_CARD_DETECT = 42;
115 const static uint8_t ACMD51_SEND_SCR = 51;