mirror of
https://github.com/sanni/cartreader.git
synced 2024-12-25 20:41:52 +01:00
V6.0: Update SdFat to Version 2
This commit is contained in:
parent
f22b156849
commit
d7cc26c560
@ -1,8 +1,8 @@
|
|||||||
/**********************************************************************************
|
/**********************************************************************************
|
||||||
Cartridge Reader for Arduino Mega2560
|
Cartridge Reader for Arduino Mega2560
|
||||||
|
|
||||||
Date: 15.04.2021
|
Date: 26.04.2021
|
||||||
Version: 5.7
|
Version: 6.0
|
||||||
|
|
||||||
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
|
||||||
@ -41,28 +41,28 @@
|
|||||||
jiyunomegami - Retrode Game Gear adapter support and code improvements
|
jiyunomegami - Retrode Game Gear adapter support and code improvements
|
||||||
|
|
||||||
**********************************************************************************/
|
**********************************************************************************/
|
||||||
#include <SdFat.h>
|
|
||||||
|
|
||||||
char ver[5] = "5.7";
|
char ver[5] = "6.0";
|
||||||
|
|
||||||
#include "options.h"
|
|
||||||
|
|
||||||
/******************************************
|
/******************************************
|
||||||
Libraries
|
Libraries
|
||||||
*****************************************/
|
*****************************************/
|
||||||
|
// Options
|
||||||
|
#include "options.h"
|
||||||
|
|
||||||
|
// SD Card
|
||||||
|
#include "SdFat.h"
|
||||||
|
#define SD_FAT_TYPE 0
|
||||||
|
SdFat sd;
|
||||||
|
SdFile myFile;
|
||||||
|
SdFile myDir;
|
||||||
|
|
||||||
// Basic Libs
|
// Basic Libs
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
#include <avr/wdt.h>
|
#include <avr/wdt.h>
|
||||||
|
|
||||||
// SD Card
|
|
||||||
#define sdSpeed SPI_FULL_SPEED
|
|
||||||
// SD Card (Pin 50 = MISO, Pin 51 = MOSI, Pin 52 = SCK, Pin 53 = SS)
|
|
||||||
#define chipSelectPin 53
|
|
||||||
SdFat sd;
|
|
||||||
SdFile myFile;
|
|
||||||
|
|
||||||
// AVR Eeprom
|
// AVR Eeprom
|
||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
// forward declarations for "T" (for non Arduino IDE)
|
// forward declarations for "T" (for non Arduino IDE)
|
||||||
@ -698,7 +698,7 @@ void setup() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Init SD card
|
// Init SD card
|
||||||
if (!sd.begin(chipSelectPin, sdSpeed)) {
|
if (!sd.begin(SdSpiConfig(SS, DEDICATED_SPI))) {
|
||||||
display_Clear();
|
display_Clear();
|
||||||
print_Error(F("SD Error"), true);
|
print_Error(F("SD Error"), true);
|
||||||
}
|
}
|
||||||
@ -1363,8 +1363,9 @@ void fileBrowser(const __FlashStringHelper* browserTitle) {
|
|||||||
int currFile;
|
int currFile;
|
||||||
filebrowse = 1;
|
filebrowse = 1;
|
||||||
|
|
||||||
// Empty filePath string
|
// Root
|
||||||
filePath[0] = '\0';
|
filePath[0] = '/';
|
||||||
|
filePath[1] = '\0';
|
||||||
|
|
||||||
// Temporary char array for filename
|
// Temporary char array for filename
|
||||||
char nameStr[FILENAME_LENGTH];
|
char nameStr[FILENAME_LENGTH];
|
||||||
@ -1379,8 +1380,14 @@ browserstart:
|
|||||||
currPage = 1;
|
currPage = 1;
|
||||||
lastPage = 1;
|
lastPage = 1;
|
||||||
|
|
||||||
|
// Open filepath directory
|
||||||
|
if (!myDir.open(filePath)) {
|
||||||
|
display_Clear();
|
||||||
|
print_Error(F("SD Error"), true);
|
||||||
|
}
|
||||||
|
|
||||||
// Read in File as long as there are files
|
// Read in File as long as there are files
|
||||||
while (myFile.openNext(sd.vwd(), O_READ)) {
|
while (myFile.openNext(&myDir, O_READ)) {
|
||||||
|
|
||||||
// Get name of file
|
// Get name of file
|
||||||
myFile.getName(nameStr, FILENAME_LENGTH);
|
myFile.getName(nameStr, FILENAME_LENGTH);
|
||||||
@ -1402,6 +1409,7 @@ browserstart:
|
|||||||
}
|
}
|
||||||
myFile.close();
|
myFile.close();
|
||||||
}
|
}
|
||||||
|
myDir.close();
|
||||||
|
|
||||||
// "Calculate number of needed pages"
|
// "Calculate number of needed pages"
|
||||||
if (currFile < 8)
|
if (currFile < 8)
|
||||||
@ -1463,11 +1471,9 @@ page:
|
|||||||
|
|
||||||
// Check if we are supposed to go back to the root dir
|
// Check if we are supposed to go back to the root dir
|
||||||
if (root) {
|
if (root) {
|
||||||
// Empty filePath string
|
|
||||||
filePath[0] = '\0';
|
|
||||||
// Rewind filesystem
|
|
||||||
//sd.vwd()->rewind();
|
|
||||||
// Change working dir to root
|
// Change working dir to root
|
||||||
|
filePath[0] = '/';
|
||||||
|
filePath[1] = '\0';
|
||||||
sd.chdir("/");
|
sd.chdir("/");
|
||||||
// Start again
|
// Start again
|
||||||
root = 0;
|
root = 0;
|
||||||
|
@ -527,7 +527,14 @@ void crc_search(char *file_p, char *folder_p, uint32_t rom_size, uint32_t crc)
|
|||||||
print_Msg(F(".pce"));
|
print_Msg(F(".pce"));
|
||||||
flag = CHKSUM_OK;
|
flag = CHKSUM_OK;
|
||||||
strcat(gamename, ".pce");
|
strcat(gamename, ".pce");
|
||||||
rom.rename(sd.vwd(), gamename);
|
|
||||||
|
// Open filepath directory
|
||||||
|
if (!myDir.open(folder_p)) {
|
||||||
|
display_Clear();
|
||||||
|
print_Error(F("SD Error"), true);
|
||||||
|
}
|
||||||
|
rom.rename(&myDir, gamename);
|
||||||
|
myDir.close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#define enable_Button2
|
#define enable_Button2
|
||||||
|
|
||||||
// Read N64 Eeprom with Adadruit clockgen, CLK1 switch needs to be switch to ON
|
// Read N64 Eeprom with Adadruit clockgen, CLK1 switch needs to be switch to ON
|
||||||
//#define clockgen_installed
|
#define clockgen_installed
|
||||||
|
|
||||||
// define enable_XXX to enable
|
// define enable_XXX to enable
|
||||||
#define enable_FLASH
|
#define enable_FLASH
|
||||||
|
Loading…
Reference in New Issue
Block a user