Skip to content

Commit

Permalink
drivers/sx127x: switch LF/HF registers
Browse files Browse the repository at this point in the history
  • Loading branch information
olegart committed Dec 15, 2019
1 parent da49a63 commit 512cd1b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions drivers/sx127x/sx127x_getset.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,19 @@ void sx127x_set_channel(sx127x_t *dev, uint32_t channel)
/* Save current operating mode */
dev->settings.channel = channel;

/* SX1276 only: choose frequency band */
if (dev->_internal.modem_chip == SX127X_MODEM_SX1276) {
uint8_t reg_opmode = sx127x_reg_read(dev, SX127X_REG_OPMODE);

if (channel >= 779000000) {
sx127x_reg_write(dev, SX127X_REG_OPMODE,
reg_opmode & ~SX127X_RF_OPMODE_LOWFREQMODE_ON);
} else {
sx127x_reg_write(dev, SX127X_REG_OPMODE,
reg_opmode | SX127X_RF_OPMODE_LOWFREQMODE_ON);
}
}

channel = (1000000ULL*(uint64_t)channel) / LORA_FREQUENCY_RESOLUTION_DEFAULT;

/* Write frequency settings into chip */
Expand Down

0 comments on commit 512cd1b

Please sign in to comment.