Skip to content

Commit

Permalink
cleanup after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Apr 4, 2021
1 parent 47ce8fe commit 6543d02
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 41 deletions.
18 changes: 9 additions & 9 deletions Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Ctrl_status sd_mmc_spi_test_unit_ready() {
Ctrl_status sd_mmc_spi_read_capacity(uint32_t *nb_sector) {
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted())
return CTRL_NO_PRESENT;
*nb_sector = card.getSd2Card()->cardSize() - 1;
*nb_sector = card.diskIODriver()->cardSize() - 1;
return CTRL_GOOD;
}

Expand Down Expand Up @@ -74,24 +74,24 @@ Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector) {
#endif

// Start reading
if (!card.getSd2Card()->readStart(addr))
if (!card.diskIODriver()->readStart(addr))
return CTRL_FAIL;

// For each specified sector
while (nb_sector--) {

// Read a sector
card.getSd2Card()->readData(sector_buf);
card.diskIODriver()->readData(sector_buf);

// RAM -> USB
if (!udi_msc_trans_block(true, sector_buf, SD_MMC_BLOCK_SIZE, nullptr)) {
card.getSd2Card()->readStop();
card.diskIODriver()->readStop();
return CTRL_FAIL;
}
}

// Stop reading
card.getSd2Card()->readStop();
card.diskIODriver()->readStop();

// Done
return CTRL_GOOD;
Expand All @@ -113,24 +113,24 @@ Ctrl_status sd_mmc_spi_usb_write_10(uint32_t addr, uint16_t nb_sector) {
}
#endif

if (!card.getSd2Card()->writeStart(addr, nb_sector))
if (!card.diskIODriver()->writeStart(addr, nb_sector))
return CTRL_FAIL;

// For each specified sector
while (nb_sector--) {

// USB -> RAM
if (!udi_msc_trans_block(false, sector_buf, SD_MMC_BLOCK_SIZE, nullptr)) {
card.getSd2Card()->writeStop();
card.diskIODriver()->writeStop();
return CTRL_FAIL;
}

// Write a sector
card.getSd2Card()->writeData(sector_buf);
card.diskIODriver()->writeData(sector_buf);
}

// Stop writing
card.getSd2Card()->writeStop();
card.diskIODriver()->writeStop();

// Done
return CTRL_GOOD;
Expand Down
16 changes: 8 additions & 8 deletions Marlin/src/HAL/STM32/msc_sd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,26 @@

class Sd2CardUSBMscHandler : public USBMscHandler {
public:
DiskIODriver* getDiskIODriver() {
DiskIODriver* diskIODriver() {
#if ENABLED(MULTI_VOLUME)
#if SHARED_VOLUME_IS(SD_ONBOARD)
return &card.sd2card_sd_spi;
return &card.media_sd_spi;
#elif SHARED_VOLUME_IS(USB_FLASH_DRIVE)
return &card.sd2card_UsbFlashDrive;
return &card.media_usbFlashDrive;
#endif
#else
return getDiskIODriver();
return diskIODriver();
#endif
}

bool GetCapacity(uint32_t *pBlockNum, uint16_t *pBlockSize) {
*pBlockNum = getDiskIODriver()->cardSize();
*pBlockNum = diskIODriver()->cardSize();
*pBlockSize = BLOCK_SIZE;
return true;
}

bool Write(uint8_t *pBuf, uint32_t blkAddr, uint16_t blkLen) {
auto sd2card = getDiskIODriver();
auto sd2card = diskIODriver();
// single block
if (blkLen == 1) {
watchdog_refresh();
Expand All @@ -69,7 +69,7 @@ class Sd2CardUSBMscHandler : public USBMscHandler {
}

bool Read(uint8_t *pBuf, uint32_t blkAddr, uint16_t blkLen) {
auto sd2card = getDiskIODriver();
auto sd2card = diskIODriver();
// single block
if (blkLen == 1) {
watchdog_refresh();
Expand All @@ -89,7 +89,7 @@ class Sd2CardUSBMscHandler : public USBMscHandler {
}

bool IsReady() {
return getDiskIODriver()->isReady();
return diskIODriver()->isReady();
}
};

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
TERN_(SDSUPPORT, card.manage_media());

// Handle USB Flash Drive insert / remove
TERN_(USB_FLASH_DRIVE_SUPPORT, DiskIODriver_USBFlash::idle());
TERN_(USB_FLASH_DRIVE_SUPPORT, card.diskIODriver()->idle());

// Announce Host Keepalive state (if any)
TERN_(HOST_KEEPALIVE_FEATURE, gcode.host_keepalive());
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_media_select.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
lv_clear_media_select();
switch (obj->mks_obj_id) {
case ID_T_USB_DISK: card.changeMedia(&card.sd2card_UsbFlashDrive); break;
case ID_T_SD_DISK: card.changeMedia(&card.sd2card_sd_spi); break;
case ID_T_USB_DISK: card.changeMedia(&card.media_usbFlashDrive); break;
case ID_T_SD_DISK: card.changeMedia(&card.media_sd_spi); break;
case ID_T_RETURN:
TERN_(MKS_TEST, curent_disp_ui = 1);
lv_draw_ready_print();
Expand Down
20 changes: 10 additions & 10 deletions Marlin/src/sd/cardreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ uint8_t CardReader::workDirDepth;
#endif // SDCARD_SORT_ALPHA

#if ENABLED(USB_FLASH_DRIVE_SUPPORT)
DiskIODriver_USBFlash CardReader::sd2card_UsbFlashDrive;
DiskIODriver_USBFlash CardReader::media_usbFlashDrive;
#endif
#if NEED_SD2CARD_SDIO
DiskIODriver_SDIO CardReader::sd2card_sdio;
DiskIODriver_SDIO CardReader::media_sdio;
#elif NEED_SD2CARD_SPI
DiskIODriver_SPI_SD CardReader::sd2card_sd_spi;
DiskIODriver_SPI_SD CardReader::media_sd_spi;
#endif

DiskIODriver* CardReader::sd2card = nullptr;
DiskIODriver* CardReader::driver = nullptr;
SdVolume CardReader::volume;
SdFile CardReader::file;

Expand All @@ -144,11 +144,11 @@ uint32_t CardReader::filesize, CardReader::sdpos;
CardReader::CardReader() {
changeMedia(&
#if SHARED_VOLUME_IS(SD_ONBOARD)
sd2card_sd_spi
media_sd_spi
#elif SHARED_VOLUME_IS(USB_FLASH_DRIVE) || ENABLED(USB_FLASH_DRIVE_SUPPORT)
sd2card_UsbFlashDrive
media_usbFlashDrive
#else
TERN(SDIO_SUPPORT, sd2card_sdio, sd2card_sd_spi)
TERN(SDIO_SUPPORT, media_sdio, media_sd_spi)
#endif
);

Expand Down Expand Up @@ -402,12 +402,12 @@ void CardReader::mount() {
flag.mounted = false;
if (root.isOpen()) root.close();

if (!sd2card->init(SD_SPI_SPEED, SDSS)
if (!driver->init(SD_SPI_SPEED, SDSS)
#if defined(LCD_SDSS) && (LCD_SDSS != SDSS)
&& !sd2card->init(SD_SPI_SPEED, LCD_SDSS)
&& !driver->init(SD_SPI_SPEED, LCD_SDSS)
#endif
) SERIAL_ECHO_MSG(STR_SD_INIT_FAIL);
else if (!volume.init(sd2card))
else if (!volume.init(driver))
SERIAL_ERROR_MSG(STR_SD_VOL_INIT_FAIL);
else if (!root.openRoot(&volume))
SERIAL_ERROR_MSG(STR_SD_OPENROOT_FAIL);
Expand Down
16 changes: 8 additions & 8 deletions Marlin/src/sd/cardreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class CardReader {

CardReader();

static void changeMedia(DiskIODriver *_driver) { sd2card = _driver; }
static void changeMedia(DiskIODriver *_driver) { driver = _driver; }

static SdFile getroot() { return root; }

Expand Down Expand Up @@ -196,8 +196,8 @@ class CardReader {
static inline int16_t read(void* buf, uint16_t nbyte) { return file.isOpen() ? file.read(buf, nbyte) : -1; }
static inline int16_t write(void* buf, uint16_t nbyte) { return file.isOpen() ? file.write(buf, nbyte) : -1; }

// TODO: rename to getDiskIODriver()
static DiskIODriver* getSd2Card() { return sd2card; }
// TODO: rename to diskIODriver()
static DiskIODriver* diskIODriver() { return driver; }

#if ENABLED(AUTO_REPORT_SD_STATUS)
//
Expand All @@ -208,12 +208,12 @@ class CardReader {
#endif

#if ENABLED(USB_FLASH_DRIVE_SUPPORT)
static DiskIODriver_USBFlash sd2card_UsbFlashDrive;
static DiskIODriver_USBFlash media_UsbFlashDrive;
#endif
#if NEED_SD2CARD_SDIO
static DiskIODriver_SDIO sd2card_sdio;
static DiskIODriver_SDIO media_sdio;
#elif NEED_SD2CARD_SPI
static DiskIODriver_SPI_SD sd2card_sd_spi;
static DiskIODriver_SPI_SD media_sd_spi;
#endif

private:
Expand Down Expand Up @@ -271,15 +271,15 @@ class CardReader {
#if ENABLED(SDSORT_DYNAMIC_RAM)
static uint8_t *isDir;
#elif ENABLED(SDSORT_CACHE_NAMES) || DISABLED(SDSORT_USES_STACK)
static uint8_t isDir[(SDSORT_LIMIT+7)>>3];
static uint8_t isDir[(SDSORT_LIMIT + 7) >> 3];
#endif
#endif

#endif // SDSORT_USES_RAM

#endif // SDCARD_SORT_ALPHA

static DiskIODriver* sd2card;
static DiskIODriver *driver;
static SdVolume volume;
static SdFile file;

Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#endif
#endif

class DiskIODriver_USBFlash: public DiskIODriver {
class DiskIODriver_USBFlash : public DiskIODriver {
private:
uint32_t pos;

Expand All @@ -62,11 +62,11 @@ class DiskIODriver_USBFlash: public DiskIODriver {

inline bool readStart(const uint32_t block) { pos = block; return isReady(); }
inline bool readData(uint8_t *dst) { return readBlock(pos++, dst); }
inline bool readStop() const { return true; }
inline bool readStop() { return true; }

inline bool writeStart(const uint32_t block, const uint32_t) { pos = block; return isReady(); }
inline bool writeData(const uint8_t *src) { return writeBlock(pos++, src); }
inline bool writeStop() const { return true; }
inline bool writeStop() { return true; }

bool readBlock(uint32_t block, uint8_t *dst);
bool writeBlock(uint32_t blockNumber, const uint8_t *src);
Expand Down

0 comments on commit 6543d02

Please sign in to comment.