add new dio handlers, consolidate DIO handlers to single function

This commit is contained in:
Morgan 'ARR\!' Allen 2021-12-02 10:03:05 -08:00
parent a347f418c8
commit c5dc9c961d

View file

@ -446,7 +446,7 @@ void lora32_read_data(lora32_cfg_t *lora, uint8_t *data) {
} }
} }
static void IRAM_ATTR lora32_on_dio0(void *arg) { static void IRAM_ATTR lora32_on_dio(void *arg) {
xQueueSend(dio_event_queue, arg, (TickType_t)0); xQueueSend(dio_event_queue, arg, (TickType_t)0);
} }
@ -551,14 +551,18 @@ uint8_t lora32_init(lora32_cfg_t *lora) {
if(lora->receive != NULL) { if(lora->receive != NULL) {
ESP_LOGI(TAG, "Setting GPIO Interrupt"); ESP_LOGI(TAG, "Setting GPIO Interrupt");
// TODO check at least one DIOx pin is not NULL
io_conf.intr_type = GPIO_PIN_INTR_POSEDGE; io_conf.intr_type = GPIO_PIN_INTR_POSEDGE;
io_conf.pin_bit_mask = (1ULL << lora->dio0); io_conf.pin_bit_mask = ((1ULL << lora->dio0) | (1ULL << lora->dio1) | (1ULL << lora->dio2));
io_conf.mode = GPIO_MODE_INPUT; io_conf.mode = GPIO_MODE_INPUT;
io_conf.pull_down_en = 0; io_conf.pull_down_en = 0;
io_conf.pull_up_en = 0; io_conf.pull_up_en = 0;
gpio_config(&io_conf); gpio_config(&io_conf);
gpio_set_intr_type(lora->dio0, GPIO_INTR_POSEDGE); gpio_set_intr_type(lora->dio0, GPIO_INTR_POSEDGE);
gpio_set_intr_type(lora->dio1, GPIO_INTR_POSEDGE);
gpio_set_intr_type(lora->dio2, GPIO_INTR_POSEDGE);
// the DIO interrupt handling for every device is done from one task // the DIO interrupt handling for every device is done from one task
if(dio_task_handle == NULL) { if(dio_task_handle == NULL) {
@ -575,7 +579,14 @@ uint8_t lora32_init(lora32_cfg_t *lora) {
// add ISR handler to the global service started (once) above // add ISR handler to the global service started (once) above
ESP_LOGI(TAG, "Installing ISR handler for GPIO%d", lora->dio0); ESP_LOGI(TAG, "Installing ISR handler for GPIO%d", lora->dio0);
gpio_isr_handler_add(lora->dio0, lora32_on_dio0, lora); if(lora->dio0 > -1)
gpio_isr_handler_add(lora->dio0, lora32_on_dio, (void*)lora);
if(lora->dio1 > -1)
gpio_isr_handler_add(lora->dio1, lora32_on_dio, (void*)lora);
if(lora->dio2 > -1)
gpio_isr_handler_add(lora->dio2, lora32_on_dio, (void*)lora);
} }
return 1; return 1;