Closed torntrousers closed 5 years ago
After digging into the datasheet I cannot find a compelling reason resetting REG_FIFO_ADDR_PTR should be done.
I do confirm. could be good as well to create a task that is calling the callback function instead of having this call in the ISR which is not safe at all. Sharing below the code I have used on my side. Hope this can help.
volatile int _dioRiseInterruptCounter = 0; portMUX_TYPE mutexDioRise = portMUX_INITIALIZER_UNLOCKED;
/**
/**
/ void LoRaClass::taskRxLoop(void pvParameters) { // configure dio0 interrupt vTaskDelay(1); pinMode(LoRa._dio0, INPUT); LoRa.writeRegister(REG_DIO_MAPPING_1, 0x00); attachInterrupt(digitalPinToInterrupt(LoRa._dio0), LoRaClass::onDio0Rise, RISING); while (true) { if (_dioRiseInterruptCounter > 0) { portENTER_CRITICAL(&mutexDioRise); _dioRiseInterruptCounter--; portEXIT_CRITICAL(&mutexDioRise); LoRa.handleDio0Rise(); } // give the opportunity to the IDLE task to run, and so avoid the TaskWatchDog timer to trigger a reset vTaskDelay(10); } }
This isn't related to this pull request.
As per the discussion in https://github.com/sandeepmistry/arduino-LoRa/issues/268 and https://github.com/sandeepmistry/arduino-LoRa/issues/218