4 #include "LR1121_Regs.h"
5 #include "LR1121_hal.h"
6 #include "SX12xxDriverCommon.h"
8 #ifdef PLATFORM_ESP8266
12 #define RADIO_SNR_SCALE 4
14 class LR1121Driver
: public SX12xxDriverCommon
17 static LR1121Driver
*instance
;
19 ///////////Radio Variables////////
22 ///////////////////////////////////
24 ////////////////Configuration Functions/////////////
26 bool Begin(uint32_t minimumFrequency
, uint32_t maximumFrequency
);
28 void SetTxIdleMode() { SetMode(LR1121_MODE_FS
, SX12XX_Radio_All
); }; // set Idle mode used when switching from RX to TX
29 void Config(uint8_t bw
, uint8_t sf
, uint8_t cr
, uint32_t freq
,
30 uint8_t PreambleLength
, bool InvertIQ
, uint8_t PayloadLength
, uint32_t interval
, bool setFSKModulation
,
31 uint8_t fskSyncWord1
, uint8_t fskSyncWord2
, SX12XX_Radio_Number_t radioNumber
= SX12XX_Radio_All
);
32 void SetFrequencyHz(uint32_t freq
, SX12XX_Radio_Number_t radioNumber
);
33 void SetFrequencyReg(uint32_t freq
, SX12XX_Radio_Number_t radioNumber
= SX12XX_Radio_All
);
34 void SetRxTimeoutUs(uint32_t interval
);
35 void SetOutputPower(int8_t power
, bool isSubGHz
= true);
36 void startCWTest(uint32_t freq
, SX12XX_Radio_Number_t radioNumber
);
39 bool GetFrequencyErrorbool(SX12XX_Radio_Number_t radioNumber
);
40 // bool FrequencyErrorAvailable() const { return modeSupportsFei && (LastPacketSNRRaw > 0); }
41 bool FrequencyErrorAvailable() const { return false; }
43 void TXnb(uint8_t * data
, uint8_t size
, bool sendGeminiBuffer
, uint8_t * dataGemini
, SX12XX_Radio_Number_t radioNumber
);
44 void RXnb(lr11xx_RadioOperatingModes_t rxMode
= LR1121_MODE_RX
);
46 uint32_t GetIrqStatus(SX12XX_Radio_Number_t radioNumber
);
47 void ClearIrqStatus(SX12XX_Radio_Number_t radioNumber
);
49 int8_t GetRssiInst(SX12XX_Radio_Number_t radioNumber
);
50 void GetLastPacketStats();
51 void CheckForSecondPacket();
54 // constant used for no power change pending
55 // must not be a valid power register value
56 static const uint8_t PWRPENDING_NONE
= 0x7f;
58 // LR1121_RadioOperatingModes_t currOpmode;
63 uint8_t pwrCurrentHF
; // HF = High Frequency
68 lr11xx_RadioOperatingModes_t fallBackMode
;
71 void SetMode(lr11xx_RadioOperatingModes_t OPmode
, SX12XX_Radio_Number_t radioNumber
);
74 void ConfigModParamsLoRa(uint8_t bw
, uint8_t sf
, uint8_t cr
, SX12XX_Radio_Number_t radioNumber
);
75 void SetPacketParamsLoRa(uint8_t PreambleLength
, lr11xx_RadioLoRaPacketLengthsModes_t HeaderType
,
76 uint8_t PayloadLength
, uint8_t InvertIQ
, SX12XX_Radio_Number_t radioNumber
);
78 void ConfigModParamsFSK(uint32_t Bitrate
, uint8_t BWF
, uint32_t Fdev
, SX12XX_Radio_Number_t radioNumber
);
79 void SetPacketParamsFSK(uint8_t PreambleLength
, uint8_t PayloadLength
, SX12XX_Radio_Number_t radioNumber
);
80 void SetFSKSyncWord(uint8_t fskSyncWord1
, uint8_t fskSyncWord2
, SX12XX_Radio_Number_t radioNumber
);
82 void SetDioIrqParams();
83 void SetDioAsRfSwitch();
84 void CorrectRegisterForSF6(uint8_t sf
, SX12XX_Radio_Number_t radioNumber
);
86 static void IsrCallback_1();
87 static void IsrCallback_2();
88 static void IsrCallback(SX12XX_Radio_Number_t radioNumber
);
89 bool RXnbISR(SX12XX_Radio_Number_t radioNumber
); // ISR for non-blocking RX routine
90 void TXnbISR(); // ISR for non-blocking TX routine
91 void CommitOutputPower();
92 void WriteOutputPower(uint8_t pwr
, bool isSubGHz
, SX12XX_Radio_Number_t radioNumber
);