feat(radio): allow disabling USB charge while the radio is running (on compatible hardware) (#7564)

Co-authored-by: 3djc <3djc@gh.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: Peter Feerick <5500713+pfeerick@users.noreply.github.com>
Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
This commit is contained in:
3djc
2026-08-21 20:16:55 +10:00
committed by GitHub
co-authored by 3djc Claude Opus 5 Peter Feerick Peter Feerick
parent 2baf75f3aa
commit a51946c4e2
38 changed files with 134 additions and 15 deletions
+4
View File
@@ -241,4 +241,8 @@ void usbChargerInit();
bool usbChargerLed();
#endif
#if defined(USB_CHARGE_CONTROL)
void usbChargerEnableCharge(bool enable);
#endif
#endif // _BOARD_H_
@@ -25,7 +25,15 @@
#include "board.h"
#include "hal/usb_driver.h"
//TODO: charger enable control
#if defined(USB_CHARGE_CONTROL)
void usbChargerEnableCharge(bool enable)
{
if (enable)
gpio_clear(UCHARGER_EN_GPIO);
else
gpio_set(UCHARGER_EN_GPIO);
}
#endif
void usbChargerInit()
{
@@ -36,6 +44,13 @@ void usbChargerInit()
bool usbChargerLed()
{
#if defined(USB_CHARGE_CONTROL)
// When charging is disabled via the "Charge while radio on" setting,
// the charger-enable pin is driven high to hold the charger off, so it is
// not charging.
if (gpio_read(UCHARGER_EN_GPIO))
return false;
#endif
#if defined UCHARGER_INVERTED
return (!gpio_read(UCHARGER_GPIO) && usbPlugged());
#else