| @@ -351,6 +351,9 @@ bool SerialFlashChip::begin(uint8_t pin) | |||
| pinMode(pin, OUTPUT); | |||
| CSRELEASE(); | |||
| 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; | |||
| size = capacity(id); | |||
| if (size > 16777216) { | |||
| @@ -94,7 +94,13 @@ void setup(){ | |||
| //SPI.setMOSI(MOSI); // uncomment these if using the alternate pins | |||
| //SPI.setMISO(MISO); | |||
| //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... | |||
| uint8_t id[5]; | |||
| @@ -25,7 +25,12 @@ void setup() { | |||
| while (!Serial && (millis() - startMillis < 10000)) ; | |||
| 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]; | |||
| SerialFlash.readID(id); | |||
| unsigned long size = SerialFlash.capacity(id); | |||
| @@ -45,7 +45,7 @@ void setup() { | |||
| delay(100); | |||
| Serial.println("Raw SerialFlash Hardware Test"); | |||
| SerialFlash.begin(FlashChipSelect); | |||
| SerialFlash.begin(FlashChipSelect); // proceed even if begin() fails | |||
| if (test()) { | |||
| Serial.println(); | |||