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::reNegotiate() { pe.renegotiate(); }
bool USBPowerDelivery::negotiationInProgress() {
if (USBPowerDelivery::negotiationComplete()) {
return false;

View File

@@ -20,6 +20,8 @@ public:
static uint8_t getStateNumber(); // Debugging - Get the internal state number
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 void reNegotiate();
private:
//
static int detectionState;
@@ -27,4 +29,4 @@ private:
#endif
#endif
#endif
#endif

View File

@@ -22,12 +22,9 @@
// Small worker thread to handle power (PD + QC) related steps
void startPOWTask(void const *argument __unused) {
bool haveNegotiatedHigherPower = false;
// Init any other misc sensors
postRToSInit();
while (preStartChecksDone() == 0) {
osDelay(3);
}
// 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
#ifdef POW_PD
@@ -37,9 +34,7 @@ void startPOWTask(void const *argument __unused) {
#endif
#if POW_PD_EXT == 2
FS2711::start();
FS2711::negotiate();
#endif
BaseType_t res;
for (;;) {
res = pdFALSE;
@@ -60,7 +55,10 @@ void startPOWTask(void const *argument __unused) {
}
USBPowerDelivery::PPSTimerCallback();
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
(void)res;
#endif
@@ -68,7 +66,9 @@ void startPOWTask(void const *argument __unused) {
hub238_check_negotiation();
#endif
#if POW_PD_EXT == 2
FS2711::negotiate();
if (tipMeasurementDone() == 1) {
FS2711::negotiate();
}
#endif
power_check();
}