Remove toggling CS in GB flash function

This commit is contained in:
sanni 2022-04-11 00:28:18 +02:00
parent 1cc7712b9e
commit b501556954
2 changed files with 23 additions and 24 deletions

View File

@ -4,7 +4,7 @@
This project represents a community-driven effort to provide This project represents a community-driven effort to provide
an easy to build and easy to modify cartridge dumper. an easy to build and easy to modify cartridge dumper.
Date: 10.04.2022 Date: 11.04.2022
Version: 8.2 Version: 8.2
SD lib: https://github.com/greiman/SdFat SD lib: https://github.com/greiman/SdFat

View File

@ -532,17 +532,17 @@ void writeByte_GB(int myAddress, byte myData) {
// Pull WR(PH5) low // Pull WR(PH5) low
PORTH &= ~(1 << 5); PORTH &= ~(1 << 5);
// Leave WE low for at least 60ns // Leave WR low for at least 60ns
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t"); __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t");
// Pull WR(PH5) HIGH // Pull WR(PH5) HIGH
PORTH |= (1 << 5); PORTH |= (1 << 5);
// Leave WE high for at least 50ns // Leave WR high for at least 50ns
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t"); __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t");
} }
// Triggers CLK pin // Triggers CS and CLK pin
byte readByteSRAM_GB(word myAddress) { byte readByteSRAM_GB(word myAddress) {
PORTF = myAddress & 0xFF; PORTF = myAddress & 0xFF;
PORTK = (myAddress >> 8) & 0xFF; PORTK = (myAddress >> 8) & 0xFF;
@ -574,7 +574,7 @@ byte readByteSRAM_GB(word myAddress) {
return tempByte; return tempByte;
} }
// Triggers CLK pin // Triggers CS and CLK pin
void writeByteSRAM_GB(int myAddress, byte myData) { void writeByteSRAM_GB(int myAddress, byte myData) {
PORTF = myAddress & 0xFF; PORTF = myAddress & 0xFF;
PORTK = (myAddress >> 8) & 0xFF; PORTK = (myAddress >> 8) & 0xFF;
@ -597,7 +597,7 @@ void writeByteSRAM_GB(int myAddress, byte myData) {
PORTH &= ~(1 << 5); PORTH &= ~(1 << 5);
} }
// Leave WE low for at least 60ns // Leave WR low for at least 60ns
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t"); __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t");
if (romType == 252) { if (romType == 252) {
@ -615,7 +615,7 @@ void writeByteSRAM_GB(int myAddress, byte myData) {
PORTH |= (1 << 3) | (1 << 1); PORTH |= (1 << 3) | (1 << 1);
} }
// Leave WE high for at least 50ns // Leave WR high for at least 50ns
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t"); __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t");
} }
@ -1172,20 +1172,19 @@ void writeFlash29F_GB(byte MBC, boolean flashErase) {
writeByte_GB(0x2aa, 0x55); writeByte_GB(0x2aa, 0x55);
writeByte_GB(0x555, 0x10); writeByte_GB(0x555, 0x10);
dataIn_GB(); // Set data pins to input
dataIn();
// Read the status register // Set OE/RD(PH6) LOW
byte statusReg = readByte_GB(0); PORTH &= ~(1 << 6);
// After a completed erase D7 will output 1 // After a completed erase D7 will output 1
while ((statusReg & 0x80) != 0x80) { while ((PINC & 0x80) != 0x80) {
// Blink led
blinkLED();
delay(100);
// Update Status
statusReg = readByte_GB(0);
} }
// Switch OE/RD(PH6) to HIGH
PORTH |= (1 << 6);
// Blankcheck // Blankcheck
println_Msg(F("Blankcheck")); println_Msg(F("Blankcheck"));
display_Update(); display_Update();
@ -1256,15 +1255,15 @@ void writeFlash29F_GB(byte MBC, boolean flashErase) {
// Set data pins to input // Set data pins to input
dataIn(); dataIn();
// Setting CS(PH3) and OE/RD(PH6) LOW // Set OE/RD(PH6) LOW
PORTH &= ~((1 << 3) | (1 << 6)); PORTH &= ~(1 << 6);
// Busy check // Busy check
while ((PINC & 0x80) != (sdBuffer[currByte] & 0x80)) { while ((PINC & 0x80) != (sdBuffer[currByte] & 0x80)) {
} }
// Switch CS(PH3) and OE/RD(PH6) to HIGH // Switch OE/RD(PH6) to HIGH
PORTH |= (1 << 3) | (1 << 6); PORTH |= (1 << 6);
// Set data pins to output // Set data pins to output
dataOut(); dataOut();
@ -1311,15 +1310,15 @@ void writeFlash29F_GB(byte MBC, boolean flashErase) {
// Set data pins to input // Set data pins to input
dataIn(); dataIn();
// Setting CS(PH3) and OE/RD(PH6) LOW // Set OE/RD(PH6) LOW
PORTH &= ~((1 << 3) | (1 << 6)); PORTH &= ~(1 << 6);
// Busy check // Busy check
while ((PINC & 0x80) != (sdBuffer[currByte] & 0x80)) { while ((PINC & 0x80) != (sdBuffer[currByte] & 0x80)) {
} }
// Switch CS(PH3) and OE/RD(PH6) to HIGH // Switch OE/RD(PH6) to HIGH
PORTH |= (1 << 3) | (1 << 6); PORTH |= (1 << 6);
// Set data pins to output // Set data pins to output
dataOut(); dataOut();