USB Class

class USBClass

USBClass. The USB class provides methods to interact with a USB hub and USB switches. Different USB hub products have varying support; check the datasheet to understand the capabilities of each product.

Public Functions

USBClass(Acroname::BrainStem::USBClass &USB)

Constructor.

~USBClass()

Destructor.

Acroname::BrainStem2CLI::USBClass::!USBClass()

Finalizer.

aErr setPortEnable(const unsigned char channel)

Enable both power and data lines for a port.

Return

Returns common entity return values

Parameters
  • channel: The USB sub channel.

aErr setPortDisable(const unsigned char channel)

Disable both power and data lines for a port.

Return

Returns common entity return values

Parameters
  • channel: The USB sub channel.

aErr setDataEnable(const unsigned char channel)

Enable the only the data lines for a port without changing the state of the power line.

Return

Returns common entity return values

Parameters
  • channel: The USB sub channel.

aErr setDataDisable(const unsigned char channel)

Disable only the data lines for a port without changing the state of the power line.

Return

Returns common entity return values

Parameters
  • channel: The USB sub channel.

aErr setHiSpeedDataEnable(const unsigned char channel)

Enable the only the data lines for a port without changing the state of the power line, Hi-Speed (2.0) only.

Return

Returns common entity return values

Parameters
  • channel: The USB sub channel.

aErr setHiSpeedDataDisable(const unsigned char channel)

Disable only the data lines for a port without changing the state of the power line, Hi-Speed (2.0) only.

Return

Returns common entity return values

Parameters
  • channel: The USB sub channel.

aErr setSuperSpeedDataEnable(const unsigned char channel)

Enable the only the data lines for a port without changing the state of the power line, SuperSpeed (3.0) only.

Return

Returns common entity return values

Parameters
  • channel: The USB sub channel.

aErr setSuperSpeedDataDisable(const unsigned char channel)

Disable only the data lines for a port without changing the state of the power line, SuperSpeed (3.0) only.

Return

Returns common entity return values

Parameters
  • channel: The USB sub channel.

aErr setPowerEnable(const unsigned char channel)

Enable only the power line for a port without changing the state of the data lines.

Return

Returns common entity return values

Parameters
  • channel: The USB sub channel.

aErr setPowerDisable(const unsigned char channel)

Disable only the power line for a port without changing the state of the data lines.

Return

Returns common entity return values

Parameters
  • channel: The USB sub channel.

aErr getPortCurrent(const unsigned char channel, int %microamps)

Get the current through the power line for a port.

Return

Returns common entity return values

Parameters
  • channel: The USB sub channel.

  • microamps: The USB channel current in micro-amps (1 == 1e-6A).

aErr getPortVoltage(const unsigned char channel, int %microvolts)

Get the voltage on the power line for a port.

Return

Returns common entity return values

Parameters
  • channel: The USB sub channel.

  • microvolts: The USB channel voltage in microvolts (1 == 1e-6V).

aErr getHubMode(unsigned int %state)

Get a bit mapped representation of the hub mode; see the product datasheet for state mapping. Usually represents the hub’s downstream ports data and power line enable/disable state.

Return

Returns common entity return values

Parameters
  • state: The USB hub state.

aErr setHubMode(const unsigned int state)

Set a bit mapped hub state; see the product datasheet for state mapping. Usually represents the hub’s downstream ports data and power line enable/disable state.

Return

Returns common entity return values

Parameters
  • state: The USB hub state.

aErr clearPortErrorStatus(const unsigned char channel)

Clear the error status for the given channel.

Return

Returns common entity return values

Parameters
  • channel: the port to clear error status for.

aErr getUpstreamMode(unsigned char %mode)

Get the upstream switch mode for the USB upstream ports. Returns auto, port 0 or port 1.

Return

Returns common entity return values

Parameters
  • mode: The Upstream port mode.

aErr setUpstreamMode(const unsigned char mode)

Set the upstream switch mode for the USB upstream ports. Values are usbUpstreamModeAuto, usbUpstreamModePort0 and usbUpstreamModePort1

Return

Returns common entity return values

Parameters
  • mode: The Upstream port mode.

aErr getUpstreamState(unsigned char %state)

Get the upstream switch state for the USB upstream ports. Returns 2 if no ports plugged in, 0 if the mode is set correctly and a cable is plugged into port 0, and 1 if the mode is set correctly and a cable is plugged into port 1.

Return

Returns common entity return values

