ArduinoAm29F010

Changeset

9:082a12881269
2015-01-20 Paul Boddie raw files shortlog changelog graph Added a simple timeout to prevent the program from hanging.
ArduinoAm29F010.cpp (file)
     1.1 --- a/ArduinoAm29F010.cpp	Tue Jan 20 00:58:34 2015 +0100
     1.2 +++ b/ArduinoAm29F010.cpp	Tue Jan 20 01:40:55 2015 +0100
     1.3 @@ -163,7 +163,7 @@
     1.4  
     1.5  bool waitForCompletion(int high, int low, int written)
     1.6  {
     1.7 -    int data;
     1.8 +    int data, then = millis();
     1.9  
    1.10      do
    1.11      {
    1.12 @@ -171,7 +171,8 @@
    1.13          data = readOp(high, low);
    1.14      } while (
    1.15          ((data & 0x80) != (written & 0x80)) &&
    1.16 -        ((data & 0x20) == 0)
    1.17 +        ((data & 0x20) == 0) &&
    1.18 +        (millis() - then < 2000)
    1.19          );
    1.20  
    1.21      return readOp(high, low) == written;