pinMode(pin, OUTPUT); | pinMode(pin, OUTPUT); | ||||
CSRELEASE(); | CSRELEASE(); | ||||
readID(id); | readID(id); | ||||
if ((id[0]==0 && id[1]==0 && id[2]==0) || (id[0]==255 && id[1]==255 && id[2]==255)) { | |||||
return false; | |||||
} | |||||
f = 0; | f = 0; | ||||
size = capacity(id); | size = capacity(id); | ||||
if (size > 16777216) { | if (size > 16777216) { |
//SPI.setMOSI(MOSI); // uncomment these if using the alternate pins | //SPI.setMOSI(MOSI); // uncomment these if using the alternate pins | ||||
//SPI.setMISO(MISO); | //SPI.setMISO(MISO); | ||||
//SPI.setSCK(SCK); | //SPI.setSCK(SCK); | ||||
SerialFlash.begin(CSPIN); | |||||
if (!SerialFlash.begin(CSPIN)) { | |||||
while (1) { | |||||
Serial.println("Unable to access SPI Flash chip"); | |||||
delay(1000); | |||||
} | |||||
} | |||||
//We start by formatting the flash... | //We start by formatting the flash... | ||||
uint8_t id[5]; | uint8_t id[5]; |
while (!Serial && (millis() - startMillis < 10000)) ; | while (!Serial && (millis() - startMillis < 10000)) ; | ||||
delay(100); | delay(100); | ||||
SerialFlash.begin(FlashChipSelect); | |||||
if (!SerialFlash.begin(FlashChipSelect)) { | |||||
while (1) { | |||||
Serial.println("Unable to access SPI Flash chip"); | |||||
delay(1000); | |||||
} | |||||
} | |||||
unsigned char id[5]; | unsigned char id[5]; | ||||
SerialFlash.readID(id); | SerialFlash.readID(id); | ||||
unsigned long size = SerialFlash.capacity(id); | unsigned long size = SerialFlash.capacity(id); |
delay(100); | delay(100); | ||||
Serial.println("Raw SerialFlash Hardware Test"); | Serial.println("Raw SerialFlash Hardware Test"); | ||||
SerialFlash.begin(FlashChipSelect); | |||||
SerialFlash.begin(FlashChipSelect); // proceed even if begin() fails | |||||
if (test()) { | if (test()) { | ||||
Serial.println(); | Serial.println(); |