Enumerations

enum class PowerSupplyType : uint8_t
Name Value Comments
kFixedSupply 0b00 --
kBattery 0b01 --
kVariableSupply 0b10 --
kAugmentedPowerDataObject 0b11

APDO

Power supply type

usbpd3.1 6.4.1 "Capabilities Message", Table 6-7 "Power Data Object"

Defined at line 24 of file ../../src/devices/power/drivers/fusb302/usb-pd-message-objects.h

enum class ControlMessageType : uint8_t
Name Value Comments
kGoodCrc 0b0'0001

GoodCRC

kGoToMinimumOperatingCurrent 0b0'0010

GotoMin

kAccept 0b0'0011

Accept

kReject 0b0'0100

Reject

kPing 0b0'0101

Ping

kPowerSupplyReady 0b0'0110

PS_RDY

kGetSourceCapabilities 0b0'0111

Get_Source_Cap

kGetSinkCapabilities 0b0'1000

Get_Sink_Cap

kDataRoleSwap 0b0'1001

DR_Swap

kPowerRoleSwap 0b0'1010

PR_Swap

kVconnSourceSwap 0b0'1011

VCONN_Swap

kWait 0b0'1100

Wait

kSoftReset 0b0'1101

Soft_Reset

kDataReset 0b0'1110

Data_Reset

kDataResetComplete 0b0'1111

Data_Reset_Complete

kNotSupported 0b1'0000

Not_Supported

kGetExtendedSourceCapabilities 0b1'0001

Get_Source_Cap_Extended

kGetStatus 0b1'0010

Get_Status

kFastRoleSwap 0b1'0011

FR_Swap

kGetProgrammablePowerSupplyStatus 0b1'0100

Get_PPS_Status

kGetCountryCodes 0b1'0101

Get_Country_Codes

kGetExtendedSinkCapabilities 0b1'0110

Get_Sink_Cap_Extended

kGetSourceInfo 0b1'0111

Get_Source_Info

kGetMaximumPdSpecRevision 0b1'1000

Get_Revision

Message type codes for messages with no data objects and no extended flag.

Each message type is described in a sub-section of usbpd3.1 6.3. The

sub-section number matches the message type's code.

usbpd3.1 6.3 "Control Message", Table 6-5 "Control Message Types"

Defined at line 25 of file ../../src/devices/power/drivers/fusb302/usb-pd-message-type.h

enum class PowerRole : int8_t
Name Value
kSink 0
kSource 1

Type-safe selector for a USB power role.

The values match usbpd3.1 6.2.1.1.4 "Port Power Role". So, instances can be

bit-copied into PD message headers.

Defined at line 29 of file ../../src/devices/power/drivers/fusb302/usb-pd-defs.h

enum class SpecRevision : uint8_t
Name Value
kRev1 0b00
kRev2 0b01
kRev3 0b10

Specification Revision

The values match usbpd3.1 6.2.1.1.5 "Specification Revision". So, instances

can be bit-copied into PD message headers.

Defined at line 41 of file ../../src/devices/power/drivers/fusb302/usb-pd-defs.h

enum class DataRole : uint8_t
Name Value Comments
kUpstreamFacingPort 0

UFP

kDownstreamFacingPort 1

DFP

Type-safe selector for a USB data role.

The values match usbpd3.1 6.2.1.1.6 "Port Data Role". So, instances can be

bit-copied into PD message headers.

Defined at line 51 of file ../../src/devices/power/drivers/fusb302/usb-pd-defs.h

enum class DataMessageType : uint8_t
Name Value Comments
kSourceCapabilities 0b0'0001

Source_Capabilities, Section 6.4.1.2

kRequestPower 0b0'0010

Request, Section 6.4.2

kBuiltInSelfTest 0b0'0011

BIST, Section 6.4.3

kSinkCapabilities 0b0'0100

Sink_Capabilities, Section 6.4.1.3

kBatteryStatus 0b0'0101

Battery_Status, Section 6.4.5

