Merge pull request #1269 from pkendall64/crsf-max-output
[ExpressLRS.git] / src / lib / SX1280Driver / SX1280_Regs.h
blob5930880ade460f72ce820acaf971ab9349b7395e
1 #pragma once
3 #define REG_LR_FIRMWARE_VERSION_MSB 0x0153 //The address of the register holding the firmware version MSB
4 #define SX1280_REG_LR_ESTIMATED_FREQUENCY_ERROR_MSB 0x0954
5 #define SX1280_REG_LR_ESTIMATED_FREQUENCY_ERROR_MASK 0x0FFFFF
7 #define SX1280_XTAL_FREQ 52000000
8 #define FREQ_STEP ((double)(SX1280_XTAL_FREQ / pow(2.0, 18.0)))
10 typedef enum
12 SX1280_RF_IDLE = 0x00, //!< The radio is idle
13 SX1280_RF_RX_RUNNING, //!< The radio is in reception state
14 SX1280_RF_TX_RUNNING, //!< The radio is in transmission state
15 SX1280_RF_CAD, //!< The radio is doing channel activity detection
16 } SX1280_RadioStates_t;
18 /*!
19 * \brief Represents the operating mode the radio is actually running
21 typedef enum
23 SX1280_MODE_SLEEP = 0x00, //! The radio is in sleep mode
24 SX1280_MODE_CALIBRATION, //! The radio is in calibration mode
25 SX1280_MODE_STDBY_RC, //! The radio is in standby mode with RC oscillator
26 SX1280_MODE_STDBY_XOSC, //! The radio is in standby mode with XOSC oscillator
27 SX1280_MODE_FS, //! The radio is in frequency synthesis mode
28 SX1280_MODE_RX, //! The radio is in receive mode
29 SX1280_MODE_TX, //! The radio is in transmit mode
30 SX1280_MODE_CAD //! The radio is in channel activity detection mode
31 } SX1280_RadioOperatingModes_t;
33 #define SX1280_RX_TX_CONTINUOUS \
34 (TickTime_t) { RADIO_TICK_SIZE_0015_US, 0xFFFF }
35 #define SX1280_RX_TX_SINGLE \
36 (TickTime_t) { RADIO_TICK_SIZE_0015_US, 0 }
38 /*!
39 * \brief Declares the oscillator in use while in standby mode
41 * Using the STDBY_RC standby mode allow to reduce the energy consumption
42 * STDBY_XOSC should be used for time critical applications
44 typedef enum
46 SX1280_STDBY_RC = 0x00,
47 SX1280_STDBY_XOSC = 0x01,
48 } SX1280_RadioStandbyModes_t;
50 /*!
51 * \brief Declares the power regulation used to power the device
53 * This command allows the user to specify if DC-DC or LDO is used for power regulation.
54 * Using only LDO implies that the Rx or Tx current is doubled
56 typedef enum
58 SX1280_USE_LDO = 0x00, //! Use LDO (default value)
59 SX1280_USE_DCDC = 0x01, //! Use DCDC
60 } SX1280_RadioRegulatorModes_t;
62 /*!
63 * \brief Represents the possible packet type (i.e. modem) used
65 typedef enum
67 SX1280_PACKET_TYPE_GFSK = 0x00,
68 SX1280_PACKET_TYPE_LORA,
69 SX1280_PACKET_TYPE_RANGING,
70 SX1280_PACKET_TYPE_FLRC,
71 SX1280_PACKET_TYPE_BLE,
72 SX1280_PACKET_TYPE_NONE = 0x0F,
73 } SX1280_RadioPacketTypes_t;
75 //only for GFSK
76 // typedef enum
77 // {
78 // SX1280_PREAMBLE_LENGTH_04_BITS = 0x00, //!< Preamble length: 04 bits
79 // SX1280_PREAMBLE_LENGTH_08_BITS = 0x10, //!< Preamble length: 08 bits
80 // SX1280_PREAMBLE_LENGTH_12_BITS = 0x20, //!< Preamble length: 12 bits
81 // SX1280_PREAMBLE_LENGTH_16_BITS = 0x30, //!< Preamble length: 16 bits
82 // SX1280_PREAMBLE_LENGTH_20_BITS = 0x40, //!< Preamble length: 20 bits
83 // SX1280_PREAMBLE_LENGTH_24_BITS = 0x50, //!< Preamble length: 24 bits
84 // SX1280_PREAMBLE_LENGTH_28_BITS = 0x60, //!< Preamble length: 28 bits
85 // SX1280_PREAMBLE_LENGTH_32_BITS = 0x70, //!< Preamble length: 32 bits
86 // } SX1280_RadioPreambleLengths_t;
88 typedef enum
90 SX1280_LORA_IQ_NORMAL = 0x40,
91 SX1280_LORA_IQ_INVERTED = 0x00,
92 } SX1280_RadioLoRaIQModes_t;
94 typedef enum
96 SX1280_RADIO_CRC_OFF = 0x00, //!< No CRC in use
97 SX1280_RADIO_CRC_1_BYTES = 0x10,
98 SX1280_RADIO_CRC_2_BYTES = 0x20,
99 SX1280_RADIO_CRC_3_BYTES = 0x30,
100 } SX1280_RadioCrcTypes_t;
103 * \brief Represents the ramping time for power amplifier
105 typedef enum
107 SX1280_RADIO_RAMP_02_US = 0x00,
108 SX1280_RADIO_RAMP_04_US = 0x20,
109 SX1280_RADIO_RAMP_06_US = 0x40,
110 SX1280_RADIO_RAMP_08_US = 0x60,
111 SX1280_RADIO_RAMP_10_US = 0x80,
112 SX1280_RADIO_RAMP_12_US = 0xA0,
113 SX1280_RADIO_RAMP_16_US = 0xC0,
114 SX1280_RADIO_RAMP_20_US = 0xE0,
115 } SX1280_RadioRampTimes_t;
118 * \brief Represents the number of symbols to be used for channel activity detection operation
120 typedef enum
122 SX1280_LORA_CAD_01_SYMBOL = 0x00,
123 SX1280_LORA_CAD_02_SYMBOLS = 0x20,
124 SX1280_LORA_CAD_04_SYMBOLS = 0x40,
125 SX1280_LORA_CAD_08_SYMBOLS = 0x60,
126 SX1280_LORA_CAD_16_SYMBOLS = 0x80,
127 } SX1280_RadioLoRaCadSymbols_t;
130 * \brief Represents the possible spreading factor values in LORA packet types
132 typedef enum
134 SX1280_LORA_SF5 = 0x50,
135 SX1280_LORA_SF6 = 0x60,
136 SX1280_LORA_SF7 = 0x70,
137 SX1280_LORA_SF8 = 0x80,
138 SX1280_LORA_SF9 = 0x90,
139 SX1280_LORA_SF10 = 0xA0,
140 SX1280_LORA_SF11 = 0xB0,
141 SX1280_LORA_SF12 = 0xC0,
142 } SX1280_RadioLoRaSpreadingFactors_t;
145 * \brief Represents the bandwidth values for LORA packet type
147 typedef enum
149 SX1280_LORA_BW_0200 = 0x34,
150 SX1280_LORA_BW_0400 = 0x26,
151 SX1280_LORA_BW_0800 = 0x18,
152 SX1280_LORA_BW_1600 = 0x0A,
153 } SX1280_RadioLoRaBandwidths_t;
156 * \brief Represents the coding rate values for LORA packet type
158 typedef enum
160 SX1280_LORA_CR_4_5 = 0x01,
161 SX1280_LORA_CR_4_6 = 0x02,
162 SX1280_LORA_CR_4_7 = 0x03,
163 SX1280_LORA_CR_4_8 = 0x04,
164 SX1280_LORA_CR_LI_4_5 = 0x05,
165 SX1280_LORA_CR_LI_4_6 = 0x06,
166 SX1280_LORA_CR_LI_4_7 = 0x07,
167 } SX1280_RadioLoRaCodingRates_t;
169 typedef enum
171 SX1280_LORA_PACKET_VARIABLE_LENGTH = 0x00, //!< The packet is on variable size, header included
172 SX1280_LORA_PACKET_FIXED_LENGTH = 0x80, //!< The packet is known on both sides, no header included in the packet
173 SX1280_LORA_PACKET_EXPLICIT = SX1280_LORA_PACKET_VARIABLE_LENGTH,
174 SX1280_LORA_PACKET_IMPLICIT = SX1280_LORA_PACKET_FIXED_LENGTH,
175 } SX1280_RadioLoRaPacketLengthsModes_t;
177 typedef enum
179 SX1280_LORA_CRC_ON = 0x20, //!< CRC activated
180 SX1280_LORA_CRC_OFF = 0x00, //!< CRC not used
181 } SX1280_RadioLoRaCrcModes_t;
183 typedef enum RadioCommands_u
185 SX1280_RADIO_GET_STATUS = 0xC0,
186 SX1280_RADIO_WRITE_REGISTER = 0x18,
187 SX1280_RADIO_READ_REGISTER = 0x19,
188 SX1280_RADIO_WRITE_BUFFER = 0x1A,
189 SX1280_RADIO_READ_BUFFER = 0x1B,
190 SX1280_RADIO_SET_SLEEP = 0x84,
191 SX1280_RADIO_SET_STANDBY = 0x80,
192 SX1280_RADIO_SET_FS = 0xC1,
193 SX1280_RADIO_SET_TX = 0x83,
194 SX1280_RADIO_SET_RX = 0x82,
195 SX1280_RADIO_SET_RXDUTYCYCLE = 0x94,
196 SX1280_RADIO_SET_CAD = 0xC5,
197 SX1280_RADIO_SET_TXCONTINUOUSWAVE = 0xD1,
198 SX1280_RADIO_SET_TXCONTINUOUSPREAMBLE = 0xD2,
199 SX1280_RADIO_SET_PACKETTYPE = 0x8A,
200 SX1280_RADIO_GET_PACKETTYPE = 0x03,
201 SX1280_RADIO_SET_RFFREQUENCY = 0x86,
202 SX1280_RADIO_SET_TXPARAMS = 0x8E,
203 SX1280_RADIO_SET_CADPARAMS = 0x88,
204 SX1280_RADIO_SET_BUFFERBASEADDRESS = 0x8F,
205 SX1280_RADIO_SET_MODULATIONPARAMS = 0x8B,
206 SX1280_RADIO_SET_PACKETPARAMS = 0x8C,
207 SX1280_RADIO_GET_RXBUFFERSTATUS = 0x17,
208 SX1280_RADIO_GET_PACKETSTATUS = 0x1D,
209 SX1280_RADIO_GET_RSSIINST = 0x1F,
210 SX1280_RADIO_SET_DIOIRQPARAMS = 0x8D,
211 SX1280_RADIO_GET_IRQSTATUS = 0x15,
212 SX1280_RADIO_CLR_IRQSTATUS = 0x97,
213 SX1280_RADIO_CALIBRATE = 0x89,
214 SX1280_RADIO_SET_REGULATORMODE = 0x96,
215 SX1280_RADIO_SET_SAVECONTEXT = 0xD5,
216 SX1280_RADIO_SET_AUTOTX = 0x98,
217 SX1280_RADIO_SET_AUTOFS = 0x9E,
218 SX1280_RADIO_SET_LONGPREAMBLE = 0x9B,
219 SX1280_RADIO_SET_UARTSPEED = 0x9D,
220 SX1280_RADIO_SET_RANGING_ROLE = 0xA3,
221 } SX1280_RadioCommands_t;
223 typedef enum
225 SX1280_IRQ_RADIO_NONE = 0x0000,
226 SX1280_IRQ_TX_DONE = 0x0001,
227 SX1280_IRQ_RX_DONE = 0x0002,
228 SX1280_IRQ_SYNCWORD_VALID = 0x0004,
229 SX1280_IRQ_SYNCWORD_ERROR = 0x0008,
230 SX1280_IRQ_HEADER_VALID = 0x0010,
231 SX1280_IRQ_HEADER_ERROR = 0x0020,
232 SX1280_IRQ_CRC_ERROR = 0x0040,
233 SX1280_IRQ_RANGING_SLAVE_RESPONSE_DONE = 0x0080,
234 SX1280_IRQ_RANGING_SLAVE_REQUEST_DISCARDED = 0x0100,
235 SX1280_IRQ_RANGING_MASTER_RESULT_VALID = 0x0200,
236 SX1280_IRQ_RANGING_MASTER_TIMEOUT = 0x0400,
237 SX1280_IRQ_RANGING_SLAVE_REQUEST_VALID = 0x0800,
238 SX1280_IRQ_CAD_DONE = 0x1000,
239 SX1280_IRQ_CAD_DETECTED = 0x2000,
240 SX1280_IRQ_RX_TX_TIMEOUT = 0x4000,
241 SX1280_IRQ_PREAMBLE_DETECTED = 0x8000,
242 SX1280_IRQ_RADIO_ALL = 0xFFFF,
243 } SX1280_RadioIrqMasks_t;
245 typedef enum
247 SX1280_RADIO_DIO1 = 0x02,
248 SX1280_RADIO_DIO2 = 0x04,
249 SX1280_RADIO_DIO3 = 0x08,
250 } SX1280_RadioDios_t;
252 typedef enum
254 SX1280_RADIO_TICK_SIZE_0015_US = 0x00,
255 SX1280_RADIO_TICK_SIZE_0062_US = 0x01,
256 SX1280_RADIO_TICK_SIZE_1000_US = 0x02,
257 SX1280_RADIO_TICK_SIZE_4000_US = 0x03,
258 } SX1280_RadioTickSizes_t;