Device

Contains the organizing hardware used to add USB Device functionality to your own designs; including the core USBDevice class.

class sol_usb.gateware.usb.usb2.device.USBDevice(*args, src_loc_at: int = 0, **kwargs)

Core gateware common to all SOL USB2 devices.

The USBDevice module contains the low-level communications hardware necessary to implement a USB device; including hardware for maintaining device state, detecting events, reading data from the host, and generating responses.

This class can be instantiated directly, and used to build a USB device, or can be subclassed to create custom device types.

To configure a USBDevice from a CPU or other wishbone master, see USBDeviceController; which can easily be attached using its attach method.

Parameters:
  • bus ([UTMI interface, ULPI Interface]) – The UTMI or ULPI PHY connection to be used for communications.

  • handle_clocking (bool, Optional) – True iff we should attempt to connect up the usb clock domain to the PHY automatically based on the clk signals’s I/O direction. This option may not work for non-simple connections; in which case you will need to connect the clock signal yourself.

Variables:
  • connect (Signal(), input) – Held high to keep the current USB device connected; or held low to disconnect.

  • low_speed_only (Signal(), input) – If high, the device will operate at low speed.

  • full_speed_only (Signal(), input) – If high, the device will be prohibited from operating at high speed.

  • frame_number (Signal(11), output) – The current USB frame number.

  • microframe_number (Signal(3), output) – The current USB microframe number. Always 0 on non-HS connections.

  • sof_detected (Signal(), output) – Pulses for one cycle each time a SOF is detected; and thus our frame number has changed.

  • new_frame (Signal(), output) – Strobe that indicates a new frame (not microframe) is detected.

  • reset_detected (Signal(), output) – Asserted when the USB device receives a bus reset.

  • signals. (# State)

  • suspended (Signal(), output) – High when the device is in USB suspend. This can be (and by the spec must be) used to trigger the device to enter lower-power states.

  • tx_activity_led (Signal(), output) – Signal that can be used to drive an activity LED for TX.

  • rx_activity_led (Signal(), output) – Signal that can be used to drive an activity LED for RX.

add_endpoint(endpoint)

Adds an endpoint interface to the device.

Parameters:

endpoint (Elaborateable) – The endpoint interface to be added. Can be any piece of gateware with a EndpointInterface attribute called interface.

add_control_endpoint()

Adds a basic control endpoint to the device.

Does not add any request handlers. If you want standard request handlers; add_standard_control_endpoint automatically adds standard request handlers.

Return type:

Returns the endpoint object for the control endpoint.

add_standard_control_endpoint(descriptors: DeviceDescriptorCollection, **kwargs)

Adds a control endpoint with standard request handlers to the device.

Parameters will be passed on to StandardRequestHandler.

Return value

The endpoint object created.