External Load Testing¶
The External Load software feature allows for load testing of devices connected to ports 0-5 by way of an external connector on the back of the hub. This connector allows you to wire the USBHub3c to programmable or resistive loads so that you can test if your device is sourcing power properly.
This software feature can be exploited through the USBHub3c Rail Entity.
Although the external load feature will work in any mode it is only recommended to be used when the USBHub3c is sinking.
Example:¶
static const int TEST_PORT = 1;
aUSBHub3c stem;
stem.discoverAndConnect(USB);
// Check if we are sourcing power
uint8_t connectionState = 0;
stem.pd[TEST_PORT].getConnectionState(&connectionState);
// Ensure we are sinking
if (connectionState == powerdeliveryPowerRoleSink) {
stem.rail[TEST_PORT].setEnable(true);
// Do Stuff
int32_t voltage = 0;
int32_t current = 0;
stem.hub.port[TEST_PORT].getVbusVoltage(&voltage);
stem.hub.port[TEST_PORT].getVbusCurrent(¤t);
// Do Stuff
stem.rail[TEST_PORT].setEnable(false);
}
stem.disconnect();
TEST_PORT = 1;
stem = brainstem.stem.USBHub3c()
stem.discoverAndConnect(brainstem.link.Spec.USB);
# Check if we are sourcing power
connection_state_result = stem.pd[TEST_PORT].getConnectionState();
# Ensure we are sinking
if ((connection_state_result.value == _BS_C.powerdeliveryPowerRoleSink):
stem.rail[TEST_PORT].setEnable(true)
# Do Stuff
voltage_result = stem.hub.port[TEST_PORT].getVbusVoltage();
current_result = stem.hub.port[TEST_PORT].getVbusCurrent();
# Do Stuff
stem.rail[TEST_PORT].setEnable(false)
stem.disconnect()