fix: halt T14 power up if USB power triggered (#4647)

This commit is contained in:
Peter Feerick
2024-02-26 10:34:54 +10:00
committed by GitHub
parent 1f341e57af
commit 4d2b588f42
+35 -29
View File
@@ -136,40 +136,46 @@ void boardInit()
#endif #endif
#endif #endif
// Support for FS Led to indicate battery charge level // If the radio was powered on by dual use USB, halt the boot process, let battery charge
#if defined(FUNCTION_SWITCHES) // TODO: needs refactoring if any other manufacturer implements either of the following:
// - function switches and the radio supports charging
// - single USB for data + charge which powers on radio
#if defined(MANUFACTURER_JUMPER)
// This is needed to prevent radio from starting when usb is plugged to charge // This is needed to prevent radio from starting when usb is plugged to charge
usbInit(); usbInit();
// prime debounce state... // prime debounce state...
usbPlugged(); usbPlugged();
if (usbPlugged()) { if (usbPlugged()) {
delaysInit(); delaysInit();
adcInit(&_adc_driver); adcInit(&_adc_driver);
getADC(); getADC();
pwrOn(); // required to get bat adc reads pwrOn(); // required to get bat adc reads
INTERNAL_MODULE_OFF(); INTERNAL_MODULE_OFF();
EXTERNAL_MODULE_OFF(); EXTERNAL_MODULE_OFF();
while (usbPlugged()) { while (usbPlugged()) {
// Let it charge ... // // Let it charge ...
getADC(); // Warning: the value read does not include VBAT calibration getADC(); // Warning: the value read does not include VBAT calibration
delay_ms(20); delay_ms(20);
if (getBatteryVoltage() >= 660) #if defined(FUNCTION_SWITCHES)
fsLedOn(0); // Support for FS Led to indicate battery charge level
if (getBatteryVoltage() >= 700) if (getBatteryVoltage() >= 660) fsLedOn(0);
fsLedOn(1); if (getBatteryVoltage() >= 700) fsLedOn(1);
if (getBatteryVoltage() >= 740) if (getBatteryVoltage() >= 740) fsLedOn(2);
fsLedOn(2); if (getBatteryVoltage() >= 780) fsLedOn(3);
if (getBatteryVoltage() >= 780) if (getBatteryVoltage() >= 820) fsLedOn(4);
fsLedOn(3); if (getBatteryVoltage() >= 842) fsLedOn(5);
if (getBatteryVoltage() >= 820) #elif defined(STATUS_LEDS)
fsLedOn(4); // Use Status LED to indicate battery charge level instead
if (getBatteryVoltage() >= 842) if (getBatteryVoltage() <= 660) ledRed(); // low discharge
fsLedOn(5); else if (getBatteryVoltage() <= 842) ledBlue(); // charging
} else ledGreen(); // charging done
pwrOff(); delay_ms(1000);
} #endif
}
pwrOff();
}
#endif #endif
keysInit(); keysInit();