mirror of
				https://github.com/davidgiven/fluxengine.git
				synced 2025-10-24 11:11:02 -07:00 
			
		
		
		
	Add support for selecting the Shugart or IBMPC GreaseWeazle bus types.
This commit is contained in:
		| @@ -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 | ||||
| ----------------- | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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"; | ||||
|   | ||||
| @@ -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(); } | ||||
|   | ||||
| @@ -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"]; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user