Port

API Documentation: [cpp] [python] [.NET] [LabVIEW]

The Port Entity provides control over the most basic items related to a USB Port. This includes actions ranging from a complete port enable and disable to the individual interface control. Voltage and current measurements are also included for devices which support the Port Entity.


Port Control

The USBHub3c has a Port Entity for every Type C port on the device; however, not all ports have the same capabilities. These ports can be referenced by their instance (port[x]) index.

Port Label

Index (port[x])

0

0

1

1

2

2

3

3

4

4

5

5

Control

6

Power C

7

One of the most powerful features of the USBHub3c is its ability to turn ports on and off which is available on Ports 0-5.

stem.hub.port[x].setEnabled() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getEnabled() [cpp] [python] [NET] [LabVIEW]

Manipulating just the USB Vbus line for a single port can be done by calling the following method on Ports 0-5.

stem.hub.port[x].setPowerEnabled() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getPowerEnabled() [cpp] [python] [NET] [LabVIEW]

Manipulating Hi-Speed data and SuperSpeed data lines while not affecting the Vbus lines simultaneously for a single port can be done by calling the following method for Ports 0-5.

stem.hub.port[x].setDataEnabled() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getDataEnabled()[cpp] [python] [NET] [LabVIEW]

Manipulating just the USB 2.0 Hi-Speed data lines for a single port can be done by calling the following for Ports 0-5.

stem.hub.port[x].setDataHSEnabled() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getDataHSEnabled() [cpp] [python] [NET] [LabVIEW]

Even further granularity can be achieved through Hi-Speed 1 and Hi-Speed 2 control methods for Ports 0-5.

stem.hub.port[x].setDataHS1Enabled() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getDataHS1Enabled() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].setDataHS2Enabled() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getDataHS2Enabled() [cpp] [python] [NET] [LabVIEW]

Manipulating just the USB 3.1 SuperSpeed data lines for a single port can be done by calling the following method for Ports 0-5.

stem.hub.port[x].setDataSSEnabled() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getDataSSEnabled() [cpp] [python] [NET] [LabVIEW]

Just as with the Hi-Speed lines the USBHub3c also has granular control of the SuperSpeed 1 and SuperSpeed 2 lines.

stem.hub.port[x].setDataSS1Enabled() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getDataSS1Enabled() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].setDataSS2Enabled() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getDataSS2Enabled() [cpp] [python] [NET] [LabVIEW]

The CC lines can also be individually controlled.

stem.hub.port[x].setCCEnabled() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getCCEnabled() [cpp] [python] [NET] [LabVIEW]

As you would expect at this point granular control is also provided.

stem.hub.port[x].setCC1Enabled() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getCC1Enabled() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].setCC2Enabled() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getCC2Enabled() [cpp] [python] [NET] [LabVIEW]

Finally we come to Vconn control; however, this one overlaps with CC control because Vconn is what the unused CC line becomes (if needed). i.e. if CC1 is used for orientation and/or PD communication then CC2 will become Vconn (Vconn2) if it is enabled. If you are unaware of which pin is being used for Vconn you can simply call:

stem.hub.port[x].setVconnEnabled() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getVconnEnabled() [cpp] [python] [NET] [LabVIEW]

and the USBHub3c will take care of the guess work for you. If you are aware of which line is being used for Vconn you can use the granualar control just as we have outlined above.

stem.hub.port[x].setVconn1Enabled() [cpp] [python] [NET] :[LabVIEW]
stem.hub.port[x].getVconn1Enabled() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].setVconn2Enabled() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getVconn2Enabled() [cpp] [python] [NET] [LabVIEW]

Voltage and Current Measurements

The USBHub3c provides Voltage and Current measurements for both the Vbus and Vconn lines. These values can be acquired for all 8 ports through the following APIs

stem.hub.port[x].getVbusVoltage() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getVbusCurrent() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getVconnVoltage() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getVconnCurrent() [cpp] [python] [NET] [LabVIEW]

Power Modes

The ports of the USBHub3c are capable of providing power in multiple formats. The default is Power Delivery (PD), but that can be changed to things like: Standard Downstream Port (SDP), Charging Downstream Port (CDP) / Dedicated Charging Port (DCP), or even Qualcomm Quick Charge (QC) 3 and 4. These modes can be set through:

stem.hub.port[x].setPowerMode() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getPowerMode() [cpp] [python] [NET] [LabVIEW]

Power Mode

Value

Define

None

0

portPowerMode_none_Value

SDP

1

portPowerMode_sdp_Value

CDP/DCP

2

portPowerMode_cdp_dcp_Value

QC

3

portPowerMode_qc_Value

PD

4

portPowerMode_pd_Value

PS

5

portPowerMode_ps_Value

Note

The Power Modes can only be changed when the port power is disabled.

