- /**
- * Same as sd_disk_status.
- *
- * Card initialization must be done with sd_init.
- */
- #define sd_disk_initialize disk_initialize
+struct SdHardware* hw;
+/**
+ * SD Card context structure.
+ */
+typedef struct Sd
+{
+ KBlock b; ///< KBlock base class
+ KFile *ch; ///< SPI communication channel
+ struct SdHardware* hw;
+ uint32_t addr;
+ uint32_t status;
+} Sd;
+
+bool sd_hw_initUnbuf(Sd *sd, KFile *ch);
+bool sd_hw_initBuf(Sd *sd, KFile *ch);
+
+bool sd_spi_initUnbuf(Sd *sd, KFile *ch);
+bool sd_spi_initBuf(Sd *sd, KFile *ch);
+
+// For old compatibility.
+#ifndef CONFIG_SD_MODE
+ #define CONFIG_SD_MODE SD_SPI_MODE
+ #define SD_INCLUDE_SPI_SOURCE
+#endif
+
+#if CONFIG_SD_OLD_INIT
+
+ #if !(ARCH & ARCH_NIGHTTEST)
+ #warning "Deprecated: this API will be removed in the next major release,"
+ #warning "please disable CONFIG_SD_OLD_INIT and pass explicitly the SD context to sd_init()."
+ #endif