/// <summary> /// Sets up a USb device connected to the specified port. /// </summary> /// <param name="portNum">The port to which the device to set up is connected.</param> protected virtual void SetupUSBDevice(byte portNum) { HCPort port = GetPort(portNum); port.deviceInfo = USBManager.CreateDeviceInfo(this, port); USBManager.SetupDevice(port.deviceInfo, (byte)(portNum + 1)); }
protected void AnalysePortStatus(byte j, ushort val) { #if UHCI_TRACE BasicConsole.WriteLine("UHCI: Anaylse port status"); BasicConsole.DelayOutput(5); #endif HCPort port = GetPort(j); if ((val & UHCI_Consts.PORT_LOWSPEED_DEVICE) != 0) { #if UHCI_TRACE BasicConsole.Write("UHCI: Lowspeed device"); #endif port.speed = USBPortSpeed.Low; // Save lowspeed/fullspeed information in data } else { #if UHCI_TRACE BasicConsole.Write("UHCI: Fullspeed device"); #endif port.speed = USBPortSpeed.Full; // Save lowspeed/fullspeed information in data } if (((val & UHCI_Consts.PORT_CS) != 0) && !port.connected) { #if UHCI_TRACE BasicConsole.WriteLine(" attached."); #endif port.connected = true; ResetPort(j); // reset on attached SetupUSBDevice(j); } else if (port.connected) { #if UHCI_TRACE BasicConsole.WriteLine(" removed."); #endif port.connected = false; if (port.deviceInfo != null) { port.deviceInfo.FreePort(); } } #if UHCI_TRACE else { BasicConsole.WriteLine(" not attached."); } #endif }
/// <summary> /// Creates new device info for the specified port. /// </summary> /// <param name="hc">The host contorller which owns the port.</param> /// <param name="port">The port to create device info for.</param> /// <returns>The new device info.</returns> public static Devices.USBDeviceInfo CreateDeviceInfo(HCI hc, HCPort port) { #if USB_TRACE DBGMSG("Creating USB device..."); #endif USBDeviceInfo deviceInf = new USBDeviceInfo(port.portNum, hc); deviceInf.Configurations = new List(1); deviceInf.Interfaces = new List(1); deviceInf.Endpoints = new List(1); deviceInf.Endpoints.Add(new Endpoint()); ((Endpoint)deviceInf.Endpoints[0]).MPS = 64; ((Endpoint)deviceInf.Endpoints[0]).Type = Endpoint.Types.BIDIR; ((Endpoint)deviceInf.Endpoints[0]).Toggle = false; #if USB_TRACE DBGMSG("Created device."); #endif return deviceInf; }