Add CFI option to SNES repro menu

Only tested with 29LV640 on Chinese LoROM repro.
This commit is contained in:
sanni 2024-06-13 16:43:20 +02:00 committed by GitHub
parent 8535552b9a
commit 27a213a3c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 2950 additions and 2724 deletions

View File

@ -1,489 +1,489 @@
/******************************************************************** /********************************************************************
Open Source Cartridge Reader Open Source Cartridge Reader
********************************************************************/ ********************************************************************/
#ifndef CONFIG_H_ #ifndef CONFIG_H_
#define CONFIG_H_ #define CONFIG_H_
/***** FIRMWARE CONFIGURATION ************************************** /***** FIRMWARE CONFIGURATION **************************************
Add or remove the "//" in front of items to toggle them. Add or remove the "//" in front of items to toggle them.
Disabled: Disabled:
//#define HW5 //#define HW5
Enabled: Enabled:
#define HW5 #define HW5
Things in ** blocks like this are comments. Changing them doesn't Things in ** blocks like this are comments. Changing them doesn't
affect the firmware that is flashed to your OSCR. affect the firmware that is flashed to your OSCR.
If you only get a blank screen or "Press Button" message after If you only get a blank screen or "Press Button" message after
flashing you have enabled too many modules. flashing you have enabled too many modules.
********************************************************************/ ********************************************************************/
/*==== HARDWARE VERSION ===========================================*/ /*==== HARDWARE VERSION ===========================================*/
/* /*
Choose your hardware version: Choose your hardware version:
*/ */
//#define HW5 //#define HW5
//#define HW4 //#define HW4
//#define HW3 //#define HW3
//#define HW2 //#define HW2
//#define HW1 //#define HW1
//#define SERIAL_MONITOR //#define SERIAL_MONITOR
/****/ /****/
/*==== HARDWARE MODULES ===========================================*/ /*==== HARDWARE MODULES ===========================================*/
/* [ Automatic Voltage Selection ---------------------------------- ] /* [ Automatic Voltage Selection ---------------------------------- ]
Enable this if you have the VSELECT module. Enable this if you have the VSELECT module.
*/ */
//#define ENABLE_VSELECT //#define ENABLE_VSELECT
/****/ /****/
/* [ Clock Generator ---------------------------------------------- ] /* [ Clock Generator ---------------------------------------------- ]
Enable this if you have the clock generator module. This will Enable this if you have the clock generator module. This will
automatically be enabled if you selected HW2 or newer above. automatically be enabled if you selected HW2 or newer above.
*/ */
//#define ENABLE_CLOCKGEN //#define ENABLE_CLOCKGEN
/****/ /****/
/* [ Real Time Clock ---------------------------------------------- ] /* [ Real Time Clock ---------------------------------------------- ]
Enable this if you have the RTC module. You can configure the Enable this if you have the RTC module. You can configure the
type later in this file. type later in this file.
*/ */
//#define ENABLE_RTC //#define ENABLE_RTC
/****/ /****/
/*==== GAME SYSTEM CORES ==========================================*/ /*==== GAME SYSTEM CORES ==========================================*/
/* [ Atari 2600 --------------------------------------------------- ] /* [ Atari 2600 --------------------------------------------------- ]
*/ */
//#define ENABLE_2600 //#define ENABLE_2600
/****/ /****/
/* [ Atari 5200 --------------------------------------------------- ] /* [ Atari 5200 --------------------------------------------------- ]
*/ */
//#define ENABLE_5200 //#define ENABLE_5200
/****/ /****/
/* [ Atari 7800 --------------------------------------------------- ] /* [ Atari 7800 --------------------------------------------------- ]
*/ */
//#define ENABLE_7800 //#define ENABLE_7800
/****/ /****/
/* [ Benesse Pocket Challenge W ----------------------------------- ] /* [ Benesse Pocket Challenge W ----------------------------------- ]
*/ */
//#define ENABLE_PCW //#define ENABLE_PCW
/****/ /****/
/* [ C64 --------------------------------------------------- ] /* [ C64 --------------------------------------------------- ]
*/ */
//#define ENABLE_C64 //#define ENABLE_C64
/****/ /****/
/* [ ColecoVision ------------------------------------------------- ] /* [ ColecoVision ------------------------------------------------- ]
*/ */
//#define ENABLE_COLV //#define ENABLE_COLV
/****/ /****/
/* [ Emerson Arcadia 2001 ----------------------------------------- ] /* [ Emerson Arcadia 2001 ----------------------------------------- ]
*/ */
//#define ENABLE_ARC //#define ENABLE_ARC
/****/ /****/
/* [ Fairchild Channel F ------------------------------------------ ] /* [ Fairchild Channel F ------------------------------------------ ]
*/ */
//#define ENABLE_FAIRCHILD //#define ENABLE_FAIRCHILD
/****/ /****/
/* [ Flashrom Programmer for SNES repros -------------------------- ] /* [ Flashrom Programmer for SNES repros -------------------------- ]
*/ */
//#define ENABLE_FLASH #define ENABLE_FLASH
//#define ENABLE_FLASH16 //#define ENABLE_FLASH16
/****/ /****/
/* [ Game Boy (Color) and Advance --------------------------------- ] /* [ Game Boy (Color) and Advance --------------------------------- ]
*/ */
#define ENABLE_GBX #define ENABLE_GBX
/****/ /****/
/* [ Intellivision ------------------------------------------------ ] /* [ Intellivision ------------------------------------------------ ]
*/ */
//#define ENABLE_INTV //#define ENABLE_INTV
/****/ /****/
/* [ Neo Geo Pocket ----------------------------------------------- ] /* [ Neo Geo Pocket ----------------------------------------------- ]
*/ */
//#define ENABLE_NGP //#define ENABLE_NGP
/****/ /****/
/* [ Nintendo 64 -------------------------------------------------- ] /* [ Nintendo 64 -------------------------------------------------- ]
*/ */
#define ENABLE_N64 #define ENABLE_N64
/****/ /****/
/* [ Nintendo Entertainment System/Family Computer ---------------- ] /* [ Nintendo Entertainment System/Family Computer ---------------- ]
*/ */
#define ENABLE_NES #define ENABLE_NES
/****/ /****/
/* [ Magnavox Odyssey 2 ------------------------------------------- ] /* [ Magnavox Odyssey 2 ------------------------------------------- ]
*/ */
//#define ENABLE_ODY2 //#define ENABLE_ODY2
/****/ /****/
/* [ MSX ------------------------------------------- ] /* [ MSX ------------------------------------------- ]
*/ */
//#define ENABLE_MSX //#define ENABLE_MSX
/****/ /****/
/* [ PC Engine/TurboGrafx 16 -------------------------------------- ] /* [ PC Engine/TurboGrafx 16 -------------------------------------- ]
*/ */
//#define ENABLE_PCE //#define ENABLE_PCE
/****/ /****/
/* [ Pokemon Mini -------------------------------------- ] /* [ Pokemon Mini -------------------------------------- ]
*/ */
//#define ENABLE_POKE //#define ENABLE_POKE
/****/ /****/
/* [ Sega Master System/Mark III/Game Gear/SG-1000 ---------------- ] /* [ Sega Master System/Mark III/Game Gear/SG-1000 ---------------- ]
*/ */
#define ENABLE_SMS #define ENABLE_SMS
/****/ /****/
/* [ Sega Mega Drive/Genesis -------------------------------------- ] /* [ Sega Mega Drive/Genesis -------------------------------------- ]
*/ */
#define ENABLE_MD #define ENABLE_MD
/****/ /****/
/* [ Super Famicom SF Memory Cassette ----------------------------- ] /* [ Super Famicom SF Memory Cassette ----------------------------- ]
*/ */
//#define ENABLE_SFM #define ENABLE_SFM
/****/ /****/
/* [ Super Famicom Satellaview ------------------------------------ ] /* [ Super Famicom Satellaview ------------------------------------ ]
*/ */
//#define ENABLE_SV //#define ENABLE_SV
/****/ /****/
/* [ Super Famicom Sufami Turbo ----------------------------------- ] /* [ Super Famicom Sufami Turbo ----------------------------------- ]
*/ */
//#define ENABLE_ST //#define ENABLE_ST
/****/ /****/
/* [ Super Famicom Game Processor RAM Cassette -------------------- ] /* [ Super Famicom Game Processor RAM Cassette -------------------- ]
*/ */
//#define ENABLE_GPC //#define ENABLE_GPC
/****/ /****/
/* [ Super Nintendo ----------------------------------------------- ] /* [ Super Nintendo ----------------------------------------------- ]
*/ */
#define ENABLE_SNES #define ENABLE_SNES
/****/ /****/
/* [ Vectrex --------------------------------------------------- ] /* [ Vectrex --------------------------------------------------- ]
*/ */
//#define ENABLE_VECTREX //#define ENABLE_VECTREX
/****/ /****/
/* [ Virtual Boy -------------------------------------------------- ] /* [ Virtual Boy -------------------------------------------------- ]
*/ */
//#define ENABLE_VBOY //#define ENABLE_VBOY
/****/ /****/
/* [ Watara Supervision ------------------------------------------- ] /* [ Watara Supervision ------------------------------------------- ]
*/ */
//#define ENABLE_WSV //#define ENABLE_WSV
/****/ /****/
/* [ WonderSwan and Benesse Pocket Challenge v2 ------------------- ] /* [ WonderSwan and Benesse Pocket Challenge v2 ------------------- ]
*/ */
//#define ENABLE_WS //#define ENABLE_WS
/****/ /****/
/* [ Super A'can -------------------------------------------------- ] /* [ Super A'can -------------------------------------------------- ]
*/ */
//#define ENABLE_SUPRACAN //#define ENABLE_SUPRACAN
/****/ /****/
/* [ Casio Loopy -------------------------------------------------- ] /* [ Casio Loopy -------------------------------------------------- ]
*/ */
//#define ENABLE_LOOPY //#define ENABLE_LOOPY
/****/ /****/
/*==== FIRMWARE OPTIONS ===========================================*/ /*==== FIRMWARE OPTIONS ===========================================*/
/* [ Config File -------------------------------------------------- ] /* [ Config File -------------------------------------------------- ]
Allow changing some configuration values via a config file. You Allow changing some configuration values via a config file. You
generally can only use the config to set options or disable generally can only use the config to set options or disable
certain featuress. It cannot be used to toggle firmware options certain featuress. It cannot be used to toggle firmware options
on, only off. on, only off.
Note For Developers: See OSCR.* for info. Note For Developers: See OSCR.* for info.
Filename: config.txt Filename: config.txt
*/ */
//#define ENABLE_CONFIG //#define ENABLE_CONFIG
/****/ /****/
/* [ LCD: Background Color ---------------------------------------- ] /* [ LCD: Background Color ---------------------------------------- ]
Set the backlight color of the LCD if you have one. Set the backlight color of the LCD if you have one.
Can be set using config: Can be set using config:
lcd.confColor=1 lcd.confColor=1
lcd.red=0 lcd.red=0
lcd.green=0 lcd.green=0
lcd.blue=0 lcd.blue=0
PARAMETERS: PARAMETERS:
Green, Red, Blue Green, Red, Blue
*/ */
#define OPTION_LCD_BG_COLOR 100, 0, 0 #define OPTION_LCD_BG_COLOR 100, 0, 0
/****/ /****/
/* [ 3.3V Stability Fix (3V3FIX) ---------------------------------- ] /* [ 3.3V Stability Fix (3V3FIX) ---------------------------------- ]
Enable this if you are having stability issues when using 3.3V, Enable this if you are having stability issues when using 3.3V,
works best with VSELECT. works best with VSELECT.
If not using VSELECT, always turn the cart reader on with the If not using VSELECT, always turn the cart reader on with the
voltage switch set to 5V and switch to 5V before selecting a voltage switch set to 5V and switch to 5V before selecting a
cartridge from the menu. cartridge from the menu.
*/ */
//#define ENABLE_3V3FIX //#define ENABLE_3V3FIX
/****/ /****/
/* [ Updater ------------------------------------------------------ ] /* [ Updater ------------------------------------------------------ ]
Disable this if you don't plan to/want to use the firmware Disable this if you don't plan to/want to use the firmware
updater utility. This setting is ignored on hardware versions updater utility. This setting is ignored on hardware versions
other than HW5 and HW3. other than HW5 and HW3.
*/ */
#define ENABLE_UPDATER #define ENABLE_UPDATER
/****/ /****/
/* [ Self Test ---------------------------------------------------- ] /* [ Self Test ---------------------------------------------------- ]
Tests for shorts and other issues in your OSCR build. Tests for shorts and other issues in your OSCR build.
*/ */
#define ENABLE_SELFTEST #define ENABLE_SELFTEST
/****/ /****/
/* [ Logging ------------------------------------------------------ ] /* [ Logging ------------------------------------------------------ ]
Write all info to OSCR_LOG.txt in root dir Write all info to OSCR_LOG.txt in root dir
Can be toggled off using config: Can be toggled off using config:
oscr.logging=0 oscr.logging=0
*/ */
#define ENABLE_GLOBAL_LOG #define ENABLE_GLOBAL_LOG
/****/ /****/
/* [ RTC: IC Type ------------------------------------------------- ] /* [ RTC: IC Type ------------------------------------------------- ]
When the RTC module is installed, choose the type here. This When the RTC module is installed, choose the type here. This
setting is ignored if the RTC option is not enabled. setting is ignored if the RTC option is not enabled.
*/ */
#define DS3231 #define DS3231
//#define DS1307 //#define DS1307
/****/ /****/
/* [ SNES Core/CLOCKGEN: Read Clock Generator Calibration Data ---- ] /* [ SNES Core/CLOCKGEN: Read Clock Generator Calibration Data ---- ]
Toggle clock calibration menu and whether or not to use calibration data from snes_clk.txt Toggle clock calibration menu and whether or not to use calibration data from snes_clk.txt
*/ */
//#define OPTION_CLOCKGEN_CALIBRATION //#define OPTION_CLOCKGEN_CALIBRATION
//#define OPTION_CLOCKGEN_USE_CALIBRATION //#define OPTION_CLOCKGEN_USE_CALIBRATION
/****/ /****/
/* [ MegaDrive/Genesis Core: Compatibility Settings --------------- ] /* [ MegaDrive/Genesis Core: Compatibility Settings --------------- ]
Allows you to create a text file on the SD card called Allows you to create a text file on the SD card called
"mdconf.txt" which you should place the following into: "mdconf.txt" which you should place the following into:
[segaSram16bit] N [segaSram16bit] N
Where N is: Where N is:
0: Output each byte once. Not supported by emulators. (default) 0: Output each byte once. Not supported by emulators. (default)
1: Duplicate each byte. Usable by Kega Fusion. 1: Duplicate each byte. Usable by Kega Fusion.
2: Same as 1 + pad with 0xFF so that the file size is 64KB. 2: Same as 1 + pad with 0xFF so that the file size is 64KB.
** **
** DEPRECATED: Use the config file instead. See below. ** DEPRECATED: Use the config file instead. See below.
** **
*/ */
//#define use_md_conf //#define use_md_conf
/* /*
Configure how the MD core saves are formatted. Configure how the MD core saves are formatted.
Can be set using config: Can be set using config:
md.saveType=0 md.saveType=0
If config is enabled, this option does nothing -- use the config. If config is enabled, this option does nothing -- use the config.
Options: Options:
0: Output each byte once. Not supported by emulators. (default) 0: Output each byte once. Not supported by emulators. (default)
1: Duplicate each byte. Usable by Kega Fusion. 1: Duplicate each byte. Usable by Kega Fusion.
2: Same as 1 + pad with 0xFF so that the file size is 64KB. 2: Same as 1 + pad with 0xFF so that the file size is 64KB.
*/ */
//#define OPTION_MD_DEFAULT_SAVE_TYPE 0 //#define OPTION_MD_DEFAULT_SAVE_TYPE 0
/****/ /****/
/* [ N64 Core: Fast CRC ------------------------------------------- ] /* [ N64 Core: Fast CRC ------------------------------------------- ]
Toggle so the CRC for N64 Roms will be calculated during dumping Toggle so the CRC for N64 Roms will be calculated during dumping
from memory instead of after dumping from SD card, not compatible from memory instead of after dumping from SD card, not compatible
with all Cart Readers with all Cart Readers
*/ */
//#define OPTION_N64_FASTCRC //#define OPTION_N64_FASTCRC
/****/ /****/
/* [ N64 Core: Log Summary ---------------------------------------- ] /* [ N64 Core: Log Summary ---------------------------------------- ]
Enable to save a n64log.txt file with rom info in /N64/ROM Enable to save a n64log.txt file with rom info in /N64/ROM
*/ */
//#define OPTION_N64_SAVESUMMARY //#define OPTION_N64_SAVESUMMARY
/****/ /****/
/*==== PROCESSING =================================================*/ /*==== PROCESSING =================================================*/
/* /*
You probably shouldn't change this stuff! You probably shouldn't change this stuff!
*/ */
#if defined(ENABLE_CONFIG) #if defined(ENABLE_CONFIG)
# define CONFIG_FILE "config.txt" # define CONFIG_FILE "config.txt"
// Define the max length of the key=value pairs // Define the max length of the key=value pairs
// Do your best not to have to increase these. // Do your best not to have to increase these.
# define CONFIG_KEY_MAX 32 # define CONFIG_KEY_MAX 32
# define CONFIG_VALUE_MAX 32 # define CONFIG_VALUE_MAX 32
#endif #endif
#if (defined(HW4) || defined(HW5)) #if (defined(HW4) || defined(HW5))
# define ENABLE_LCD # define ENABLE_LCD
# define ENABLE_NEOPIXEL # define ENABLE_NEOPIXEL
# define ENABLE_ROTARY # define ENABLE_ROTARY
//# define rotate_counter_clockwise //# define rotate_counter_clockwise
# define ENABLE_CLOCKGEN # define ENABLE_CLOCKGEN
# define OPTION_N64_FASTCRC # define OPTION_N64_FASTCRC
# define OPTION_WS_ADAPTER_V2 # define OPTION_WS_ADAPTER_V2
#endif #endif
#if (defined(HW2) || defined(HW3)) #if (defined(HW2) || defined(HW3))
# define ENABLE_OLED # define ENABLE_OLED
# define ENABLE_BUTTON2 # define ENABLE_BUTTON2
# define ENABLE_CLOCKGEN # define ENABLE_CLOCKGEN
# define ENABLE_CA_LED # define ENABLE_CA_LED
# define OPTION_N64_FASTCRC # define OPTION_N64_FASTCRC
#endif #endif
#if defined(HW1) #if defined(HW1)
# define ENABLE_OLED # define ENABLE_OLED
//#define ENABLE_CLOCKGEN //#define ENABLE_CLOCKGEN
//#define OPTION_N64_FASTCRC //#define OPTION_N64_FASTCRC
#endif #endif
#if defined(SERIAL_MONITOR) #if defined(SERIAL_MONITOR)
# define ENABLE_SERIAL # define ENABLE_SERIAL
//#define ENABLE_CLOCKGEN //#define ENABLE_CLOCKGEN
//#define OPTION_N64_FASTCRC //#define OPTION_N64_FASTCRC
#endif #endif
/* Firmware updater only works with HW3 and HW5 */ /* Firmware updater only works with HW3 and HW5 */
#if !(defined(HW5) || defined(HW3)) #if !(defined(HW5) || defined(HW3))
# undef ENABLE_UPDATER # undef ENABLE_UPDATER
#endif #endif
/* End of settings */ /* End of settings */
#endif /* CONFIG_H_ */ #endif /* CONFIG_H_ */

