|
SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
|
USB Power Delivery protocol helper definitions. More...
Classes | |
| struct | FixedSourcePdo |
| Parsed fixed source PDO fields. More... | |
| struct | Header |
| USB-PD 16-bit message header wrapper. More... | |
Enumerations | |
| enum class | SpecRev : uint8_t { Rev10 = 0 , Rev20 = 1 , Rev30 = 2 } |
| USB-PD specification revision values used in message headers. More... | |
| enum class | ControlMsg : uint8_t { GoodCRC = 0x01 , GotoMin = 0x02 , Accept = 0x03 , Reject = 0x04 , Ping = 0x05 , PS_RDY = 0x06 , GetSourceCap = 0x07 , GetSinkCap = 0x08 , DR_Swap = 0x09 , PR_Swap = 0x0A , VCONN_Swap = 0x0B , Wait = 0x0C , SoftReset = 0x0D } |
| USB-PD control message type field values. More... | |
| enum class | DataMsg : uint8_t { SourceCapabilities = 0x01 , Request = 0x02 , BIST = 0x03 , SinkCapabilities = 0x04 , VendorDefined = 0x0F } |
| USB-PD data message type field values. More... | |
| enum class | PdoType : uint8_t { Fixed = 0b00 , Battery = 0b01 , Variable = 0b10 , Augmented = 0b11 } |
| USB-PD Power Data Object type. More... | |
Functions | |
| uint16_t | le16 (const uint8_t *p) |
| Read a 16-bit little-endian integer from a byte buffer. | |
| uint32_t | le32 (const uint8_t *p) |
| Read a 32-bit little-endian integer from a byte buffer. | |
| void | wr_le16 (uint8_t *p, uint16_t v) |
| Write a 16-bit value to a byte buffer in little-endian order. | |
| void | wr_le32 (uint8_t *p, uint32_t v) |
| Write a 32-bit value to a byte buffer in little-endian order. | |
| uint16_t | buildControlHeader (ControlMsg type, uint8_t msgId, bool powerRoleSource, bool dataRoleDfp, SpecRev specRev) |
| Build a USB-PD control message header. | |
| uint16_t | buildDataHeader (DataMsg type, uint8_t objCount, uint8_t msgId, bool powerRoleSource, bool dataRoleDfp, SpecRev specRev) |
| Build a USB-PD data message header. | |
| PdoType | pdoType (uint32_t pdo) |
| Return the type field of a raw PDO. | |
| bool | parseFixedSourcePdo (uint32_t pdo, FixedSourcePdo &out) |
| Parse a fixed source PDO. | |
| uint32_t | buildRdoFixedCurrent (uint8_t objectPos1based, uint16_t opMa, uint16_t maxMa, bool capMismatch=false, bool usbCommCapable=true, bool noUsbSuspend=true) |
| Build a fixed-current Request Data Object. | |
USB Power Delivery protocol helper definitions.
|
strong |
USB-PD control message type field values.
Definition at line 201 of file UsbPdDefs.hpp.
|
strong |
USB-PD data message type field values.
| Enumerator | |
|---|---|
| SourceCapabilities | Source_Capabilities. |
| Request | Request. |
| BIST | Built-In Self Test. |
| SinkCapabilities | Sink_Capabilities. |
| VendorDefined | Vendor Defined Message. |
Definition at line 220 of file UsbPdDefs.hpp.
|
strong |
USB-PD Power Data Object type.
| Enumerator | |
|---|---|
| Fixed | Fixed supply PDO. |
| Battery | Battery supply PDO. |
| Variable | Variable supply PDO. |
| Augmented | Augmented PDO. |
Definition at line 289 of file UsbPdDefs.hpp.
|
strong |
USB-PD specification revision values used in message headers.
| Enumerator | |
|---|---|
| Rev10 | USB-PD 1.0. |
| Rev20 | USB-PD 2.0. |
| Rev30 | USB-PD 3.0. |
Definition at line 192 of file UsbPdDefs.hpp.
|
inline |
Build a USB-PD control message header.
| type | Control message type. |
| msgId | Three-bit USB-PD message ID. |
| powerRoleSource | true for Source, false for Sink. |
| dataRoleDfp | true for DFP, false for UFP. |
| specRev | USB-PD specification revision. |
Definition at line 237 of file UsbPdDefs.hpp.
References usbpd::Header::setExtended().
|
inline |
Build a USB-PD data message header.
| type | Data message type. |
| objCount | Number of 32-bit data objects. |
| msgId | Three-bit USB-PD message ID. |
| powerRoleSource | true for Source, false for Sink. |
| dataRoleDfp | true for DFP, false for UFP. |
| specRev | USB-PD specification revision. |
Definition at line 266 of file UsbPdDefs.hpp.
References usbpd::Header::setExtended().
|
inline |
Build a fixed-current Request Data Object.
The generated RDO uses the common PD2.0 fixed/variable current layout: object position, capability mismatch, USB communications capable, no USB suspend, operating current, and maximum operating current.
| objectPos1based | Source PDO object position, 1 through 7. |
| opMa | Operating current in milliamps. |
| maxMa | Maximum operating current in milliamps. |
| capMismatch | Set the Capability Mismatch bit. |
| usbCommCapable | Set the USB Communications Capable bit. |
| noUsbSuspend | Set the No USB Suspend bit. |
Definition at line 352 of file UsbPdDefs.hpp.
|
inline |
Read a 16-bit little-endian integer from a byte buffer.
| p | Pointer to at least two bytes. |
Definition at line 46 of file UsbPdDefs.hpp.
|
inline |
Read a 32-bit little-endian integer from a byte buffer.
| p | Pointer to at least four bytes. |
Definition at line 56 of file UsbPdDefs.hpp.
Referenced by AXP517PdNegotiator::parseSourceCaps().
|
inline |
Parse a fixed source PDO.
| pdo | Raw 32-bit PDO value. |
| out | Destination for decoded fixed-source fields. |
| true | if the PDO is fixed-source, false for other PDO types. |
Definition at line 322 of file UsbPdDefs.hpp.
References usbpd::FixedSourcePdo::dualRolePower, Fixed, usbpd::FixedSourcePdo::ma, usbpd::FixedSourcePdo::mv, pdoType(), and usbpd::FixedSourcePdo::usbCommCapable.
Referenced by AXP517PdNegotiator::parseSourceCaps().
|
inline |
Return the type field of a raw PDO.
| pdo | Raw 32-bit PDO value. |
Definition at line 311 of file UsbPdDefs.hpp.
Referenced by parseFixedSourcePdo().
|
inline |
Write a 16-bit value to a byte buffer in little-endian order.
| p | Pointer to at least two destination bytes. |
| v | Value to write. |
Definition at line 69 of file UsbPdDefs.hpp.
|
inline |
Write a 32-bit value to a byte buffer in little-endian order.
| p | Pointer to at least four destination bytes. |
| v | Value to write. |
Definition at line 80 of file UsbPdDefs.hpp.