47#define PD_TARGET_MV 9000
51#define PD_TIMEOUT_MS 6000
55#error "AXP517 PD negotiation requires a valid PMIC_IRQ pin."
79 Serial.println(
"\n--- Source Capabilities ---");
80 Serial.print(
"Total PDO count: ");
84 Serial.println(
"No fixed PDO found.");
89 const auto &pdo = caps.
fixed[
i];
92 Serial.print(pdo.pdoIndex1Based);
95 Serial.print(
" mV / ");
96 Serial.print(pdo.maMax);
97 Serial.print(
" mA, raw=0x");
98 Serial.println(pdo.rawPdo, HEX);
107 Serial.print(
"TCPC VBUS: ");
108 Serial.print(vbusMv);
109 Serial.println(
" mV");
115 Serial.begin(115200);
118 Serial.println(
"\n=== AXP517 PD Voltage Example ===\n");
119 Serial.print(
"Target voltage: ");
121 Serial.println(
" mV");
124 Serial.println(
"Failed to init AXP517 or PMIC_IRQ pin!");
125 while (1) delay(1000);
129 Serial.println(
"Failed to route AXP517 GPIO0 to PD_IRQ!");
130 while (1) delay(1000);
133 Serial.print(
"PMIC_IRQ pin: ");
135 Serial.println(
"Connect a USB-C PD source now.");
140 Serial.println(
"\n--- PD Result ---");
141 Serial.println(
pdReady ?
"Negotiation success." :
"Negotiation failed.");
145 Serial.println(
"Check PD source capability, CC wiring, and PMIC_IRQ wiring.");
151 static uint32_t lastPrint = 0;
153 if (millis() - lastPrint > 2000) {
154 lastPrint = millis();
156 Serial.println(
"\n--- Status ---");
157 Serial.print(
"PD: ");
158 Serial.println(
pdReady ?
"Ready" :
"Not ready");
bool configurePdIrqOutput()
void printSourceCaps(const AXP517PdNegotiator::SourceCaps &caps)
AXP517PdNegotiator::SourceCaps sourceCaps
bool setOutputSource(uint8_t pin, OutputSource src)
Select GPIO output source.
bool readVbusMv(uint16_t &mv)
Read TCPC VBUS ADC value.
High-level driver facade for the X-Powers AXP517 PMIC.
AXP517Tcpc & tcpc()
Access the low-level AXP517 TCPC helper.
AXP517Gpio & gpio()
Access the AXP517 GPIO driver.
bool requestPd(uint16_t targetMv, uint32_t timeoutMs=6000, AXP517PdNegotiator::SourceCaps *outCaps=nullptr)
Request a fixed USB-PD voltage from the attached source.
bool begin(SensorCommCustom::CustomCallback callback, SensorCommCustomHal::CustomHalCallback hal_cb, uint8_t addr)
Initialization using a custom communication interface.
@ OpenDrain
Open-drain output: only pulls low, high-impedance for high.
static constexpr bool isOk(Status s)
@ Output
Configure pin as output (drive external circuits)
Parsed Source_Capabilities message.
uint8_t totalPdoCount
Total PDO count advertised in the message.
FixedOffer fixed[7]
Parsed fixed PDO offers.
uint8_t fixedCount
Number of valid entries in fixed[].