Make CardReader class static (#12451)

* Make CardReader a static class
* Make CardReader flags into bitfields
This commit is contained in:
Scott Lahteine
2018-11-16 22:39:16 -06:00
committed by GitHub
parent 3e9ffaddb6
commit 66580f32c2
15 changed files with 281 additions and 190 deletions

View File

@ -19,7 +19,7 @@ void sd_mmc_spi_mem_init(void) {
}
Ctrl_status sd_mmc_spi_test_unit_ready(void) {
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.cardOK)
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.flag.cardOK)
return CTRL_NO_PRESENT;
return CTRL_GOOD;
}
@ -27,7 +27,7 @@ Ctrl_status sd_mmc_spi_test_unit_ready(void) {
// NOTE: This function is defined as returning the address of the last block
// in the card, which is cardSize() - 1
Ctrl_status sd_mmc_spi_read_capacity(uint32_t *nb_sector) {
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.cardOK)
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.flag.cardOK)
return CTRL_NO_PRESENT;
*nb_sector = card.getSd2Card().cardSize() - 1;
return CTRL_GOOD;
@ -42,7 +42,7 @@ bool sd_mmc_spi_wr_protect(void) {
}
bool sd_mmc_spi_removal(void) {
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.cardOK)
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.flag.cardOK)
return true;
return false;
}
@ -61,7 +61,7 @@ uint8_t sector_buf[SD_MMC_BLOCK_SIZE];
// #define DEBUG_MMC
Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector) {
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.cardOK)
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.flag.cardOK)
return CTRL_NO_PRESENT;
#ifdef DEBUG_MMC
@ -95,7 +95,7 @@ Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector) {
}
Ctrl_status sd_mmc_spi_usb_write_10(uint32_t addr, uint16_t nb_sector) {
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.cardOK)
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.flag.cardOK)
return CTRL_NO_PRESENT;
#ifdef DEBUG_MMC

View File

@ -106,7 +106,7 @@ void HAL_idletask(void) {
// the disk if Marlin has it mounted. Unfortuately there is currently no way
// to unmount the disk from the LCD menu.
// if (IS_SD_PRINTING() || IS_SD_FILE_OPEN())
if (card.cardOK)
if (card.flag.cardOK)
MSC_Aquire_Lock();
else
MSC_Release_Lock();

View File

@ -41,7 +41,7 @@ char HAL_STM32F1_eeprom_content[HAL_STM32F1_EEPROM_SIZE];
char eeprom_filename[] = "eeprom.dat";
bool PersistentStore::access_start() {
if (!card.cardOK) return false;
if (!card.flag.cardOK) return false;
int16_t bytes_read = 0;
constexpr char eeprom_zero = 0xFF;
card.openFile(eeprom_filename, true);
@ -54,7 +54,7 @@ bool PersistentStore::access_start() {
}
bool PersistentStore::access_finish() {
if (!card.cardOK) return false;
if (!card.flag.cardOK) return false;
card.openFile(eeprom_filename, true);
int16_t bytes_written = card.write(HAL_STM32F1_eeprom_content, HAL_STM32F1_EEPROM_SIZE);
card.closefile();