kAlert 0b0'0110

Alert, Section 6.4.6

kGetCountryInfo 0b0'0111

Get_Country_Info, Section 6.4.7

kEnterUsb 0b0'1000

Enter_USB, Section 6.4.8

kExtendedPowerRangeRequest 0b0'1001

EPR_Request, Section 6.4.9

kExtendedPowerRangeMode 0b0'1010

EPR_Mode, Section 6.4.10

kSourceInfo 0b0'1011

Source_Info, Section 6.4.11

kMaximumPdSpecRevision 0b0'1100

Revision, Section 6.4.12

kVendorDefined 0b0'1111

Vendor_Defined, Section 6.4.4

Message type codes for messages with data objects and no extended flag.

usbpd3.1 6.4 "Data Message", Table 6-6 "Data Message Types"

Defined at line 57 of file ../../src/devices/power/drivers/fusb302/usb-pd-message-type.h

enum class ConfigChannelPinId : int8_t
Name Value
kCc1 1
kCc2 2

Type-safe selector for one of the two CC (Configuration Channel) pins.

The Configuration Channel is introduced in usbpd3.1 2.1 "Introduction", and

its role is summarized in usbpd3.1 2.3 "Configuration Process".

Defined at line 63 of file ../../src/devices/power/drivers/fusb302/usb-pd-defs.h

enum class ConfigChannelPinSwitch : int8_t
Name Value
kNone 0
kCc1 1
kCc2 2

State of a switch that can either point to a CC pin or be open.

See `ConfigChannelPinId` for a description of the CC (Configuration Channel)

pins.

Defined at line 75 of file ../../src/devices/power/drivers/fusb302/usb-pd-defs.h

enum class PeakCurrentSupport
Name Value Comments
kNoOverload 0b00 --
kOverloadLevel1 0b01

Overload limit: 150% for 1ms / 125% for 2ms / 110% for 10ms

kOverloadLevel2 0b10

Overload limit: 200% for 1ms / 150% for 2ms / 125% for 10ms

kOverloadLevel3 0b11

Overload limit: 200% for 1ms / 175% for 2ms / 150% for 10ms

A fixed power source's ability to briefly exceed the operating current.

usbpd3.1 measures the Source's ability to handle spikes of three maximum

durations (1ms / 2ms / 10ms) out of a 20ms duty cycle. In all cases, the

current consumption over an entire duty cycle must still match the source's

operating current. So, a spike must be compensated by lower current

consumption during the rest of the duty cycle.

usbpd3.1 6.4.1.2.2.8 "Peak Current"

Defined at line 75 of file ../../src/devices/power/drivers/fusb302/usb-pd-message-objects.h

enum class ConfigChannelTermination : int8_t
Name Value Comments
kUnknown 0 --
kOpen 1 --
kRa 2 --
kRd 3 --
kRpStandardUsb 4 --
kRp1500mA 5

usbpd3.1 5.7 "Collision Avoidance" states that after a PD Explicit Contract
is established, this Source termination signals SinkTxOk (the Sink may
initiate a BMC transmission). This helps avoid BMC collisions.

kRp3000mA 6

usbpd3.1 5.7 "Collision Avoidance" states that after a PD Explicit Contract
is established, this Source termination signals SinkTxNG (Sink transmission
No Go). This helps avoid BMC collisions.

Measured voltage of a CC pin.

The voltage ranges are specified in typec2.2 4.11.3 "Voltage Parameters".

Defined at line 87 of file ../../src/devices/power/drivers/fusb302/usb-pd-defs.h

