From 05a4cf1ef145c9e6e61f760250241b75bd26f35c Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 5 Jun 2022 11:15:54 +0200 Subject: [PATCH] [SX126x] Added LR-FHSS registers --- src/modules/SX126x/SX126x.cpp | 6 ++-- src/modules/SX126x/SX126x.h | 52 ++++++++++++++++++++++++----------- 2 files changed, 39 insertions(+), 19 deletions(-) diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index 0b9a9b3e..64161ea3 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -1538,17 +1538,17 @@ int16_t SX126x::fixImplicitTimeout() { // stop RTC counter uint8_t rtcStop = 0x00; - int16_t state = writeRegister(RADIOLIB_SX126X_REG_RTC_STOP, &rtcStop, 1); + int16_t state = writeRegister(RADIOLIB_SX126X_REG_DIO3_OUT_VOLTAGE_CTRL, &rtcStop, 1); RADIOLIB_ASSERT(state); // read currently active event uint8_t rtcEvent = 0; - state = readRegister(RADIOLIB_SX126X_REG_RTC_EVENT, &rtcEvent, 1); + state = readRegister(RADIOLIB_SX126X_REG_EVENT_MASK, &rtcEvent, 1); RADIOLIB_ASSERT(state); // clear events rtcEvent |= 0x02; - return(writeRegister(RADIOLIB_SX126X_REG_RTC_EVENT, &rtcEvent, 1)); + return(writeRegister(RADIOLIB_SX126X_REG_EVENT_MASK, &rtcEvent, 1)); } int16_t SX126x::fixInvertedIQ(uint8_t iqConfig) { diff --git a/src/modules/SX126x/SX126x.h b/src/modules/SX126x/SX126x.h index 57f3df66..df2d2952 100644 --- a/src/modules/SX126x/SX126x.h +++ b/src/modules/SX126x/SX126x.h @@ -70,6 +70,19 @@ // SX126X register map +#define RADIOLIB_SX126X_REG_HOPPING_ENABLE 0x0385 +#define RADIOLIB_SX126X_REG_LR_FHSS_PACKET_LENGTH 0x0386 +#define RADIOLIB_SX126X_REG_LR_FHSS_NUM_HOPPING_BLOCKS 0x0387 +#define RADIOLIB_SX126X_REG_LR_FHSS_NUM_SYMBOLS_FREQX_MSB(X) (0x0388 + (X)*6) +#define RADIOLIB_SX126X_REG_LR_FHSS_NUM_SYMBOLS_FREQX_LSB(X) (0x0389 + (X)*6) +#define RADIOLIB_SX126X_REG_LR_FHSS_FREQX_0(X) (0x038A + (X)*6) +#define RADIOLIB_SX126X_REG_LR_FHSS_FREQX_1(X) (0x038B + (X)*6) +#define RADIOLIB_SX126X_REG_LR_FHSS_FREQX_2(X) (0x038C + (X)*6) +#define RADIOLIB_SX126X_REG_LR_FHSS_FREQX_3(X) (0x038D + (X)*6) +#define RADIOLIB_SX126X_REG_DIOX_OUT_ENABLE 0x0580 +#define RADIOLIB_SX126X_REG_DIOX_IN_ENABLE 0x0583 +#define RADIOLIB_SX126X_REG_DIOX_PULL_UP_CTRL 0x0584 +#define RADIOLIB_SX126X_REG_DIOX_PULL_DOWN_CTRL 0x0585 #define RADIOLIB_SX126X_REG_WHITENING_INITIAL_MSB 0x06B8 #define RADIOLIB_SX126X_REG_WHITENING_INITIAL_LSB 0x06B9 #define RADIOLIB_SX126X_REG_CRC_INITIAL_MSB 0x06BC @@ -86,6 +99,7 @@ #define RADIOLIB_SX126X_REG_SYNC_WORD_7 0x06C7 #define RADIOLIB_SX126X_REG_NODE_ADDRESS 0x06CD #define RADIOLIB_SX126X_REG_BROADCAST_ADDRESS 0x06CE +#define RADIOLIB_SX126X_REG_IQ_CONFIG 0x0736 #define RADIOLIB_SX126X_REG_LORA_SYNC_WORD_MSB 0x0740 #define RADIOLIB_SX126X_REG_LORA_SYNC_WORD_LSB 0x0741 #define RADIOLIB_SX126X_REG_RANDOM_NUMBER_0 0x0819 @@ -93,16 +107,16 @@ #define RADIOLIB_SX126X_REG_RANDOM_NUMBER_2 0x081B #define RADIOLIB_SX126X_REG_RANDOM_NUMBER_3 0x081C #define RADIOLIB_SX126X_REG_RX_GAIN 0x08AC +#define RADIOLIB_SX126X_REG_TX_CLAMP_CONFIG 0x08D8 #define RADIOLIB_SX126X_REG_OCP_CONFIGURATION 0x08E7 +#define RADIOLIB_SX126X_REG_RTC_CTRL 0x0902 #define RADIOLIB_SX126X_REG_XTA_TRIM 0x0911 #define RADIOLIB_SX126X_REG_XTB_TRIM 0x0912 +#define RADIOLIB_SX126X_REG_DIO3_OUT_VOLTAGE_CTRL 0x0920 +#define RADIOLIB_SX126X_REG_EVENT_MASK 0x0944 // undocumented registers #define RADIOLIB_SX126X_REG_SENSITIVITY_CONFIG 0x0889 // SX1268 datasheet v1.1, section 15.1 -#define RADIOLIB_SX126X_REG_TX_CLAMP_CONFIG 0x08D8 // SX1268 datasheet v1.1, section 15.2 -#define RADIOLIB_SX126X_REG_RTC_STOP 0x0920 // SX1268 datasheet v1.1, section 15.3 -#define RADIOLIB_SX126X_REG_RTC_EVENT 0x0944 // SX1268 datasheet v1.1, section 15.3 -#define RADIOLIB_SX126X_REG_IQ_CONFIG 0x0736 // SX1268 datasheet v1.1, section 15.4 #define RADIOLIB_SX126X_REG_RX_GAIN_RETENTION_0 0x029F // SX1268 datasheet v1.1, section 9.6 #define RADIOLIB_SX126X_REG_RX_GAIN_RETENTION_1 0x02A0 // SX1268 datasheet v1.1, section 9.6 #define RADIOLIB_SX126X_REG_RX_GAIN_RETENTION_2 0x02A1 // SX1268 datasheet v1.1, section 9.6 @@ -174,18 +188,19 @@ #define RADIOLIB_SX126X_RX_TX_FALLBACK_MODE_STDBY_RC 0x20 // 7 0 standby with RC oscillator (default) //RADIOLIB_SX126X_CMD_SET_DIO_IRQ_PARAMS -#define RADIOLIB_SX126X_IRQ_TIMEOUT 0b1000000000 // 9 9 Rx or Tx timeout -#define RADIOLIB_SX126X_IRQ_CAD_DETECTED 0b0100000000 // 8 8 channel activity detected -#define RADIOLIB_SX126X_IRQ_CAD_DONE 0b0010000000 // 7 7 channel activity detection finished -#define RADIOLIB_SX126X_IRQ_CRC_ERR 0b0001000000 // 6 6 wrong CRC received -#define RADIOLIB_SX126X_IRQ_HEADER_ERR 0b0000100000 // 5 5 LoRa header CRC error -#define RADIOLIB_SX126X_IRQ_HEADER_VALID 0b0000010000 // 4 4 valid LoRa header received -#define RADIOLIB_SX126X_IRQ_SYNC_WORD_VALID 0b0000001000 // 3 3 valid sync word detected -#define RADIOLIB_SX126X_IRQ_RADIOLIB_PREAMBLE_DETECTED 0b0000000100 // 2 2 preamble detected -#define RADIOLIB_SX126X_IRQ_RX_DONE 0b0000000010 // 1 1 packet received -#define RADIOLIB_SX126X_IRQ_TX_DONE 0b0000000001 // 0 0 packet transmission completed -#define RADIOLIB_SX126X_IRQ_ALL 0b1111111111 // 9 0 all interrupts -#define RADIOLIB_SX126X_IRQ_NONE 0b0000000000 // 9 0 no interrupts +#define RADIOLIB_SX126X_IRQ_LR_FHSS_HOP 0b0100000000000000 // 14 14 PA ramped up during LR-FHSS hop +#define RADIOLIB_SX126X_IRQ_TIMEOUT 0b0000001000000000 // 9 9 Rx or Tx timeout +#define RADIOLIB_SX126X_IRQ_CAD_DETECTED 0b0000000100000000 // 8 8 channel activity detected +#define RADIOLIB_SX126X_IRQ_CAD_DONE 0b0000000010000000 // 7 7 channel activity detection finished +#define RADIOLIB_SX126X_IRQ_CRC_ERR 0b0000000001000000 // 6 6 wrong CRC received +#define RADIOLIB_SX126X_IRQ_HEADER_ERR 0b0000000000100000 // 5 5 LoRa header CRC error +#define RADIOLIB_SX126X_IRQ_HEADER_VALID 0b0000000000010000 // 4 4 valid LoRa header received +#define RADIOLIB_SX126X_IRQ_SYNC_WORD_VALID 0b0000000000001000 // 3 3 valid sync word detected +#define RADIOLIB_SX126X_IRQ_RADIOLIB_PREAMBLE_DETECTED 0b0000000000000100 // 2 2 preamble detected +#define RADIOLIB_SX126X_IRQ_RX_DONE 0b0000000000000010 // 1 1 packet received +#define RADIOLIB_SX126X_IRQ_TX_DONE 0b0000000000000001 // 0 0 packet transmission completed +#define RADIOLIB_SX126X_IRQ_ALL 0b0100001111111111 // 14 0 all interrupts +#define RADIOLIB_SX126X_IRQ_NONE 0b0000000000000000 // 14 0 no interrupts //RADIOLIB_SX126X_CMD_SET_DIO2_AS_RF_SWITCH_CTRL #define RADIOLIB_SX126X_DIO2_AS_IRQ 0x00 // 7 0 DIO2 configuration: IRQ @@ -204,6 +219,7 @@ //RADIOLIB_SX126X_CMD_SET_PACKET_TYPE #define RADIOLIB_SX126X_PACKET_TYPE_GFSK 0x00 // 7 0 packet type: GFSK #define RADIOLIB_SX126X_PACKET_TYPE_LORA 0x01 // 7 0 LoRa +#define RADIOLIB_SX126X_PACKET_TYPE_LR_FHSS 0x03 // 7 0 LR-FHSS //RADIOLIB_SX126X_CMD_SET_TX_PARAMS #define RADIOLIB_SX126X_PA_RAMP_10U 0x00 // 7 0 ramp time: 10 us @@ -328,6 +344,10 @@ // SX126X SPI register variables +//RADIOLIB_SX126X_REG_HOPPING_ENABLE +#define RADIOLIB_SX126X_HOPPING_ENABLED 0b00000001 // 0 0 intra-packet hopping for LR-FHSS: enabled +#define RADIOLIB_SX126X_HOPPING_DISABLED 0b00000000 // 0 0 (disabled) + //RADIOLIB_SX126X_REG_LORA_SYNC_WORD_MSB + LSB #define RADIOLIB_SX126X_SYNC_WORD_PUBLIC 0x34 // actually 0x3444 NOTE: The low nibbles in each byte (0x_4_4) are masked out since apparently, they're reserved. #define RADIOLIB_SX126X_SYNC_WORD_PRIVATE 0x12 // actually 0x1424 You couldn't make this up if you tried.