mirror of
https://github.com/nippur72/apple1-videocard-lib.git
synced 2024-12-28 21:30:24 +00:00
sd card command MOUNT, SD OS v1.1
This commit is contained in:
parent
a2105f88c6
commit
7852ff37c2
@ -36,6 +36,7 @@ in Verilog syntax: data = { PORTB[1:0], PORTD[7:2] };
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// FASTWRITE not working (yet)
|
||||||
// #define FASTWRITE 1
|
// #define FASTWRITE 1
|
||||||
|
|
||||||
#ifdef FASTWRITE
|
#ifdef FASTWRITE
|
||||||
@ -46,9 +47,6 @@ in Verilog syntax: data = { PORTB[1:0], PORTD[7:2] };
|
|||||||
#define set_mcu_strobe(c) digitalWrite(MCU_STROBE,(c))
|
#define set_mcu_strobe(c) digitalWrite(MCU_STROBE,(c))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// #include <Regexp.h>
|
|
||||||
|
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
#include "SdFat.h"
|
#include "SdFat.h"
|
||||||
|
|
||||||
@ -218,6 +216,7 @@ const byte CMD_MKDIR = 14;
|
|||||||
const byte CMD_PWD = 19;
|
const byte CMD_PWD = 19;
|
||||||
const byte CMD_RMDIR = 15;
|
const byte CMD_RMDIR = 15;
|
||||||
const byte CMD_TEST = 20;
|
const byte CMD_TEST = 20;
|
||||||
|
const byte CMD_MOUNT = 21;
|
||||||
|
|
||||||
const byte ERR_RESPONSE = 255;
|
const byte ERR_RESPONSE = 255;
|
||||||
const byte WAIT_RESPONSE = 1;
|
const byte WAIT_RESPONSE = 1;
|
||||||
@ -244,6 +243,8 @@ const char *CANT_MAKE_DIR = "?CAN'T MAKE DIR";
|
|||||||
const char *DIR_CREATED = " (DIR) CREATED";
|
const char *DIR_CREATED = " (DIR) CREATED";
|
||||||
const char *CANT_CD_DIR = "?CAN'T CHANGE DIR";
|
const char *CANT_CD_DIR = "?CAN'T CHANGE DIR";
|
||||||
const char *NOT_A_DIRECTORY = "?NOT A DIRECTORY";
|
const char *NOT_A_DIRECTORY = "?NOT A DIRECTORY";
|
||||||
|
const char *MOUNT_OK = "MOUNTING SDCARD...\rOK";
|
||||||
|
const char *MOUNT_FAILED = "?SD CARD ERROR";
|
||||||
|
|
||||||
// file structures used to operate with the SD card
|
// file structures used to operate with the SD card
|
||||||
File myFile;
|
File myFile;
|
||||||
@ -254,9 +255,7 @@ void setup() {
|
|||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
Serial.println(F("SDCARD library: SDFat.h"));
|
Serial.println(F("SDCARD library: SDFat.h"));
|
||||||
|
|
||||||
// initialize SD card
|
mount_sdcard();
|
||||||
if (!SD.begin(SD_CS_PIN)) Serial.println(F("SD card initialization failed"));
|
|
||||||
else Serial.println(F("SD card initialized"));
|
|
||||||
|
|
||||||
// control pins setup
|
// control pins setup
|
||||||
pinMode(CPU_STROBE, INPUT);
|
pinMode(CPU_STROBE, INPUT);
|
||||||
@ -267,21 +266,21 @@ void setup() {
|
|||||||
last_dir = -1; // no previous data direction
|
last_dir = -1; // no previous data direction
|
||||||
set_data_port_direction(DIR_INPUT);
|
set_data_port_direction(DIR_INPUT);
|
||||||
|
|
||||||
/*
|
|
||||||
// regex disabled for now
|
|
||||||
MatchState ms;
|
|
||||||
char buf [100] = { "The quick " };
|
|
||||||
ms.Target (buf);
|
|
||||||
char result = ms.Match ("f.x");
|
|
||||||
if(result >0) {
|
|
||||||
Serial.println("match!");
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// set working directory to root
|
// set working directory to root
|
||||||
strcpy(cd_path, "/");
|
strcpy(cd_path, "/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool mount_sdcard() {
|
||||||
|
// initialize SD card
|
||||||
|
if(!SD.begin(SD_CS_PIN)) {
|
||||||
|
Serial.println(F("SD card initialization failed"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Serial.println(F("SD card initialized"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// **************************************************************************************
|
// **************************************************************************************
|
||||||
// **************************************************************************************
|
// **************************************************************************************
|
||||||
@ -1067,6 +1066,11 @@ void loop() {
|
|||||||
send_byte_to_cpu(data ^ 0xFF);
|
send_byte_to_cpu(data ^ 0xFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(data == CMD_MOUNT) {
|
||||||
|
bool mount = mount_sdcard();
|
||||||
|
if(mount) send_string_to_cpu(MOUNT_OK);
|
||||||
|
else send_string_to_cpu(MOUNT_FAILED);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
Serial.print(F("unknown command "));
|
Serial.print(F("unknown command "));
|
||||||
Serial.print(data);
|
Serial.print(data);
|
||||||
|
8
demos/sdcard/cmd_mount.h
Normal file
8
demos/sdcard/cmd_mount.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
void comando_mount() {
|
||||||
|
// send command byte
|
||||||
|
send_byte_to_MCU(CMD_MOUNT);
|
||||||
|
if(TIMEOUT) return;
|
||||||
|
|
||||||
|
print_string_response();
|
||||||
|
return;
|
||||||
|
}
|
@ -43,7 +43,8 @@ const byte CMD_PWD = 19;
|
|||||||
const byte CMD_TEST = 20;
|
const byte CMD_TEST = 20;
|
||||||
const byte CMD_HELP = 21;
|
const byte CMD_HELP = 21;
|
||||||
const byte CMD_QMARK = 22;
|
const byte CMD_QMARK = 22;
|
||||||
const byte CMD_EXIT = 23;
|
const byte CMD_MOUNT = 23;
|
||||||
|
const byte CMD_EXIT = 24;
|
||||||
|
|
||||||
// the list of recognized commands
|
// the list of recognized commands
|
||||||
byte *DOS_COMMANDS[] = {
|
byte *DOS_COMMANDS[] = {
|
||||||
@ -70,6 +71,7 @@ byte *DOS_COMMANDS[] = {
|
|||||||
"TEST",
|
"TEST",
|
||||||
"HELP",
|
"HELP",
|
||||||
"?",
|
"?",
|
||||||
|
"MOUNT",
|
||||||
"EXIT"
|
"EXIT"
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -177,12 +179,13 @@ void append_hex_tmpword(char *dest) {
|
|||||||
#include "cmd_pwd.h"
|
#include "cmd_pwd.h"
|
||||||
#include "cmd_test.h"
|
#include "cmd_test.h"
|
||||||
#include "cmd_help.h"
|
#include "cmd_help.h"
|
||||||
|
#include "cmd_mount.h"
|
||||||
|
|
||||||
void console() {
|
void console() {
|
||||||
|
|
||||||
VIA_init();
|
VIA_init();
|
||||||
|
|
||||||
woz_puts("\r\r*** SD CARD OS 1.0\r\r");
|
woz_puts("\r\r*** SD CARD OS 1.1\r\r");
|
||||||
|
|
||||||
cmd = 0;
|
cmd = 0;
|
||||||
|
|
||||||
@ -406,6 +409,9 @@ void console() {
|
|||||||
get_token(filename, 32); // parse filename
|
get_token(filename, 32); // parse filename
|
||||||
comando_help();
|
comando_help();
|
||||||
}
|
}
|
||||||
|
else if(cmd == CMD_MOUNT) {
|
||||||
|
comando_mount();
|
||||||
|
}
|
||||||
else if(cmd == CMD_EXIT) {
|
else if(cmd == CMD_EXIT) {
|
||||||
woz_puts("BYE\r");
|
woz_puts("BYE\r");
|
||||||
woz_mon();
|
woz_mon();
|
||||||
|
Loading…
Reference in New Issue
Block a user