Power Delivery¶
- class brainstem.entity.PowerDelivery(module, index)[source]¶
PowerDeliveryClass: Power Delivery or PD is a power specification which allows more charging options and device behaviors within the USB interface. This Entity will allow you to directly access the vast landscape of PD.
- getCableCurrentMax()[source]¶
Gets the maximum current capability report by the e-mark of the attached cable. Variable to be filled with an enumerated representation of current. - Unknown/Unattached (0) - 3 Amps (1) - 5 Amps (2)
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getCableOrientation()[source]¶
Gets the current orientation being used for PD communication Variable filled with an enumeration of the orientation. - Unconnected (0) - CC1 (1) - CC2 (2)
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getCableSpeedMax()[source]¶
Gets the maximum data rate capability reported by the e-mark of the attached cable. Variable to be filled with an enumerated representation of data speed. - Unknown/Unattached (0) - USB 2.0 (1) - USB 3.2 gen 1 (2) - USB 3.2 / USB 4 gen 2 (3) - USB 4 gen 3 (4)
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getCableType()[source]¶
Gets the cable type reported by the e-mark of the attached cable. Variable to be filled with an enumerated representation of the cable type. - Invalid, no e-mark and not Vconn powered (0) - Passive cable with e-mark (1) - Active cable (2)
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getCableVoltageMax()[source]¶
Gets the maximum voltage capability reported by the e-mark of the attached cable. Variable to be filled with an enumerated representation of voltage. - Unknown/Unattached (0) - 20 Volts DC (1) - 30 Volts DC (2) - 40 Volts DC (3) - 50 Volts DC (4)
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getConnectionState()[source]¶
Gets the current state of the connection in the form of an enumeration. Pointer to be filled with the current connection state.
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getFastRoleSwapCurrent()[source]¶
Gets the Fast Role Swap Current The fast role swap current refers to the amount of current required by the Local Sink in order to successfully preform the swap. An enumerated value referring to current swap value. - 0A (0) - 900mA (1) - 1.5A (2) - 3A (3)
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getFlagMode(flag)[source]¶
Gets the current mode of the local partner flag/advertisement. These flags are apart of the first Local Power Data Object and must be managed in order to accurately represent the system to other PD devices. This API allows overriding of that feature. Overriding may lead to unexpected behaviors. Variable to be filled with the current mode. - Disabled (0) - Enabled (1) - Auto (2) default
- Parameters:
flag (const unsigned char) – Flag/Advertisement to be modified
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getNumberOfPowerDataObjects(partner, powerRole)[source]¶
Gets the number of Power Data Objects (PDOs) for a given partner and power role. Variable to be filled with the number of PDOs.
- Parameters:
partner (const unsigned char) – Indicates which side of the PD connection is in question. - Local = 0 = powerdeliveryPartnerLocal - Remote = 1 = powerdeliveryPartnerRemote
powerRole (const unsigned char) – Indicates which power role of PD connection is in question. - Source = 1 = powerdeliveryPowerRoleSource - Sink = 2 = powerdeliveryPowerRoleSink
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getOverride()[source]¶
Gets the current enabled overrides Bit mapped representation of the current override configuration.
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getPeakCurrentConfiguration()[source]¶
Gets the Peak Current Configuration for the Local Source. The peak current configuration refers to the allowable tolerance/overload capabilities in regards to the devices max current. This tolerance includes a maximum value and a time unit. An enumerated value referring to the current configuration. - Allowable values are 0 - 4
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getPowerDataObject(partner, powerRole, ruleIndex)[source]¶
Gets the Power Data Object (PDO) for the requested partner, powerRole and index. Variable to be filled with the requested power rule.
- Parameters:
partner (const unsigned char) – Indicates which side of the PD connection is in question. - Local = 0 = powerdeliveryPartnerLocal - Remote = 1 = powerdeliveryPartnerRemote
powerRole (const unsigned char) – Indicates which power role of PD connection is in question. - Source = 1 = powerdeliveryPowerRoleSource - Sink = 2 = powerdeliveryPowerRoleSink
ruleIndex (const unsigned char) – The index of the PDO in question. Valid index are 1-7.
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getPowerDataObjectEnabled(powerRole, ruleIndex)[source]¶
Gets the enabled state of the Local Power Data Object (PDO) for a given power role and index. Enabled refers to whether the PDO will be advertised when a PD connection is made. This does not indicate the currently active rule index. This information can be found in Request Data Object (RDO). Variable to be filled with enabled state.
- Parameters:
powerRole (const unsigned char) – Indicates which power role of PD connection is in question. - Source = 1 = powerdeliveryPowerRoleSource - Sink = 2 = powerdeliveryPowerRoleSink
ruleIndex (const unsigned char) – The index of the PDO in question. Valid index are 1-7.
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getPowerDataObjectEnabledList(powerRole)[source]¶
Gets all Power Data Object enables for a given power role. Equivalent of calling PowerDeliveryClass::getPowerDataObjectEnabled() for all indexes. Variable to be filled with a mapped representation of the enabled PDOs for a given power role. Values align with a given rule index (bits 1-7, bit 0 is invalid)
- Parameters:
powerRole (const unsigned char) – Indicates which power role of PD connection is in question. - Source = 1 = powerdeliveryPowerRoleSource - Sink = 2 = powerdeliveryPowerRoleSink
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getPowerDataObjectList(buffer_length=65536)[source]¶
Gets all Power Data Objects (PDOs). Equivalent to calling PowerDeliveryClass::getPowerDataObject() on all partners, power roles, and index’s. Length that was actually received and filled. On success this value should be 28 (7 rules * 2 partners * 2 power roles)
- Parameters:
buffer_length – Length of the buffer to be filed
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getPowerRole()[source]¶
Gets the power role that is currently being advertised by the local partner. (CC Strapping). Variable to be filed with the power role - Disabled = 0 = powerdeliveryPowerRoleDisabled - Source = 1= powerdeliveryPowerRoleSource - Sink = 2 = powerdeliveryPowerRoleSink - Source/Sink = 3 = powerdeliveryPowerRoleSourceSink (Dual Role Port)
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getPowerRolePreferred()[source]¶
Gets the preferred power role currently being advertised by the Local partner. (CC Strapping). Value to be applied. - Disabled = 0 = powerdeliveryPowerRoleDisabled - Source = 1= powerdeliveryPowerRoleSource - Sink = 2 = powerdeliveryPowerRoleSink
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getRequestDataObject(partner)[source]¶
Gets the current Request Data Object (RDO) for a given partner. RDOs: Are provided by the sinking device. Exist only after a successful PD negotiation (Otherwise zero). Only one RDO can exist at a time. i.e. Either the Local or Remote partner RDO Variable to be filled with the current RDO. Zero indicates the RDO is not active.
- Parameters:
partner (const unsigned char) – Indicates which side of the PD connection is in question. - Local = 0 = powerdeliveryPartnerLocal - Remote = 1 = powerdeliveryPartnerRemote
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- packDataObjectAttributes(attributes, partner, powerRole, ruleIndex)[source]¶
Helper function for packing Data Object attributes. This value is used as a subindex for all Data Object calls with the BrainStem Protocol. aErrNone on success; aErrParam with bad input.
- Parameters:
attributes (unsigned char *) – variable to be filled with packed values.
partner (const unsigned char) – Indicates which side of the PD connection. - Local = 0 = powerdeliveryPartnerLocal - Remote = 1 = powerdeliveryPartnerRemote
powerRole (const unsigned char) – Indicates which power role of PD connection. - Source = 1 = powerdeliveryPowerRoleSource - Sink = 2 = powerdeliveryPowerRoleSink
ruleIndex (const unsigned char) – Data object index.
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- request(request)[source]¶
Requests an action of the Remote partner. Actions are not guaranteed to occur. The returned error represents the success of the request being sent to the partner only. The success of the request being serviced by the remote partner can be obtained through PowerDeliveryClass::requestStatus() Returns
ef EntityReturnValues “common entity” return values
- param request:
Request to be issued to the remote partner - pdRequestHardReset (0) - pdRequestSoftReset (1) - pdRequestDataReset (2) - pdRequestPowerRoleSwap (3) - pdRequestPowerFastRoleSwap (4) - pdRequestDataRoleSwap (5) - pdRequestVconnSwap (6) - pdRequestSinkGoToMinimum (7) - pdRequestRemoteSourcePowerDataObjects (8) - pdRequestRemoteSinkPowerDataObjects (9)
- type request:
const unsigned char
- return:
An error result from the list of defined error codes in brainstem.result
- rtype:
unsigned byte
- requestStatus()[source]¶
Gets the status of the last request command sent. Variable to be filled with the status
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- resetEntityToFactoryDefaults()[source]¶
Resets the PowerDeliveryClass Entity to it factory default configuration.
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- resetPowerDataObjectToDefault(powerRole, ruleIndex)[source]¶
Resets the Power Data Object (PDO) of the Local partner for a given power role and index.
- Parameters:
powerRole (const unsigned char) – Indicates which power role of PD connection is in question. - Source = 1 = powerdeliveryPowerRoleSource - Sink = 2 = powerdeliveryPowerRoleSink
ruleIndex (const unsigned char) – The index of the PDO in question. Valid index are 1-7.
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setFastRoleSwapCurrent(swapCurrent)[source]¶
Sets the Fast Role Swap Current The fast role swap current refers to the amount of current required by the Local Sink in order to successfully preform the swap.
- Parameters:
swapCurrent (const unsigned char) – An enumerated value referring to value to be set. - 0A (0) - 900mA (1) - 1.5A (2) - 3A (3)
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setFlagMode(flag, mode)[source]¶
Sets how the local partner flag/advertisement is managed. These flags are apart of the first Local Power Data Object and must be managed in order to accurately represent the system to other PD devices. This API allows overriding of that feature. Overriding may lead to unexpected behaviors.
- Parameters:
flag (const unsigned char) – Flag/Advertisement to be modified
mode (const unsigned char) – Value to be applied. - Disabled (0) - Enabled (1) - Auto (2) default
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setOverride(overrides)[source]¶
Sets the current enabled overrides
- Parameters:
overrides (const unsigned int) – Overrides to be set in a bit mapped representation.
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setPeakCurrentConfiguration(configuration)[source]¶
Sets the Peak Current Configuration for the Local Source. The peak current configuration refers to the allowable tolerance/overload capabilities in regards to the devices max current. This tolerance includes a maximum value and a time unit.
- Parameters:
configuration (const unsigned char) – An enumerated value referring to the configuration to be set - Allowable values are 0 - 4
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setPowerDataObject(powerRole, ruleIndex, pdo)[source]¶
Sets the Power Data Object (PDO) of the local partner for a given power role and index.
- Parameters:
powerRole (const unsigned char) – Indicates which power role of PD connection is in question. - Source = 1 = powerdeliveryPowerRoleSource - Sink = 2 = powerdeliveryPowerRoleSink
ruleIndex (const unsigned char) – The index of the PDO in question. Valid index are 1-7.
pdo (const unsigned int) – Power Data Object to be set.
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setPowerDataObjectEnabled(powerRole, ruleIndex, enabled)[source]¶
Sets the enabled state of the Local Power Data Object (PDO) for a given powerRole and index. Enabled refers to whether the PDO will be advertised when a PD connection is made. This does not indicate the currently active rule index. This information can be found in Request Data Object (RDO).
- Parameters:
powerRole (const unsigned char) – Indicates which power role of PD connection is in question. - Source = 1 = powerdeliveryPowerRoleSource - Sink = 2 = powerdeliveryPowerRoleSink
ruleIndex (const unsigned char) – The index of the PDO in question. Valid index are 1-7.
enabled (const unsigned char) – The state to be set.
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setPowerRole(powerRole)[source]¶
Set the current power role to be advertised by the Local partner. (CC Strapping).
- Parameters:
powerRole (const unsigned char) – Value to be applied. - Disabled = 0 = powerdeliveryPowerRoleDisabled - Source = 1= powerdeliveryPowerRoleSource - Sink = 2 = powerdeliveryPowerRoleSink - Source/Sink = 3 = powerdeliveryPowerRoleSourceSink (Dual Role Port)
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setPowerRolePreferred(powerRole)[source]¶
Set the preferred power role to be advertised by the Local partner (CC Strapping).
- Parameters:
powerRole (const unsigned char) – Value to be applied. - Disabled = 0 = powerdeliveryPowerRoleDisabled - Source = 1= powerdeliveryPowerRoleSource - Sink = 2 = powerdeliveryPowerRoleSink
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setRequestDataObject(rdo)[source]¶
Sets the current Request Data Object (RDO) for a given partner. (Only the local partner can be changed.) RDOs: Are provided by the sinking device. Exist only after a successful PD negotiation (Otherwise zero). Only one RDO can exist at a time. i.e. Either the Local or Remote partner RDO
- Parameters:
rdo (const unsigned int) – Request Data Object to be set.
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- unpackDataObjectAttributes(attributes, partner, powerRole)[source]¶
Helper function for unpacking Data Object attributes. This value is used as a subindex for all Data Object calls with the BrainStem Protocol. Data object index. aErrNone on success; aErrParam with bad input.
- Parameters:
attributes (const unsigned char) – variable to be filled with packed values.
partner (unsigned char *) – Indicates which side of the PD connection. - Local = 0 = powerdeliveryPartnerLocal - Remote = 1 = powerdeliveryPartnerRemote
powerRole (unsigned char *) – Indicates which power role of PD connection. - Source = 1 = powerdeliveryPowerRoleSource - Sink = 2 = powerdeliveryPowerRoleSink
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type: