mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #13604 from gschorcht/drivers/sx127x/dio_handling
drivers/sx127x: changes in DIO handling
This commit is contained in:
commit
1776e54d80
@ -289,6 +289,10 @@ static int _init_gpios(sx127x_t *dev)
|
||||
return res;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* if frequency hopping is enabled, DIO2 pin must be defined */
|
||||
assert(LORA_FREQUENCY_HOPPING_DEFAULT == false);
|
||||
}
|
||||
|
||||
/* check if DIO3 pin is defined */
|
||||
if (dev->params.dio3_pin != GPIO_UNDEF) {
|
||||
|
@ -282,13 +282,14 @@ void sx127x_set_rx(sx127x_t *dev)
|
||||
/* SX127X_RF_LORA_IRQFLAGS_FHSSCHANGEDCHANNEL | */
|
||||
SX127X_RF_LORA_IRQFLAGS_CADDETECTED);
|
||||
|
||||
/* DIO0=RxDone, DIO2=FhssChangeChannel, DIO3=ValidHeader */
|
||||
/* DIO0=RxDone, DIO1=RxTimeout, DIO2=FhssChangeChannel, DIO3=ValidHeader */
|
||||
sx127x_reg_write(dev, SX127X_REG_DIOMAPPING1,
|
||||
(sx127x_reg_read(dev, SX127X_REG_DIOMAPPING1) &
|
||||
SX127X_RF_LORA_DIOMAPPING1_DIO0_MASK &
|
||||
SX127X_RF_LORA_DIOMAPPING1_DIO2_MASK &
|
||||
SX127X_RF_LORA_DIOMAPPING1_DIO3_MASK) |
|
||||
SX127X_RF_LORA_DIOMAPPING1_DIO0_00 |
|
||||
SX127X_RF_LORA_DIOMAPPING1_DIO1_00 |
|
||||
SX127X_RF_LORA_DIOMAPPING1_DIO2_00 |
|
||||
SX127X_RF_LORA_DIOMAPPING1_DIO3_01);
|
||||
}
|
||||
@ -303,12 +304,13 @@ void sx127x_set_rx(sx127x_t *dev)
|
||||
SX127X_RF_LORA_IRQFLAGS_FHSSCHANGEDCHANNEL |
|
||||
SX127X_RF_LORA_IRQFLAGS_CADDETECTED);
|
||||
|
||||
/* DIO0=RxDone, DIO3=ValidHeader */
|
||||
/* DIO0=RxDone, DIO1=RxTimeout, DIO3=ValidHeader */
|
||||
sx127x_reg_write(dev, SX127X_REG_DIOMAPPING1,
|
||||
(sx127x_reg_read(dev, SX127X_REG_DIOMAPPING1) &
|
||||
SX127X_RF_LORA_DIOMAPPING1_DIO0_MASK &
|
||||
SX127X_RF_LORA_DIOMAPPING1_DIO3_MASK) |
|
||||
SX127X_RF_LORA_DIOMAPPING1_DIO0_00 |
|
||||
SX127X_RF_LORA_DIOMAPPING1_DIO1_00 |
|
||||
SX127X_RF_LORA_DIOMAPPING1_DIO3_01);
|
||||
}
|
||||
|
||||
@ -353,9 +355,9 @@ void sx127x_set_tx(sx127x_t *dev)
|
||||
SX127X_RF_LORA_IRQFLAGS_RXDONE |
|
||||
SX127X_RF_LORA_IRQFLAGS_PAYLOADCRCERROR |
|
||||
SX127X_RF_LORA_IRQFLAGS_VALIDHEADER |
|
||||
/* RFLR_IRQFLAGS_TXDONE | */
|
||||
/* SX127X_RF_LORA_IRQFLAGS_TXDONE | */
|
||||
SX127X_RF_LORA_IRQFLAGS_CADDONE |
|
||||
/* RFLR_IRQFLAGS_FHSSCHANGEDCHANNEL | */
|
||||
/* SX127X_RF_LORA_IRQFLAGS_FHSSCHANGEDCHANNEL | */
|
||||
SX127X_RF_LORA_IRQFLAGS_CADDETECTED);
|
||||
|
||||
/* DIO0=TxDone, DIO2=FhssChangeChannel */
|
||||
|
@ -201,11 +201,20 @@ void sx127x_start_cad(sx127x_t *dev)
|
||||
/* | SX127X_RF_LORA_IRQFLAGS_CADDETECTED*/
|
||||
);
|
||||
|
||||
/* DIO3 = CADDone */
|
||||
sx127x_reg_write(dev, SX127X_REG_DIOMAPPING1,
|
||||
(sx127x_reg_read(dev, SX127X_REG_DIOMAPPING1) &
|
||||
SX127X_RF_LORA_DIOMAPPING1_DIO3_MASK) |
|
||||
SX127X_RF_LORA_DIOMAPPING1_DIO3_00);
|
||||
if (dev->params.dio3_pin != GPIO_UNDEF) {
|
||||
/* DIO3 = CADDone */
|
||||
sx127x_reg_write(dev, SX127X_REG_DIOMAPPING1,
|
||||
(sx127x_reg_read(dev, SX127X_REG_DIOMAPPING1) &
|
||||
SX127X_RF_LORA_DIOMAPPING1_DIO3_MASK) |
|
||||
SX127X_RF_LORA_DIOMAPPING1_DIO3_00);
|
||||
}
|
||||
else {
|
||||
/* DIO0 = CADDone */
|
||||
sx127x_reg_write(dev, SX127X_REG_DIOMAPPING1,
|
||||
(sx127x_reg_read(dev, SX127X_REG_DIOMAPPING1) &
|
||||
SX127X_RF_LORA_DIOMAPPING1_DIO0_MASK) |
|
||||
SX127X_RF_LORA_DIOMAPPING1_DIO0_10);
|
||||
}
|
||||
|
||||
sx127x_set_state(dev, SX127X_RF_CAD);
|
||||
sx127x_set_op_mode(dev, SX127X_RF_LORA_OPMODE_CAD);
|
||||
|
@ -721,6 +721,11 @@ void _on_dio3_irq(void *arg)
|
||||
break;
|
||||
default:
|
||||
DEBUG("[sx127x] netdev: sx127x_on_dio3: unknown state");
|
||||
/* at least the related interrupts should be cleared in this case */
|
||||
sx127x_reg_write(dev, SX127X_REG_LR_IRQFLAGS,
|
||||
SX127X_RF_LORA_IRQFLAGS_VALIDHEADER |
|
||||
SX127X_RF_LORA_IRQFLAGS_CADDETECTED |
|
||||
SX127X_RF_LORA_IRQFLAGS_CADDONE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user