enum class MessageType : uint8_t
Name Value
kGoodCrc static_cast<uint8_t>(ControlMessageType::kGoodCrc)
kGoToMinimumOperatingCurrent static_cast<uint8_t>(ControlMessageType::kGoToMinimumOperatingCurrent)
kAccept static_cast<uint8_t>(ControlMessageType::kAccept)
kReject static_cast<uint8_t>(ControlMessageType::kReject)
kPing static_cast<uint8_t>(ControlMessageType::kPing)
kPowerSupplyReady static_cast<uint8_t>(ControlMessageType::kPowerSupplyReady)
kGetSourceCapabilities static_cast<uint8_t>(ControlMessageType::kGetSourceCapabilities)
kGetSinkCapabilities static_cast<uint8_t>(ControlMessageType::kGetSinkCapabilities)
kDataRoleSwap static_cast<uint8_t>(ControlMessageType::kDataRoleSwap)
kPowerRoleSwap static_cast<uint8_t>(ControlMessageType::kPowerRoleSwap)
kVconnSourceSwap static_cast<uint8_t>(ControlMessageType::kVconnSourceSwap)
kWait static_cast<uint8_t>(ControlMessageType::kWait)
kSoftReset static_cast<uint8_t>(ControlMessageType::kSoftReset)
kDataReset static_cast<uint8_t>(ControlMessageType::kDataReset)
kDataResetComplete static_cast<uint8_t>(ControlMessageType::kDataResetComplete)
kNotSupported static_cast<uint8_t>(ControlMessageType::kNotSupported)
kGetExtendedSourceCapabilities static_cast<uint8_t>(ControlMessageType::kGetExtendedSourceCapabilities)
kGetStatus static_cast<uint8_t>(ControlMessageType::kGetStatus)
kFastRoleSwap static_cast<uint8_t>(ControlMessageType::kFastRoleSwap)
kGetProgrammablePowerSupplyStatus static_cast<uint8_t>(ControlMessageType::kGetProgrammablePowerSupplyStatus)
kGetCountryCodes static_cast<uint8_t>(ControlMessageType::kGetCountryCodes)
kGetExtendedSinkCapabilities static_cast<uint8_t>(ControlMessageType::kGetExtendedSinkCapabilities)
kGetSourceInfo static_cast<uint8_t>(ControlMessageType::kGetSourceInfo)
kGetMaximumPdSpecRevision static_cast<uint8_t>(ControlMessageType::kGetMaximumPdSpecRevision)
kSourceCapabilities kMessageTypeDataBit | static_cast<uint8_t>(DataMessageType::kSourceCapabilities)
kRequestPower kMessageTypeDataBit | static_cast<uint8_t>(DataMessageType::kRequestPower)
kBuiltInSelfTest kMessageTypeDataBit | static_cast<uint8_t>(DataMessageType::kBuiltInSelfTest)
kSinkCapabilities kMessageTypeDataBit | static_cast<uint8_t>(DataMessageType::kSinkCapabilities)
kBatteryStatus kMessageTypeDataBit | static_cast<uint8_t>(DataMessageType::kBatteryStatus)
kAlert kMessageTypeDataBit | static_cast<uint8_t>(DataMessageType::kAlert)
kGetCountryInfo kMessageTypeDataBit | static_cast<uint8_t>(DataMessageType::kGetCountryInfo)
kEnterUsb kMessageTypeDataBit | static_cast<uint8_t>(DataMessageType::kEnterUsb)
kExtendedPowerRangeRequest kMessageTypeDataBit | static_cast<uint8_t>(DataMessageType::kExtendedPowerRangeRequest)
kExtendedPowerRangeMode kMessageTypeDataBit | static_cast<uint8_t>(DataMessageType::kExtendedPowerRangeMode)
kSourceInfo kMessageTypeDataBit | static_cast<uint8_t>(DataMessageType::kSourceInfo)
kMaximumPdSpecRevision kMessageTypeDataBit | static_cast<uint8_t>(DataMessageType::kMaximumPdSpecRevision)
kVendorDefined kMessageTypeDataBit | static_cast<uint8_t>(DataMessageType::kVendorDefined)

Message type codes for messages with data objects and no extended flag.

This is effectively a hand-rolled sum type (like std::variant) of

