Merge pull request #37 from adafruit/floppsy-apple2-interface
Floppsy: Changes for apple2 interface & output enable
This commit is contained in:
commit
e66f50dd33
10 changed files with 64 additions and 29 deletions
|
|
@ -73,6 +73,10 @@ void setup() {
|
|||
pinMode(FLOPPY_DIRECTION_PIN, OUTPUT);
|
||||
digitalWrite(FLOPPY_DIRECTION_PIN, HIGH);
|
||||
#endif
|
||||
#if defined(FLOPPY_ENABLE_PIN)
|
||||
pinMode(FLOPPY_ENABLE_PIN, OUTPUT);
|
||||
digitalWrite(FLOPPY_ENABLE_PIN, LOW); // do second after setting direction
|
||||
#endif
|
||||
|
||||
Serial.println("its time for a nice floppy transfer!");
|
||||
Serial.print("Sample freqency ");
|
||||
|
|
|
|||
|
|
@ -75,6 +75,10 @@ void setup() {
|
|||
pinMode(FLOPPY_DIRECTION_PIN, OUTPUT);
|
||||
digitalWrite(FLOPPY_DIRECTION_PIN, HIGH);
|
||||
#endif
|
||||
#if defined(FLOPPY_ENABLE_PIN)
|
||||
pinMode(FLOPPY_ENABLE_PIN, OUTPUT);
|
||||
digitalWrite(FLOPPY_ENABLE_PIN, LOW); // do second after setting direction
|
||||
#endif
|
||||
|
||||
delay(500); // wait for serial to open
|
||||
Serial.println("its time for a nice floppy transfer!");
|
||||
|
|
|
|||
|
|
@ -91,6 +91,10 @@ void setup() {
|
|||
pinMode(FLOPPY_DIRECTION_PIN, OUTPUT);
|
||||
digitalWrite(FLOPPY_DIRECTION_PIN, HIGH);
|
||||
#endif
|
||||
#if defined(FLOPPY_ENABLE_PIN)
|
||||
pinMode(FLOPPY_ENABLE_PIN, OUTPUT);
|
||||
digitalWrite(FLOPPY_ENABLE_PIN, LOW); // do second after setting direction
|
||||
#endif
|
||||
|
||||
Serial.println("Floppy FAT directory listing demo");
|
||||
|
||||
|
|
|
|||
|
|
@ -86,6 +86,10 @@ void setup() {
|
|||
pinMode(FLOPPY_DIRECTION_PIN, OUTPUT);
|
||||
digitalWrite(FLOPPY_DIRECTION_PIN, HIGH);
|
||||
#endif
|
||||
#if defined(FLOPPY_ENABLE_PIN)
|
||||
pinMode(FLOPPY_ENABLE_PIN, OUTPUT);
|
||||
digitalWrite(FLOPPY_ENABLE_PIN, LOW); // do second after setting direction
|
||||
#endif
|
||||
|
||||
#if defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_RP2040)
|
||||
// Manual begin() is required on core without built-in support for TinyUSB
|
||||
|
|
|
|||
|
|
@ -75,6 +75,10 @@ void setup() {
|
|||
pinMode(FLOPPY_DIRECTION_PIN, OUTPUT);
|
||||
digitalWrite(FLOPPY_DIRECTION_PIN, HIGH);
|
||||
#endif
|
||||
#if defined(FLOPPY_ENABLE_PIN)
|
||||
pinMode(FLOPPY_ENABLE_PIN, OUTPUT);
|
||||
digitalWrite(FLOPPY_ENABLE_PIN, LOW); // do second after setting direction
|
||||
#endif
|
||||
|
||||
delay(500); // wait for serial to open
|
||||
Serial.println("its time for a nice floppy transfer!");
|
||||
|
|
|
|||
|
|
@ -77,6 +77,10 @@ void setup() {
|
|||
pinMode(FLOPPY_DIRECTION_PIN, OUTPUT);
|
||||
digitalWrite(FLOPPY_DIRECTION_PIN, HIGH);
|
||||
#endif
|
||||
#if defined(FLOPPY_ENABLE_PIN)
|
||||
pinMode(FLOPPY_ENABLE_PIN, OUTPUT);
|
||||
digitalWrite(FLOPPY_ENABLE_PIN, LOW); // do second after setting direction
|
||||
#endif
|
||||
|
||||
Serial.println("its time for a nice floppy transfer!");
|
||||
floppy.debug_serial = &Serial;
|
||||
|
|
|
|||
|
|
@ -113,7 +113,8 @@ uint8_t cmd_buff_idx = 0;
|
|||
#define GW_CMD_SETBUSTYPE 14
|
||||
#define GW_CMD_SETBUSTYPE_IBM 1
|
||||
#define GW_CMD_SETBUSTYPE_SHUGART 2
|
||||
#define GW_CMD_SETBUSTYPE_APPLE2 3
|
||||
#define GW_CMD_SETBUSTYPE_APPLE2_GW 4
|
||||
#define GW_CMD_SETBUSTYPE_APPLE2_FLUXENGINE 3
|
||||
#define GW_CMD_SETPIN 15
|
||||
#define GW_CMD_SETPIN_DENSITY 2
|
||||
#define GW_CMD_RESET 16
|
||||
|
|
@ -146,7 +147,8 @@ bool setbustype(int bustype) {
|
|||
break;
|
||||
#endif
|
||||
#ifdef APPLE2_RDDATA_PIN
|
||||
case GW_CMD_SETBUSTYPE_APPLE2:
|
||||
case GW_CMD_SETBUSTYPE_APPLE2_GW:
|
||||
case GW_CMD_SETBUSTYPE_APPLE2_FLUXENGINE:
|
||||
floppy = &apple2floppy;
|
||||
apple2floppy.step_mode(Adafruit_Apple2Floppy::STEP_MODE_QUARTER);
|
||||
break;
|
||||
|
|
@ -169,6 +171,10 @@ void setup() {
|
|||
pinMode(FLOPPY_DIRECTION_PIN, OUTPUT);
|
||||
digitalWrite(FLOPPY_DIRECTION_PIN, HIGH);
|
||||
#endif
|
||||
#if defined(FLOPPY_ENABLE_PIN)
|
||||
pinMode(FLOPPY_ENABLE_PIN, OUTPUT);
|
||||
digitalWrite(FLOPPY_ENABLE_PIN, LOW); // do second after setting direction
|
||||
#endif
|
||||
|
||||
delay(100);
|
||||
|
||||
|
|
@ -230,10 +236,11 @@ void loop() {
|
|||
|
||||
int i = 0;
|
||||
uint8_t cmd = cmd_buffer[0];
|
||||
uint8_t len = cmd_buffer[1];
|
||||
memset(reply_buffer, 0, sizeof(reply_buffer));
|
||||
reply_buffer[i++] = cmd; // echo back the cmd itself
|
||||
|
||||
Serial1.printf("Got command 0x%02x of length %d\n\r", cmd, cmd_buffer[1]);
|
||||
Serial1.printf("Got command 0x%02x of length %d\n\r", cmd, len);
|
||||
|
||||
|
||||
if (cmd == GW_CMD_GETINFO) {
|
||||
|
|
@ -328,7 +335,11 @@ void loop() {
|
|||
else if (cmd == GW_CMD_SEEK) {
|
||||
if (!floppy) goto needfloppy;
|
||||
|
||||
uint8_t track = cmd_buffer[2];
|
||||
int track = cmd_buffer[2];
|
||||
if (len > 3) {
|
||||
track |= cmd_buffer[3] << 8;
|
||||
}
|
||||
|
||||
Serial1.printf("Seek track %d\n\r", track);
|
||||
bool r = floppy->goto_track(track);
|
||||
if (r) {
|
||||
|
|
@ -682,4 +693,4 @@ needfloppy:
|
|||
Serial.write(reply_buffer, 2);
|
||||
|
||||
//Serial1.println("cmd complete!");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@ void Adafruit_Floppy::select(bool selected) {
|
|||
@note If _sidepin is no pin, then only head 0 can be selected
|
||||
*/
|
||||
/**************************************************************************/
|
||||
bool Adafruit_Floppy::side(uint8_t head) {
|
||||
bool Adafruit_Floppy::side(int head) {
|
||||
if (head != 0 && head != 1) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -321,7 +321,7 @@ bool Adafruit_Floppy::spin_motor(bool motor_on) {
|
|||
@return True If we were able to get to the track location
|
||||
*/
|
||||
/**************************************************************************/
|
||||
bool Adafruit_Floppy::goto_track(uint8_t track_num) {
|
||||
bool Adafruit_Floppy::goto_track(int track_num) {
|
||||
// track 0 is a very special case because its the only one we actually know we
|
||||
// got to. if we dont know where we are, or we're going to track zero, step
|
||||
// back till we get there.
|
||||
|
|
@ -417,9 +417,9 @@ void Adafruit_Floppy::step(bool dir, uint8_t times) {
|
|||
@return The cached track location
|
||||
*/
|
||||
/**************************************************************************/
|
||||
int8_t Adafruit_Floppy::track(void) { return _track; }
|
||||
int Adafruit_Floppy::track(void) { return _track; }
|
||||
|
||||
int8_t Adafruit_Floppy::get_side(void) { return _side; }
|
||||
int Adafruit_Floppy::get_side(void) { return _side; }
|
||||
|
||||
bool Adafruit_Floppy::get_write_protect(void) {
|
||||
if (_protectpin == -1) {
|
||||
|
|
@ -1079,7 +1079,7 @@ enum {
|
|||
@return True If we were able to get to the track location
|
||||
*/
|
||||
/**************************************************************************/
|
||||
bool Adafruit_Apple2Floppy::goto_track(uint8_t track_num) {
|
||||
bool Adafruit_Apple2Floppy::goto_track(int track_num) {
|
||||
if (_quartertrack == -1) {
|
||||
_quartertrack = 160;
|
||||
goto_quartertrack(0);
|
||||
|
|
@ -1152,7 +1152,7 @@ void Adafruit_Apple2Floppy::_step(int direction, int count) {
|
|||
@note Apple II floppy drives only have a single side
|
||||
*/
|
||||
/**************************************************************************/
|
||||
bool Adafruit_Apple2Floppy::side(uint8_t head) { return head == 0; }
|
||||
bool Adafruit_Apple2Floppy::side(int head) { return head == 0; }
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
|
|
@ -1161,7 +1161,7 @@ bool Adafruit_Apple2Floppy::side(uint8_t head) { return head == 0; }
|
|||
@note Partial tracks are rounded, with quarter tracks always rounded down.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
int8_t Adafruit_Apple2Floppy::track(void) {
|
||||
int Adafruit_Apple2Floppy::track(void) {
|
||||
if (_quartertrack == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -1239,7 +1239,7 @@ bool Adafruit_Apple2Floppy::get_track0_sense(void) { return track() == 0; }
|
|||
@note Returns -1 if the position is unknown
|
||||
*/
|
||||
/**************************************************************************/
|
||||
int8_t Adafruit_Apple2Floppy::quartertrack() { return _quartertrack; }
|
||||
int Adafruit_Apple2Floppy::quartertrack() { return _quartertrack; }
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ public:
|
|||
@return True If we were able to get to the track location
|
||||
*/
|
||||
/**************************************************************************/
|
||||
virtual bool goto_track(uint8_t track_num) = 0;
|
||||
virtual bool goto_track(int track_num) = 0;
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Which head/side to read from
|
||||
|
|
@ -98,14 +98,14 @@ public:
|
|||
@return true if the head exists, false otherwise
|
||||
*/
|
||||
/**************************************************************************/
|
||||
virtual bool side(uint8_t head) = 0;
|
||||
virtual bool side(int head) = 0;
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Current head in use, based on internal caching
|
||||
@return Head 0 or 1
|
||||
*/
|
||||
/**************************************************************************/
|
||||
virtual int8_t get_side() = 0;
|
||||
virtual int get_side() = 0;
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief The current track location, based on internal caching
|
||||
|
|
@ -113,7 +113,7 @@ public:
|
|||
@note Returns -1 if the track is not known.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
virtual int8_t track(void) = 0;
|
||||
virtual int track(void) = 0;
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Check whether the floppy in the drive is write protected
|
||||
|
|
@ -239,10 +239,10 @@ public:
|
|||
|
||||
void select(bool selected) override;
|
||||
bool spin_motor(bool motor_on) override;
|
||||
bool goto_track(uint8_t track) override;
|
||||
bool side(uint8_t head) override;
|
||||
int8_t track(void) override;
|
||||
int8_t get_side(void) override;
|
||||
bool goto_track(int track) override;
|
||||
bool side(int head) override;
|
||||
int track(void) override;
|
||||
int get_side(void) override;
|
||||
void step(bool dir, uint8_t times);
|
||||
bool set_density(bool high_density) override;
|
||||
bool get_write_protect() override;
|
||||
|
|
@ -254,7 +254,7 @@ private:
|
|||
int8_t _densitypin, _selectpin, _motorpin, _directionpin, _steppin,
|
||||
_track0pin, _protectpin, _sidepin, _readypin;
|
||||
|
||||
int8_t _track = -1, _side = -1;
|
||||
int _track = -1, _side = -1;
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -284,19 +284,19 @@ public:
|
|||
|
||||
void select(bool selected) override;
|
||||
bool spin_motor(bool motor_on) override;
|
||||
bool goto_track(uint8_t track) override;
|
||||
bool side(uint8_t head) override;
|
||||
int8_t track(void) override;
|
||||
bool goto_track(int track) override;
|
||||
bool side(int head) override;
|
||||
int track(void) override;
|
||||
bool set_density(bool high_density) override;
|
||||
bool get_write_protect() override;
|
||||
bool get_track0_sense() override;
|
||||
bool get_ready_sense() override { return true; }
|
||||
|
||||
int8_t quartertrack();
|
||||
int quartertrack();
|
||||
bool goto_quartertrack(int);
|
||||
void step_mode(StepMode mode);
|
||||
|
||||
int8_t get_side() override { return 0; }
|
||||
int get_side() override { return 0; }
|
||||
|
||||
private:
|
||||
int _step_multiplier() const;
|
||||
|
|
@ -324,7 +324,7 @@ public:
|
|||
void end(void);
|
||||
|
||||
uint32_t size(void) const;
|
||||
int32_t readTrack(uint8_t track, bool head);
|
||||
int32_t readTrack(int track, bool head);
|
||||
|
||||
/**! @brief The expected number of sectors per track in this format
|
||||
@returns The number of sectors per track */
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ uint32_t Adafruit_MFM_Floppy::size(void) const {
|
|||
@returns Number of sectors captured, or -1 if we couldn't seek
|
||||
*/
|
||||
/**************************************************************************/
|
||||
int32_t Adafruit_MFM_Floppy::readTrack(uint8_t logical_track, bool head) {
|
||||
int32_t Adafruit_MFM_Floppy::readTrack(int logical_track, bool head) {
|
||||
syncDevice();
|
||||
|
||||
uint8_t physical_track = _double_step ? 2 * logical_track : logical_track;
|
||||
|
|
|
|||
Loading…
Reference in a new issue