34 #define SPI_INIT_SLOW 0 39 #define SPI_DEFAULT_HALF_SPEED false 42 #define SD_READ_TIMEOUT 300 46 #define SD_CARD_ERROR_CMD0 0X1 48 #define SD_CARD_ERROR_CMD8 0X2 50 #define SD_CARD_ERROR_CMD17 0X3 52 #define SD_CARD_ERROR_CMD24 0X4 54 #define SD_CARD_ERROR_CMD58 0X5 56 #define SD_CARD_ERROR_ACMD41 0X6 58 #define SD_CARD_ERROR_BAD_CSD 0X7 60 #define SD_CARD_ERROR_READ_REG 0X8 62 #define SD_CARD_ERROR_CMD8_ECHO 0X09 64 #define SD_CARD_ERROR_READ_TIMEOUT 0XD 66 #define SD_CARD_ERROR_READ 0X10 70 #define SD_CARD_TYPE_SD1 1 72 #define SD_CARD_TYPE_SD2 2 74 #define SD_CARD_TYPE_SDHC 3 89 uint8_t partialBlockRead_;
92 uint8_t cardCommand(uint8_t cmd, uint32_t arg);
93 void error(uint8_t code) { errorCode_ = code; }
94 void error(uint8_t code, uint8_t data) {
98 uint8_t readRegister(uint8_t cmd, uint8_t *dst);
99 void type(uint8_t value) { type_ = value; }
100 uint8_t waitNotBusy(uint16_t timeoutMillis);
101 uint8_t waitStartBlock(
void);
105 SdReader(
void) : errorCode_(0), inBlock_(0), partialBlockRead_(0), type_(0){};
125 partialBlockRead_ = value;
137 return readData(block, 0, dst, 512);
139 uint8_t
readData(uint32_t block, uint16_t offset, uint8_t *dst,
153 uint8_t
readCID(
cid_t &cid) {
return readRegister(CMD10, (uint8_t *)&cid); }
161 uint8_t
readCSD(
csd_t &csd) {
return readRegister(CMD9, (uint8_t *)&csd); }
167 uint8_t
type() {
return type_; }
void readEnd(void)
Definition: SdReader.cpp:289
uint8_t readBlock(uint32_t block, uint8_t *dst)
Definition: SdReader.h:136
uint8_t readCSD(csd_t &csd)
Read a cards CSD register. The CSD contains Card-Specific Data that provides information regarding ac...
Definition: SdReader.h:161
Hardware access class for SD flash cards.
Definition: SdReader.h:83
uint8_t init(uint8_t slow=SPI_DEFAULT_HALF_SPEED)
Definition: SdReader.cpp:137
void partialBlockRead(uint8_t value)
Definition: SdReader.h:123
uint8_t readData(uint32_t block, uint16_t offset, uint8_t *dst, uint16_t count)
Definition: SdReader.cpp:235
SdReader(void)
Definition: SdReader.h:105
uint32_t cardSize(void)
Definition: SdReader.cpp:104
< union of old and new style CSD register
Definition: SdInfo.h:282
uint8_t readCID(cid_t &cid)
Read a cards CID register. The CID contains card identification information such as Manufacturer ID...
Definition: SdReader.h:153
uint8_t type()
Return the card type: SD V1, SD V2 or SDHC.
Definition: SdReader.h:167
#define SPI_DEFAULT_HALF_SPEED
Definition: SdReader.h:39
uint8_t errorData(void)
Definition: SdReader.h:110
< CID typedef struct
Definition: SdInfo.h:88
uint8_t errorCode(void)
Definition: SdReader.h:108