USB Entity

group USBEntity

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.

void usb_setPortEnable(unsigned int *id, struct Result *result, const int index, const unsigned char channel)

Enable both power and data lines for a port.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone on success. Non-zero error code on failure.

  • index – The index of the entity in question.

  • channel – The USB sub channel.

void usb_setPortDisable(unsigned int *id, struct Result *result, const int index, const unsigned char channel)

Disable both power and data lines for a port.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone on success. Non-zero error code on failure.

  • index – The index of the entity in question.

  • channel – The USB sub channel.

void usb_setDataEnable(unsigned int *id, struct Result *result, const int index, const unsigned char channel)

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

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone on success. Non-zero error code on failure.

  • index – The index of the entity in question.

  • channel – The USB sub channel.

void usb_setDataDisable(unsigned int *id, struct Result *result, const int index, const unsigned char channel)

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

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone on success. Non-zero error code on failure.

  • index – The index of the entity in question.

  • channel – The USB sub channel.

void usb_setHiSpeedDataEnable(unsigned int *id, struct Result *result, const int index, 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.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone on success. Non-zero error code on failure.

  • index – The index of the entity in question.

  • channel – The USB sub channel.

void usb_setHiSpeedDataDisable(unsigned int *id, struct Result *result, const int index, 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.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone on success. Non-zero error code on failure.

  • index – The index of the entity in question.

  • channel – The USB sub channel.

void usb_setSuperSpeedDataEnable(unsigned int *id, struct Result *result, const int index, 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.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone on success. Non-zero error code on failure.

  • index – The index of the entity in question.

  • channel – The USB sub channel.

void usb_setSuperSpeedDataDisable(unsigned int *id, struct Result *result, const int index, const unsigned char channel)

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

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone on success. Non-zero error code on failure.

  • index – The index of the entity in question.

  • channel – The USB sub channel.

void usb_setPowerEnable(unsigned int *id, struct Result *result, const int index, const unsigned char channel)

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

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone on success. Non-zero error code on failure.

  • index – The index of the entity in question.

  • channel – The USB sub channel.

void usb_setPowerDisable(unsigned int *id, struct Result *result, const int index, const unsigned char channel)

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

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone on success. Non-zero error code on failure.

  • index – The index of the entity in question.

  • channel – The USB sub channel.

void usb_getPortCurrent(unsigned int *id, struct Result *result, const int index, const unsigned char channel)

Get the current through the power line for a port.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. The USB channel current in micro-amps (1 == 1e-6A).

  • index – The index of the entity in question.

  • channel – The USB sub channel.

void usb_getPortVoltage(unsigned int *id, struct Result *result, const int index, const unsigned char channel)

Get the voltage on the power line for a port.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. The USB channel voltage in microvolts (1 == 1e-6V).

  • index – The index of the entity in question.

  • channel – The USB sub channel.

void usb_getHubMode(unsigned int *id, struct Result *result, const int index)

Get a bit mapped representation of the hubs mode; see the product datasheet for mode mapping and meaning.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. The USB hub mode.

  • index – The index of the entity in question.

void usb_setHubMode(unsigned int *id, struct Result *result, const int index, const unsigned int mode)

Set a bit mapped hub state; see the product datasheet for state mapping and meaning.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone on success. Non-zero error code on failure.

  • index – The index of the entity in question.

  • mode – The USB hub mode.

void usb_clearPortErrorStatus(unsigned int *id, struct Result *result, const int index, const unsigned char channel)

Clear the error status for the given port.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone on success. Non-zero error code on failure.

  • index – The index of the entity in question.

  • channel – The port to clear error status for.

void usb_getUpstreamMode(unsigned int *id, struct Result *result, const int index)

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

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. The Upstream port mode.

  • index – The index of the entity in question.

void usb_setUpstreamMode(unsigned int *id, struct Result *result, const int index, const unsigned char mode)

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

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone on success. Non-zero error code on failure.

  • index – The index of the entity in question.

  • mode – The Upstream port mode.

void usb_getUpstreamState(unsigned int *id, struct Result *result, const int index)

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.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. The Upstream port state.

  • index – The index of the entity in question.

void usb_setEnumerationDelay(unsigned int *id, struct Result *result, const int index, const unsigned int ms_delay)

Set the inter-port enumeration delay in milliseconds.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone on success. Non-zero error code on failure.

  • index – The index of the entity in question.

  • ms_delay – Millisecond delay in 100mS increments (100, 200, 300 etc.)

void usb_getEnumerationDelay(unsigned int *id, struct Result *result, const int index)

Get the inter-port enumeration delay in milliseconds.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. Millisecond delay in 100mS increments (100, 200, 300 etc.)

  • index – The index of the entity in question.

void usb_setPortCurrentLimit(unsigned int *id, struct Result *result, const int index, 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.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone on success. Non-zero error code on failure.

  • index – The index of the entity in question.

  • channel – USB downstream channel to limit.

  • microamps – The current limit setting.

void usb_getPortCurrentLimit(unsigned int *id, struct Result *result, const int index, const unsigned char channel)

Get the current limit for the port.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. The current limit setting.

  • index – The index of the entity in question.

  • channel – USB downstream channel to limit.

void usb_setPortMode(unsigned int *id, struct Result *result, const int index, 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 reference page for a complete list of capabilities. Some devices use a common bit mapping for port mode at usbPortMode

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone on success. Non-zero error code on failure.

  • index – The index of the entity in question.

  • channel – USB downstream channel to set the mode on.

  • mode – The port mode setting as packed bit field.

void usb_getPortMode(unsigned int *id, struct Result *result, const int index, const unsigned char channel)

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 reference page for a complete list of capabilities. Some devices implement a common bit mapping for port mode at usbPortMode

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. 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

  • index – The index of the entity in question.

  • channel – USB downstream channel.

void usb_getPortState(unsigned int *id, struct Result *result, const int index, const unsigned char channel)

Get the current State for the Port.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. 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

  • index – The index of the entity in question.

  • channel – USB downstream channel.

void usb_getPortError(unsigned int *id, struct Result *result, const int index, const unsigned char channel)

Get the current error for the Port.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. 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

  • index – The index of the entity in question.

  • channel – USB downstream channel.

void usb_setUpstreamBoostMode(unsigned int *id, struct Result *result, const int index, 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.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone on success. Non-zero error code on failure.

  • index – The index of the entity in question.

  • setting – Upstream boost setting 0, 1, 2, or 3.

void usb_setDownstreamBoostMode(unsigned int *id, struct Result *result, const int index, 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.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone on success. Non-zero error code on failure.

  • index – The index of the entity in question.

  • setting – Downstream boost setting 0, 1, 2, or 3.

void usb_getUpstreamBoostMode(unsigned int *id, struct Result *result, const int index)

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

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. The current Upstream boost setting 0, 1, 2, or 3.

  • index – The index of the entity in question.

void usb_getDownstreamBoostMode(unsigned int *id, struct Result *result, const int index)

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

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. The current Downstream boost setting 0, 1, 2, or 3.

  • index – The index of the entity in question.

void usb_getDownstreamDataSpeed(unsigned int *id, struct Result *result, const int index, const unsigned char channel)

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

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. Filled with the current port data speed

    • N/A: usbDownstreamDataSpeed_na = 0

    • Hi Speed: usbDownstreamDataSpeed_hs = 1

    • SuperSpeed: usbDownstreamDataSpeed_ss = 2

  • index – The index of the entity in question.

  • channel – USB downstream channel to check.

void usb_setConnectMode(unsigned int *id, struct Result *result, const int index, const unsigned char channel, const unsigned char mode)

Sets the connect mode of the switch.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone on success. Non-zero error code on failure.

  • index – The index of the entity in question.

  • channel – The USB sub channel.

  • mode – The connect mode

    • usbManualConnect = 0

    • usbAutoConnect = 1

void usb_getConnectMode(unsigned int *id, struct Result *result, const int index, const unsigned char channel)

Gets the connect mode of the switch.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. The current connect mode

  • index – The index of the entity in question.

  • channel – The USB sub channel.

void usb_setCC1Enable(unsigned int *id, struct Result *result, const int index, const unsigned char channel, const unsigned char bEnable)

Set Enable/Disable on the CC1 line.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone on success. Non-zero error code on failure.

  • index – The index of the entity in question.

  • channel – USB channel.

  • bEnable – State to be set

    • Disabled: 0

    • Enabled: 1

void usb_getCC1Enable(unsigned int *id, struct Result *result, const int index, const unsigned char channel)

Get Enable/Disable on the CC1 line.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. State to be filled

    • Disabled: 0

    • Enabled: 1

  • index – The index of the entity in question.

  • channel – USB channel.

void usb_setCC2Enable(unsigned int *id, struct Result *result, const int index, const unsigned char channel, const unsigned char bEnable)

Set Enable/Disable on the CC2 line.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone on success. Non-zero error code on failure.

  • index – The index of the entity in question.

  • channel – USB channel.

  • bEnable – State to be filled

    • Disabled: 0

    • Enabled: 1

void usb_getCC2Enable(unsigned int *id, struct Result *result, const int index, const unsigned char channel)

Get Enable/Disable on the CC1 line.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure.

    • State to be filled

    • Disabled: 0

    • Enabled: 1

  • index – The index of the entity in question.

  • channel – - USB channel.

void usb_getCC1Current(unsigned int *id, struct Result *result, const int index, const unsigned char channel)

Get the current through the CC1 for a port.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. The USB channel current in micro-amps (1 == 1e-6A).

  • index – The index of the entity in question.

  • channel – The USB sub channel.

void usb_getCC2Current(unsigned int *id, struct Result *result, const int index, const unsigned char channel)

Get the current through the CC2 for a port.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. The USB channel current in micro-amps (1 == 1e-6A).

  • index – The index of the entity in question.

  • channel – The USB sub channel.

void usb_getCC1Voltage(unsigned int *id, struct Result *result, const int index, const unsigned char channel)

Get the voltage of CC1 for a port.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. The USB channel voltage in micro-volts (1 == 1e-6V).

  • index – The index of the entity in question.

  • channel – The USB sub channel.

void usb_getCC2Voltage(unsigned int *id, struct Result *result, const int index, const unsigned char channel)

Get the voltage of CC2 for a port.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. The USB channel voltage in micro-volts (1 == 1e-6V).

  • index – The index of the entity in question.

  • channel – The USB sub channel.

void usb_setSBUEnable(unsigned int *id, struct Result *result, const int index, const unsigned char channel, const unsigned char bEnable)

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

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone on success. Non-zero error code on failure.

  • index – The index of the entity in question.

  • channel – The USB sub channel.

  • bEnable – The state to be set

    • Disabled: 0

    • Enabled: 1

void usb_getSBUEnable(unsigned int *id, struct Result *result, const int index, const unsigned char channel)

Get the Enable/Disable status of the SBU

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. The enable/disable status of the SBU

  • index – The index of the entity in question.

  • channel – The USB sub channel.

void usb_setCableFlip(unsigned int *id, struct Result *result, const int index, const unsigned char channel, const unsigned char bEnable)

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

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone on success. Non-zero error code on failure.

  • index – The index of the entity in question.

  • channel – The USB sub channel.

  • bEnable – The state to be set The state to be set

    • Disabled: 0

    • Enabled: 1

void usb_getCableFlip(unsigned int *id, struct Result *result, const int index, const unsigned char channel)

Get Cable flip setting.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. The enable/disable status of cable flip.

  • index – The index of the entity in question.

  • channel – The USB sub channel.

void usb_setAltModeConfig(unsigned int *id, struct Result *result, const int index, const unsigned char channel, const unsigned int configuration)

Set USB Alt Mode Configuration.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone on success. Non-zero error code on failure.

  • index – The index of the entity in question.

  • channel – The USB sub channel

  • configuration – The USB configuration to be set for the given channel.

void usb_getAltModeConfig(unsigned int *id, struct Result *result, const int index, const unsigned char channel)

Get USB Alt Mode Configuration.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. The USB configuration for the given channel.

  • index – The index of the entity in question.

  • channel – The USB sub channel

void usb_getSBU1Voltage(unsigned int *id, struct Result *result, const int index, const unsigned char channel)

Get the voltage of SBU1 for a port.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. The USB channel voltage in micro-volts (1 == 1e-6V).

  • index – The index of the entity in question.

  • channel – The USB sub channel.

void usb_getSBU2Voltage(unsigned int *id, struct Result *result, const int index, const unsigned char channel)

Get the voltage of SBU2 for a port.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. The USB channel voltage in micro-volts (1 == 1e-6V).

  • index – The index of the entity in question.

  • channel – The USB sub channel.