4 #include "SX1280_Regs.h"
5 #include "SX1280_hal.h"
6 #include "SX12xxDriverCommon.h"
8 #ifdef PLATFORM_ESP8266
12 #define RADIO_SNR_SCALE 4 // Units for LastPacketSNRRaw
14 class SX1280Driver
: public SX12xxDriverCommon
17 static SX1280Driver
*instance
;
20 ///////////Radio Variables////////
23 ///////////////////////////////////
25 ////////////////Configuration Functions/////////////
27 bool Begin(uint32_t minimumFrequency
, uint32_t maximumFrequency
);
29 void SetTxIdleMode() { SetMode(SX1280_MODE_FS
, SX12XX_Radio_All
); }; // set Idle mode used when switching from RX to TX
30 void Config(uint8_t bw
, uint8_t sf
, uint8_t cr
, uint32_t freq
,
31 uint8_t PreambleLength
, bool InvertIQ
, uint8_t PayloadLength
, uint32_t interval
,
32 uint32_t flrcSyncWord
=0, uint16_t flrcCrcSeed
=0, uint8_t flrc
=0);
33 void SetFrequencyHz(uint32_t freq
, SX12XX_Radio_Number_t radioNumber
);
34 void SetFrequencyReg(uint32_t freq
, SX12XX_Radio_Number_t radioNumber
= SX12XX_Radio_All
);
35 void SetRxTimeoutUs(uint32_t interval
);
36 void SetOutputPower(int8_t power
);
37 void startCWTest(uint32_t freq
, SX12XX_Radio_Number_t radioNumber
);
40 bool GetFrequencyErrorbool(SX12XX_Radio_Number_t radioNumber
);
41 bool FrequencyErrorAvailable() const { return modeSupportsFei
&& (LastPacketSNRRaw
> 0); }
43 void TXnb(uint8_t * data
, uint8_t size
, bool sendGeminiBuffer
, uint8_t * dataGemini
, SX12XX_Radio_Number_t radioNumber
);
44 void RXnb(SX1280_RadioOperatingModes_t rxMode
= SX1280_MODE_RX
, uint32_t incomingTimeout
= 0);
46 uint16_t GetIrqStatus(SX12XX_Radio_Number_t radioNumber
);
47 void ClearIrqStatus(uint16_t irqMask
, SX12XX_Radio_Number_t radioNumber
);
49 void GetStatus(SX12XX_Radio_Number_t radioNumber
);
51 uint8_t GetRxBufferAddr(SX12XX_Radio_Number_t radioNumber
);
52 int8_t GetRssiInst(SX12XX_Radio_Number_t radioNumber
);
53 void GetLastPacketStats();
54 void CheckForSecondPacket();
57 // constant used for no power change pending
58 // must not be a valid power register value
59 static const uint8_t PWRPENDING_NONE
= 0x7f;
61 SX1280_RadioOperatingModes_t currOpmode
;
66 SX1280_RadioOperatingModes_t fallBackMode
;
68 void SetMode(SX1280_RadioOperatingModes_t OPmode
, SX12XX_Radio_Number_t radioNumber
, uint32_t incomingTimeout
= 0);
69 void SetFIFOaddr(uint8_t txBaseAddr
, uint8_t rxBaseAddr
);
72 void ConfigModParamsLoRa(uint8_t bw
, uint8_t sf
, uint8_t cr
);
73 void SetPacketParamsLoRa(uint8_t PreambleLength
, SX1280_RadioLoRaPacketLengthsModes_t HeaderType
,
74 uint8_t PayloadLength
, uint8_t InvertIQ
);
76 void ConfigModParamsFLRC(uint8_t bw
, uint8_t cr
, uint8_t bt
=SX1280_FLRC_BT_0_5
);
77 void SetPacketParamsFLRC(uint8_t HeaderType
,
78 uint8_t PreambleLength
,
79 uint8_t PayloadLength
,
84 void SetDioIrqParams(uint16_t irqMask
,
85 uint16_t dio1Mask
=SX1280_IRQ_RADIO_NONE
,
86 uint16_t dio2Mask
=SX1280_IRQ_RADIO_NONE
,
87 uint16_t dio3Mask
=SX1280_IRQ_RADIO_NONE
);
89 static void IsrCallback_1();
90 static void IsrCallback_2();
91 static void IsrCallback(SX12XX_Radio_Number_t radioNumber
);
92 bool RXnbISR(uint16_t irqStatus
, SX12XX_Radio_Number_t radioNumber
); // ISR for non-blocking RX routine
93 void TXnbISR(); // ISR for non-blocking TX routine
94 void CommitOutputPower();