mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Hold PD negotiation until detection is done for tip res
This commit is contained in:
@@ -98,6 +98,7 @@ void setStatusLED(const enum StatusLED state);
|
|||||||
// By the PID, after each ADC sample comes in
|
// By the PID, after each ADC sample comes in
|
||||||
// For example, on the MHP30 this is used to figure out the resistance of the hotplate
|
// For example, on the MHP30 this is used to figure out the resistance of the hotplate
|
||||||
uint8_t preStartChecks();
|
uint8_t preStartChecks();
|
||||||
|
uint8_t preStartChecksDone();
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ void setStatusLED(const enum StatusLED state) {
|
|||||||
// Dont have one
|
// Dont have one
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t lastTipResistance = 85; // default safe
|
uint8_t lastTipResistance = 0; // default to unknown
|
||||||
uint32_t lastTipReadinguV = 0;
|
uint32_t lastTipReadinguV = 0;
|
||||||
uint8_t getTipResitanceX10() {
|
uint8_t getTipResitanceX10() {
|
||||||
// Return tip resistance in x10 ohms
|
// Return tip resistance in x10 ohms
|
||||||
@@ -269,8 +269,7 @@ void FinishMeasureTipResistance() {
|
|||||||
}
|
}
|
||||||
lastTipResistance = newRes;
|
lastTipResistance = newRes;
|
||||||
}
|
}
|
||||||
volatile bool tipMeasurementOccuring = false;
|
volatile bool tipMeasurementOccuring = false;
|
||||||
volatile uint8_t tipSenseResistancex10Ohms = 0;
|
|
||||||
|
|
||||||
void performTipMeasurementStep(bool start) {
|
void performTipMeasurementStep(bool start) {
|
||||||
static TickType_t lastMeas = 0;
|
static TickType_t lastMeas = 0;
|
||||||
@@ -280,14 +279,14 @@ void performTipMeasurementStep(bool start) {
|
|||||||
// We want to perform our startup measurements of the tip resistance until we detect one fitted
|
// We want to perform our startup measurements of the tip resistance until we detect one fitted
|
||||||
|
|
||||||
// Step 1; if not setup, we turn on pullup and then wait
|
// Step 1; if not setup, we turn on pullup and then wait
|
||||||
if (tipMeasurementOccuring == false && (start || tipSenseResistancex10Ohms == 0 || lastMeas == 0)) {
|
if (tipMeasurementOccuring == false && (start || lastTipResistance == 0 || lastMeas == 0)) {
|
||||||
// Block starting if tip removed
|
// Block starting if tip removed
|
||||||
if (isTipDisconnected()) {
|
if (isTipDisconnected()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tipMeasurementOccuring = true;
|
tipMeasurementOccuring = true;
|
||||||
tipSenseResistancex10Ohms = 0;
|
lastTipResistance = 0;
|
||||||
lastMeas = xTaskGetTickCount();
|
lastMeas = xTaskGetTickCount();
|
||||||
startMeasureTipResistance();
|
startMeasureTipResistance();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -308,6 +307,7 @@ uint8_t preStartChecks() {
|
|||||||
performTipMeasurementStep(false);
|
performTipMeasurementStep(false);
|
||||||
return tipMeasurementOccuring ? 1 : 0;
|
return tipMeasurementOccuring ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
uint8_t preStartChecksDone() { return (lastTipResistance == 0 || tipMeasurementOccuring) ? 0 : 1; }
|
||||||
|
|
||||||
// Return hardware unique ID if possible
|
// Return hardware unique ID if possible
|
||||||
uint64_t getDeviceID() {
|
uint64_t getDeviceID() {
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
void startPOWTask(void const *argument __unused) {
|
void startPOWTask(void const *argument __unused) {
|
||||||
// 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
|
||||||
#if POW_PD
|
#if POW_PD
|
||||||
|
|||||||
Reference in New Issue
Block a user