Port Entity¶
API Documentation: [cpp] [python] [.NET] [CCA] [REST]
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.
USB-C-Switch Pro exposes a Port Entity for each Type-C port on the device; however, most of these functions apply to the Common Port shared data and power path. While Port Entity is the recommended way to interface to USB-C-Switch Pro, some features are only available through the lower-level USB Entity:
Cable flip
Error clearing
Connect mode
SBU enable/disable
Ports are referenced by their instance index port[x] as shown below.
Port Label |
Index (port[x]) |
|---|---|
Mux 0-3 |
0-3 |
Common |
4 |
Control |
5 |
Data and Power Control (Common Port)¶
Enable or disable the entire port, including both data and power lines.
Enable or disable VBUS power only (independent of data path).
Enable or disable USB data lines (both USB 2.0 Hi-Speed and USB 3.x SuperSpeed) without affecting VBUS.
Enable or disable only the USB 2.0 Hi-Speed data lines.
Enable or disable only the USB 3.x SuperSpeed lanes.
Enable or disable both CC lines simultaneously.
Enable or disable individual CC1 / CC2 pins.
Electrical Measurements (Common, Mux, and Control Ports)¶
Voltage (µV)¶
Current (µA)¶
Note
SBU1 / SBU2 expose voltage only.
Port Mode¶
Port Mode provides a higher-level shortcut that bundles these controls into a single bit-mapped configuration, allowing you to enable or disable groups of lines and set routing behaviors in one operation.
Bit |
Port Mode Bit Map |
|---|---|
0 |
Reserved |
1 |
Reserved |
2 |
Keep Alive Charging Enable |
3 |
Reserved |
4 |
HS Data enable |
5 |
Reserved |
6 |
VBUS enable |
7 |
SS Data enable |
8:11 |
Reserved |
12 |
CC1 enable |
13 |
CC2 enable |
14 |
SBU enable |
15 |
CC Flip enable |
16 |
Super-Speed Flip enable |
17 |
SBU Flip enable |
18 |
Hi-Speed Flip enable |
19:31 |
Reserved |
Hi-Speed Data Routing and Protocol¶
Routing¶
Controls how the HighSpeed lanes will be routed.
Value |
Name |
Description |
|---|---|---|
0 |
Follow CC |
Hi-Speed lines follow the detected CC orientation. Default. |
1 |
Side A |
Route the Hi-Speed lines to side A. |
2 |
Side B |
Route the Hi-Speed lines to side B. |
3 |
Shorted |
Short the Hi-Speed lines on side A and side B together. |
Protocol¶
HighSpeed protocol controls what what the lines are used for and allows for UART injection.
Value |
Name |
Description |
|---|---|---|
0 |
None |
No data mode selection. |
1 |
Automatic |
Automatic data protocol selection. |
2 |
USB 2.0 |
USB 2.0 on the oriented D+/D- pair. Default. |
3 |
USB 2.0 + UART (RX on D+) |
USB 2.0 on the active pair. 2-wire UART on the opposite pair: RX on D+ and TX on D-. Requires the RS-232 feature. |
4 |
USB 2.0 + UART (TX on D+) |
USB 2.0 on the active pair. 2-wire UART on the opposite pair: TX on D+ and RX on D-. Requires the RS-232 feature. |
The 2-wire UART protocol requires the RS-232 feature.
SuperSpeed Data Routing and Protocol¶
Routing¶
Controls how the SuperSpeed lanes will be routed.
Value |
Name |
Description |
|---|---|---|
0 |
Follow CC |
SuperSpeed lanes follow the detected CC orientation. Default. |
1 |
Side A |
Route the SuperSpeed lanes to side A. |
2 |
Side B |
Route the SuperSpeed lanes to side B. |
3 |
Follow CC (inverted) |
SuperSpeed lanes follow the opposite of the detected CC orientation. |
Protocol¶
SuperSpeed protocol controls how the lanes are configured for alternate modes.
Value |
Name |
Description |
|---|---|---|
0 |
None |
SuperSpeed redrivers disabled. |
1 |
Automatic |
Follow the mode negotiated on the Common port. Default. |
2 |
USB 3.2 |
USB 3.2 SuperSpeed only. |
3 |
USB4 / Thunderbolt |
USB4 or Thunderbolt. |
4 |
4-lane DisplayPort |
DisplayPort on all four SuperSpeed lanes. |
5 |
2-lane DisplayPort + USB 3.2 |
Two DisplayPort lanes with USB 3.2 on the remaining pair. |
SBU Data Routing and Protocol¶
Routing¶
Controls how the SBU lanes will be routed.
Value |
Name |
Description |
|---|---|---|
0 |
Follow CC |
SBU lines follow the detected CC orientation. Default. |
1 |
Follow CC (inverted) |
SBU lines follow the opposite of the detected CC orientation. |
2 |
Side A |
Route the SBU lines to side A. |
3 |
Side B |
Route the SBU lines to side B. |
Protocol¶
SBU protocol controls what the lines are used for.
Value |
Name |
Description |
|---|---|---|
0 |
None |
Sideband decode and inject disabled. |
1 |
Automatic |
Follow the sideband use negotiated on the Common port. Default. |
2 |
2-wire UART |
UART on the sideband pins selected by SBU routing. RX on the A debug channel and TX on the B debug channel. Requires the RS-232 feature. |
3 |
2-wire DAP |
2-wire debug with SWCLK on SBU1 and SWDIO on SBU2. |
4 |
Link training |
Decode USB4 or Thunderbolt link training on both SBU lines. Requires PD Logging. |
5 |
DisplayPort Aux |
DisplayPort Aux channel. |
The 2-wire UART protocol requires the RS-232 feature. Link training requires PD Logging.
Port State¶
getState returns a 32-bit word describing the port as it is operating. It is available on every port index. Enable bits for Hi-Speed, SuperSpeed, and SBU are set on a Mux port only when that signal group is enabled and that port is the active channel for the group. Flip bits reflect the Common-to-Mux mapping and are reported on Mux and Common ports. Keep-alive charging is reported on Mux ports 0-3.
Port State Item |
Bit |
Value |
Define |
|---|---|---|---|
Power Enable |
0 |
0/1 |
portPortState_powerEnabled_Bit |
HS 1 Enable |
1 |
0/1 |
portPortState_HS1Enabled_Bit |
HS 2 Enable |
2 |
0/1 |
portPortState_HS2Enabled_Bit |
SS 1 Enable |
3 |
0/1 |
portPortState_SS1Enabled_Bit |
SS 2 Enable |
4 |
0/1 |
portPortState_SS2Enabled_Bit |
CC 1 Enable |
5 |
0/1 |
portPortState_CC1Enabled_Bit |
CC 2 Enable |
6 |
0/1 |
portPortState_CC2Enabled_Bit |
Vconn 1 Enable |
7 |
0/1 |
portPortState_Vconn1Enabled_Bit |
Vconn 2 Enable |
8 |
0/1 |
portPortState_Vconn2Enabled_Bit |
SBU 1 Enable |
9 |
0/1 |
portPortState_SBU1Enabled_Bit |
SBU 2 Enable |
10 |
0/1 |
portPortState_SBU2Enabled_Bit |
CC Flipped |
11 |
0/1 |
portPortState_CC_Flipped_Bit |
HS Flipped |
12 |
0/1 |
portPortState_HS_Flipped_Bit |
SS Flipped |
13 |
0/1 |
portPortState_SS_Flipped_Bit |
SBU Flipped |
14 |
0/1 |
portPortState_SBU_Flipped_Bit |
KAC Enable |
15 |
0/1 |
portPortState_KACEnabled_Bit |
HS Data Protocol: Offset |
19 |
portPortState_HSDataProtocol_Offset |
|
HS Data Protocol: Mask |
0x7 |
portPortState_HSDataProtocol_Mask |
|
HS Data Protocol: None |
19-21 |
0 |
portPortState_HSDataProtocol_None_Value |
HS Data Protocol: Unknown |
19-21 |
1 |
portPortState_HSDataProtocol_Unknown_Value |
HS Data Protocol: USB 2.0 |
19-21 |
2 |
portPortState_HSDataProtocol_USB2_Value |
HS Data Protocol: USB 2.0 + UART (RX on D+ / TX on D-) |
19-21 |
3 |
portPortState_HSDataProtocol_USB2 _TwoWire_UART_RX_TX_Value |
HS Data Protocol: USB 2.0 + UART (TX on D+ / RX on D-) |
19-21 |
4 |
portPortState_HSDataProtocol_USB2 _TwoWire_UART_TX_RX_Value |
SS Data Protocol: Offset |
22 |
portPortState_SSDataProtocol_Offset |
|
SS Data Protocol: Mask |
0xF |
portPortState_SSDataProtocol_Mask |
|
SS Data Protocol: None |
22-25 |
0 |
portPortState_SSDataProtocol_None_Value |
SS Data Protocol: Unknown |
22-25 |
1 |
portPortState_SSDataProtocol_Unknown_Value |
SS Data Protocol: USB 3.2 |
22-25 |
2 |
portPortState_SSDataProtocol_USB3_Value |
SS Data Protocol: USB4 / Thunderbolt |
22-25 |
3 |
portPortState_SSDataProtocol_USB4_Value |
SS Data Protocol: 4-lane DisplayPort |
22-25 |
4 |
portPortState_SSDataProtocol_4LaneDP_Value |
SS Data Protocol: 2-lane DisplayPort + USB 3.2 |
22-25 |
5 |
portPortState_SSDataProtocol_2LaneDP_With _USB3_Value |
SBU Data Protocol: Offset |
26 |
portPortState_SBUDataProtocol_Offset |
|
SBU Data Protocol: Mask |
0xF |
portPortState_SBUDataProtocol_Mask |
|
SBU Data Protocol: None |
26-29 |
0 |
portPortState_SBUDataProtocol_None_Value |
SBU Data Protocol: Unknown |
26-29 |
1 |
portPortState_SBUDataProtocol_Unknown_Value |
SBU Data Protocol: 2-wire UART |
26-29 |
2 |
portPortState_SBUDataProtocol_TwoWire_UART_Value |
SBU Data Protocol: 2-wire debug (SWCLK / SWDIO) |
26-29 |
3 |
portPortState_SBUDataProtocol_TwoWire_DAP _Value |
SBU Data Protocol: Link training |
26-29 |
4 |
portPortState_SBUDataProtocol_LinkTraining_Value |
SBU Data Protocol: DisplayPort Aux |
26-29 |
5 |
portPortState_SBUDataProtocol_Display_Aux_Value |
Accumulated Power¶
Reads total accumulated energy (mWh) sourced or sunk on VBUS and VCONN.
Resets accumulated energy and measurement interval.