fix(st16): port Flysky specific charging driver (#6145)
This commit is contained in:
@@ -75,25 +75,6 @@ extern "C" void initialise_monitor_handles();
|
||||
extern "C" void flushFTL();
|
||||
#endif
|
||||
|
||||
static void led_strip_charge_animation(uint8_t ledOn)
|
||||
{
|
||||
for (uint8_t i = 0; i < LED_STRIP_LENGTH; i++) {
|
||||
if (i == ledOn)
|
||||
ws2812_set_color(i, 10, 10, 10);
|
||||
else
|
||||
ws2812_set_color(i, 0, 0, 0);
|
||||
}
|
||||
ws2812_update(&_led_timer);
|
||||
}
|
||||
|
||||
static void led_strip_off()
|
||||
{
|
||||
for (uint8_t i = 0; i < LED_STRIP_LENGTH; i++) {
|
||||
ws2812_set_color(i, 0, 0, 0);
|
||||
}
|
||||
ws2812_update(&_led_timer);
|
||||
}
|
||||
|
||||
void INTERNAL_MODULE_ON()
|
||||
{
|
||||
bsp_output_clear(BSP_INT_PWR);
|
||||
@@ -213,6 +194,9 @@ void boardInit()
|
||||
flashRegisterDriver(FLASH_BANK1_BASE, BOOTLOADER_SIZE, &stm32_flash_driver);
|
||||
flashRegisterDriver(QSPI_BASE, QSPI_FLASH_SIZE, &extflash_driver);
|
||||
|
||||
board_trainer_init();
|
||||
battery_charge_init();
|
||||
|
||||
// init_trainer();
|
||||
flysky_gimbal_init();
|
||||
|
||||
@@ -222,61 +206,48 @@ void boardInit()
|
||||
rgbLedInit();
|
||||
#endif
|
||||
|
||||
#if !defined(DEBUG_SEGGER_RTT)
|
||||
// prime debounce state...
|
||||
usbPlugged();
|
||||
rotaryEncoderInit();
|
||||
|
||||
if (usbPlugged()) {
|
||||
delaysInit();
|
||||
uint8_t ledOn = 0;
|
||||
while (usbPlugged()) {
|
||||
if(IS_UCHARGER_ACTIVE()) {
|
||||
led_strip_charge_animation(ledOn++);
|
||||
if (ledOn == LED_STRIP_LENGTH)
|
||||
ledOn = 0;
|
||||
#if !defined(DEBUG_SEGGER_RTT)
|
||||
|
||||
uint32_t press_start = 0;
|
||||
uint32_t press_end = 0;
|
||||
rotenc_t lastEncoderValue = 0;
|
||||
|
||||
if (UNEXPECTED_SHUTDOWN()) {
|
||||
pwrOn();
|
||||
} else if (isChargerActive()) {
|
||||
while (true) {
|
||||
pwrOn();
|
||||
uint32_t now = timersGetMsTick();
|
||||
if (pwrPressed()) {
|
||||
press_end = now;
|
||||
if (press_start == 0) press_start = now;
|
||||
if ((now - press_start) > POWER_ON_DELAY) {
|
||||
break;
|
||||
}
|
||||
} else if (!isChargerActive()) {
|
||||
boardOff();
|
||||
} else {
|
||||
uint32_t press_end_touch = press_end;
|
||||
rotenc_t value = rotaryEncoderGetValue();
|
||||
if (value != lastEncoderValue) {
|
||||
lastEncoderValue = value;
|
||||
press_end_touch = timersGetMsTick();
|
||||
}
|
||||
press_start = 0;
|
||||
handle_battery_charge(press_end_touch);
|
||||
delay_ms(10);
|
||||
press_end = 0;
|
||||
}
|
||||
else {
|
||||
led_strip_off();
|
||||
}
|
||||
delay_ms(1000);
|
||||
}
|
||||
while(1) // Wait power to drain
|
||||
boardOff();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
led_strip_off();
|
||||
|
||||
// uint32_t press_start = 0;
|
||||
// uint32_t press_end = 0;
|
||||
|
||||
// if (UNEXPECTED_SHUTDOWN()) {
|
||||
pwrOn();
|
||||
// } else if (isChargerActive()) {
|
||||
// while (true) {
|
||||
// pwrOn();
|
||||
// uint32_t now = get_tmr10ms();
|
||||
// if (pwrPressed()) {
|
||||
// press_end = now;
|
||||
// if (press_start == 0) press_start = now;
|
||||
// if ((now - press_start) > POWER_ON_DELAY) {
|
||||
// break;
|
||||
// }
|
||||
// } else if (!isChargerActive()) {
|
||||
// boardOff();
|
||||
// } else {
|
||||
// uint32_t press_end_touch = press_end;
|
||||
// press_start = 0;
|
||||
// handle_battery_charge(press_end_touch);
|
||||
// delay_ms(10);
|
||||
// press_end = 0;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
rgbLedClearAll();
|
||||
keysInit();
|
||||
switchInit();
|
||||
rotaryEncoderInit();
|
||||
touchPanelInit();
|
||||
audioInit();
|
||||
adcInit(&_adc_driver);
|
||||
@@ -306,6 +277,18 @@ void boardOff()
|
||||
|
||||
rtcDisableBackupReg();
|
||||
|
||||
#if !defined(BOOT)
|
||||
#if defined(LED_STRIP_GPIO)
|
||||
rgbLedClearAll();
|
||||
#endif
|
||||
if (isChargerActive())
|
||||
{
|
||||
// RTC->BKP0R = SOFTRESET_REQUEST;
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
||||
// RTC->BKP0R = SHUTDOWN_REQUEST;
|
||||
pwrOff();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user