re-negotiate PD post tip measurement

This commit is contained in:
Ben V. Brown
2025-07-16 13:29:37 +10:00
committed by Ben Brown
parent d98ed3ca1a
commit 1771aa1c6d
3 changed files with 12 additions and 9 deletions

View File

@@ -52,6 +52,7 @@ void USBPowerDelivery::step() {
} }
void USBPowerDelivery::PPSTimerCallback() { pe.TimersCallback(); } void USBPowerDelivery::PPSTimerCallback() { pe.TimersCallback(); }
void USBPowerDelivery::reNegotiate() { pe.renegotiate(); }
bool USBPowerDelivery::negotiationInProgress() { bool USBPowerDelivery::negotiationInProgress() {
if (USBPowerDelivery::negotiationComplete()) { if (USBPowerDelivery::negotiationComplete()) {
return false; return false;

View File

@@ -20,6 +20,8 @@ public:
static uint8_t getStateNumber(); // Debugging - Get the internal state number static uint8_t getStateNumber(); // Debugging - Get the internal state number
static bool isVBUSConnected(); // Is the VBus pin connected on the FUSB302 static bool isVBUSConnected(); // Is the VBus pin connected on the FUSB302
static uint32_t *getLastSeenCapabilities(); // returns pointer to the last seen capabilities from the powersource static uint32_t *getLastSeenCapabilities(); // returns pointer to the last seen capabilities from the powersource
static void reNegotiate();
private: private:
// //
static int detectionState; static int detectionState;
@@ -27,4 +29,4 @@ private:
#endif #endif
#endif #endif
#endif #endif

View File

@@ -22,12 +22,9 @@
// Small worker thread to handle power (PD + QC) related steps // Small worker thread to handle power (PD + QC) related steps
void startPOWTask(void const *argument __unused) { void startPOWTask(void const *argument __unused) {
bool haveNegotiatedHigherPower = false;
// Init any other misc sensors // Init any other misc sensors
postRToSInit(); postRToSInit();
while (preStartChecksDone() == 0) {
osDelay(3);
}
// You have to run this once we are willing to answer PD messages // You have to run this once we are willing to answer PD messages
// Setting up too early can mean that we miss the ~20ms window to respond on some chargers // Setting up too early can mean that we miss the ~20ms window to respond on some chargers
#ifdef POW_PD #ifdef POW_PD
@@ -37,9 +34,7 @@ void startPOWTask(void const *argument __unused) {
#endif #endif
#if POW_PD_EXT == 2 #if POW_PD_EXT == 2
FS2711::start(); FS2711::start();
FS2711::negotiate();
#endif #endif
BaseType_t res; BaseType_t res;
for (;;) { for (;;) {
res = pdFALSE; res = pdFALSE;
@@ -60,7 +55,10 @@ void startPOWTask(void const *argument __unused) {
} }
USBPowerDelivery::PPSTimerCallback(); USBPowerDelivery::PPSTimerCallback();
USBPowerDelivery::step(); USBPowerDelivery::step();
// Once tip measurement is done, and we have done the basic negotiation, we want to do the higher voltage negotiation steps
if (tipMeasurementDone() == 1 && !haveNegotiatedHigherPower) {
USBPowerDelivery::reNegotiate();
}
#else #else
(void)res; (void)res;
#endif #endif
@@ -68,7 +66,9 @@ void startPOWTask(void const *argument __unused) {
hub238_check_negotiation(); hub238_check_negotiation();
#endif #endif
#if POW_PD_EXT == 2 #if POW_PD_EXT == 2
FS2711::negotiate(); if (tipMeasurementDone() == 1) {
FS2711::negotiate();
}
#endif #endif
power_check(); power_check();
} }