check IRQ flags that this is actually a receive

This commit is contained in:
Morgan 'ARR\!' Allen 2020-02-21 08:55:01 -08:00
parent d0e394a4af
commit 1e1c34bac8

View file

@ -268,23 +268,25 @@ static void IRAM_ATTR lora32_dio0_task(void *arg) {
ESP_LOGD(TAG, "handling DIO0");
// read IRQ flags
ESP_LOGD(TAG, "reading irqs");
uint8_t irqs = lora32_read_reg(lora, REG_IRQ_FLAGS);
ESP_LOGI(TAG, "reading irqs: %02X", irqs);
// clear IRQ flags
ESP_LOGD(TAG, "clearing irqs");
lora32_write_reg(lora, REG_IRQ_FLAGS, irqs);
if((irqs & IRQ_RX_DONE_MASK) == IRQ_RX_DONE_MASK) {
uint8_t len = lora32_read_reg(lora, (lora->implicitHeader ? REG_PAYLOAD_LENGTH : REG_RX_NB_BYTES));
ESP_LOGD(TAG, "lora32_receive_task packet length: %d", len);
ESP_LOGD(TAG, "lora32_dio0_task packet length: %d", len);
// TODO: set FIFO address to RX address
uint8_t fifo_addr = lora32_read_reg(lora, REG_FIFO_RX_CURRENT_ADDR);
ESP_LOGD(TAG, "lora32_receive_task current FIFO address: %d", fifo_addr);
ESP_LOGD(TAG, "lora32_dio0_task current FIFO address: %d", fifo_addr);
lora32_write_reg(lora, REG_FIFO_ADDR_PTR, fifo_addr);
lora->receive(len);
}
}
}
void lora32_read_data(lora32_cfg_t *lora, uint8_t *data) {