mirror of
https://github.com/sanni/cartreader.git
synced 2025-02-26 01:23:32 +01:00
writeFlash29F032: Retry writing, for when /RESET is not connected (floating)
This commit is contained in:
parent
712c4cc83d
commit
2096ec7597
@ -933,21 +933,58 @@ void writeFlash29F032() {
|
|||||||
// Set data pins to output
|
// Set data pins to output
|
||||||
dataOut();
|
dataOut();
|
||||||
|
|
||||||
|
// Retry writing, for when /RESET is not connected (floating)
|
||||||
|
int dq5failcnt = 0;
|
||||||
|
int noread = 0;
|
||||||
// Fill sdBuffer
|
// Fill sdBuffer
|
||||||
for (unsigned long currByte = 0; currByte < fileSize; currByte += 512) {
|
for (unsigned long currByte = 0; currByte < fileSize; currByte += 512) {
|
||||||
|
// if (currByte >= 0) {
|
||||||
|
// print_Msg(currByte);
|
||||||
|
// print_Msg(F(" "));
|
||||||
|
// print_Msg(dq5failcnt);
|
||||||
|
// println_Msg(F(""));
|
||||||
|
// }
|
||||||
|
if (!noread) {
|
||||||
myFile.read(sdBuffer, 512);
|
myFile.read(sdBuffer, 512);
|
||||||
|
}
|
||||||
// Blink led
|
// Blink led
|
||||||
if (currByte % 2048 == 0)
|
if (currByte % 2048 == 0)
|
||||||
PORTB ^= (1 << 4);
|
PORTB ^= (1 << 4);
|
||||||
|
|
||||||
|
noInterrupts();
|
||||||
|
int blockfailcnt = 0;
|
||||||
for (int c = 0; c < 512; c++) {
|
for (int c = 0; c < 512; c++) {
|
||||||
|
uint8_t datum = sdBuffer[c];
|
||||||
|
dataIn8();
|
||||||
|
uint8_t d = readByte_Flash(currByte + c);
|
||||||
|
dataOut();
|
||||||
|
if (d == datum || datum == 0xFF) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// Write command sequence
|
// Write command sequence
|
||||||
writeByte_Flash(0x555, 0xaa);
|
writeByte_Flash(0x555, 0xaa);
|
||||||
writeByte_Flash(0x2aa, 0x55);
|
writeByte_Flash(0x2aa, 0x55);
|
||||||
writeByte_Flash(0x555, 0xa0);
|
writeByte_Flash(0x555, 0xa0);
|
||||||
// Write current byte
|
// Write current byte
|
||||||
writeByte_Flash(currByte + c, sdBuffer[c]);
|
writeByte_Flash(currByte + c, datum);
|
||||||
busyCheck29F032(sdBuffer[c]);
|
if (busyCheck29F032(currByte + c, datum)) {
|
||||||
|
dq5failcnt++;
|
||||||
|
blockfailcnt++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
interrupts();
|
||||||
|
if (blockfailcnt > 0) {
|
||||||
|
print_Msg(F("Failures at "));
|
||||||
|
print_Msg(currByte);
|
||||||
|
print_Msg(F(": "));
|
||||||
|
print_Msg(blockfailcnt);
|
||||||
|
println_Msg(F(""));
|
||||||
|
dq5failcnt -= blockfailcnt;
|
||||||
|
currByte -= 512;
|
||||||
|
delay(100);
|
||||||
|
noread = 1;
|
||||||
|
} else {
|
||||||
|
noread = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Set data pins to input again
|
// Set data pins to input again
|
||||||
|
Loading…
x
Reference in New Issue
Block a user