USB Entity

The USB Entity provides the software control interface for USB related features. This entity is supported by BrainStem products which have programmatically controlled USB features.

Port Enable/Disable (Set)

usb . setPortEnable => (unsigned char) channel
usb . setPortDisable => (unsigned char) channel

Enables or Disables the given downstream channel. This call enables or disables data and power together for the given channel.

Data Enable/Disable (Set)

usb . setDataEnable => (unsigned char) channel
usb . setDataDisable => (unsigned char) channel

Enables or Disables data only for given downstream channel. This call enables or disables the usb data (+) and data (-) lines for the given channel.

Calls to this command have no side effects on the power connections for the channel. If power was enabled before the call then it will still be enabled after the call to setDataEnable/Disable.

High Speed Data Enable/Disable (Set)

usb . setHiSpeedDataEnable => (unsigned char) channel
usb . setHiSpeedDataDisable => (unsigned char) channel

Enables or Disables Hi Speed data only for given downstream channel. This call enables or disables the usb data (+) and data (-) lines for the given channel.

Calls to this command have no side effects on the power connections for the channel. If power was enabled before the call then it will still be enabled after the call to setSuperSpeedDataEnable/Disable.

Super Speed Data Enable/Disable (Set)

usb . setSuperSpeedDataEnable => (unsigned char) channel
usb . setSuperSpeedDataDisable => (unsigned char) channel

Enables or Disables Super Speed (3.0) data only for given downstream channel. This call enables or disables the usb data (+) and data (-) lines for the given channel.

Calls to this command have no side effects on the power connections for the channel. If power was enabled before the call then it will still be enabled after the call to setSuperSpeedDataEnable/Disable.

Power Enable/Disable (Set)

usb . setPowerEnable => (unsigned char) channel
usb . setPowerDisable => (unsigned char) channel

Enables or Disables power only for given downstream channel. This call enables or disables the usb power connection for the given channel.

Calls to this command have no side effects on the data connections for the channel. If data was enabled before the call then it will still be enabled after the call to setPowerEnable/Disable.

port Voltage/Current (Get)

usb . getPortVoltage (unsigned char) channel <= (unsigned int) microvolts
usb . getPortCurrent (unsigned char) channel <= (unsigned int) microamps

Returns the last read values for Voltage (in microvolts) and Current (in microamps) for the given channel.

Hub Mode (Get/Set)

usb . getHubMode <= (unsigned int) state
usb . setHubMode => (unsigned int) state

Gets/Sets the hubs mode in the form of a big mapped representation. See the product datasheet for state mapping. Usually represents the downstream ports power and data lines enable/disable state.

Hub State (Get)

Note

This function has been removed in version 2.5. This functionality is moved to Port State.

Hub Error Status (Get)

Note

This function has been removed in version 2.5. This functionality is moved to Port Error.

Clear Port Error Status (Set)

usb . clearPortErrorStatus => (unsigned char) channel

Clears the error status for the given channel

Upstream Mode (Get/Set)

usb . getUpstreamMode <= (unsigned char) mode
usb . setUpstreamMode => (unsigned char) mode

Gets/Sets the mode of the upstream USB ports. Options are Auto, 0 or 1

Upstream State (Get)

usb . getUpstreamState <= (unsigned char) state

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

Enumeration Delay (Get/Set)

usb . getEnumerationDelay <= (unsigned int) ms_delay
usb . setEnumerationDelay => (unsigned int) ms_delay

Gets/Sets the inter-port enumeration delay in milliseconds. The enumeration delay sequentially enables data and power to downstream ports after the defined delay time. After setting and saving this parameter all downstream ports will be initially disabled upon system power-on or reset. Similarly, if there is no upstream connection, all downstream ports will be disabled. When an upstream connection is applied, or after the system boots, the system will wait for the defined delay time and enable the lowest port number. The system will then wait for the defined delay time and then enable the next highest port. This behavior repeats until all ports are enabled.

Inconsistent behavior from race conditions may occur if enumeration delay is used in conjunction with Reflex programs which also manipulate the downstream port states. Care should be taken to ensure no conflicts between the enumeration delay and Reflex programs.

Note

This setting should be saved with a stem.system.save() call.

Upstream Boost Mode (Get/Set)

usb . getUpstreamBoostMode <= (unsigned char) setting
usb . setUpstreamBoostMode => (unsigned char) setting

