main: also check GPIO0 for DFU
This commit is contained in:
parent
70e734f21e
commit
e51bddae50
11
main/main.c
11
main/main.c
|
@ -40,17 +40,24 @@ void app_main(void)
|
||||||
{
|
{
|
||||||
// check DFU force
|
// check DFU force
|
||||||
gpio_config_t io_conf = {}; // to configure GPIO
|
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.pin_bit_mask = (1ULL << DFU_PIN); // GPIO to configure
|
||||||
io_conf.intr_type = GPIO_INTR_DISABLE; // disable interrupt
|
io_conf.intr_type = GPIO_INTR_DISABLE; // disable interrupt
|
||||||
io_conf.mode = GPIO_MODE_INPUT; // set as input
|
io_conf.mode = GPIO_MODE_INPUT; // set as input
|
||||||
io_conf.pull_down_en = 1; // enable pull-down mode
|
io_conf.pull_down_en = 1; // enable pull-down mode
|
||||||
io_conf.pull_up_en = 0; // disable pull-up mode
|
io_conf.pull_up_en = 0; // disable pull-up mode
|
||||||
ESP_ERROR_CHECK( gpio_config(&io_conf) ); // configure GPIO
|
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
|
tud_dfu_runtime_reboot_to_dfu_cb(); // reboot to DFU mode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// configure LEDs
|
// configure LEDs
|
||||||
io_conf.pin_bit_mask = (1ULL << LED_BOARD); // GPIO to configure
|
io_conf.pin_bit_mask = (1ULL << LED_BOARD); // GPIO to configure
|
||||||
io_conf.intr_type = GPIO_INTR_DISABLE; // disable interrupt
|
io_conf.intr_type = GPIO_INTR_DISABLE; // disable interrupt
|
||||||
|
|
Loading…
Reference in New Issue