mirror of
https://github.com/sanni/cartreader.git
synced 2024-12-25 04:21:53 +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
|
||||
|
||||
Date: 15.04.2021
|
||||
Version: 5.7
|
||||
Date: 26.04.2021
|
||||
Version: 6.0
|
||||
|
||||
SD lib: https://github.com/greiman/SdFat
|
||||
LCD lib: https://github.com/adafruit/Adafruit_SSD1306
|
||||
@ -41,28 +41,28 @@
|
||||
jiyunomegami - Retrode Game Gear adapter support and code improvements
|
||||
|
||||
**********************************************************************************/
|
||||
#include <SdFat.h>
|
||||
|
||||
char ver[5] = "5.7";
|
||||
|
||||
#include "options.h"
|
||||
char ver[5] = "6.0";
|
||||
|
||||
/******************************************
|
||||
Libraries
|
||||
*****************************************/
|
||||
// Options
|
||||
#include "options.h"
|
||||
|
||||
// SD Card
|
||||
#include "SdFat.h"
|
||||
#define SD_FAT_TYPE 0
|
||||
SdFat sd;
|
||||
SdFile myFile;
|
||||
SdFile myDir;
|
||||
|
||||
// Basic Libs
|
||||
#include <SPI.h>
|
||||
#include <Wire.h>
|
||||
#include <avr/pgmspace.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
|
||||
#include <EEPROM.h>
|
||||
// forward declarations for "T" (for non Arduino IDE)
|
||||
@ -698,7 +698,7 @@ void setup() {
|
||||
#endif
|
||||
|
||||
// Init SD card
|
||||
if (!sd.begin(chipSelectPin, sdSpeed)) {
|
||||
if (!sd.begin(SdSpiConfig(SS, DEDICATED_SPI))) {
|
||||
display_Clear();
|
||||
print_Error(F("SD Error"), true);
|
||||
}
|
||||
@ -1363,8 +1363,9 @@ void fileBrowser(const __FlashStringHelper* browserTitle) {
|
||||
int currFile;
|
||||
filebrowse = 1;
|
||||
|
||||
// Empty filePath string
|
||||
filePath[0] = '\0';
|
||||
// Root
|
||||
filePath[0] = '/';
|
||||
filePath[1] = '\0';
|
||||
|
||||
// Temporary char array for filename
|
||||
char nameStr[FILENAME_LENGTH];
|
||||
@ -1379,8 +1380,14 @@ browserstart:
|
||||
currPage = 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
|
||||
while (myFile.openNext(sd.vwd(), O_READ)) {
|
||||
while (myFile.openNext(&myDir, O_READ)) {
|
||||
|
||||
// Get name of file
|
||||
myFile.getName(nameStr, FILENAME_LENGTH);
|
||||
@ -1402,6 +1409,7 @@ browserstart:
|
||||
}
|
||||
myFile.close();
|
||||
}
|
||||
myDir.close();
|
||||
|
||||
// "Calculate number of needed pages"
|
||||
if (currFile < 8)
|
||||
@ -1463,11 +1471,9 @@ page:
|
||||
|
||||
// Check if we are supposed to go back to the root dir
|
||||
if (root) {
|
||||
// Empty filePath string
|
||||
filePath[0] = '\0';
|
||||
// Rewind filesystem
|
||||
//sd.vwd()->rewind();
|
||||
// Change working dir to root
|
||||
filePath[0] = '/';
|
||||
filePath[1] = '\0';
|
||||
sd.chdir("/");
|
||||
// Start again
|
||||
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"));
|
||||
flag = CHKSUM_OK;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
#define enable_Button2
|
||||
|
||||
// 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_FLASH
|
||||
|
Loading…
Reference in New Issue
Block a user