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();
41 bool FrequencyErrorAvailable() const { return modeSupportsFei
&& (LastPacketSNRRaw
> 0); }
43 void TXnb(uint8_t * data
, uint8_t size
, 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();
56 // constant used for no power change pending
57 // must not be a valid power register value
58 static const uint8_t PWRPENDING_NONE
= 0x7f;
60 SX1280_RadioOperatingModes_t currOpmode
;
65 SX1280_RadioOperatingModes_t fallBackMode
;
67 void SetMode(SX1280_RadioOperatingModes_t OPmode
, SX12XX_Radio_Number_t radioNumber
, uint32_t incomingTimeout
= 0);
68 void SetFIFOaddr(uint8_t txBaseAddr
, uint8_t rxBaseAddr
);
71 void ConfigModParamsLoRa(uint8_t bw
, uint8_t sf
, uint8_t cr
);
72 void SetPacketParamsLoRa(uint8_t PreambleLength
, SX1280_RadioLoRaPacketLengthsModes_t HeaderType
,
73 uint8_t PayloadLength
, uint8_t InvertIQ
);
75 void ConfigModParamsFLRC(uint8_t bw
, uint8_t cr
, uint8_t bt
=SX1280_FLRC_BT_0_5
);
76 void SetPacketParamsFLRC(uint8_t HeaderType
,
77 uint8_t PreambleLength
,
78 uint8_t PayloadLength
,
83 void SetDioIrqParams(uint16_t irqMask
,
84 uint16_t dio1Mask
=SX1280_IRQ_RADIO_NONE
,
85 uint16_t dio2Mask
=SX1280_IRQ_RADIO_NONE
,
86 uint16_t dio3Mask
=SX1280_IRQ_RADIO_NONE
);
88 static void IsrCallback_1();
89 static void IsrCallback_2();
90 static void IsrCallback(SX12XX_Radio_Number_t radioNumber
);
91 bool RXnbISR(uint16_t irqStatus
, SX12XX_Radio_Number_t radioNumber
); // ISR for non-blocking RX routine
92 void TXnbISR(); // ISR for non-blocking TX routine
93 void CommitOutputPower();