diff --git a/Kconfig b/Kconfig index 06ce10b..a9387a1 100644 --- a/Kconfig +++ b/Kconfig @@ -55,6 +55,21 @@ config TTN_SPI_FREQ help SPI frequency to communicate between ESP32 and SX127x radio chip +choice TTN_RESET + prompt "Reset states" + default TTN_RESET_STATES_FLOATING + help + Reset pin can be floating for most boards and shields. + A few boards/shields require the pin to be held high for operation. + +config TTN_RESET_STATES_FLOATING + bool "Toggle between low and floating" + +config TTN_RESET_STATES_ASSERTED + bool "Toggle between low and high" + +endchoice + config TTN_BG_TASK_PRIO int "Background task priority" default 10 diff --git a/src/hal/hal_esp32.cpp b/src/hal/hal_esp32.cpp index 4071fa6..ace7626 100755 --- a/src/hal/hal_esp32.cpp +++ b/src/hal/hal_esp32.cpp @@ -124,14 +124,22 @@ void hal_pin_rst(u1_t val) return; if (val == 0 || val == 1) - { // drive pin + { + // drive pin gpio_set_level(ttn_hal.pinRst, val); gpio_set_direction(ttn_hal.pinRst, GPIO_MODE_OUTPUT); } else - { // keep pin floating + { +#if defined(CONFIG_TTN_RESET_STATES_ASSERTED) + // drive up the pin because the hardware is nonstandard + gpio_set_level(ttn_hal.pinRst, 1); + gpio_set_direction(ttn_hal.pinRst, GPIO_MODE_OUTPUT); +#else + // keep pin floating gpio_set_level(ttn_hal.pinRst, val); gpio_set_direction(ttn_hal.pinRst, GPIO_MODE_INPUT); +#endif } }