1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

sx127x: remove DIOMULTI

This commit is contained in:
Jose Alamos 2019-07-04 14:23:48 +02:00
parent 14f91388bd
commit d94d587e5e
4 changed files with 10 additions and 90 deletions

View File

@ -92,9 +92,6 @@ extern "C" {
#define SX127X_IRQ_DIO3 (1<<3) /**< DIO3 IRQ */
#define SX127X_IRQ_DIO4 (1<<4) /**< DIO4 IRQ */
#define SX127X_IRQ_DIO5 (1<<5) /**< DIO5 IRQ */
#ifdef SX127X_USE_DIO_MULTI
#define SX127X_IRQ_DIO_MULTI (1<<6) /**< DIO MULTI IRQ */
#endif
#ifndef SX127X_DIO_PULL_MODE
#define SX127X_DIO_PULL_MODE (GPIO_IN_PD) /**< pull down DIOx */
#endif
@ -214,9 +211,6 @@ typedef struct {
gpio_t dio3_pin; /**< Interrupt line DIO3 (CAD done) */
gpio_t dio4_pin; /**< Interrupt line DIO4 (not used) */
gpio_t dio5_pin; /**< Interrupt line DIO5 (not used) */
#ifdef SX127X_USE_DIO_MULTI
gpio_t dio_multi_pin; /**< Interrupt line for multiple IRQs */
#endif
#if defined(SX127X_USE_TX_SWITCH) || defined(SX127X_USE_RX_SWITCH)
gpio_t rx_switch_pin; /**< Rx antenna switch */
gpio_t tx_switch_pin; /**< Tx antenna switch */

View File

@ -60,10 +60,6 @@ extern "C" {
#define SX127X_PARAM_DIO3 GPIO_PIN(1, 4) /* D5 */
#endif
#ifndef SX127X_PARAM_DIO_MULTI
#define SX127X_PARAM_DIO_MULTI GPIO_UNDEF
#endif
#ifndef SX127X_PARAM_PASELECT
#define SX127X_PARAM_PASELECT (SX127X_PA_RFO)
#endif
@ -77,17 +73,7 @@ extern "C" {
#endif
#ifndef SX127X_PARAMS
#ifdef SX127X_USE_DIO_MULTI
#define SX127X_PARAMS { .spi = SX127X_PARAM_SPI, \
.nss_pin = SX127X_PARAM_SPI_NSS, \
.reset_pin = SX127X_PARAM_RESET, \
.dio0_pin = SX127X_PARAM_DIO0, \
.dio1_pin = SX127X_PARAM_DIO1, \
.dio2_pin = SX127X_PARAM_DIO2, \
.dio3_pin = SX127X_PARAM_DIO3, \
.dio_multi_pin = SX127X_PARAM_DIO_MULTI,\
.paselect = SX127X_PARAM_PASELECT }
#elif defined(SX127X_USE_TX_SWITCH) || defined(SX127X_USE_RX_SWITCH)
#if defined(SX127X_USE_TX_SWITCH) || defined(SX127X_USE_RX_SWITCH)
#define SX127X_PARAMS { .spi = SX127X_PARAM_SPI, \
.nss_pin = SX127X_PARAM_SPI_NSS, \
.reset_pin = SX127X_PARAM_RESET, \

View File

@ -48,14 +48,10 @@ static void _on_tx_timeout(void *arg);
static void _on_rx_timeout(void *arg);
/* SX127X DIO interrupt handlers initialization */
#ifndef SX127X_USE_DIO_MULTI
static void sx127x_on_dio0_isr(void *arg);
static void sx127x_on_dio1_isr(void *arg);
static void sx127x_on_dio2_isr(void *arg);
static void sx127x_on_dio3_isr(void *arg);
#else
static void sx127x_on_dio_multi_isr(void *arg);
#endif
void sx127x_setup(sx127x_t *dev, const sx127x_params_t *params)
{
@ -210,7 +206,6 @@ static void sx127x_on_dio_isr(sx127x_t *dev, sx127x_flags_t flag)
sx127x_isr((netdev_t *)dev);
}
#ifndef SX127X_USE_DIO_MULTI
static void sx127x_on_dio0_isr(void *arg)
{
sx127x_on_dio_isr((sx127x_t*) arg, SX127X_IRQ_DIO0);
@ -230,19 +225,12 @@ static void sx127x_on_dio3_isr(void *arg)
{
sx127x_on_dio_isr((sx127x_t*) arg, SX127X_IRQ_DIO3);
}
#else
static void sx127x_on_dio_multi_isr(void *arg)
{
sx127x_on_dio_isr((sx127x_t*) arg, SX127X_IRQ_DIO_MULTI);
}
#endif
/* Internal event handlers */
static int _init_gpios(sx127x_t *dev)
{
int res;
#ifndef SX127X_USE_DIO_MULTI
/* Check if DIO0 pin is defined */
if (dev->params.dio0_pin != GPIO_UNDEF) {
res = gpio_init_int(dev->params.dio0_pin, SX127X_DIO_PULL_MODE,
@ -287,24 +275,6 @@ static int _init_gpios(sx127x_t *dev)
return res;
}
}
#else
if (dev->params.dio_multi_pin != GPIO_UNDEF) {
DEBUG("[sx127x] info: Trying to initialize DIO MULTI pin\n");
res = gpio_init_int(dev->params.dio_multi_pin, SX127X_DIO_PULL_MODE,
GPIO_RISING, sx127x_on_dio_multi_isr, dev);
if (res < 0) {
DEBUG("[sx127x] error: failed to initialize DIO MULTI pin\n");
return res;
}
DEBUG("[sx127x] info: DIO MULTI pin initialized successfully\n");
}
else {
DEBUG("[sx127x] error: no DIO MULTI pin defined\n");
DEBUG("[sx127x] error at least one interrupt should be defined\n");
return SX127X_ERR_GPIOS;
}
#endif
return res;
}

View File

@ -225,55 +225,25 @@ static void _isr(netdev_t *netdev)
{
sx127x_t *dev = (sx127x_t *) netdev;
uint8_t irq = dev->irq;
uint8_t interruptReg = sx127x_reg_read(dev, SX127X_REG_LR_IRQFLAGS);
#ifdef SX127X_USE_DIO_MULTI
/* if the IRQ is from an OR'd pin check the actual IRQ on the registers */
if (irq == SX127X_IRQ_DIO_MULTI) {
uint8_t interruptReg = sx127x_reg_read(dev, SX127X_REG_LR_IRQFLAGS);
switch (interruptReg) {
case SX127X_RF_LORA_IRQFLAGS_TXDONE:
case SX127X_RF_LORA_IRQFLAGS_RXDONE:
irq = SX127X_IRQ_DIO0;
break;
case SX127X_RF_LORA_IRQFLAGS_RXTIMEOUT:
irq = SX127X_IRQ_DIO1;
break;
case SX127X_RF_LORA_IRQFLAGS_FHSSCHANGEDCHANNEL:
irq = SX127X_IRQ_DIO2;
break;
case SX127X_RF_LORA_IRQFLAGS_CADDETECTED:
case SX127X_RF_LORA_IRQFLAGS_CADDONE:
case SX127X_RF_LORA_IRQFLAGS_VALIDHEADER:
irq = SX127X_IRQ_DIO3;
break;
default:
break;
}
}
#endif
dev->irq = 0;
switch (irq) {
case SX127X_IRQ_DIO0:
switch (interruptReg) {
case SX127X_RF_LORA_IRQFLAGS_TXDONE:
case SX127X_RF_LORA_IRQFLAGS_RXDONE:
_on_dio0_irq(dev);
break;
case SX127X_IRQ_DIO1:
case SX127X_RF_LORA_IRQFLAGS_RXTIMEOUT:
_on_dio1_irq(dev);
break;
case SX127X_IRQ_DIO2:
case SX127X_RF_LORA_IRQFLAGS_FHSSCHANGEDCHANNEL:
_on_dio2_irq(dev);
break;
case SX127X_IRQ_DIO3:
case SX127X_RF_LORA_IRQFLAGS_CADDETECTED:
case SX127X_RF_LORA_IRQFLAGS_CADDONE:
case SX127X_RF_LORA_IRQFLAGS_VALIDHEADER:
_on_dio3_irq(dev);
break;