Working Re-Neg

This commit is contained in:
Ben Brown
2025-07-17 20:47:18 +10:00
parent 1771aa1c6d
commit 79b6c37c65
3 changed files with 13 additions and 5 deletions

View File

@@ -135,6 +135,10 @@ bool parseCapabilitiesArray(const uint8_t numCaps, uint8_t *bestIndex, uint16_t
*bestIndex = 0xFF; // Mark unselected *bestIndex = 0xFF; // Mark unselected
*bestVoltage = 5000; // Default 5V *bestVoltage = 5000; // Default 5V
if (tipMeasurementDone() != 1) {
// Tip measurement not done, so we cannot select anything other than 5V
return false;
}
// Fudge of 0.5 ohms to round up a little to account for us always having off periods in PWM // Fudge of 0.5 ohms to round up a little to account for us always having off periods in PWM
uint8_t tipResistance = getTipResistanceX10(); uint8_t tipResistance = getTipResistanceX10();
if (getSettingValue(SettingsOptions::USBPDMode) == usbpdMode_t::DEFAULT) { if (getSettingValue(SettingsOptions::USBPDMode) == usbpdMode_t::DEFAULT) {

View File

@@ -22,7 +22,7 @@
// 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; bool haveDoneSecondNegotiation = false;
// Init any other misc sensors // Init any other misc sensors
postRToSInit(); postRToSInit();
// 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
@@ -56,8 +56,11 @@ 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 // 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) { if (tipMeasurementDone() == 1 && !haveDoneSecondNegotiation) {
USBPowerDelivery::reNegotiate(); if (USBPowerDelivery::negotiationComplete()) {
USBPowerDelivery::reNegotiate();
haveDoneSecondNegotiation = true;
}
} }
#else #else
(void)res; (void)res;
@@ -66,8 +69,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
if (tipMeasurementDone() == 1) { if (tipMeasurementDone() == 1 && !haveDoneSecondNegotiation) {
FS2711::negotiate(); FS2711::negotiate();
haveDoneSecondNegotiation = true;
} }
#endif #endif
power_check(); power_check();