SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
Loading...
Searching...
No Matches
UsbPdDefs.hpp File Reference

@license MIT License More...

#include <stdint.h>
Include dependency graph for UsbPdDefs.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  usbpd::Header
 USB-PD 16-bit message header wrapper. More...
 
struct  usbpd::FixedSourcePdo
 Parsed fixed source PDO fields. More...
 

Namespaces

namespace  usbpd
 USB Power Delivery protocol helper definitions.
 

Enumerations

enum class  usbpd::SpecRev : uint8_t { usbpd::Rev10 = 0 , usbpd::Rev20 = 1 , usbpd::Rev30 = 2 }
 USB-PD specification revision values used in message headers. More...
 
enum class  usbpd::ControlMsg : uint8_t {
  usbpd::GoodCRC = 0x01 , usbpd::GotoMin = 0x02 , usbpd::Accept = 0x03 , usbpd::Reject = 0x04 ,
  usbpd::Ping = 0x05 , usbpd::PS_RDY = 0x06 , usbpd::GetSourceCap = 0x07 , usbpd::GetSinkCap = 0x08 ,
  usbpd::DR_Swap = 0x09 , usbpd::PR_Swap = 0x0A , usbpd::VCONN_Swap = 0x0B , usbpd::Wait = 0x0C ,
  usbpd::SoftReset = 0x0D
}
 USB-PD control message type field values. More...
 
enum class  usbpd::DataMsg : uint8_t {
  usbpd::SourceCapabilities = 0x01 , usbpd::Request = 0x02 , usbpd::BIST = 0x03 , usbpd::SinkCapabilities = 0x04 ,
  usbpd::VendorDefined = 0x0F
}
 USB-PD data message type field values. More...
 
enum class  usbpd::PdoType : uint8_t { usbpd::Fixed = 0b00 , usbpd::Battery = 0b01 , usbpd::Variable = 0b10 , usbpd::Augmented = 0b11 }
 USB-PD Power Data Object type. More...
 

Functions

uint16_t usbpd::le16 (const uint8_t *p)
 Read a 16-bit little-endian integer from a byte buffer.
 
uint32_t usbpd::le32 (const uint8_t *p)
 Read a 32-bit little-endian integer from a byte buffer.
 
void usbpd::wr_le16 (uint8_t *p, uint16_t v)
 Write a 16-bit value to a byte buffer in little-endian order.
 
void usbpd::wr_le32 (uint8_t *p, uint32_t v)
 Write a 32-bit value to a byte buffer in little-endian order.
 
uint16_t usbpd::buildControlHeader (ControlMsg type, uint8_t msgId, bool powerRoleSource, bool dataRoleDfp, SpecRev specRev)
 Build a USB-PD control message header.
 
uint16_t usbpd::buildDataHeader (DataMsg type, uint8_t objCount, uint8_t msgId, bool powerRoleSource, bool dataRoleDfp, SpecRev specRev)
 Build a USB-PD data message header.
 
PdoType usbpd::pdoType (uint32_t pdo)
 Return the type field of a raw PDO.
 
bool usbpd::parseFixedSourcePdo (uint32_t pdo, FixedSourcePdo &out)
 Parse a fixed source PDO.
 
uint32_t usbpd::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.
 

Detailed Description

@license MIT License

Copyright (c) 2026 lewis he

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Author
Lewis He (lewis.nosp@m.he@o.nosp@m.utloo.nosp@m.k.co.nosp@m.m)
Date
2026-07-29

Small USB-PD header, PDO, and RDO helpers used by AXP517.

Definition in file UsbPdDefs.hpp.