Parameters
  • state: The Upstream port state.

aErr setEnumerationDelay(const unsigned int ms_delay)

Set the interport enumeration delay in milliseconds. This setting should be saved with a stem.system.save() call.

Return

Returns common entity return values

Parameters
  • ms_delay: 100ms delay increment.

aErr getEnumerationDelay(unsigned int %ms_delay)

Get the interport enumeration delay.

Return

Returns common entity return values

Parameters
  • ms_delay: 100ms delay increment.

aErr setPortCurrentLimit(const unsigned char channel, const unsigned int microAmps)

Set the current limit for the port. If the set limit is not achievable, devices will round down to the nearest available current limit setting. This setting can be saved with a stem.system.save() call.

Return

Returns common entity return values

Parameters
  • channel: USB downstream channel to limit.

  • microAmps: The current limit setting.

aErr getPortCurrentLimit(const unsigned char channel, unsigned int %microAmps)

Get the current limit for the port. This reflects the limit setting currently. in effect.

Return

Returns common entity return values

Parameters
  • channel: USB downstream channel to limit.

  • microAmps: The current limit setting.

aErr setPortMode(const unsigned char channel, const unsigned int mode)

Set the mode for the Port. The mode is a bitmapped representation of the capabilities of the usb port. These capabilities change for each of the BrainStem devices which implement the usb entity. See your device datasheet for a complete list of capabilities. There is a unified bit mapping for port mode at usbPortMode

Return

Returns common entity return values

Parameters
  • channel: USB downstream channel to set the mode on.

  • mode: The port mode setting as packet bit mask.

aErr getPortMode(const unsigned char channel, unsigned int %mode)

Get the current mode for the Port. The mode is a bitmapped representation of the capabilities of the usb port. These capabilities change for each of the BrainStem devices which implement the usb entity. See your device datasheet for a complete list of capabilities. There is a unified bit mapping for port mode at usbPortMode

Return

Returns common entity return values

Parameters
  • channel: USB downstream channel.

  • mode: The port mode setting. Mode will be filled with the current setting. Mode bits that are not used will be marked as don’t care

aErr getPortState(const unsigned char channel, unsigned int %state)

Get the current State for the Port.

Return

Returns common entity return values

Parameters
  • channel: USB downstream channel.

  • state: The port mode setting. Mode will be filled with the current setting. Mode bits that are not used will be marked as don’t care

aErr getPortError(const unsigned char channel, unsigned int %error)

Get the current error for the Port.

Return

Returns common entity return values

Parameters
  • channel: USB downstream channel.

  • error: The port mode setting. Mode will be filled with the current setting. Mode bits that are not used will be marked as don’t care

aErr setUpstreamBoostMode(const unsigned char setting)

Set the upstream boost mode. Boost mode increases the drive strength of the USB data signals (power signals are not changed). Boosting the data signal strength may help to overcome connectivity issues when using long cables or connecting through “pogo” pins. Possible modes are 0 - no boost, 1 - 4% boost, 2 - 8% boost, 3 - 12% boost. This setting is not applied until a stem.system.save() call and power cycle of the hub. Setting is then persistent until changed or the hub is reset. After reset, default value of 0% boost is restored.

Return

Returns common entity return values

Parameters
  • setting: Upstream boost setting 0, 1, 2, or 3.

aErr setDownstreamBoostMode(const unsigned char setting)

Set the downstream boost mode. Boost mode increases the drive strength of the USB data signals (power signals are not changed). Boosting the data signal strength may help to overcome connectivity issues when using long cables or connecting through “pogo” pins. Possible modes are 0 - no boost, 1 - 4% boost, 2 - 8% boost, 3 - 12% boost. This setting is not applied until a stem.system.save() call and power cycle of the hub. Setting is then persistent until changed or the hub is reset. After reset, default value of 0% boost is restored.

Return

Returns common entity return values

Parameters
  • setting: Downstream boost setting 0, 1, 2, or 3.

aErr getUpstreamBoostMode(unsigned char %setting)

Get the upstream boost mode. Possible modes are 0 - no boost, 1 - 4% boost, 2 - 8% boost, 3 - 12% boost.

Return

Returns common entity return values

Parameters
  • setting: The current Upstream boost setting 0, 1, 2, or 3.

aErr getDownstreamBoostMode(unsigned char %setting)

Get the downstream boost mode. Possible modes are 0 - no boost, 1 - 4% boost, 2 - 8% boost, 3 - 12% boost.

