mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-14 08:55:06 +01:00
V27D: Fixed 16bit flashrom functions for writing 29L3211 and similar
Seems like my last fix did break more than it did repair but this time everything should work.
This commit is contained in:
parent
90fad59080
commit
00f4720f76
@ -2,8 +2,8 @@
|
|||||||
Cartridge Reader for Arduino Mega2560
|
Cartridge Reader for Arduino Mega2560
|
||||||
|
|
||||||
Author: sanni
|
Author: sanni
|
||||||
Date: 2017-06-28
|
Date: 2017-07-13
|
||||||
Version: V27B
|
Version: V27D
|
||||||
|
|
||||||
SD lib: https://github.com/greiman/SdFat
|
SD lib: https://github.com/greiman/SdFat
|
||||||
LCD lib: https://github.com/adafruit/Adafruit_SSD1306
|
LCD lib: https://github.com/adafruit/Adafruit_SSD1306
|
||||||
@ -34,7 +34,7 @@
|
|||||||
YamaArashi - GBA flashrom bank switch command
|
YamaArashi - GBA flashrom bank switch command
|
||||||
|
|
||||||
**********************************************************************************/
|
**********************************************************************************/
|
||||||
char ver[5] = "V27B";
|
char ver[5] = "V27D";
|
||||||
|
|
||||||
/******************************************
|
/******************************************
|
||||||
Define Output
|
Define Output
|
||||||
|
@ -1019,7 +1019,7 @@ void writeFlash16() {
|
|||||||
|
|
||||||
// Write one full page at a time
|
// Write one full page at a time
|
||||||
for (byte c = 0; c < 64; c++) {
|
for (byte c = 0; c < 64; c++) {
|
||||||
word currWord = ( ( sdBuffer[d] & 0xFF ) << 8 ) | ( sdBuffer[d + 1] & 0xFF );
|
word currWord = ( ( sdBuffer[d + 1] & 0xFF ) << 8 ) | ( sdBuffer[d] & 0xFF );
|
||||||
writeWord_Flash(currByte + c, currWord);
|
writeWord_Flash(currByte + c, currWord);
|
||||||
d += 2;
|
d += 2;
|
||||||
}
|
}
|
||||||
@ -1078,7 +1078,7 @@ void writeFlash16_29F1601() {
|
|||||||
|
|
||||||
// Write one full page at a time
|
// Write one full page at a time
|
||||||
for (byte c = 0; c < 64; c++) {
|
for (byte c = 0; c < 64; c++) {
|
||||||
word currWord = ( ( sdBuffer[d] & 0xFF ) << 8 ) | ( sdBuffer[d + 1] & 0xFF );
|
word currWord = ( ( sdBuffer[d + 1] & 0xFF ) << 8 ) | ( sdBuffer[d] & 0xFF );
|
||||||
writeWord_Flash(currByte + c, currWord);
|
writeWord_Flash(currByte + c, currWord);
|
||||||
|
|
||||||
if (c == 63) {
|
if (c == 63) {
|
||||||
@ -1195,7 +1195,7 @@ void verifyFlash16() {
|
|||||||
//fill sdBuffer
|
//fill sdBuffer
|
||||||
myFile.read(sdBuffer, 512);
|
myFile.read(sdBuffer, 512);
|
||||||
for (int c = 0; c < 256; c++) {
|
for (int c = 0; c < 256; c++) {
|
||||||
word currWord = ((sdBuffer[d] << 8) | sdBuffer[d + 1]);
|
word currWord = ((sdBuffer[d + 1] << 8) | sdBuffer[d]);
|
||||||
|
|
||||||
if (readWord_Flash(currByte + c) != currWord) {
|
if (readWord_Flash(currByte + c) != currWord) {
|
||||||
blank++;
|
blank++;
|
||||||
@ -1254,10 +1254,10 @@ void readFlash16() {
|
|||||||
for (word c = 0; c < 256; c++) {
|
for (word c = 0; c < 256; c++) {
|
||||||
word currWord = readWord_Flash(currByte + c);
|
word currWord = readWord_Flash(currByte + c);
|
||||||
// Split word into two bytes
|
// Split word into two bytes
|
||||||
// Left
|
|
||||||
sdBuffer[d] = (( currWord >> 8 ) & 0xFF);
|
|
||||||
// Right
|
// Right
|
||||||
sdBuffer[d + 1] = (currWord & 0xFF);
|
sdBuffer[d + 1] = (( currWord >> 8 ) & 0xFF);
|
||||||
|
// Left
|
||||||
|
sdBuffer[d] = (currWord & 0xFF);
|
||||||
d += 2;
|
d += 2;
|
||||||
}
|
}
|
||||||
myFile.write(sdBuffer, 512);
|
myFile.write(sdBuffer, 512);
|
||||||
@ -1277,30 +1277,31 @@ void printFlash16(int numBytes) {
|
|||||||
short_val = ( ( left_byte & 0xFF ) << 8 ) | ( right_byte & 0xFF );
|
short_val = ( ( left_byte & 0xFF ) << 8 ) | ( right_byte & 0xFF );
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char buffer[3];
|
char buf[3];
|
||||||
|
|
||||||
for (int currByte = 0; currByte < numBytes / 2; currByte += 5) {
|
for (int currByte = 0; currByte < numBytes / 2; currByte += 5) {
|
||||||
|
// 5 words per line
|
||||||
for (int c = 0; c < 5; c++) {
|
for (int c = 0; c < 5; c++) {
|
||||||
|
|
||||||
word currWord = readWord_Flash(currByte + c);
|
word currWord = readWord_Flash(currByte + c);
|
||||||
|
|
||||||
// Split word into two bytes
|
// Split word into two bytes
|
||||||
byte right_byte = currWord & 0xFF;
|
byte left_byte = currWord & 0xFF;
|
||||||
byte left_byte = ( currWord >> 8 ) & 0xFF;
|
byte right_byte = ( currWord >> 8 ) & 0xFF;
|
||||||
|
|
||||||
itoa (left_byte, buffer, 16);
|
|
||||||
for (int i = 0; i < 2 - strlen(buffer); i++) {
|
sprintf (buf, "%x", left_byte);
|
||||||
print_Msg('0');
|
for (int i = 0; i < 2 - strlen(buf); i++) {
|
||||||
|
print_Msg("0");
|
||||||
}
|
}
|
||||||
// Now print the significant bits
|
// Now print the significant bits
|
||||||
print_Msg(buffer);
|
print_Msg(buf);
|
||||||
|
|
||||||
itoa (right_byte, buffer, 16);
|
sprintf (buf, "%x", right_byte);
|
||||||
for (int i = 0; i < 2 - strlen(buffer); i++) {
|
for (int i = 0; i < 2 - strlen(buf); i++) {
|
||||||
print_Msg('0');
|
print_Msg("0");
|
||||||
}
|
}
|
||||||
// Now print the significant bits
|
// Now print the significant bits
|
||||||
print_Msg(buffer);
|
print_Msg(buf);
|
||||||
}
|
}
|
||||||
println_Msg("");
|
println_Msg("");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user