diff --git a/inc/template/app_const_llcc68_template.hpp b/inc/template/app_const_llcc68_template.hpp index 067ca1b..9e9f92e 100644 --- a/inc/template/app_const_llcc68_template.hpp +++ b/inc/template/app_const_llcc68_template.hpp @@ -26,6 +26,9 @@ constexpr auto RST_PIN = NC_PIN; constexpr auto DIO1_PIN = GPIO_NUM_NC; constexpr auto DIO2_PIN = NC_PIN; constexpr auto DIO3_PIN = NC_PIN; + +/// @brief the pin numbers that needs to be configured as interrupt +constexpr gpio_num_t EXTI_PIN[] = {DIO1_PIN}; } #endif /* B0CD865F_D860_44B7_B289_4F512C770D2B */ diff --git a/src/llcc68.cpp b/src/llcc68.cpp index 87990cf..021b650 100644 --- a/src/llcc68.cpp +++ b/src/llcc68.cpp @@ -20,9 +20,13 @@ void init_exti() { details::__dio_flag__ = true; }; + uint64_t pin_bit_mask = 0; + for (const auto pin : EXTI_PIN) { + pin_bit_mask |= (1ULL << pin); + } gpio_config_t io_conf = { - .pin_bit_mask = (1ULL << DIO2_PIN), + .pin_bit_mask = pin_bit_mask, .mode = GPIO_MODE_INPUT, .pull_up_en = GPIO_PULLUP_DISABLE, .pull_down_en = GPIO_PULLDOWN_DISABLE, @@ -31,6 +35,8 @@ void init_exti() { // https://github.com/espressif/esp-idf/blob/v5.3.2/examples/peripherals/gpio/generic_gpio/main/gpio_example_main.c ESP_ERROR_CHECK(gpio_config(&io_conf)); gpio_install_isr_service(ESP_INTR_FLAG_DEFAULT); - gpio_isr_handler_add(DIO2_PIN, isr, nullptr); + for (const auto pin : EXTI_PIN) { + gpio_isr_handler_add(pin, isr, nullptr); + } } }