Gets/Sets the upstream boost mode. Boost mode increase 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. Modes: 0 = no boost, 1 = 4% boost, 2 = 8% boost, 3 = 12% boost.

Note

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.

Down Stream Boost Mode (Get/Set)

usb . getDownstreamBoostMode <= (unsigned char) setting
usb . setDownstreamBoostMode => (unsigned char) setting

Gets/Sets the Downstream boost mode. Boost mode increase 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. Modes: 0 = no boost, 1 = 4% boost, 2 = 8% boost, 3 = 12% boost.

Note

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.

Port Current Limit (Get/Set)

usb . setPortCurrentLimit  => (unsigned char) channel, (unsigned int) microamps
usb . getPortCurrentLimit (unsigned char) channel <=  (unsigned int) microamps

Gets/Sets the current limit for the downstream channel. There are a number of settings for current limits ranging from 100 mAmps to 2.5 amps. See the USB hub datasheet for specific settings information.

Port Mode setting (Get/Set)

usb . setPortMode => (unsigned char) channel, (unsigned char) mode
usb . getPortMode (unsigned char) channel <= (unsigned char) mode

Gets/Sets the Port mode for the channel specified. The portmode is a bitmapped setting. Device specific mode options are listed in the data-sheet. There is a unifed listing of all port mode bits at usbPortMode within USB Entity.

Port State (Get)

usb . getPortState (unsigned char) channel <= (unsigned char) mode

Gets the Port state for the channel specified. State options for the device are listed in the device data-sheet.

Port Error (Get)

usb . getPortError (unsigned char) channel <= (unsigned char) mode

Gets the Port error status for the channel specified. Error status for the device are listed in the device data-sheet.

System Temperature (Get)

Note

This function has been removed in version 2.5. This functionality is moved to Temperature Entity.

Connect Mode setting (Get/Set)

usb . setConnectMode => (unsigned char) channel, (unsigned char) mode
usb . getConnectMode (unsigned char) channel <= (unsigned char) mode

Gets/Sets the connect mode for the channel specified. Check the device datasheet for more information regarding the use of this function.

CC1/CC2 Enable/Disable setting (Get/Set)

usb . setCC[1|2]Enable => (unsigned char) channel, (unsigned char) bEnable
usb . getCC[1|2]Enable (unsigned char) channel <= (unsigned char) bEnable

Gets or sets the enabled status of the CC1/CC2 lines.

CC1/CC2 Current (Get)

usb . getCC[1|2]Current (unsigned char) channel <= (unsigned char) microAmps

Gets the current on the CC1/CC2 line in microAmps.

CC1/CC2 Voltage (Get)

usb . getCC[1|2]Voltage (unsigned char) channel <= (unsigned char) microVolts

Gets the voltage on the CC1/CC2 lines in microVolts.

SBU Enable/Disable setting (Get/Set)

usb . setSBUEnable => (unsigned char) channel, (unsigned char) bEnable
usb . getSBUEnable (unsigned char) channel <= (unsigned char) bEnable

Gets or sets the enabled status of the SBU lines.

Cable Flip (Get/Set)

usb . setCableFlip => (unsigned char) channel, (unsigned char) bEnable
usb . setCableFlip (unsigned char) channel <= (unsigned char) bEnable

Change the orientation of the common side to Mux side cable connection.

Code Examples

C++

// All commands return aErr values when errors are encountered and aErrNone on
// success. Get commands fill the variable with the returned value.

stem.usb.setPortEnable(1);
stem.usb.setPortDisable(2);
stem.usb.setDataEnable(0);
...

Reflex

// Get commands fill the variable with the returned value.

stem.usb.setPortEnable(1);
stem.usb.setPortDisable(2);
stem.usb.setDataEnable(0);
...

Python

stem.usb.setPortEnable(1)
stem.usb.setPortDisable(2)
stem.usb.setDataEnable(0)
stem.usb.setDataDisable(1)
stem.usb.setPowerEnable(0)
stem.usb.setPowerDisable(0)
microamps = stem.usb.getPortCurrent(0)
print microamps.value
microvolts = stem.usb.getPortVoltage(0)
print microvolts.value
stem.usb.setPortCurrentLimit(0, limit_setting)
state = stem.usb.getHubState()
print state.value
...