Skip to content

Commit 45fd906

Browse files
Merge pull request #16 from jcook793/sdfat2-support
Updated SdCard to version 2
2 parents 27fdab9 + ce0d8a9 commit 45fd906

3 files changed

Lines changed: 23 additions & 13 deletions

File tree

SIO2Arduino.ino

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void changeDirectory(int ix);
4646
DriveAccess driveAccess(getDeviceStatus, readSector, writeSector, format);
4747
DriveControl driveControl(getFileList, mountFileIndex, changeDirectory);
4848
SIOChannel sioChannel(PIN_ATARI_CMD, &SIO_UART, &driveAccess, &driveControl);
49-
Sd2Card card;
49+
SdFat32 card;
5050
SdFile currDir;
5151
SdFile file; // TODO: make this unnecessary
5252
DiskDrive drive1;
@@ -63,10 +63,18 @@ LiquidCrystal lcd(PIN_LCD_RD,PIN_LCD_ENABLE,PIN_LCD_DB4,PIN_LCD_DB5,PIN_LCD_DB6,
6363
#endif
6464

6565
void setup() {
66-
#ifdef DEBUG
67-
// set up logging serial port
68-
LOGGING_UART.begin(115200);
69-
#endif
66+
#ifdef DEBUG
67+
// set up logging serial port
68+
LOGGING_UART.begin(115200);
69+
while (!LOGGING_UART) {
70+
yield();
71+
}
72+
LOG_MSG_CR(F("Debug logging enabled"));
73+
#ifdef ARDUINO_UNO
74+
LOG_MSG_CR(F("WARNING: using debug logging with Uno, which only has 1 UART - SIO will conflict"));
75+
LOG_MSG_FLUSH(); // make sure this log displays before making the SIO connection
76+
#endif
77+
#endif
7078

7179
// initialize serial port to Atari
7280
SIO_UART.begin(19200);
@@ -190,18 +198,18 @@ boolean format(int deviceId, int density) {
190198
}
191199

192200
void changeDisk(int deviceId) {
193-
dir_t dir;
201+
DirFat_t dir;
194202
char name[13];
195203
boolean imageChanged = false;
196204

197205
while (!imageChanged) {
198206
// get next dir entry
199-
int8_t result = currDir.readDir((dir_t*)&dir);
207+
int8_t result = currDir.readDir((DirFat_t*)&dir);
200208

201209
// if we got back a 0, rewind the directory and get the first dir entry
202210
if (!result) {
203211
currDir.rewind();
204-
result = currDir.readDir((dir_t*)&dir);
212+
result = currDir.readDir((DirFat_t*)&dir);
205213
}
206214

207215
// if we have a valid file response code, open it
@@ -253,20 +261,20 @@ void createFilename(char* filename, char* name) {
253261
* entries = a pointer to the a FileEntry array to hold the returned data
254262
*/
255263
int getFileList(int startIndex, int count, FileEntry *entries) {
256-
dir_t dir;
264+
DirFat_t dir;
257265
int currentEntry = 0;
258266

259267
currDir.rewind();
260268

261269
int ix = 0;
262270
while (ix < count) {
263-
if (currDir.readDir((dir_t*)&dir) < 1) {
271+
if (currDir.readDir((DirFat_t*)&dir) < 1) {
264272
break;
265273
}
266-
if (isValidFilename((char*)&dir.name) || (DIR_IS_SUBDIR(&dir) && dir.name[0] != '.')) {
274+
if (isValidFilename((char*)&dir.name) || (isSubdir(&dir) && dir.name[0] != '.')) {
267275
if (currentEntry >= startIndex) {
268276
memcpy(entries[ix].name, dir.name, 11);
269-
if (DIR_IS_SUBDIR(&dir)) {
277+
if (isSubdir(&dir)) {
270278
entries[ix].isDirectory = true;
271279
} else {
272280
entries[ix].isDirectory = false;

config.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#ifndef CONFIG_H
2424
#define CONFIG_H
2525

26-
#define USE_SD_VOLUME
2726
/**
2827
* These are SIO2Arduino feature definitions.
2928
*/
@@ -141,9 +140,11 @@
141140
#define LOGGING_UART Serial
142141
#define LOG_MSG(...) LOGGING_UART.print(__VA_ARGS__)
143142
#define LOG_MSG_CR(...) LOGGING_UART.println(__VA_ARGS__)
143+
#define LOG_MSG_FLUSH() LOGGING_UART.flush()
144144
#else
145145
#define LOG_MSG(...)
146146
#define LOG_MSG_CR(...)
147+
#define LOG_MSG_FLUSH()
147148
#endif
148149

149150
#endif

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
SIO2Arduino is an open-source implementation of the Atari SIO device protocol that runs on Arduino hardware. Arduino hardware is open-source and can be assembled by hand or purchased preassembled.
22

33
Note: You will need the SdFat library (https://github.com/greiman/SdFat) in your Arduino libraries directory in order to compile.
4+
This has been tested using SdFat version 2.1.2.
45

56
For more information on SIO2Arduino, see the website at:
67
http://www.whizzosoftware.com/sio2arduino

0 commit comments

Comments
 (0)