void sdError_P(const char* str) { cout << pstr("error: "); cout << pgm(str) << endl; if (card.errorCode()) { cout << pstr("SD error: ") << hex << int(card.errorCode()); cout << ',' << int(card.errorData()) << dec << endl; } while (1); }
void error_P(const char* str) { PgmPrint("error: "); SerialPrintln_P(str); if (card.errorCode()) { PgmPrint("SD error: "); Serial.print(card.errorCode(), HEX); Serial.print(','); Serial.println(card.errorData(), HEX); } while(1); }
void error(const char* str) { Serial.print("error: "); Serial.println(str); if (card.errorCode()) { Serial.print("SD error: "); Serial.print(card.errorCode(), HEX); Serial.print(','); Serial.println(card.errorData(), HEX); } while(1) { SPARK_WLAN_Loop(); }; }
// ---------------------------------------------------------------------------- // Scan the SD card and open the volume // Set reg[STATUS] to FDC_ST_NOTREADY if no card present // ---------------------------------------------------------------------------- void scanSD() { if (!card.init(SPI_FULL_SPEED, SD_CHIP_SELECT_PIN)) { Serial.print("Init failed, error:"); Serial.println(card.errorCode()); mb8877.reg[STATUS] = FDC_ST_NOTREADY; return; } #ifdef SD_DEBUG Serial.print("\nCard type: "); switch(card.type()) { case SD_CARD_TYPE_SD1: Serial.println("SD1"); break; case SD_CARD_TYPE_SD2: Serial.println("SD2"); break; case SD_CARD_TYPE_SDHC: Serial.println("SDHC"); break; default: Serial.println("Unknown"); } #endif if (!volume.init(card)) { #ifdef SD_DEBUG Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card"); #endif mb8877.reg[STATUS] = FDC_ST_NOTREADY; return; } #ifdef SD_DEBUG // ----- Print the type and size of the first FAT-type volume Serial.print("\nVolume type is FAT"); Serial.println(volume.fatType(), DEC); Serial.println(); long volumesize; volumesize = volume.blocksPerCluster(); // clusters are collections of blocks volumesize *= volume.clusterCount(); // we'll have a lot of clusters volumesize *= 512; // SD card blocks are always 512 bytes Serial.print("Volume size (bytes): "); Serial.println(volumesize); #endif root.openRoot(volume); mb8877.reg[STATUS]=0x00; }