Pārlūkot izejas kodu

begin() returns false when chip not detected, fixes #53

main
PaulStoffregen pirms 6 gadiem
vecāks
revīzija
754e1d025c
4 mainītis faili ar 17 papildinājumiem un 3 dzēšanām
  1. +3
    -0
      SerialFlashChip.cpp
  2. +7
    -1
      examples/CopyFromSerial/CopyFromSerial.ino
  3. +6
    -1
      examples/EraseEverything/EraseEverything.ino
  4. +1
    -1
      examples/RawHardwareTest/RawHardwareTest.ino

+ 3
- 0
SerialFlashChip.cpp Parādīt failu

@@ -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) {

+ 7
- 1
examples/CopyFromSerial/CopyFromSerial.ino Parādīt failu

@@ -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];

+ 6
- 1
examples/EraseEverything/EraseEverything.ino Parādīt failu

@@ -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);

+ 1
- 1
examples/RawHardwareTest/RawHardwareTest.ino Parādīt failu

@@ -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();

Notiek ielāde…
Atcelt
Saglabāt