Port Mode

As outlined in the “Port Control” section the USBHub3c can individually manipulate almost every pin on the Type-C connector; however, depending on your application that might require multiple function calls in order to configure the port how you want it. Port Mode on the other hand is a one stop shop that allows you to pick and choose which lines you want enabled or disabled through a single call. Additionally, it has a few other features tucked away inside of it.

stem.hub.port[x].setMode() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getMode() [cpp] [python] [NET] [LabVIEW]

Port Mode Item

Bit

Value

Define

Power Enable

0

0/1

portPortMode_powerEnabled_Bit

HS 1 Enable

1

0/1

portPortMode_HS1Enabled_Bit

HS 2 Enable

2

0/1

portPortMode_HS2Enabled_Bit

SS 1 Enable

3

0/1

portPortMode_SS1Enabled_Bit

SS 2 Enable

4

0/1

portPortMode_SS2Enabled_Bit

CC 1 Enable

5

0/1

portPortMode_CC1Enabled_Bit

CC 2 Enable

6

0/1

portPortMode_CC2Enabled_Bit

Vconn 1 Enable

7

0/1

portPortMode_Vconn1Enabled_Bit

Vconn 2 Enable

8

0/1

portPortMode_Vconn2Enabled_Bit

Power Mode: Offset

16

portPortMode_portPowerMode_Offset

Power Mode: Mask

0x7

portPortMode_portPowerMode_Mask

Power Mode: None

16-18

0

portPortMode_portPowerMode_none_Value

Power Mode: SDP

16-18

1

portPortMode_portPowerMode_sdp_Value

Power Mode: CDP/DCP

16-18

2

portPortMode_cdp_dcp_Value

Power Mode: QC

16-18

3

portPortMode_portPowerMode_qc_Value

Power Mode: PD

16-18

4

portPortMode_portPowerMode_pd_Value

Power Mode: PS

16-18

4

portPortMode_portPowerMode_ps_Value

Data Role

The data role describes the current configuration of the port in regards to its data direction. In most cases this evaluates to an Upstream Facing Port (UFP) or a Downstream Facing Port (DFP). Upstream in this case means the host side of the port and Downstream refers to the device side. The Data Role can be aquired through:

stem.hub.port[x].getDataRole() [cpp] [python] [NET] [LabVIEW]

Data Role

Value

Define

Disabled

0

portDataRole_Disabled_Value

Upstream

1

portDataRole_Upstream_Value

Downstream

2

portDataRole_Downstream_Value

Control

3

portDataRole_Control_Value

Port Limits and Modes

At the Port level the user has the ability to define current limit and/or a power limit.

stem.hub.port[x].setCurrentLimit() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getCurrentLimit() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].setPowerLimit() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getPowerLimit() [cpp] [python] [NET] [LabVIEW]

If either of these values are exceed then the USBHub3c will then apply on of the following modes

stem.hub.port[x].setCurrentLimitMode() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getCurrentLimitMode() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].setPowerLimitMode() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getPowerLimitMode() [cpp] [python] [NET] [LabVIEW]

Available Power

One of the unique features of the USBHub3c is its ability to manage input and output power. Because of smart charging technologies like PD we know exactly how much power we have access too. That input power must then be shared across all of the ports. The following function allows the user to request the amount of power that is currently allocated to the port in question.

stem.hub.port[x].getAvailablePower() [cpp] [python] [NET] [LabVIEW]

Accumulated Power

The USBHub3c is capable of monitoring the accumulated power (energy) it has sank or sourced on both the VBus and VConn lines of each port. This value is presented as mWh.

stem.hub.port[x].getVbusAccumulatedPower() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getVconnAccumulatedPower() [cpp] [python] [NET] [LabVIEW]

The accumulated power is set to zero and the accumulation period is restarted with these commands.

stem.hub.port[x].resetVbusAccumulatedPower() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].resetVconnAccumulatedPower() [cpp] [python] [NET] [LabVIEW]

Downstream Data Speed

The USBHub3c can detect if a device has been enumerated. Additionally, it can detect at what speed a device has enumerated at.

stem.hub.port[x].getDataSpeed() [cpp] [python] [NET] [LabVIEW]

Data Speed

Bit

Value

Define

1.5 Mbit/s

0

0/1

portDataSpeed_ls_1p5M_Bit

12 Mbit/s

1

0/1

portDataSpeed_fs_12M_Bit

480 Mbit/s

2

0/1

portDataSpeed_hs_480M_Bit

5 Gbit/s

3

0/1

portDataSpeed_ss_5G_Bit

10 Gbit/s

4

0/1

portDataSpeed_ss_10G_Bit

USB 2.0

6

0/1

portDataSpeed_Connected_2p0_Bit

USB 3.0

7

0/1

portDataSpeed_Connected_3p0_Bit