public void AttachDevice(IUSBPeripheral device, byte port) { if (device.GetSpeed() == USBDeviceSpeed.High) { ports[port - 1] |= (uint)PortStatus.CPortConnection | (uint)PortStatus.PortConnection | (uint)PortStatus.PortHighSpeed; } else if (device.GetSpeed() == USBDeviceSpeed.Low) { ports[port - 1] |= (uint)PortStatus.CPortConnection | (uint)PortStatus.PortConnection | (uint)PortStatus.PortLowSpeed; } else { ports[port - 1] |= (uint)PortStatus.CPortConnection | (uint)PortStatus.PortConnection; } registeredDevices.Add(port, device); changed = true; /* Connect device to controller and send interrupt*/ var connected = Connected; if (connected != null) { connected(DeviceAddress); } }
public PortStatusAndControlRegisterChanges Attach(IUSBPeripheral portDevice) { uint oldPortValue = portValue; portValue |= CurrentConnectStatus | PortEnabledDisabled | PortEnabledDisabledChange | ConnectStatusChange; device = portDevice; attached = true; return(checkChanges(oldPortValue, portValue)); }
public PortStatusAndControlRegisterChanges Attach(IUSBPeripheral portDevice) { uint oldPortValue = portValue; portValue |= CurrentConnectStatus | PortEnabledDisabled | PortEnabledDisabledChange | ConnectStatusChange; device = portDevice; attached = true; return checkChanges(oldPortValue, portValue); }
public void ProcessClassSet(USBPacket packet, USBSetupPacket setupPacket) { //MessageRecipient recipient = (MessageRecipient)(setupPacket.requestType & 0x3); ushort index = setupPacket.index; byte request = setupPacket.request; ushort value = setupPacket.value; switch ((HUBRequestCode)request) { case HUBRequestCode.ClearHubFeature: if (index > 0) { switch ((PortFeature)value) { case PortFeature.CPortSuspend: ports[index - 1] = (uint)(ports[index - 1] & (~((uint)PortStatus.CPortSuspend))); break; case PortFeature.CPortOverCurrent: ports[index - 1] = (uint)(ports[index - 1] & (~((uint)PortStatus.CPortOverCurrent))); break; case PortFeature.CPortEnable: ports[index - 1] = (uint)(ports[index - 1] & (~((uint)PortStatus.CPortEnable))); break; case PortFeature.PortEnable: ports[index - 1] = (uint)(ports[index - 1] & (uint)PortStatus.PortEnable); break; case PortFeature.PortSuspend: ports[index - 1] = (uint)(ports[index - 1] & (uint)PortStatus.PortSuspend); break; case PortFeature.CPortConnection: ports[index - 1] = (uint)(ports[index - 1] & (~((uint)PortStatus.CPortConnection))); break; case PortFeature.CPortReset: ActiveDevice(this.GetDevice((byte)(index))); ports[index - 1] = (uint)(ports[index - 1] & (~((uint)PortStatus.CPortReset))); break; default: this.Log(LogLevel.Warning, "Unsupported ClearHubFeature request!!!"); break; } } break; case HUBRequestCode.SetHubFeature: if (index > 0) { if ((PortFeature)value == PortFeature.PortReset) { IUSBPeripheral device = GetDevice((byte)(index)); ports[index - 1] |= (uint)PortStatus.CPortReset; ports[index - 1] |= (uint)PortStatus.PortEnable; if (device != null) { device.SetAddress(0); device.Reset(); } } else if ((PortFeature)value == PortFeature.PortSuspend) { ports[index - 1] |= (uint)PortStatus.PortSuspend; } } break; default: this.Log(LogLevel.Warning, "Unsupported HUB ProcessClassSet request!!!"); break; } }
public void Unregister(IUSBPeripheral peripheral) { DetachDevice(registrationPoints[peripheral].Address.Value); machine.UnregisterAsAChildOf(this, registrationPoints[peripheral]); registrationPoints.Remove(peripheral); }
public IEnumerable <USBRegistrationPoint> GetRegistrationPoints(IUSBPeripheral peripheral) { throw new System.NotImplementedException(); }
public void Register(IUSBPeripheral peripheral, USBRegistrationPoint registrationPoint) { AttachDevice(peripheral, registrationPoint.Address.Value); machine.RegisterAsAChildOf(this, peripheral, registrationPoint); registrationPoints.Add(peripheral, registrationPoint); }
public void AttachDevice(IUSBPeripheral device, byte port) { if (device.GetSpeed()==USBDeviceSpeed.High) ports[port - 1] |= (uint)PortStatus.CPortConnection | (uint)PortStatus.PortConnection | (uint)PortStatus.PortHighSpeed; else if (device.GetSpeed()==USBDeviceSpeed.Low) ports[port - 1] |= (uint)PortStatus.CPortConnection | (uint)PortStatus.PortConnection | (uint)PortStatus.PortLowSpeed; else ports[port - 1] |= (uint)PortStatus.CPortConnection | (uint)PortStatus.PortConnection; registeredDevices.Add(port, device); changed = true; /* Connect device to controller and send interrupt*/ var connected = Connected; if(connected != null) { connected(DeviceAddress); } }
public IEnumerable<USBRegistrationPoint> GetRegistrationPoints(IUSBPeripheral peripheral) { throw new System.NotImplementedException(); }