From e51bddae50fb6aa5a526f1d2389a99b08b556d9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Mon, 13 Mar 2023 19:35:06 +0100 Subject: [PATCH] main: also check GPIO0 for DFU --- main/main.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/main/main.c b/main/main.c index fabf62b..c7aede3 100644 --- a/main/main.c +++ b/main/main.c @@ -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