View File

@ -2363,7 +2363,197 @@ void print_Eprom(int numBytes) {
} }
display_Update(); display_Update();
} }
#endif #endif
/******************************************
CFI flashrom functions (copy&paste from GB.ino)
*****************************************/
void sendCFICommand_Flash(byte cmd) {
writeByteCompensated_Flash(0xAAA, 0xaa);
writeByteCompensated_Flash(0x555, 0x55);
writeByteCompensated_Flash(0xAAA, cmd);
}
byte readByteCompensated_Flash(int address) {
byte data = readByte_Flash(address >> (flashX16Mode ? 1 : 0));
if (flashSwitchLastBits) {
return (data & 0b11111100) | ((data << 1) & 0b10) | ((data >> 1) & 0b01);
}
return data;
}
void writeByteCompensated_Flash(int address, byte data) {
if (flashSwitchLastBits) {
data = (data & 0b11111100) | ((data << 1) & 0b10) | ((data >> 1) & 0b01);
}
writeByte_Flash(address >> (flashX16Mode ? 1 : 0), data);
}
void startCFIMode_Flash(boolean x16Mode) {
if (x16Mode) {
writeByte_Flash(0x555, 0xf0); //x16 mode reset command
delay(500);
writeByte_Flash(0x555, 0xf0); //Double reset to get out of possible Autoselect + CFI mode
delay(500);
writeByte_Flash(0x55, 0x98); //x16 CFI Query command
} else {
writeByte_Flash(0xAAA, 0xf0); //x8 mode reset command
delay(100);
writeByte_Flash(0xAAA, 0xf0); //Double reset to get out of possible Autoselect + CFI mode
delay(100);
writeByte_Flash(0xAA, 0x98); //x8 CFI Query command
}
}
void identifyCFI_Flash() {
display_Clear();
// Reset flash
dataOut();
writeByteCompensated_Flash(0xAAA, 0xf0);
delay(100);
// Trying x8 mode first
startCFIMode_Flash(false);
dataIn8();
char cfiQRYx8[7];
char cfiQRYx16[7];
sprintf(cfiQRYx8, "%02X%02X%02X", readByte_Flash(0x20), readByte_Flash(0x22), readByte_Flash(0x24));
sprintf(cfiQRYx16, "%02X%02X%02X", readByte_Flash(0x10), readByte_Flash(0x11), readByte_Flash(0x12));
if (strcmp(cfiQRYx8, "515259") == 0) {
println_Msg(F("Normal CFI x8 Mode"));
flashX16Mode = false;
flashSwitchLastBits = false;
} else if (strcmp(cfiQRYx8, "52515A") == 0) { // QRY in x8 mode with switched last bit
println_Msg(F("Switched CFI x8 Mode"));
flashX16Mode = false;
flashSwitchLastBits = true;
} else if (strcmp(cfiQRYx16, "515259") == 0) { // QRY in x16 mode
println_Msg(F("Normal CFI x16 Mode"));
flashX16Mode = true;
flashSwitchLastBits = false;
} else if (strcmp(cfiQRYx16, "52515A") == 0) { // QRY in x16 mode with switched last bit
println_Msg(F("Switched CFI x16 Mode"));
flashX16Mode = true;
flashSwitchLastBits = true;
} else {
// Try x16 mode next
startCFIMode(true);
sprintf(cfiQRYx16, "%02X%02X%02X", readByte_Flash(0x10), readByte_Flash(0x11), readByte_Flash(0x12));
if (strcmp(cfiQRYx16, "515259") == 0) { // QRY in x16 mode
println_Msg(F("Normal CFI x16 Mode"));
flashX16Mode = true;
flashSwitchLastBits = false;
} else if (strcmp(cfiQRYx16, "52515A") == 0) { // QRY in x16 mode with switched last bit
println_Msg(F("Switched CFI x16 Mode"));
flashX16Mode = true;
flashSwitchLastBits = true;
} else {
println_Msg(F("CFI Query failed!"));
display_Update();
wait();
return;
}
}
flashBanks = 1 << (readByteCompensated_Flash(0x4E) - 14); // - flashX16Mode);
// Reset flash
dataOut();
writeByteCompensated_Flash(0xAAA, 0xf0);
dataIn8();
delay(100);
display_Update();
}
// Write flashrom
void writeCFI_Flash() {
filePath[0] = '\0';
sd.chdir("/");
fileBrowser(F("Select file"));
display_Clear();
if (openFlashFile()) {
// Reset flash
dataOut();
writeByteCompensated_Flash(0xAAA, 0xf0);
dataIn8();
delay(100);
// Reset flash
dataOut();
writeByte_Flash(0x555, 0xf0);
dataIn8();
delay(100);
println_Msg(F("Erasing..."));
display_Update();
// Erase flash
dataOut();
sendCFICommand_Flash(0x80);
sendCFICommand_Flash(0x10);
dataIn8();
// Read the status register
byte statusReg = readByte_Flash(0);
// After a completed erase D7 will output 1
while ((statusReg & 0x80) != 0x80) {
// Blink led
blinkLED();
delay(100);
// Update Status
statusReg = readByte_Flash(0);
}
println_Msg(F("Writing flash"));
display_Update();
//Initialize progress bar
uint32_t processedProgressBar = 0;
uint32_t totalProgressBar = (uint32_t)fileSize;
draw_progressbar(0, totalProgressBar);
for (unsigned long currAddr = 0; currAddr < fileSize; currAddr += 512) {
myFile.read(sdBuffer, 512);
// Blink led
if (currAddr % 4096 == 0)
blinkLED();
for (int currByte = 0; currByte < 512; currByte++) {
// Write command sequence
dataOut();
sendCFICommand_Flash(0xa0);
// Write current byte
writeByte_Flash(currAddr + currByte, sdBuffer[currByte]);
dataIn8();
// Read the status register
byte statusReg = readByte_Flash(currAddr + currByte);
while ((statusReg & 0x80) != (sdBuffer[currByte] & 0x80)) {
statusReg = readByte_Flash(currAddr + currByte);
}
}
// update progress bar
processedProgressBar += 512;
draw_progressbar(processedProgressBar, totalProgressBar);
}
// Close the file:
myFile.close();
}
// Reset flash
dataOut();
writeByteCompensated_Flash(0xAAA, 0xf0);
delay(100);
dataIn8();
}
#endif #endif
//****************************************** //******************************************

File diff suppressed because it is too large Load Diff