`ControlMessageType` and `DataMessageType`. The discriminant (the type is of

the variant value) is stored in the kMessageTypeDataBit`. Values are

allocated such that they easily map (via `kMessageTypeUsbPdValueMask`) to the

bit patterns used in USB PD message headers.

usbpd3.1 6.4 "Data Message", Table 6-6 "Data Message Types"

Defined at line 91 of file ../../src/devices/power/drivers/fusb302/usb-pd-message-type.h

enum class FastSwapCurrentRequirement
Name Value
kNotSupported 0b00
kDefaultUsb 0b01
k1500mA 0b10
k3000mA 0b11

Values for `fast_swap_current_requirement` in SinkFixedPowerSupplyData.

usbpd3.1 6.4.1.3.1 "Sink Fixed Supply Power Data Object", sub-table inside

the "Fast Role Swap required USB Type-C Current" row

Defined at line 382 of file ../../src/devices/power/drivers/fusb302/usb-pd-message-objects.h

Records

Functions

  • const char * PowerRoleToString (PowerRole power_role)

    Descriptor for logging and debugging.

    Defined at line 14 of file ../../src/devices/power/drivers/fusb302/usb-pd-defs.cc

  • const char * DataRoleToString (DataRole data_role)

    Descriptor for logging and debugging.

    Defined at line 25 of file ../../src/devices/power/drivers/fusb302/usb-pd-defs.cc

  • const char * ConfigChannelPinIdToString (ConfigChannelPinId pin_id)

    Descriptor for logging and debugging.

    Defined at line 36 of file ../../src/devices/power/drivers/fusb302/usb-pd-defs.cc

  • const char * ConfigChannelPinSwitchToString (ConfigChannelPinSwitch cc_switch)

    Descriptor for logging and debugging.

    Defined at line 47 of file ../../src/devices/power/drivers/fusb302/usb-pd-defs.cc

  • const char * ConfigChannelTerminationToString (ConfigChannelTermination termination)

    Descriptor for logging and debugging.

    Defined at line 61 of file ../../src/devices/power/drivers/fusb302/usb-pd-defs.cc

  • const char * MessageTypeToString (MessageType type)

    Descriptor for logging and debugging.

    Defined at line 9 of file ../../src/devices/power/drivers/fusb302/usb-pd-message-type.cc

  • ConfigChannelPinId ConfigChannelPinIdFromInverse (ConfigChannelPinId id)

    Inverts a ConfigChannelPinId.

    Defined at line 109 of file ../../src/devices/power/drivers/fusb302/usb-pd-defs.h

  • ConfigChannelPinId ConfigChannelPinIdFromSwitch (ConfigChannelPinSwitch cc_switch)

    `cc_switch` must not be `kNone`.

    Defined at line 114 of file ../../src/devices/power/drivers/fusb302/usb-pd-defs.h

  • bool IsDataMessageType (MessageType type)

    Defined at line 141 of file ../../src/devices/power/drivers/fusb302/usb-pd-message-type.h

  • MessageType MessageTypeFromDataMessageType (DataMessageType type)

    Defined at line 144 of file ../../src/devices/power/drivers/fusb302/usb-pd-message-type.h

  • MessageType MessageTypeFromControlMessageType (ControlMessageType type)

    Defined at line 147 of file ../../src/devices/power/drivers/fusb302/usb-pd-message-type.h

  • DataMessageType DataMessageTypeFromMessageType (MessageType type)

    Defined at line 150 of file ../../src/devices/power/drivers/fusb302/usb-pd-message-type.h

  • ControlMessageType ControlMessageTypeFromMessageType (MessageType type)

    Defined at line 154 of file ../../src/devices/power/drivers/fusb302/usb-pd-message-type.h

  • const char * ControlMessageTypeToString (ControlMessageType type)

    Descriptor for logging and debugging.

    Defined at line 163 of file ../../src/devices/power/drivers/fusb302/usb-pd-message-type.h

  • const char * DataMessageTypeToString (DataMessageType type)

    Descriptor for logging and debugging.

    Defined at line 167 of file ../../src/devices/power/drivers/fusb302/usb-pd-message-type.h