public USBPendrive(string imageFile, long?size = null, bool persistent = false, uint blockSize = 512) { BlockSize = blockSize; dataBackend = DataStorage.Create(imageFile, size, persistent); if (dataBackend.Length % blockSize != 0) { this.Log(LogLevel.Warning, "Underlying data size ({0} bytes) is not aligned to the block size ({1} bytes)", dataBackend.Length, blockSize); } USBCore = new USBDeviceCore(this) .WithConfiguration(configure: c => c.WithInterface <Core.USB.MSC.Interface>( (byte)Core.USB.MSC.Subclass.ScsiTransparentCommandSet, (byte)Core.USB.MSC.Protocol.BulkOnlyTransport, configure: x => x.WithEndpoint( Direction.HostToDevice, EndpointTransferType.Bulk, MaximumPacketSize, 0x10, out hostToDeviceEndpoint) .WithEndpoint( Direction.DeviceToHost, EndpointTransferType.Bulk, MaximumPacketSize, 0x10, out deviceToHostEndpoint)) ); hostToDeviceEndpoint.DataWritten += HandleInput; }
public ArduinoLoader(CortexM cpu, ulong binaryLoadAddress = 0x10000) { USBEndpoint interruptEndpoint = null; this.cpu = cpu; this.machine = cpu.GetMachine(); this.binaryLoadAddress = binaryLoadAddress; USBCore = new USBDeviceCore(this, classCode: USBClassCode.CommunicationsCDCControl, maximalPacketSize: PacketSize.Size16, vendorId: 0x2341, productId: 0x805a, deviceReleaseNumber: 0x0100) .WithConfiguration(configure: c => c .WithInterface(new Antmicro.Renode.Core.USB.CDC.Interface(this, identifier: 0, subClassCode: 0x2, protocol: 0x1, descriptors: new [] { new FunctionalDescriptor(CdcFunctionalDescriptorType.Interface, CdcFunctionalDescriptorSubtype.Header, 0x10, 0x01), new FunctionalDescriptor(CdcFunctionalDescriptorType.Interface, CdcFunctionalDescriptorSubtype.CallManagement, 0x01, 0x01), new FunctionalDescriptor(CdcFunctionalDescriptorType.Interface, CdcFunctionalDescriptorSubtype.AbstractControlManagement, 0x02), new FunctionalDescriptor(CdcFunctionalDescriptorType.Interface, CdcFunctionalDescriptorSubtype.Union, 0x00, 0x01) }) .WithEndpoint(Direction.DeviceToHost, EndpointTransferType.Interrupt, maximumPacketSize: 0x08, interval: 0x0a, createdEndpoint: out interruptEndpoint)) .WithInterface(new USBInterface(this, identifier: 1, classCode: USBClassCode.CDCData, subClassCode: 0x0, protocol: 0x0) .WithEndpoint(id: 2, direction: Direction.HostToDevice, transferType: EndpointTransferType.Bulk, maximumPacketSize: 0x20, interval: 0x0, createdEndpoint: out hostToDeviceEndpoint) .WithEndpoint(id: 3, direction: Direction.DeviceToHost, transferType: EndpointTransferType.Bulk, maximumPacketSize: 0x20, interval: 0x0, createdEndpoint: out deviceToHostEndpoint))); // when asked, say that nothing interesting happened interruptEndpoint.NonBlocking = true; deviceToHostEndpoint.NonBlocking = true; hostToDeviceEndpoint.DataWritten += HandleData; sramBuffer = new byte[BufferSize]; flashBuffer = new byte[BufferSize]; binarySync = new AutoResetEvent(false); }
public USBMouse() { USBCore = new USBDeviceCore(this) .WithConfiguration(configure: c => c.WithInterface(new Core.USB.HID.Interface(this, 0, subClassCode: (byte)Core.USB.HID.SubclassCode.BootInterfaceSubclass, protocol: (byte)Core.USB.HID.Protocol.Mouse, reportDescriptor: new Core.USB.HID.ReportDescriptor(ReportHidDescriptor)), configure: i => i.WithEndpoint( Direction.DeviceToHost, EndpointTransferType.Interrupt, maximumPacketSize: 0x4, interval: 0xa, createdEndpoint: out endpoint))); }
public ValentyUSB(Machine machine, int maximumPacketSize = 64) : base(machine) { maxPacketSize = maximumPacketSize; USBCore = new USBDeviceCore(this, customSetupPacketHandler: SetupPacketHandler); DefineRegisters(); }