main: also check GPIO0 for DFU

This commit is contained in:
King Kévin 2023-03-13 19:35:06 +01:00
parent 70e734f21e
commit e51bddae50
1 changed files with 9 additions and 2 deletions

View File

@ -40,17 +40,24 @@ void app_main(void)
{
// check DFU force
gpio_config_t io_conf = {}; // to configure GPIO
// GPIO0 can also be pressed while soft reboot
io_conf.pin_bit_mask = (1ULL << 0); // GPIO to configure
io_conf.intr_type = GPIO_INTR_DISABLE; // disable interrupt
io_conf.mode = GPIO_MODE_INPUT; // set as input
io_conf.pull_down_en = false; // disable pull-down mode
io_conf.pull_up_en = true; // enable pull-up mode
ESP_ERROR_CHECK( gpio_config(&io_conf) ); // configure GPIO
// dedicated DFU button
io_conf.pin_bit_mask = (1ULL << DFU_PIN); // GPIO to configure
io_conf.intr_type = GPIO_INTR_DISABLE; // disable interrupt
io_conf.mode = GPIO_MODE_INPUT; // set as input
io_conf.pull_down_en = 1; // enable pull-down mode
io_conf.pull_up_en = 0; // disable pull-up mode
ESP_ERROR_CHECK( gpio_config(&io_conf) ); // configure GPIO
if (gpio_get_level(DFU_PIN)) { // DFU mode asserted
if (!gpio_get_level(0) || gpio_get_level(DFU_PIN)) { // DFU mode asserted
tud_dfu_runtime_reboot_to_dfu_cb(); // reboot to DFU mode
}
// configure LEDs
io_conf.pin_bit_mask = (1ULL << LED_BOARD); // GPIO to configure
io_conf.intr_type = GPIO_INTR_DISABLE; // disable interrupt