SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
Loading...
Searching...
No Matches
usbpd::Header Struct Reference

USB-PD 16-bit message header wrapper. More...

#include <UsbPdDefs.hpp>

Public Member Functions

 Header ()=default
 Construct an empty header.
 
 Header (uint16_t v)
 Construct a header from a raw value.
 
uint8_t msgType () const
 Return the USB-PD message type field.
 
bool dataRoleDfp () const
 Return true when the data role field is DFP.
 
uint8_t specRev () const
 Return the USB-PD specification revision field.
 
bool powerRoleSource () const
 Return true when the power role field is Source.
 
uint8_t msgId () const
 Return the USB-PD message ID field.
 
uint8_t objCount () const
 Return the number of 32-bit data objects in this message.
 
bool extended () const
 Return true when the extended message bit is set.
 
void setMsgType (uint8_t v)
 Set the USB-PD message type field.
 
void setDataRoleDfp (bool dfp)
 Set the data role field.
 
void setSpecRev (uint8_t r)
 Set the USB-PD specification revision field.
 
void setPowerRoleSource (bool src)
 Set the power role field.
 
void setMsgId (uint8_t id)
 Set the USB-PD message ID field.
 
void setObjCount (uint8_t n)
 Set the number of 32-bit data objects.
 
void setExtended (bool ex)
 Set or clear the extended message bit.
 

Public Attributes

uint16_t raw = 0
 Raw 16-bit header value in little-endian host order.
 

Detailed Description

USB-PD 16-bit message header wrapper.

Definition at line 91 of file UsbPdDefs.hpp.

Constructor & Destructor Documentation

◆ Header() [1/2]

usbpd::Header::Header ( )
default

Construct an empty header.

◆ Header() [2/2]

usbpd::Header::Header ( uint16_t  v)
inlineexplicit

Construct a header from a raw value.

Parameters
vRaw 16-bit header value.

Definition at line 102 of file UsbPdDefs.hpp.

Member Function Documentation

◆ dataRoleDfp()

bool usbpd::Header::dataRoleDfp ( ) const
inline

Return true when the data role field is DFP.

Definition at line 111 of file UsbPdDefs.hpp.

References raw.

◆ extended()

bool usbpd::Header::extended ( ) const
inline

Return true when the extended message bit is set.

Definition at line 141 of file UsbPdDefs.hpp.

References raw.

◆ msgId()

uint8_t usbpd::Header::msgId ( ) const
inline

Return the USB-PD message ID field.

Definition at line 129 of file UsbPdDefs.hpp.

References raw.

◆ msgType()

uint8_t usbpd::Header::msgType ( ) const
inline

Return the USB-PD message type field.

Definition at line 105 of file UsbPdDefs.hpp.

References raw.

Referenced by AXP517PdNegotiator::handleIrq(), and AXP517PdNegotiator::parseSourceCaps().

◆ objCount()

uint8_t usbpd::Header::objCount ( ) const
inline

Return the number of 32-bit data objects in this message.

Definition at line 135 of file UsbPdDefs.hpp.

References raw.

Referenced by AXP517PdNegotiator::handleIrq(), and AXP517PdNegotiator::parseSourceCaps().

◆ powerRoleSource()

bool usbpd::Header::powerRoleSource ( ) const
inline

Return true when the power role field is Source.

Definition at line 123 of file UsbPdDefs.hpp.

References raw.

◆ setDataRoleDfp()

void usbpd::Header::setDataRoleDfp ( bool  dfp)
inline

Set the data role field.

Definition at line 153 of file UsbPdDefs.hpp.

References raw.

◆ setExtended()

void usbpd::Header::setExtended ( bool  ex)
inline

Set or clear the extended message bit.

Definition at line 183 of file UsbPdDefs.hpp.

References raw.

Referenced by usbpd::buildControlHeader(), and usbpd::buildDataHeader().

◆ setMsgId()

void usbpd::Header::setMsgId ( uint8_t  id)
inline

Set the USB-PD message ID field.

Definition at line 171 of file UsbPdDefs.hpp.

References raw.

◆ setMsgType()

void usbpd::Header::setMsgType ( uint8_t  v)
inline

Set the USB-PD message type field.

Definition at line 147 of file UsbPdDefs.hpp.

References raw.

◆ setObjCount()

void usbpd::Header::setObjCount ( uint8_t  n)
inline

Set the number of 32-bit data objects.

Definition at line 177 of file UsbPdDefs.hpp.

References raw.

◆ setPowerRoleSource()

void usbpd::Header::setPowerRoleSource ( bool  src)
inline

Set the power role field.

Definition at line 165 of file UsbPdDefs.hpp.

References raw.

◆ setSpecRev()

void usbpd::Header::setSpecRev ( uint8_t  r)
inline

Set the USB-PD specification revision field.

Definition at line 159 of file UsbPdDefs.hpp.

References raw.

◆ specRev()

uint8_t usbpd::Header::specRev ( ) const
inline

Return the USB-PD specification revision field.

Definition at line 117 of file UsbPdDefs.hpp.

References raw.

Member Data Documentation

◆ raw

uint16_t usbpd::Header::raw = 0

Raw 16-bit header value in little-endian host order.

Definition at line 93 of file UsbPdDefs.hpp.

Referenced by dataRoleDfp(), extended(), msgId(), msgType(), objCount(), powerRoleSource(), setDataRoleDfp(), setExtended(), setMsgId(), setMsgType(), setObjCount(), setPowerRoleSource(), setSpecRev(), and specRev().


The documentation for this struct was generated from the following file: