Open topherbuckley opened 1 year ago
The message that you mentioned is used by power sinks to advertise their capabilities. That's a rare case and not implemented by this library. The very similar message of a power source advertising its capabilities is implemented. You'll find it here:
The input is a PDMessage
instance. If you have the raw USB PD message with 2 bytes of header and multiple bytes of payload, just copy them to the position where the instance variable header
is, e.g.:
PDMessage msg;
const uint8_t* rawMessage = ...;
int rawMessageLength = ...;
memcpy((uint8_t*)msg.header, rawMessage, rawMessageLength);
Then create an array for the resulting capabilities and call xxx
:
int numCapabilities = 0;
PDSourceCapability capabilities[8];
PDSourceCapability::parseCapability(&msg, numCapabilities, capabilities);
Hello,
You pointed me here from my question on the tinyusb repo. I had a quick skim through the code, but I'm not well versed in C++. Is there code in here somewhere that handles the generation of PDOs?
In particular I'm looking for some kind of function that takes in the binary values of the various Descriptions specified in Table 6-16 of the USB-PD Standard V1.8 and returns an array of bytes that I can pass via i2c. I'm normally doing everything in C, so I'll likely end up making my own, but just wanted to check if you had something to work off of, and if so, I could potentially add what I'm working on to this instead.