# HG changeset patch # User Paul Boddie # Date 1421778803 -3600 # Node ID 44bf682cef17b41df3c6a934e910b769baee5477 # Parent 7b4963a03d602f60040d03b546be7b81245de26d Changed the completion detection to possibly be more correct. Added serial flush and bad command echoing. diff -r 7b4963a03d60 -r 44bf682cef17 ArduinoAm29F010.cpp --- a/ArduinoAm29F010.cpp Tue Jan 20 14:52:20 2015 +0100 +++ b/ArduinoAm29F010.cpp Tue Jan 20 19:33:23 2015 +0100 @@ -165,16 +165,24 @@ { int data, then = millis(); + setDataIn(); + digitalWrite(CE, LOW); + digitalWrite(OE, LOW); + do { delay(10); - data = readOp(high, low); + data = sampleData(); } while ( ((data & 0x80) != (written & 0x80)) && ((data & 0x20) == 0) && (millis() - then < 2000) ); + digitalWrite(OE, HIGH); + digitalWrite(CE, HIGH); + setDataOut(); + delay(10); return readOp(high, low) == written; } @@ -299,9 +307,11 @@ break; default: - Serial.println("?"); + Serial.println(inbuffer[0]); break; } + + Serial.flush(); } }