SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
Loading...
Searching...
No Matches
AXP517Pd.hpp
Go to the documentation of this file.
1
31#pragma once
32
33#include <stdint.h>
34#include "AXP517Tcpc.hpp"
35
45{
46public:
51 explicit AXP517Pd(AXP517Tcpc &tcpc) : _tcpc(tcpc) {}
52
56 enum class SpecRev : uint8_t {
57 Rev10 = 0,
58 Rev20 = 1,
59 Rev30 = 2,
60 };
61
65 enum class PowerRole : uint8_t {
66 Sink = 0,
67 Source = 1,
68 };
69
73 enum class DataRole : uint8_t {
74 UFP = 0,
75 DFP = 1,
76 };
77
81 enum class ControlMsg : uint8_t {
82 Accept = 0x03,
83 PS_RDY = 0x06,
84 GetSourceCap = 0x07,
85 SoftReset = 0x0D,
86 };
87
96
102 bool configureHeaderInfo(const HeaderInfoCfg &cfg);
103
109 bool setReceiveDetectSop(bool enable);
110
115 bool sendGetSourceCap();
116
122 bool sendControl(ControlMsg msgType);
123
132 bool sendHardReset();
133
142 bool sendRaw(uint8_t msgType, const uint8_t *payload, uint8_t payloadLen);
143
150
156 bool handleFaultOnce(uint8_t &faultStatus);
157
165 {
166 _msgId = 0;
167 }
168
169private:
176 uint16_t buildHeader(uint8_t msgType, uint8_t objCnt);
177
178private:
179 AXP517Tcpc &_tcpc;
180 HeaderInfoCfg _cfg{};
181 uint8_t _msgId = 0;
182};
@license MIT License
USB-PD message builder and FIFO helper for AXP517.
Definition AXP517Pd.hpp:45
bool sendControl(ControlMsg msgType)
Send a USB-PD control message.
Definition AXP517Pd.cpp:68
void resetMsgId()
Reset the local USB-PD message ID counter to zero.
Definition AXP517Pd.hpp:164
PowerRole
USB-PD power role encoded in the message header.
Definition AXP517Pd.hpp:65
@ Sink
Sink/UFP consumes VBUS.
@ Source
Source/DFP supplies VBUS.
bool sendRaw(uint8_t msgType, const uint8_t *payload, uint8_t payloadLen)
Send a raw USB-PD data message.
Definition AXP517Pd.cpp:93
bool tryReceive(AXP517Tcpc::RxFifoMsg &out)
Try to read one pending RX FIFO message.
Definition AXP517Pd.cpp:104
AXP517Pd(AXP517Tcpc &tcpc)
Construct a PD helper that uses an initialized TCPC instance.
Definition AXP517Pd.hpp:51
bool handleFaultOnce(uint8_t &faultStatus)
Read and clear one TCPC fault status sample.
Definition AXP517Pd.cpp:109
bool setReceiveDetectSop(bool enable)
Enable or disable SOP receive detection.
Definition AXP517Pd.cpp:48
bool configureHeaderInfo(const HeaderInfoCfg &cfg)
Configure local message-header defaults.
Definition AXP517Pd.cpp:36
DataRole
USB Type-C data role encoded in the message header.
Definition AXP517Pd.hpp:73
@ UFP
Upstream Facing Port.
@ DFP
Downstream Facing Port.
SpecRev
USB-PD specification revision encoded in the message header.
Definition AXP517Pd.hpp:56
@ Rev10
USB-PD 1.0.
@ Rev30
USB-PD 3.0.
@ Rev20
USB-PD 2.0.
ControlMsg
Supported USB-PD control message type values.
Definition AXP517Pd.hpp:81
@ SoftReset
Soft Reset control message.
@ PS_RDY
Power Supply Ready control message.
@ GetSourceCap
Get Source Capabilities control message.
@ Accept
Accept control message.
bool sendHardReset()
Send a Hard Reset ordered set.
Definition AXP517Pd.cpp:83
bool sendGetSourceCap()
Send a Get_Source_Cap control message.
Definition AXP517Pd.cpp:78
AXP517 Type-C Port Controller helper.
Local USB-PD header defaults used for transmitted messages.
Definition AXP517Pd.hpp:91
PowerRole pr
Local power role.
Definition AXP517Pd.hpp:93
DataRole dr
Local data role.
Definition AXP517Pd.hpp:94
SpecRev spec
USB-PD revision to advertise.
Definition AXP517Pd.hpp:92
Decoded RX FIFO message.