Add support for selecting the Shugart or IBMPC GreaseWeazle bus types.

This commit is contained in:
David Given
2022-01-01 22:45:27 +01:00
parent d7b21bf07e
commit a32ea6e5f8
5 changed files with 26 additions and 7 deletions

View File

@@ -30,6 +30,8 @@ Supported features with the GreaseWeazle include:
- simple reading and writing of disks, seeking etc
- erasing disks
- determining disk rotation speed
- both Shugart and normal IBM buses (via
`--usb.greaseweazle.bus_type=SHUGART` or `IBMPC`; the default is `IBMPC`)
What doesn't work
-----------------

View File

@@ -4,6 +4,7 @@
#include "fluxmap.h"
#include "bytes.h"
#include "fmt/format.h"
#include "lib/usb/usb.pb.h"
#include "greaseweazle.h"
#include "serial.h"
@@ -61,8 +62,9 @@ private:
}
public:
GreaseWeazleUsb(const std::string& port):
_serial(SerialPort::openSerialPort(port))
GreaseWeazleUsb(const std::string& port, const GreaseWeazleProto& config):
_serial(SerialPort::openSerialPort(port)),
_config(config)
{
int version = getVersion();
if (version >= 29)
@@ -79,7 +81,7 @@ public:
/* Configure the hardware. */
do_command({ CMD_SET_BUS_TYPE, 3, BUS_IBMPC });
do_command({ CMD_SET_BUS_TYPE, 3, (uint8_t)config.bus_type() });
}
int getVersion()
@@ -384,14 +386,15 @@ private:
};
std::unique_ptr<SerialPort> _serial;
const GreaseWeazleProto& _config;
int _version;
nanoseconds_t _clock;
nanoseconds_t _revolutions;
};
USB* createGreaseWeazleUsb(const std::string& port)
USB* createGreaseWeazleUsb(const std::string& port, const GreaseWeazleProto& config)
{
return new GreaseWeazleUsb(port);
return new GreaseWeazleUsb(port, config);
}
// vim: sw=4 ts=4 et

View File

@@ -66,7 +66,7 @@ USB* get_usb_impl()
case GREASEWEAZLE_ID:
std::cerr << fmt::format("Using GreaseWeazle {} on {}\n", candidate->serial, candidate->serialPort);
return createGreaseWeazleUsb(candidate->serialPort);
return createGreaseWeazleUsb(candidate->serialPort, config.usb().greaseweazle());
default:
Error() << "internal";

View File

@@ -5,6 +5,7 @@
#include "flags.h"
class Fluxmap;
class GreaseWeazleProto;
namespace libusbp { class device; }
class USB
@@ -33,7 +34,7 @@ protected:
extern USB& getUsb();
extern USB* createFluxengineUsb(libusbp::device& device);
extern USB* createGreaseWeazleUsb(const std::string& serialPort);
extern USB* createGreaseWeazleUsb(const std::string& serialPort, const GreaseWeazleProto& config);
static inline int usbGetVersion() { return getUsb().getVersion(); }
static inline void usbRecalibrate() { getUsb().recalibrate(); }

View File

@@ -2,9 +2,22 @@ syntax = "proto2";
import "lib/common.proto";
message GreaseWeazleProto {
enum BusType {
BUSTYPE_INVALID = 0;
IBMPC = 1;
SHUGART = 2;
};
optional BusType bus_type = 1
[(help) = "which FDD bus type is in use", default = IBMPC];
}
message UsbProto {
oneof device {
string serial = 1
[(help) = "serial number of FluxEngine or GreaseWeazle device to use"];
}
optional GreaseWeazleProto greaseweazle = 2 [(help) = "GreaseWeazle-specific options"];
}