Return

Returns common entity return values

Parameters
  • setting: The current Downstream boost setting 0, 1, 2, or 3.

aErr getDownstreamDataSpeed(const unsigned char channel, unsigned char %speed)

Get the current data transfer speed for the downstream port. The data speed can be Hi-Speed (2.0) or SuperSpeed (3.0) depending on what the downstream device attached is using

Return

Returns common entity return values

Parameters
  • channel: USB downstream channel to check.

  • speed: Filled with the current port data speed

    • N/A: usbDownstreamDataSpeed_na = 0

    • Hi Speed: usbDownstreamDataSpeed_hs = 1

    • SuperSpeed: usbDownstreamDataSpeed_ss = 2

aErr setConnectMode(const unsigned char channel, const unsigned char mode)

Sets the connect mode of the switch.

Return

Returns common entity return values

Parameters
  • channel: The USB sub channel.

  • mode: The connect mode

    • usbManualConnect = 0

    • usbAutoConnect = 1

aErr getConnectMode(const unsigned char channel, unsigned char %mode)

Gets the connect mode of the switch.

Return

Returns common entity return values

Parameters
  • channel: The USB sub channel.

  • mode: The current connect mode

aErr setCC1Enable(const unsigned char channel, const unsigned char bEnable)

Set Enable/Disable on the CC1 line.

Return

Returns common entity return values

Parameters
  • channel: - USB channel.

  • bEnable:

    • Disabled: 0

    • Enabled: 1

aErr getCC1Enable(const unsigned char channel, unsigned char %pEnable)

Get Enable/Disable on the CC1 line.

Return

Returns common entity return values

Parameters
  • channel: - USB channel.

  • pEnable:

    • Disabled: 0

    • Enabled: 1

aErr setCC2Enable(const unsigned char channel, const unsigned char bEnable)

Set Enable/Disable on the CC2 line.

Return

Returns common entity return values

Parameters
  • channel: - USB channel.

  • bEnable:

    • Disabled: 0

    • Enabled: 1

aErr getCC2Enable(const unsigned char channel, unsigned char %pEnable)

Get Enable/Disable on the CC1 line.

Return

Returns common entity return values

Parameters
  • channel: - USB channel.

  • pEnable:

    • Disabled: 0

    • Enabled: 1

aErr getCC1Current(const unsigned char channel, int %microamps)

Get the current through the CC1 for a port.

Return

Returns common entity return values

Parameters
  • channel: The USB sub channel.

  • microamps: The USB channel current in micro-amps (1 == 1e-6A).

aErr getCC2Current(const unsigned char channel, int %microamps)

Get the current through the CC2 for a port.

Return

Returns common entity return values

Parameters
  • channel: The USB sub channel.

  • microamps: The USB channel current in micro-amps (1 == 1e-6A).

aErr getCC1Voltage(const unsigned char channel, int %microvolts)

Get the voltage of CC1 for a port.

Return

Returns common entity return values

Parameters
  • channel: The USB sub channel.

  • microvolts: The USB channel voltage in micro-volts (1 == 1e-6V).

aErr getCC2Voltage(const unsigned char channel, int %microvolts)

Get the voltage of CC2 for a port.

Return

Returns common entity return values

Parameters
  • channel: The USB sub channel.

  • microvolts: The USB channel voltage in micro-volts (1 == 1e-6V).

aErr setSBUEnable(const unsigned char channel, const unsigned char bEnable)

Enable/Disable the only the SBU1/2 based on the configuration of the usbPortMode settings.

Return

Returns common entity return values

Parameters
  • channel: The USB sub channel.

  • bEnable:

    • Disabled: 0

    • Enabled: 1

aErr getSBUEnable(const unsigned char channel, unsigned char %pEnable)

Get the Enable/Disable status of the SBU

Return

Returns common entity return values

Parameters
  • channel: The USB sub channel.

  • pEnable: The enable/disable status of the SBU

aErr setCableFlip(const unsigned char channel, const unsigned char bEnable)

Set Cable flip. This will flip SBU, CC and SS data lines.

Return

Returns common entity return values

Parameters
  • channel: The USB sub channel.

  • bEnable:

    • Disabled: 0

    • Enabled: 1

aErr getCableFlip(const unsigned char channel, unsigned char %pEnable)

Get Cable setting.

Return

Returns common entity return values

Parameters
  • channel: The USB sub channel.

  • pEnable: The enable/disable status of cable flip.