#pragma once #include namespace roro { // Why the SD driver last gave up on a write (see sd_diskio.cpp, issue #21). The framework's driver // fails without saying why; ours records it. struct SdFault { enum Step : uint8_t { None, EraseCount, // ACMD23 before a multi-block write was refused Select, // the card stayed busy for 500 ms Command, // the write command itself was refused DataToken, // the card's answer to a data block: 0x0B CRC error, 0x0D write error BusyAfter, // still busy 500 ms after the last block Status, // CMD13 after the write reported an error (resp) StopCommand, // CMD12 after a rejected block was refused }; Step step = None; uint8_t token = 0; // the driver's or the card's answer at that step uint32_t resp = 0; // CMD13's status bits, for Status uint32_t count = 0; // failed writes since boot uint32_t retried = 0; // blocks resent after a CRC error, since boot }; SdFault sdLastFault(); // The mounted card's identity register (CID, CMD10): who made it, its name, serial and date. // Call it where card access is allowed (the storage task). bool sdReadCid(uint8_t cid[16]); } // namespace roro