[SX128x] Update to 5.0.0

This commit is contained in:
jgromes 2021-11-14 11:42:36 +01:00
parent 8c7b8a1b63
commit 1126e64587
13 changed files with 706 additions and 704 deletions

View file

@ -38,7 +38,7 @@ void setup() {
// initialize SX1280 with default settings
Serial.print(F("[SX1280] Initializing ... "));
int state = radio.beginBLE();
if (state == ERR_NONE) {
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
@ -59,7 +59,7 @@ void setup() {
state = radio.setOutputPower(5);
state = radio.setDataShaping(1.0);
state = radio.setAccessAddress(0x12345678);
if (state != ERR_NONE) {
if (state != RADIOLIB_ERR_NONE) {
Serial.print(F("Unable to set configuration, code "));
Serial.println(state);
while (true);
@ -79,11 +79,11 @@ void loop() {
0x89, 0xAB, 0xCD, 0xEF};
int state = radio.transmit(byteArr, 8);
*/
if (state == ERR_NONE) {
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("[SX1280] Packet transmitted successfully!"));
} else if (state == ERR_PACKET_TOO_LONG) {
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
Serial.println(F("[SX1280] Packet too long!"));
} else if (state == ERR_TX_TIMEOUT) {
} else if (state == RADIOLIB_ERR_TX_TIMEOUT) {
Serial.println(F("[SX1280] Timed out while transmitting!"));
} else {
Serial.print(F("[SX1280] Failed to transmit packet, code "));
@ -97,11 +97,11 @@ void loop() {
byte byteArr[8];
int state = radio.receive(byteArr, 8);
*/
if (state == ERR_NONE) {
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("[SX1280] Received packet!"));
Serial.print(F("[SX1280] Data:\t"));
Serial.println(str);
} else if (state == ERR_RX_TIMEOUT) {
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
Serial.println(F("[SX1280] Timed out while waiting for packet!"));
} else {
Serial.print(F("[SX1280] Failed to receive packet, code "));

View file

@ -33,7 +33,7 @@ void setup() {
// initialize SX1280 with default settings
Serial.print(F("[SX1280] Initializing ... "));
int state = radio.begin();
if (state == ERR_NONE) {
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
@ -48,11 +48,11 @@ void loop() {
// start scanning current channel
int state = radio.scanChannel();
if (state == LORA_DETECTED) {
if (state == RADIOLIB_LORA_DETECTED) {
// LoRa preamble was detected
Serial.println(F("detected!"));
} else if (state == CHANNEL_FREE) {
} else if (state == RADIOLIB_CHANNEL_FREE) {
// no preamble was detected, channel is free
Serial.println(F("channel is free!"));

View file

@ -36,7 +36,7 @@ void setup() {
// initialize SX1280 with default settings
Serial.print(F("[SX1280] Initializing ... "));
int state = radio.beginFLRC();
if (state == ERR_NONE) {
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
@ -58,7 +58,7 @@ void setup() {
state = radio.setDataShaping(1.0);
uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67};
state = radio.setSyncWord(syncWord, 4);
if (state != ERR_NONE) {
if (state != RADIOLIB_ERR_NONE) {
Serial.print(F("Unable to set configuration, code "));
Serial.println(state);
while (true);
@ -78,11 +78,11 @@ void loop() {
0x89, 0xAB, 0xCD, 0xEF};
int state = radio.transmit(byteArr, 8);
*/
if (state == ERR_NONE) {
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("[SX1280] Packet transmitted successfully!"));
} else if (state == ERR_PACKET_TOO_LONG) {
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
Serial.println(F("[SX1280] Packet too long!"));
} else if (state == ERR_TX_TIMEOUT) {
} else if (state == RADIOLIB_ERR_TX_TIMEOUT) {
Serial.println(F("[SX1280] Timed out while transmitting!"));
} else {
Serial.println(F("[SX1280] Failed to transmit packet, code "));
@ -96,11 +96,11 @@ void loop() {
byte byteArr[8];
int state = radio.receive(byteArr, 8);
*/
if (state == ERR_NONE) {
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("[SX1280] Received packet!"));
Serial.print(F("[SX1280] Data:\t"));
Serial.println(str);
} else if (state == ERR_RX_TIMEOUT) {
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
Serial.println(F("[SX1280] Timed out while waiting for packet!"));
} else {
Serial.print(F("[SX1280] Failed to receive packet, code "));

View file

@ -36,7 +36,7 @@ void setup() {
// initialize SX1280 with default settings
Serial.print(F("[SX1280] Initializing ... "));
int state = radio.beginGFSK();
if (state == ERR_NONE) {
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
@ -58,7 +58,7 @@ void setup() {
state = radio.setDataShaping(RADIOLIB_SHAPING_1_0);
uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67, 0x89};
state = radio.setSyncWord(syncWord, 5);
if (state != ERR_NONE) {
if (state != RADIOLIB_ERR_NONE) {
Serial.print(F("Unable to set configuration, code "));
Serial.println(state);
while (true);
@ -78,11 +78,11 @@ void loop() {
0x89, 0xAB, 0xCD, 0xEF};
int state = radio.transmit(byteArr, 8);
*/
if (state == ERR_NONE) {
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("[SX1280] Packet transmitted successfully!"));
} else if (state == ERR_PACKET_TOO_LONG) {
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
Serial.println(F("[SX1280] Packet too long!"));
} else if (state == ERR_TX_TIMEOUT) {
} else if (state == RADIOLIB_ERR_TX_TIMEOUT) {
Serial.println(F("[SX1280] Timed out while transmitting!"));
} else {
Serial.println(F("[SX1280] Failed to transmit packet, code "));
@ -96,11 +96,11 @@ void loop() {
byte byteArr[8];
int state = radio.receive(byteArr, 8);
*/
if (state == ERR_NONE) {
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("[SX1280] Received packet!"));
Serial.print(F("[SX1280] Data:\t"));
Serial.println(str);
} else if (state == ERR_RX_TIMEOUT) {
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
Serial.println(F("[SX1280] Timed out while waiting for packet!"));
} else {
Serial.print(F("[SX1280] Failed to receive packet, code "));

View file

@ -35,7 +35,7 @@ void setup() {
// initialize SX1280 with default settings
Serial.print(F("[SX1280] Initializing ... "));
int state = radio.begin();
if (state == ERR_NONE) {
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
@ -57,14 +57,14 @@ void loop() {
int state = radio.range(false, 0x12345678);
*/
if (state == ERR_NONE) {
if (state == RADIOLIB_ERR_NONE) {
// ranging finished successfully
Serial.println(F("success!"));
Serial.print(F("[SX1280] Distance:\t\t\t"));
Serial.print(radio.getRangingResult());
Serial.println(F(" meters"));
} else if (state == ERR_RANGING_TIMEOUT) {
} else if (state == RADIOLIB_ERR_RANGING_TIMEOUT) {
// timed out waiting for ranging packet
Serial.println(F("timed out!"));

View file

@ -40,7 +40,7 @@ void setup() {
// initialize SX1280 with default settings
Serial.print(F("[SX1280] Initializing ... "));
int state = radio.begin();
if (state == ERR_NONE) {
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
@ -65,7 +65,7 @@ void loop() {
int state = radio.receive(byteArr, 8);
*/
if (state == ERR_NONE) {
if (state == RADIOLIB_ERR_NONE) {
// packet was successfully received
Serial.println(F("success!"));
@ -85,11 +85,11 @@ void loop() {
Serial.print(radio.getSNR());
Serial.println(F(" dB"));
} else if (state == ERR_RX_TIMEOUT) {
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
// timeout occurred while waiting for a packet
Serial.println(F("timeout!"));
} else if (state == ERR_CRC_MISMATCH) {
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
// packet was received, but is malformed
Serial.println(F("CRC error!"));

View file

@ -41,7 +41,7 @@ void setup() {
// initialize SX1280 with default settings
Serial.print(F("[SX1280] Initializing ... "));
int state = radio.begin();
if (state == ERR_NONE) {
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
@ -56,7 +56,7 @@ void setup() {
// start listening for LoRa packets
Serial.print(F("[SX1280] Starting to listen ... "));
state = radio.startReceive();
if (state == ERR_NONE) {
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
@ -115,7 +115,7 @@ void loop() {
int state = radio.readData(byteArr, 8);
*/
if (state == ERR_NONE) {
if (state == RADIOLIB_ERR_NONE) {
// packet was successfully received
Serial.println(F("[SX1280] Received packet!"));
@ -133,7 +133,7 @@ void loop() {
Serial.print(radio.getSNR());
Serial.println(F(" dB"));
} else if (state == ERR_CRC_MISMATCH) {
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
// packet was received, but is malformed
Serial.println(F("CRC error!"));

View file

@ -48,7 +48,7 @@ void setup() {
// initialize SX1280 with default settings
Serial.print(F("[SX1280] Initializing ... "));
int state = radio1.begin();
if (state == ERR_NONE) {
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
@ -68,7 +68,7 @@ void setup() {
// output power: 2 dBm
// preamble length: 20 symbols
state = radio2.begin(2450.0, 1625.0, 7, 5, 2, 20);
if (state == ERR_NONE) {
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
@ -80,43 +80,43 @@ void setup() {
// and check if the configuration was changed successfully
// set carrier frequency to 2410.5 MHz
if (radio1.setFrequency(2410.5) == ERR_INVALID_FREQUENCY) {
if (radio1.setFrequency(2410.5) == RADIOLIB_ERR_INVALID_FREQUENCY) {
Serial.println(F("Selected frequency is invalid for this module!"));
while (true);
}
// set bandwidth to 203.125 kHz
if (radio1.setBandwidth(203.125) == ERR_INVALID_BANDWIDTH) {
if (radio1.setBandwidth(203.125) == RADIOLIB_ERR_INVALID_BANDWIDTH) {
Serial.println(F("Selected bandwidth is invalid for this module!"));
while (true);
}
// set spreading factor to 10
if (radio1.setSpreadingFactor(10) == ERR_INVALID_SPREADING_FACTOR) {
if (radio1.setSpreadingFactor(10) == RADIOLIB_ERR_INVALID_SPREADING_FACTOR) {
Serial.println(F("Selected spreading factor is invalid for this module!"));
while (true);
}
// set coding rate to 6
if (radio1.setCodingRate(6) == ERR_INVALID_CODING_RATE) {
if (radio1.setCodingRate(6) == RADIOLIB_ERR_INVALID_CODING_RATE) {
Serial.println(F("Selected coding rate is invalid for this module!"));
while (true);
}
// set output power to -2 dBm
if (radio1.setOutputPower(-2) == ERR_INVALID_OUTPUT_POWER) {
if (radio1.setOutputPower(-2) == RADIOLIB_ERR_INVALID_OUTPUT_POWER) {
Serial.println(F("Selected output power is invalid for this module!"));
while (true);
}
// set LoRa preamble length to 16 symbols (accepted range is 2 - 65535)
if (radio1.setPreambleLength(16) == ERR_INVALID_PREAMBLE_LENGTH) {
if (radio1.setPreambleLength(16) == RADIOLIB_ERR_INVALID_PREAMBLE_LENGTH) {
Serial.println(F("Selected preamble length is invalid for this module!"));
while (true);
}
// disable CRC
if (radio1.setCRC(false) == ERR_INVALID_CRC_CONFIGURATION) {
if (radio1.setCRC(false) == RADIOLIB_ERR_INVALID_CRC_CONFIGURATION) {
Serial.println(F("Selected CRC is invalid for this module!"));
while (true);
}

View file

@ -43,7 +43,7 @@ void setup() {
// preamble length: 12 symbols
// CRC: enabled
int state = radio.begin();
if (state == ERR_NONE) {
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
@ -78,11 +78,11 @@ void loop() {
int state = radio.transmit(byteArr, 8);
*/
if (state == ERR_NONE) {
if (state == RADIOLIB_ERR_NONE) {
// the packet was successfully transmitted
Serial.println(F("success!"));
} else if (state == ERR_PACKET_TOO_LONG) {
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
// the supplied packet was longer than 256 bytes
Serial.println(F("too long!"));

View file

@ -32,7 +32,7 @@ SX1280 radio = new Module(10, 2, 3, 9);
//SX1280 radio = RadioShield.ModuleA;
// save transmission state between loops
int transmissionState = ERR_NONE;
int transmissionState = RADIOLIB_ERR_NONE;
void setup() {
Serial.begin(9600);
@ -40,7 +40,7 @@ void setup() {
// initialize SX1280 with default settings
Serial.print(F("[SX1280] Initializing ... "));
int state = radio.begin();
if (state == ERR_NONE) {
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
@ -97,7 +97,7 @@ void loop() {
// reset flag
transmittedFlag = false;
if (transmissionState == ERR_NONE) {
if (transmissionState == RADIOLIB_ERR_NONE) {
// packet was successfully sent
Serial.println(F("transmission finished!"));

View file

@ -11,13 +11,13 @@ int16_t SX1280::range(bool master, uint32_t addr) {
RADIOLIB_ASSERT(state);
// wait until ranging is finished
uint32_t start = Module::millis();
while(!Module::digitalRead(_mod->getIrq())) {
Module::yield();
if(Module::millis() - start > 10000) {
uint32_t start = _mod->millis();
while(!_mod->digitalRead(_mod->getIrq())) {
_mod->yield();
if(_mod->millis() - start > 10000) {
clearIrqStatus();
standby();
return(ERR_RANGING_TIMEOUT);
return(RADIOLIB_ERR_RANGING_TIMEOUT);
}
}
@ -34,8 +34,8 @@ int16_t SX1280::range(bool master, uint32_t addr) {
int16_t SX1280::startRanging(bool master, uint32_t addr) {
// check active modem
uint8_t modem = getPacketType();
if(!((modem == SX128X_PACKET_TYPE_LORA) || (modem == SX128X_PACKET_TYPE_RANGING))) {
return(ERR_WRONG_MODEM);
if(!((modem == RADIOLIB_SX128X_PACKET_TYPE_LORA) || (modem == RADIOLIB_SX128X_PACKET_TYPE_RANGING))) {
return(RADIOLIB_ERR_WRONG_MODEM);
}
// set mode to standby
@ -43,8 +43,8 @@ int16_t SX1280::startRanging(bool master, uint32_t addr) {
RADIOLIB_ASSERT(state);
// ensure modem is set to ranging
if(modem == SX128X_PACKET_TYPE_LORA) {
state = setPacketType(SX128X_PACKET_TYPE_RANGING);
if(modem == RADIOLIB_SX128X_PACKET_TYPE_LORA) {
state = setPacketType(RADIOLIB_SX128X_PACKET_TYPE_RANGING);
RADIOLIB_ASSERT(state);
}
@ -58,21 +58,21 @@ int16_t SX1280::startRanging(bool master, uint32_t addr) {
// check all address bits
uint8_t regValue;
state = readRegister(SX128X_REG_SLAVE_RANGING_ADDRESS_WIDTH, &regValue, 1);
state = readRegister(RADIOLIB_SX128X_REG_SLAVE_RANGING_ADDRESS_WIDTH, &regValue, 1);
RADIOLIB_ASSERT(state);
regValue &= 0b00111111;
regValue |= 0b11000000;
state = writeRegister(SX128X_REG_SLAVE_RANGING_ADDRESS_WIDTH, &regValue, 1);
state = writeRegister(RADIOLIB_SX128X_REG_SLAVE_RANGING_ADDRESS_WIDTH, &regValue, 1);
RADIOLIB_ASSERT(state);
// set remaining parameter values
uint32_t addrReg = SX128X_REG_SLAVE_RANGING_ADDRESS_BYTE_3;
uint32_t irqMask = SX128X_IRQ_RANGING_SLAVE_RESP_DONE | SX128X_IRQ_RANGING_SLAVE_REQ_DISCARD;
uint32_t irqDio1 = SX128X_IRQ_RANGING_SLAVE_RESP_DONE;
uint32_t addrReg = RADIOLIB_SX128X_REG_SLAVE_RANGING_ADDRESS_BYTE_3;
uint32_t irqMask = RADIOLIB_SX128X_IRQ_RANGING_SLAVE_RESP_DONE | RADIOLIB_SX128X_IRQ_RANGING_SLAVE_REQ_DISCARD;
uint32_t irqDio1 = RADIOLIB_SX128X_IRQ_RANGING_SLAVE_RESP_DONE;
if(master) {
addrReg = SX128X_REG_MASTER_RANGING_ADDRESS_BYTE_3;
irqMask = SX128X_IRQ_RANGING_MASTER_RES_VALID | SX128X_IRQ_RANGING_MASTER_TIMEOUT;
irqDio1 = SX128X_IRQ_RANGING_MASTER_RES_VALID;
addrReg = RADIOLIB_SX128X_REG_MASTER_RANGING_ADDRESS_BYTE_3;
irqMask = RADIOLIB_SX128X_IRQ_RANGING_MASTER_RES_VALID | RADIOLIB_SX128X_IRQ_RANGING_MASTER_TIMEOUT;
irqDio1 = RADIOLIB_SX128X_IRQ_RANGING_MASTER_RES_VALID;
}
// set ranging address
@ -93,35 +93,35 @@ int16_t SX1280::startRanging(bool master, uint32_t addr) {
};
uint16_t val = 0;
switch(_bw) {
case(SX128X_LORA_BW_406_25):
case(RADIOLIB_SX128X_LORA_BW_406_25):
val = calTable[0][index];
break;
case(SX128X_LORA_BW_812_50):
case(RADIOLIB_SX128X_LORA_BW_812_50):
val = calTable[1][index];
break;
case(SX128X_LORA_BW_1625_00):
case(RADIOLIB_SX128X_LORA_BW_1625_00):
val = calTable[2][index];
break;
default:
return(ERR_INVALID_BANDWIDTH);
return(RADIOLIB_ERR_INVALID_BANDWIDTH);
}
uint8_t calBuff[] = { (uint8_t)((val >> 8) & 0xFF), (uint8_t)(val & 0xFF) };
state = writeRegister(SX128X_REG_RANGING_CALIBRATION_MSB, calBuff, 2);
state = writeRegister(RADIOLIB_SX128X_REG_RANGING_CALIBRATION_MSB, calBuff, 2);
RADIOLIB_ASSERT(state);
// set role and start ranging
if(master) {
state = setRangingRole(SX128X_RANGING_ROLE_MASTER);
state = setRangingRole(RADIOLIB_SX128X_RANGING_ROLE_MASTER);
RADIOLIB_ASSERT(state);
state = setTx(SX128X_TX_TIMEOUT_NONE);
state = setTx(RADIOLIB_SX128X_TX_TIMEOUT_NONE);
RADIOLIB_ASSERT(state);
} else {
state = setRangingRole(SX128X_RANGING_ROLE_SLAVE);
state = setRangingRole(RADIOLIB_SX128X_RANGING_ROLE_SLAVE);
RADIOLIB_ASSERT(state);
state = setRx(SX128X_RX_TIMEOUT_INF);
state = setRx(RADIOLIB_SX128X_RX_TIMEOUT_INF);
RADIOLIB_ASSERT(state);
}
@ -131,33 +131,33 @@ int16_t SX1280::startRanging(bool master, uint32_t addr) {
float SX1280::getRangingResult() {
// set mode to standby XOSC
int16_t state = standby(SX128X_STANDBY_XOSC);
int16_t state = standby(RADIOLIB_SX128X_STANDBY_XOSC);
RADIOLIB_ASSERT(state);
// enable clock
uint8_t data[4];
state = readRegister(SX128X_REG_RANGING_LORA_CLOCK_ENABLE, data, 1);
state = readRegister(RADIOLIB_SX128X_REG_RANGING_LORA_CLOCK_ENABLE, data, 1);
RADIOLIB_ASSERT(state);
data[0] |= (1 << 1);
state = writeRegister(SX128X_REG_RANGING_LORA_CLOCK_ENABLE, data, 1);
state = writeRegister(RADIOLIB_SX128X_REG_RANGING_LORA_CLOCK_ENABLE, data, 1);
RADIOLIB_ASSERT(state);
// set result type to filtered
state = readRegister(SX128X_REG_RANGING_TYPE, data, 1);
state = readRegister(RADIOLIB_SX128X_REG_RANGING_TYPE, data, 1);
RADIOLIB_ASSERT(state);
data[0] &= 0xCF;
data[0] |= (1 << 4);
state = writeRegister(SX128X_REG_RANGING_TYPE, data, 1);
state = writeRegister(RADIOLIB_SX128X_REG_RANGING_TYPE, data, 1);
RADIOLIB_ASSERT(state);
// read the register values
state = readRegister(SX128X_REG_RANGING_RESULT_MSB, &data[0], 1);
state = readRegister(RADIOLIB_SX128X_REG_RANGING_RESULT_MSB, &data[0], 1);
RADIOLIB_ASSERT(state);
state = readRegister(SX128X_REG_RANGING_RESULT_MID, &data[1], 1);
state = readRegister(RADIOLIB_SX128X_REG_RANGING_RESULT_MID, &data[1], 1);
RADIOLIB_ASSERT(state);
state = readRegister(SX128X_REG_RANGING_RESULT_LSB, &data[2], 1);
state = readRegister(RADIOLIB_SX128X_REG_RANGING_RESULT_LSB, &data[2], 1);
RADIOLIB_ASSERT(state);
// set mode to standby RC

File diff suppressed because it is too large Load diff

View file

@ -10,336 +10,336 @@
#include "../../protocols/PhysicalLayer/PhysicalLayer.h"
// SX128X physical layer properties
#define SX128X_FREQUENCY_STEP_SIZE 198.3642578
#define SX128X_MAX_PACKET_LENGTH 255
#define SX128X_CRYSTAL_FREQ 52.0
#define SX128X_DIV_EXPONENT 18
#define RADIOLIB_SX128X_FREQUENCY_STEP_SIZE 198.3642578
#define RADIOLIB_SX128X_MAX_PACKET_LENGTH 255
#define RADIOLIB_SX128X_CRYSTAL_FREQ 52.0
#define RADIOLIB_SX128X_DIV_EXPONENT 18
// SX128X SPI commands
#define SX128X_CMD_NOP 0x00
#define SX128X_CMD_GET_STATUS 0xC0
#define SX128X_CMD_WRITE_REGISTER 0x18
#define SX128X_CMD_READ_REGISTER 0x19
#define SX128X_CMD_WRITE_BUFFER 0x1A
#define SX128X_CMD_READ_BUFFER 0x1B
#define SX128X_CMD_SET_SLEEP 0x84
#define SX128X_CMD_SET_STANDBY 0x80
#define SX128X_CMD_SET_FS 0xC1
#define SX128X_CMD_SET_TX 0x83
#define SX128X_CMD_SET_RX 0x82
#define SX128X_CMD_SET_RX_DUTY_CYCLE 0x94
#define SX128X_CMD_SET_CAD 0xC5
#define SX128X_CMD_SET_TX_CONTINUOUS_WAVE 0xD1
#define SX128X_CMD_SET_TX_CONTINUOUS_PREAMBLE 0xD2
#define SX128X_CMD_SET_PACKET_TYPE 0x8A
#define SX128X_CMD_GET_PACKET_TYPE 0x03
#define SX128X_CMD_SET_RF_FREQUENCY 0x86
#define SX128X_CMD_SET_TX_PARAMS 0x8E
#define SX128X_CMD_SET_CAD_PARAMS 0x88
#define SX128X_CMD_SET_BUFFER_BASE_ADDRESS 0x8F
#define SX128X_CMD_SET_MODULATION_PARAMS 0x8B
#define SX128X_CMD_SET_PACKET_PARAMS 0x8C
#define SX128X_CMD_GET_RX_BUFFER_STATUS 0x17
#define SX128X_CMD_GET_PACKET_STATUS 0x1D
#define SX128X_CMD_GET_RSSI_INST 0x1F
#define SX128X_CMD_SET_DIO_IRQ_PARAMS 0x8D
#define SX128X_CMD_GET_IRQ_STATUS 0x15
#define SX128X_CMD_CLEAR_IRQ_STATUS 0x97
#define SX128X_CMD_SET_REGULATOR_MODE 0x96
#define SX128X_CMD_SET_SAVE_CONTEXT 0xD5
#define SX128X_CMD_SET_AUTO_TX 0x98
#define SX128X_CMD_SET_AUTO_FS 0x9E
#define SX128X_CMD_SET_PERF_COUNTER_MODE 0x9C
#define SX128X_CMD_SET_LONG_PREAMBLE 0x9B
#define SX128X_CMD_SET_UART_SPEED 0x9D
#define SX128X_CMD_SET_RANGING_ROLE 0xA3
#define SX128X_CMD_SET_ADVANCED_RANGING 0x9A
#define RADIOLIB_SX128X_CMD_NOP 0x00
#define RADIOLIB_SX128X_CMD_GET_STATUS 0xC0
#define RADIOLIB_SX128X_CMD_WRITE_REGISTER 0x18
#define RADIOLIB_SX128X_CMD_READ_REGISTER 0x19
#define RADIOLIB_SX128X_CMD_WRITE_BUFFER 0x1A
#define RADIOLIB_SX128X_CMD_READ_BUFFER 0x1B
#define RADIOLIB_SX128X_CMD_SET_SLEEP 0x84
#define RADIOLIB_SX128X_CMD_SET_STANDBY 0x80
#define RADIOLIB_SX128X_CMD_SET_FS 0xC1
#define RADIOLIB_SX128X_CMD_SET_TX 0x83
#define RADIOLIB_SX128X_CMD_SET_RX 0x82
#define RADIOLIB_SX128X_CMD_SET_RX_DUTY_CYCLE 0x94
#define RADIOLIB_SX128X_CMD_SET_CAD 0xC5
#define RADIOLIB_SX128X_CMD_SET_TX_CONTINUOUS_WAVE 0xD1
#define RADIOLIB_SX128X_CMD_SET_TX_CONTINUOUS_PREAMBLE 0xD2
#define RADIOLIB_SX128X_CMD_SET_PACKET_TYPE 0x8A
#define RADIOLIB_SX128X_CMD_GET_PACKET_TYPE 0x03
#define RADIOLIB_SX128X_CMD_SET_RF_FREQUENCY 0x86
#define RADIOLIB_SX128X_CMD_SET_TX_PARAMS 0x8E
#define RADIOLIB_SX128X_CMD_SET_CAD_PARAMS 0x88
#define RADIOLIB_SX128X_CMD_SET_BUFFER_BASE_ADDRESS 0x8F
#define RADIOLIB_SX128X_CMD_SET_MODULATION_PARAMS 0x8B
#define RADIOLIB_SX128X_CMD_SET_PACKET_PARAMS 0x8C
#define RADIOLIB_SX128X_CMD_GET_RX_BUFFER_STATUS 0x17
#define RADIOLIB_SX128X_CMD_GET_PACKET_STATUS 0x1D
#define RADIOLIB_SX128X_CMD_GET_RSSI_INST 0x1F
#define RADIOLIB_SX128X_CMD_SET_DIO_IRQ_PARAMS 0x8D
#define RADIOLIB_SX128X_CMD_GET_IRQ_STATUS 0x15
#define RADIOLIB_SX128X_CMD_CLEAR_IRQ_STATUS 0x97
#define RADIOLIB_SX128X_CMD_SET_REGULATOR_MODE 0x96
#define RADIOLIB_SX128X_CMD_SET_SAVE_CONTEXT 0xD5
#define RADIOLIB_SX128X_CMD_SET_AUTO_TX 0x98
#define RADIOLIB_SX128X_CMD_SET_AUTO_FS 0x9E
#define RADIOLIB_SX128X_CMD_SET_PERF_COUNTER_MODE 0x9C
#define RADIOLIB_SX128X_CMD_SET_LONG_PREAMBLE 0x9B
#define RADIOLIB_SX128X_CMD_SET_UART_SPEED 0x9D
#define RADIOLIB_SX128X_CMD_SET_RANGING_ROLE 0xA3
#define RADIOLIB_SX128X_CMD_SET_ADVANCED_RANGING 0x9A
// SX128X register map
#define SX128X_REG_GAIN_MODE 0x0891
#define SX128X_REG_MANUAL_GAIN_CONTROL_ENABLE_2 0x0895
#define SX128X_REG_MANUAL_GAIN_SETTING 0x089E
#define SX128X_REG_MANUAL_GAIN_CONTROL_ENABLE_1 0x089F
#define SX128X_REG_SYNCH_PEAK_ATTENUATION 0x08C2
#define SX128X_REG_LORA_FIXED_PAYLOAD_LENGTH 0x0901
#define SX128X_REG_LORA_HEADER_MODE 0x0903
#define SX128X_REG_MASTER_RANGING_ADDRESS_BYTE_3 0x0912
#define SX128X_REG_MASTER_RANGING_ADDRESS_BYTE_2 0x0913
#define SX128X_REG_MASTER_RANGING_ADDRESS_BYTE_1 0x0914
#define SX128X_REG_MASTER_RANGING_ADDRESS_BYTE_0 0x0915
#define SX128X_REG_SLAVE_RANGING_ADDRESS_BYTE_3 0x0916
#define SX128X_REG_SLAVE_RANGING_ADDRESS_BYTE_2 0x0917
#define SX128X_REG_SLAVE_RANGING_ADDRESS_BYTE_1 0x0918
#define SX128X_REG_SLAVE_RANGING_ADDRESS_BYTE_0 0x0919
#define SX128X_REG_RANGING_FILTER_WINDOW_SIZE 0x091E
#define SX128X_REG_RANGING_FILTER_RESET 0x0923
#define SX128X_REG_RANGING_TYPE 0x0924
#define SX128X_REG_LORA_SF_CONFIG 0x0925
#define SX128X_REG_RANGING_ADDRESS_SWITCH 0x0927
#define SX128X_REG_RANGING_CALIBRATION_BYTE_2 0x092B
#define SX128X_REG_RANGING_CALIBRATION_MSB 0x092C
#define SX128X_REG_RANGING_CALIBRATION_LSB 0x092D
#define SX128X_REG_SLAVE_RANGING_ADDRESS_WIDTH 0x0931
#define SX128X_REG_FREQ_ERROR_CORRECTION 0x093C
#define SX128X_REG_LORA_SYNC_WORD_MSB 0x0944
#define SX128X_REG_LORA_SYNC_WORD_LSB 0x0945
#define SX128X_REG_RANGING_FILTER_RSSI_OFFSET 0x0953
#define SX128X_REG_FEI_MSB 0x0954
#define SX128X_REG_FEI_MID 0x0955
#define SX128X_REG_FEI_LSB 0x0956
#define SX128X_REG_RANGING_ADDRESS_MSB 0x095F
#define SX128X_REG_RANGING_ADDRESS_LSB 0x0960
#define SX128X_REG_RANGING_RESULT_MSB 0x0961
#define SX128X_REG_RANGING_RESULT_MID 0x0962
#define SX128X_REG_RANGING_RESULT_LSB 0x0963
#define SX128X_REG_RANGING_RSSI 0x0964
#define SX128X_REG_RANGING_LORA_CLOCK_ENABLE 0x097F
#define SX128X_REG_PACKET_PREAMBLE_SETTINGS 0x09C1
#define SX128X_REG_WHITENING_INITIAL_VALUE 0x09C5
#define SX128X_REG_CRC_POLYNOMIAL_MSB 0x09C6
#define SX128X_REG_CRC_POLYNOMIAL_LSB 0x09C7
#define SX128X_REG_CRC_INITIAL_MSB 0x09C8
#define SX128X_REG_CRC_INITIAL_LSB 0x09C9
#define SX128X_REG_BLE_CRC_INITIAL_MSB 0x09C7
#define SX128X_REG_BLE_CRC_INITIAL_MID (SX128X_REG_CRC_INITIAL_MSB)
#define SX128X_REG_BLE_CRC_INITIAL_LSB (SX128X_REG_CRC_INITIAL_LSB)
#define SX128X_REG_SYNCH_ADDRESS_CONTROL 0x09CD
#define SX128X_REG_SYNC_WORD_1_BYTE_4 0x09CE
#define SX128X_REG_SYNC_WORD_1_BYTE_3 0x09CF
#define SX128X_REG_SYNC_WORD_1_BYTE_2 0x09D0
#define SX128X_REG_SYNC_WORD_1_BYTE_1 0x09D1
#define SX128X_REG_SYNC_WORD_1_BYTE_0 0x09D2
#define SX128X_REG_SYNC_WORD_2_BYTE_4 0x09D3
#define SX128X_REG_SYNC_WORD_2_BYTE_3 0x09D4
#define SX128X_REG_SYNC_WORD_2_BYTE_2 0x09D5
#define SX128X_REG_SYNC_WORD_2_BYTE_1 0x09D6
#define SX128X_REG_SYNC_WORD_2_BYTE_0 0x09D7
#define SX128X_REG_SYNC_WORD_3_BYTE_4 0x09D8
#define SX128X_REG_SYNC_WORD_3_BYTE_3 0x09D9
#define SX128X_REG_SYNC_WORD_3_BYTE_2 0x09DA
#define SX128X_REG_SYNC_WORD_3_BYTE_1 0x09DB
#define SX128X_REG_SYNC_WORD_3_BYTE_0 0x09DC
#define SX128X_REG_ACCESS_ADDRESS_BYTE_3 (SX128X_REG_SYNC_WORD_1_BYTE_3)
#define SX128X_REG_ACCESS_ADDRESS_BYTE_2 (SX128X_REG_SYNC_WORD_1_BYTE_2)
#define SX128X_REG_ACCESS_ADDRESS_BYTE_1 (SX128X_REG_SYNC_WORD_1_BYTE_1)
#define SX128X_REG_ACCESS_ADDRESS_BYTE_0 (SX128X_REG_SYNC_WORD_1_BYTE_0)
#define RADIOLIB_SX128X_REG_GAIN_MODE 0x0891
#define RADIOLIB_SX128X_REG_MANUAL_GAIN_CONTROL_ENABLE_2 0x0895
#define RADIOLIB_SX128X_REG_MANUAL_GAIN_SETTING 0x089E
#define RADIOLIB_SX128X_REG_MANUAL_GAIN_CONTROL_ENABLE_1 0x089F
#define RADIOLIB_SX128X_REG_SYNCH_PEAK_ATTENUATION 0x08C2
#define RADIOLIB_SX128X_REG_LORA_FIXED_PAYLOAD_LENGTH 0x0901
#define RADIOLIB_SX128X_REG_LORA_HEADER_MODE 0x0903
#define RADIOLIB_SX128X_REG_MASTER_RANGING_ADDRESS_BYTE_3 0x0912
#define RADIOLIB_SX128X_REG_MASTER_RANGING_ADDRESS_BYTE_2 0x0913
#define RADIOLIB_SX128X_REG_MASTER_RANGING_ADDRESS_BYTE_1 0x0914
#define RADIOLIB_SX128X_REG_MASTER_RANGING_ADDRESS_BYTE_0 0x0915
#define RADIOLIB_SX128X_REG_SLAVE_RANGING_ADDRESS_BYTE_3 0x0916
#define RADIOLIB_SX128X_REG_SLAVE_RANGING_ADDRESS_BYTE_2 0x0917
#define RADIOLIB_SX128X_REG_SLAVE_RANGING_ADDRESS_BYTE_1 0x0918
#define RADIOLIB_SX128X_REG_SLAVE_RANGING_ADDRESS_BYTE_0 0x0919
#define RADIOLIB_SX128X_REG_RANGING_FILTER_WINDOW_SIZE 0x091E
#define RADIOLIB_SX128X_REG_RANGING_FILTER_RESET 0x0923
#define RADIOLIB_SX128X_REG_RANGING_TYPE 0x0924
#define RADIOLIB_SX128X_REG_LORA_SF_CONFIG 0x0925
#define RADIOLIB_SX128X_REG_RANGING_ADDRESS_SWITCH 0x0927
#define RADIOLIB_SX128X_REG_RANGING_CALIBRATION_BYTE_2 0x092B
#define RADIOLIB_SX128X_REG_RANGING_CALIBRATION_MSB 0x092C
#define RADIOLIB_SX128X_REG_RANGING_CALIBRATION_LSB 0x092D
#define RADIOLIB_SX128X_REG_SLAVE_RANGING_ADDRESS_WIDTH 0x0931
#define RADIOLIB_SX128X_REG_FREQ_ERROR_CORRECTION 0x093C
#define RADIOLIB_SX128X_REG_LORA_SYNC_WORD_MSB 0x0944
#define RADIOLIB_SX128X_REG_LORA_SYNC_WORD_LSB 0x0945
#define RADIOLIB_SX128X_REG_RANGING_FILTER_RSSI_OFFSET 0x0953
#define RADIOLIB_SX128X_REG_FEI_MSB 0x0954
#define RADIOLIB_SX128X_REG_FEI_MID 0x0955
#define RADIOLIB_SX128X_REG_FEI_LSB 0x0956
#define RADIOLIB_SX128X_REG_RANGING_ADDRESS_MSB 0x095F
#define RADIOLIB_SX128X_REG_RANGING_ADDRESS_LSB 0x0960
#define RADIOLIB_SX128X_REG_RANGING_RESULT_MSB 0x0961
#define RADIOLIB_SX128X_REG_RANGING_RESULT_MID 0x0962
#define RADIOLIB_SX128X_REG_RANGING_RESULT_LSB 0x0963
#define RADIOLIB_SX128X_REG_RANGING_RSSI 0x0964
#define RADIOLIB_SX128X_REG_RANGING_LORA_CLOCK_ENABLE 0x097F
#define RADIOLIB_SX128X_REG_PACKET_PREAMBLE_SETTINGS 0x09C1
#define RADIOLIB_SX128X_REG_WHITENING_INITIAL_VALUE 0x09C5
#define RADIOLIB_SX128X_REG_CRC_POLYNOMIAL_MSB 0x09C6
#define RADIOLIB_SX128X_REG_CRC_POLYNOMIAL_LSB 0x09C7
#define RADIOLIB_SX128X_REG_CRC_INITIAL_MSB 0x09C8
#define RADIOLIB_SX128X_REG_CRC_INITIAL_LSB 0x09C9
#define RADIOLIB_SX128X_REG_BLE_CRC_INITIAL_MSB 0x09C7
#define RADIOLIB_SX128X_REG_BLE_CRC_INITIAL_MID (RADIOLIB_SX128X_REG_CRC_INITIAL_MSB)
#define RADIOLIB_SX128X_REG_BLE_CRC_INITIAL_LSB (RADIOLIB_SX128X_REG_CRC_INITIAL_LSB)
#define RADIOLIB_SX128X_REG_SYNCH_ADDRESS_CONTROL 0x09CD
#define RADIOLIB_SX128X_REG_SYNC_WORD_1_BYTE_4 0x09CE
#define RADIOLIB_SX128X_REG_SYNC_WORD_1_BYTE_3 0x09CF
#define RADIOLIB_SX128X_REG_SYNC_WORD_1_BYTE_2 0x09D0
#define RADIOLIB_SX128X_REG_SYNC_WORD_1_BYTE_1 0x09D1
#define RADIOLIB_SX128X_REG_SYNC_WORD_1_BYTE_0 0x09D2
#define RADIOLIB_SX128X_REG_SYNC_WORD_2_BYTE_4 0x09D3
#define RADIOLIB_SX128X_REG_SYNC_WORD_2_BYTE_3 0x09D4
#define RADIOLIB_SX128X_REG_SYNC_WORD_2_BYTE_2 0x09D5
#define RADIOLIB_SX128X_REG_SYNC_WORD_2_BYTE_1 0x09D6
#define RADIOLIB_SX128X_REG_SYNC_WORD_2_BYTE_0 0x09D7
#define RADIOLIB_SX128X_REG_SYNC_WORD_3_BYTE_4 0x09D8
#define RADIOLIB_SX128X_REG_SYNC_WORD_3_BYTE_3 0x09D9
#define RADIOLIB_SX128X_REG_SYNC_WORD_3_BYTE_2 0x09DA
#define RADIOLIB_SX128X_REG_SYNC_WORD_3_BYTE_1 0x09DB
#define RADIOLIB_SX128X_REG_SYNC_WORD_3_BYTE_0 0x09DC
#define RADIOLIB_SX128X_REG_ACCESS_ADDRESS_BYTE_3 (RADIOLIB_SX128X_REG_SYNC_WORD_1_BYTE_3)
#define RADIOLIB_SX128X_REG_ACCESS_ADDRESS_BYTE_2 (RADIOLIB_SX128X_REG_SYNC_WORD_1_BYTE_2)
#define RADIOLIB_SX128X_REG_ACCESS_ADDRESS_BYTE_1 (RADIOLIB_SX128X_REG_SYNC_WORD_1_BYTE_1)
#define RADIOLIB_SX128X_REG_ACCESS_ADDRESS_BYTE_0 (RADIOLIB_SX128X_REG_SYNC_WORD_1_BYTE_0)
// SX128X SPI command variables
//SX128X_CMD_GET_STATUS MSB LSB DESCRIPTION
#define SX128X_STATUS_MODE_STDBY_RC 0b01000000 // 7 5 current chip mode: STDBY_RC
#define SX128X_STATUS_MODE_STDBY_XOSC 0b01100000 // 7 5 STDBY_XOSC
#define SX128X_STATUS_MODE_FS 0b10000000 // 7 5 FS
#define SX128X_STATUS_MODE_RX 0b10100000 // 7 5 Rx
#define SX128X_STATUS_MODE_TX 0b11000000 // 7 5 Tx
#define SX128X_STATUS_CMD_PROCESSED 0b00000100 // 4 2 command status: processing OK
#define SX128X_STATUS_DATA_AVAILABLE 0b00001000 // 4 2 data available
#define SX128X_STATUS_CMD_TIMEOUT 0b00001100 // 4 2 timeout
#define SX128X_STATUS_CMD_ERROR 0b00010000 // 4 2 processing error
#define SX128X_STATUS_CMD_FAILED 0b00010100 // 4 2 failed to execute
#define SX128X_STATUS_TX_DONE 0b00011000 // 4 2 transmission finished
#define SX128X_STATUS_BUSY 0b00000001 // 0 0 chip busy
#define SX128X_STATUS_SPI_FAILED 0b11111111 // 7 0 SPI transaction failed
//RADIOLIB_SX128X_CMD_GET_STATUS MSB LSB DESCRIPTION
#define RADIOLIB_SX128X_STATUS_MODE_STDBY_RC 0b01000000 // 7 5 current chip mode: STDBY_RC
#define RADIOLIB_SX128X_STATUS_MODE_STDBY_XOSC 0b01100000 // 7 5 STDBY_XOSC
#define RADIOLIB_SX128X_STATUS_MODE_FS 0b10000000 // 7 5 FS
#define RADIOLIB_SX128X_STATUS_MODE_RX 0b10100000 // 7 5 Rx
#define RADIOLIB_SX128X_STATUS_MODE_TX 0b11000000 // 7 5 Tx
#define RADIOLIB_SX128X_STATUS_CMD_PROCESSED 0b00000100 // 4 2 command status: processing OK
#define RADIOLIB_SX128X_STATUS_DATA_AVAILABLE 0b00001000 // 4 2 data available
#define RADIOLIB_SX128X_STATUS_CMD_TIMEOUT 0b00001100 // 4 2 timeout
#define RADIOLIB_SX128X_STATUS_CMD_ERROR 0b00010000 // 4 2 processing error
#define RADIOLIB_SX128X_STATUS_CMD_FAILED 0b00010100 // 4 2 failed to execute
#define RADIOLIB_SX128X_STATUS_TX_DONE 0b00011000 // 4 2 transmission finished
#define RADIOLIB_SX128X_STATUS_BUSY 0b00000001 // 0 0 chip busy
#define RADIOLIB_SX128X_STATUS_SPI_FAILED 0b11111111 // 7 0 SPI transaction failed
//SX128X_CMD_SET_SLEEP
#define SX128X_SLEEP_DATA_BUFFER_FLUSH 0b00000000 // 1 1 data buffer behavior in sleep mode: flush
#define SX128X_SLEEP_DATA_BUFFER_RETAIN 0b00000010 // 1 1 retain
#define SX128X_SLEEP_DATA_RAM_FLUSH 0b00000000 // 0 0 data RAM (configuration) behavior in sleep mode: flush
#define SX128X_SLEEP_DATA_RAM_RETAIN 0b00000001 // 0 0 retain
//RADIOLIB_SX128X_CMD_SET_SLEEP
#define RADIOLIB_SX128X_SLEEP_DATA_BUFFER_FLUSH 0b00000000 // 1 1 data buffer behavior in sleep mode: flush
#define RADIOLIB_SX128X_SLEEP_DATA_BUFFER_RETAIN 0b00000010 // 1 1 retain
#define RADIOLIB_SX128X_SLEEP_DATA_RAM_FLUSH 0b00000000 // 0 0 data RAM (configuration) behavior in sleep mode: flush
#define RADIOLIB_SX128X_SLEEP_DATA_RAM_RETAIN 0b00000001 // 0 0 retain
//SX128X_CMD_SET_STANDBY
#define SX128X_STANDBY_RC 0x00 // 7 0 standby mode: 13 MHz RC oscillator
#define SX128X_STANDBY_XOSC 0x01 // 7 0 52 MHz crystal oscillator
//RADIOLIB_SX128X_CMD_SET_STANDBY
#define RADIOLIB_SX128X_STANDBY_RC 0x00 // 7 0 standby mode: 13 MHz RC oscillator
#define RADIOLIB_SX128X_STANDBY_XOSC 0x01 // 7 0 52 MHz crystal oscillator
//SX128X_CMD_SET_TX + SX128X_CMD_SET_RX + SX128X_CMD_SET_RX_DUTY_CYCLE
#define SX128X_PERIOD_BASE_15_625_US 0x00 // 7 0 time period step: 15.625 us
#define SX128X_PERIOD_BASE_62_5_US 0x01 // 7 0 62.5 us
#define SX128X_PERIOD_BASE_1_MS 0x02 // 7 0 1 ms
#define SX128X_PERIOD_BASE_4_MS 0x03 // 7 0 4 ms
//RADIOLIB_SX128X_CMD_SET_TX + RADIOLIB_SX128X_CMD_SET_RX + RADIOLIB_SX128X_CMD_SET_RX_DUTY_CYCLE
#define RADIOLIB_SX128X_PERIOD_BASE_15_625_US 0x00 // 7 0 time period step: 15.625 us
#define RADIOLIB_SX128X_PERIOD_BASE_62_5_US 0x01 // 7 0 62.5 us
#define RADIOLIB_SX128X_PERIOD_BASE_1_MS 0x02 // 7 0 1 ms
#define RADIOLIB_SX128X_PERIOD_BASE_4_MS 0x03 // 7 0 4 ms
//SX128X_CMD_SET_TX
#define SX128X_TX_TIMEOUT_NONE 0x0000 // 15 0 Tx timeout duration: no timeout (Tx single mode)
//RADIOLIB_SX128X_CMD_SET_TX
#define RADIOLIB_SX128X_TX_TIMEOUT_NONE 0x0000 // 15 0 Tx timeout duration: no timeout (Tx single mode)
//SX128X_CMD_SET_RX
#define SX128X_RX_TIMEOUT_NONE 0x0000 // 15 0 Rx timeout duration: no timeout (Rx single mode)
#define SX128X_RX_TIMEOUT_INF 0xFFFF // 15 0 infinite (Rx continuous mode)
//RADIOLIB_SX128X_CMD_SET_RX
#define RADIOLIB_SX128X_RX_TIMEOUT_NONE 0x0000 // 15 0 Rx timeout duration: no timeout (Rx single mode)
#define RADIOLIB_SX128X_RX_TIMEOUT_INF 0xFFFF // 15 0 infinite (Rx continuous mode)
//SX128X_CMD_SET_PACKET_TYPE
#define SX128X_PACKET_TYPE_GFSK 0x00 // 7 0 packet type: (G)FSK
#define SX128X_PACKET_TYPE_LORA 0x01 // 7 0 LoRa
#define SX128X_PACKET_TYPE_RANGING 0x02 // 7 0 ranging engine
#define SX128X_PACKET_TYPE_FLRC 0x03 // 7 0 FLRC
#define SX128X_PACKET_TYPE_BLE 0x04 // 7 0 BLE
//RADIOLIB_SX128X_CMD_SET_PACKET_TYPE
#define RADIOLIB_SX128X_PACKET_TYPE_GFSK 0x00 // 7 0 packet type: (G)FSK
#define RADIOLIB_SX128X_PACKET_TYPE_LORA 0x01 // 7 0 LoRa
#define RADIOLIB_SX128X_PACKET_TYPE_RANGING 0x02 // 7 0 ranging engine
#define RADIOLIB_SX128X_PACKET_TYPE_FLRC 0x03 // 7 0 FLRC
#define RADIOLIB_SX128X_PACKET_TYPE_BLE 0x04 // 7 0 BLE
//SX128X_CMD_SET_TX_PARAMS
#define SX128X_PA_RAMP_02_US 0x00 // 7 0 PA ramp time: 2 us
#define SX128X_PA_RAMP_04_US 0x20 // 7 0 4 us
#define SX128X_PA_RAMP_06_US 0x40 // 7 0 6 us
#define SX128X_PA_RAMP_08_US 0x60 // 7 0 8 us
#define SX128X_PA_RAMP_10_US 0x80 // 7 0 10 us
#define SX128X_PA_RAMP_12_US 0xA0 // 7 0 12 us
#define SX128X_PA_RAMP_16_US 0xC0 // 7 0 16 us
#define SX128X_PA_RAMP_20_US 0xE0 // 7 0 20 us
//RADIOLIB_SX128X_CMD_SET_TX_PARAMS
#define RADIOLIB_SX128X_PA_RAMP_02_US 0x00 // 7 0 PA ramp time: 2 us
#define RADIOLIB_SX128X_PA_RAMP_04_US 0x20 // 7 0 4 us
#define RADIOLIB_SX128X_PA_RAMP_06_US 0x40 // 7 0 6 us
#define RADIOLIB_SX128X_PA_RAMP_08_US 0x60 // 7 0 8 us
#define RADIOLIB_SX128X_PA_RAMP_10_US 0x80 // 7 0 10 us
#define RADIOLIB_SX128X_PA_RAMP_12_US 0xA0 // 7 0 12 us
#define RADIOLIB_SX128X_PA_RAMP_16_US 0xC0 // 7 0 16 us
#define RADIOLIB_SX128X_PA_RAMP_20_US 0xE0 // 7 0 20 us
//SX128X_CMD_SET_CAD_PARAMS
#define SX128X_CAD_ON_1_SYMB 0x00 // 7 0 number of symbols used for CAD: 1
#define SX128X_CAD_ON_2_SYMB 0x20 // 7 0 2
#define SX128X_CAD_ON_4_SYMB 0x40 // 7 0 4
#define SX128X_CAD_ON_8_SYMB 0x60 // 7 0 8
#define SX128X_CAD_ON_16_SYMB 0x80 // 7 0 16
//RADIOLIB_SX128X_CMD_SET_CAD_PARAMS
#define RADIOLIB_SX128X_CAD_ON_1_SYMB 0x00 // 7 0 number of symbols used for CAD: 1
#define RADIOLIB_SX128X_CAD_ON_2_SYMB 0x20 // 7 0 2
#define RADIOLIB_SX128X_CAD_ON_4_SYMB 0x40 // 7 0 4
#define RADIOLIB_SX128X_CAD_ON_8_SYMB 0x60 // 7 0 8
#define RADIOLIB_SX128X_CAD_ON_16_SYMB 0x80 // 7 0 16
//SX128X_CMD_SET_MODULATION_PARAMS
#define SX128X_BLE_GFSK_BR_2_000_BW_2_4 0x04 // 7 0 GFSK/BLE bit rate and bandwidth setting: 2.0 Mbps 2.4 MHz
#define SX128X_BLE_GFSK_BR_1_600_BW_2_4 0x28 // 7 0 1.6 Mbps 2.4 MHz
#define SX128X_BLE_GFSK_BR_1_000_BW_2_4 0x4C // 7 0 1.0 Mbps 2.4 MHz
#define SX128X_BLE_GFSK_BR_1_000_BW_1_2 0x45 // 7 0 1.0 Mbps 1.2 MHz
#define SX128X_BLE_GFSK_BR_0_800_BW_2_4 0x70 // 7 0 0.8 Mbps 2.4 MHz
#define SX128X_BLE_GFSK_BR_0_800_BW_1_2 0x69 // 7 0 0.8 Mbps 1.2 MHz
#define SX128X_BLE_GFSK_BR_0_500_BW_1_2 0x8D // 7 0 0.5 Mbps 1.2 MHz
#define SX128X_BLE_GFSK_BR_0_500_BW_0_6 0x86 // 7 0 0.5 Mbps 0.6 MHz
#define SX128X_BLE_GFSK_BR_0_400_BW_1_2 0xB1 // 7 0 0.4 Mbps 1.2 MHz
#define SX128X_BLE_GFSK_BR_0_400_BW_0_6 0xAA // 7 0 0.4 Mbps 0.6 MHz
#define SX128X_BLE_GFSK_BR_0_250_BW_0_6 0xCE // 7 0 0.25 Mbps 0.6 MHz
#define SX128X_BLE_GFSK_BR_0_250_BW_0_3 0xC7 // 7 0 0.25 Mbps 0.3 MHz
#define SX128X_BLE_GFSK_BR_0_125_BW_0_3 0xEF // 7 0 0.125 Mbps 0.3 MHz
#define SX128X_BLE_GFSK_MOD_IND_0_35 0x00 // 7 0 GFSK/BLE modulation index: 0.35
#define SX128X_BLE_GFSK_MOD_IND_0_50 0x01 // 7 0 0.50
#define SX128X_BLE_GFSK_MOD_IND_0_75 0x02 // 7 0 0.75
#define SX128X_BLE_GFSK_MOD_IND_1_00 0x03 // 7 0 1.00
#define SX128X_BLE_GFSK_MOD_IND_1_25 0x04 // 7 0 1.25
#define SX128X_BLE_GFSK_MOD_IND_1_50 0x05 // 7 0 1.50
#define SX128X_BLE_GFSK_MOD_IND_1_75 0x06 // 7 0 1.75
#define SX128X_BLE_GFSK_MOD_IND_2_00 0x07 // 7 0 2.00
#define SX128X_BLE_GFSK_MOD_IND_2_25 0x08 // 7 0 2.25
#define SX128X_BLE_GFSK_MOD_IND_2_50 0x09 // 7 0 2.50
#define SX128X_BLE_GFSK_MOD_IND_2_75 0x0A // 7 0 2.75
#define SX128X_BLE_GFSK_MOD_IND_3_00 0x0B // 7 0 3.00
#define SX128X_BLE_GFSK_MOD_IND_3_25 0x0C // 7 0 3.25
#define SX128X_BLE_GFSK_MOD_IND_3_50 0x0D // 7 0 3.50
#define SX128X_BLE_GFSK_MOD_IND_3_75 0x0E // 7 0 3.75
#define SX128X_BLE_GFSK_MOD_IND_4_00 0x0F // 7 0 4.00
#define SX128X_BLE_GFSK_BT_OFF 0x00 // 7 0 GFSK Gaussian filter BT product: filter disabled
#define SX128X_BLE_GFSK_BT_1_0 0x10 // 7 0 1.0
#define SX128X_BLE_GFSK_BT_0_5 0x20 // 7 0 0.5
#define SX128X_FLRC_BR_1_300_BW_1_2 0x45 // 7 0 FLRC bit rate and bandwidth setting: 1.3 Mbps 1.2 MHz
#define SX128X_FLRC_BR_1_000_BW_1_2 0x69 // 7 0 1.04 Mbps 1.2 MHz
#define SX128X_FLRC_BR_0_650_BW_0_6 0x86 // 7 0 0.65 Mbps 0.6 MHz
#define SX128X_FLRC_BR_0_520_BW_0_6 0xAA // 7 0 0.52 Mbps 0.6 MHz
#define SX128X_FLRC_BR_0_325_BW_0_3 0xC7 // 7 0 0.325 Mbps 0.3 MHz
#define SX128X_FLRC_BR_0_260_BW_0_3 0xEB // 7 0 0.260 Mbps 0.3 MHz
#define SX128X_FLRC_CR_1_2 0x00 // 7 0 FLRC coding rate: 1/2
#define SX128X_FLRC_CR_3_4 0x02 // 7 0 3/4
#define SX128X_FLRC_CR_1_0 0x04 // 7 0 1/1
#define SX128X_FLRC_BT_OFF 0x00 // 7 0 FLRC Gaussian filter BT product: filter disabled
#define SX128X_FLRC_BT_1_0 0x10 // 7 0 1.0
#define SX128X_FLRC_BT_0_5 0x20 // 7 0 0.5
#define SX128X_LORA_SF_5 0x50 // 7 0 LoRa spreading factor: 5
#define SX128X_LORA_SF_6 0x60 // 7 0 6
#define SX128X_LORA_SF_7 0x70 // 7 0 7
#define SX128X_LORA_SF_8 0x80 // 7 0 8
#define SX128X_LORA_SF_9 0x90 // 7 0 9
#define SX128X_LORA_SF_10 0xA0 // 7 0 10
#define SX128X_LORA_SF_11 0xB0 // 7 0 11
#define SX128X_LORA_SF_12 0xC0 // 7 0 12
#define SX128X_LORA_BW_1625_00 0x0A // 7 0 LoRa bandwidth: 1625.0 kHz
#define SX128X_LORA_BW_812_50 0x18 // 7 0 812.5 kHz
#define SX128X_LORA_BW_406_25 0x26 // 7 0 406.25 kHz
#define SX128X_LORA_BW_203_125 0x34 // 7 0 203.125 kHz
#define SX128X_LORA_CR_4_5 0x01 // 7 0 LoRa coding rate: 4/5
#define SX128X_LORA_CR_4_6 0x02 // 7 0 4/6
#define SX128X_LORA_CR_4_7 0x03 // 7 0 4/7
#define SX128X_LORA_CR_4_8 0x04 // 7 0 4/8
#define SX128X_LORA_CR_4_5_LI 0x05 // 7 0 4/5, long interleaving
#define SX128X_LORA_CR_4_6_LI 0x06 // 7 0 4/6, long interleaving
#define SX128X_LORA_CR_4_7_LI 0x07 // 7 0 4/7, long interleaving
//RADIOLIB_SX128X_CMD_SET_MODULATION_PARAMS
#define RADIOLIB_SX128X_BLE_GFSK_BR_2_000_BW_2_4 0x04 // 7 0 GFSK/BLE bit rate and bandwidth setting: 2.0 Mbps 2.4 MHz
#define RADIOLIB_SX128X_BLE_GFSK_BR_1_600_BW_2_4 0x28 // 7 0 1.6 Mbps 2.4 MHz
#define RADIOLIB_SX128X_BLE_GFSK_BR_1_000_BW_2_4 0x4C // 7 0 1.0 Mbps 2.4 MHz
#define RADIOLIB_SX128X_BLE_GFSK_BR_1_000_BW_1_2 0x45 // 7 0 1.0 Mbps 1.2 MHz
#define RADIOLIB_SX128X_BLE_GFSK_BR_0_800_BW_2_4 0x70 // 7 0 0.8 Mbps 2.4 MHz
#define RADIOLIB_SX128X_BLE_GFSK_BR_0_800_BW_1_2 0x69 // 7 0 0.8 Mbps 1.2 MHz
#define RADIOLIB_SX128X_BLE_GFSK_BR_0_500_BW_1_2 0x8D // 7 0 0.5 Mbps 1.2 MHz
#define RADIOLIB_SX128X_BLE_GFSK_BR_0_500_BW_0_6 0x86 // 7 0 0.5 Mbps 0.6 MHz
#define RADIOLIB_SX128X_BLE_GFSK_BR_0_400_BW_1_2 0xB1 // 7 0 0.4 Mbps 1.2 MHz
#define RADIOLIB_SX128X_BLE_GFSK_BR_0_400_BW_0_6 0xAA // 7 0 0.4 Mbps 0.6 MHz
#define RADIOLIB_SX128X_BLE_GFSK_BR_0_250_BW_0_6 0xCE // 7 0 0.25 Mbps 0.6 MHz
#define RADIOLIB_SX128X_BLE_GFSK_BR_0_250_BW_0_3 0xC7 // 7 0 0.25 Mbps 0.3 MHz
#define RADIOLIB_SX128X_BLE_GFSK_BR_0_125_BW_0_3 0xEF // 7 0 0.125 Mbps 0.3 MHz
#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_0_35 0x00 // 7 0 GFSK/BLE modulation index: 0.35
#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_0_50 0x01 // 7 0 0.50
#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_0_75 0x02 // 7 0 0.75
#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_1_00 0x03 // 7 0 1.00
#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_1_25 0x04 // 7 0 1.25
#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_1_50 0x05 // 7 0 1.50
#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_1_75 0x06 // 7 0 1.75
#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_2_00 0x07 // 7 0 2.00
#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_2_25 0x08 // 7 0 2.25
#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_2_50 0x09 // 7 0 2.50
#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_2_75 0x0A // 7 0 2.75
#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_3_00 0x0B // 7 0 3.00
#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_3_25 0x0C // 7 0 3.25
#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_3_50 0x0D // 7 0 3.50
#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_3_75 0x0E // 7 0 3.75
#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_4_00 0x0F // 7 0 4.00
#define RADIOLIB_SX128X_BLE_GFSK_BT_OFF 0x00 // 7 0 GFSK Gaussian filter BT product: filter disabled
#define RADIOLIB_SX128X_BLE_GFSK_BT_1_0 0x10 // 7 0 1.0
#define RADIOLIB_SX128X_BLE_GFSK_BT_0_5 0x20 // 7 0 0.5
#define RADIOLIB_SX128X_FLRC_BR_1_300_BW_1_2 0x45 // 7 0 FLRC bit rate and bandwidth setting: 1.3 Mbps 1.2 MHz
#define RADIOLIB_SX128X_FLRC_BR_1_000_BW_1_2 0x69 // 7 0 1.04 Mbps 1.2 MHz
#define RADIOLIB_SX128X_FLRC_BR_0_650_BW_0_6 0x86 // 7 0 0.65 Mbps 0.6 MHz
#define RADIOLIB_SX128X_FLRC_BR_0_520_BW_0_6 0xAA // 7 0 0.52 Mbps 0.6 MHz
#define RADIOLIB_SX128X_FLRC_BR_0_325_BW_0_3 0xC7 // 7 0 0.325 Mbps 0.3 MHz
#define RADIOLIB_SX128X_FLRC_BR_0_260_BW_0_3 0xEB // 7 0 0.260 Mbps 0.3 MHz
#define RADIOLIB_SX128X_FLRC_CR_1_2 0x00 // 7 0 FLRC coding rate: 1/2
#define RADIOLIB_SX128X_FLRC_CR_3_4 0x02 // 7 0 3/4
#define RADIOLIB_SX128X_FLRC_CR_1_0 0x04 // 7 0 1/1
#define RADIOLIB_SX128X_FLRC_BT_OFF 0x00 // 7 0 FLRC Gaussian filter BT product: filter disabled
#define RADIOLIB_SX128X_FLRC_BT_1_0 0x10 // 7 0 1.0
#define RADIOLIB_SX128X_FLRC_BT_0_5 0x20 // 7 0 0.5
#define RADIOLIB_SX128X_LORA_SF_5 0x50 // 7 0 LoRa spreading factor: 5
#define RADIOLIB_SX128X_LORA_SF_6 0x60 // 7 0 6
#define RADIOLIB_SX128X_LORA_SF_7 0x70 // 7 0 7
#define RADIOLIB_SX128X_LORA_SF_8 0x80 // 7 0 8
#define RADIOLIB_SX128X_LORA_SF_9 0x90 // 7 0 9
#define RADIOLIB_SX128X_LORA_SF_10 0xA0 // 7 0 10
#define RADIOLIB_SX128X_LORA_SF_11 0xB0 // 7 0 11
#define RADIOLIB_SX128X_LORA_SF_12 0xC0 // 7 0 12
#define RADIOLIB_SX128X_LORA_BW_1625_00 0x0A // 7 0 LoRa bandwidth: 1625.0 kHz
#define RADIOLIB_SX128X_LORA_BW_812_50 0x18 // 7 0 812.5 kHz
#define RADIOLIB_SX128X_LORA_BW_406_25 0x26 // 7 0 406.25 kHz
#define RADIOLIB_SX128X_LORA_BW_203_125 0x34 // 7 0 203.125 kHz
#define RADIOLIB_SX128X_LORA_CR_4_5 0x01 // 7 0 LoRa coding rate: 4/5
#define RADIOLIB_SX128X_LORA_CR_4_6 0x02 // 7 0 4/6
#define RADIOLIB_SX128X_LORA_CR_4_7 0x03 // 7 0 4/7
#define RADIOLIB_SX128X_LORA_CR_4_8 0x04 // 7 0 4/8
#define RADIOLIB_SX128X_LORA_CR_4_5_LI 0x05 // 7 0 4/5, long interleaving
#define RADIOLIB_SX128X_LORA_CR_4_6_LI 0x06 // 7 0 4/6, long interleaving
#define RADIOLIB_SX128X_LORA_CR_4_7_LI 0x07 // 7 0 4/7, long interleaving
//SX128X_CMD_SET_PACKET_PARAMS
#define SX128X_GFSK_FLRC_SYNC_WORD_OFF 0x00 // 7 0 GFSK/FLRC sync word used: none
#define SX128X_GFSK_FLRC_SYNC_WORD_1 0x10 // 7 0 sync word 1
#define SX128X_GFSK_FLRC_SYNC_WORD_2 0x20 // 7 0 sync word 2
#define SX128X_GFSK_FLRC_SYNC_WORD_1_2 0x30 // 7 0 sync words 1 and 2
#define SX128X_GFSK_FLRC_SYNC_WORD_3 0x40 // 7 0 sync word 3
#define SX128X_GFSK_FLRC_SYNC_WORD_1_3 0x50 // 7 0 sync words 1 and 3
#define SX128X_GFSK_FLRC_SYNC_WORD_2_3 0x60 // 7 0 sync words 2 and 3
#define SX128X_GFSK_FLRC_SYNC_WORD_1_2_3 0x70 // 7 0 sync words 1, 2 and 3
#define SX128X_GFSK_FLRC_PACKET_FIXED 0x00 // 7 0 GFSK/FLRC packet length mode: fixed
#define SX128X_GFSK_FLRC_PACKET_VARIABLE 0x20 // 7 0 variable
#define SX128X_GFSK_FLRC_CRC_OFF 0x00 // 7 0 GFSK/FLRC packet CRC: none
#define SX128X_GFSK_FLRC_CRC_1_BYTE 0x10 // 7 0 1 byte
#define SX128X_GFSK_FLRC_CRC_2_BYTE 0x20 // 7 0 2 bytes
#define SX128X_GFSK_FLRC_CRC_3_BYTE 0x30 // 7 0 3 bytes (FLRC only)
#define SX128X_GFSK_BLE_WHITENING_ON 0x00 // 7 0 GFSK/BLE whitening: enabled
#define SX128X_GFSK_BLE_WHITENING_OFF 0x08 // 7 0 disabled
#define SX128X_BLE_PAYLOAD_LENGTH_MAX_31 0x00 // 7 0 BLE maximum payload length: 31 bytes
#define SX128X_BLE_PAYLOAD_LENGTH_MAX_37 0x20 // 7 0 37 bytes
#define SX128X_BLE_PAYLOAD_LENGTH_TEST 0x40 // 7 0 63 bytes (test mode)
#define SX128X_BLE_PAYLOAD_LENGTH_MAX_255 0x80 // 7 0 255 bytes (Bluetooth 4.2 and above)
#define SX128X_BLE_CRC_OFF 0x00 // 7 0 BLE packet CRC: none
#define SX128X_BLE_CRC_3_BYTE 0x10 // 7 0 3 byte
#define SX128X_BLE_PRBS_9 0x00 // 7 0 BLE test payload contents: PRNG sequence using x^9 + x^5 + x
#define SX128X_BLE_EYELONG 0x04 // 7 0 repeated 0xF0
#define SX128X_BLE_EYESHORT 0x08 // 7 0 repeated 0xAA
#define SX128X_BLE_PRBS_15 0x0C // 7 0 PRNG sequence using x^15 + x^14 + x^13 + x^12 + x^2 + x + 1
#define SX128X_BLE_ALL_1 0x10 // 7 0 repeated 0xFF
#define SX128X_BLE_ALL_0 0x14 // 7 0 repeated 0x00
#define SX128X_BLE_EYELONG_INV 0x18 // 7 0 repeated 0x0F
#define SX128X_BLE_EYESHORT_INV 0x1C // 7 0 repeated 0x55
#define SX128X_FLRC_SYNC_WORD_OFF 0x00 // 7 0 FLRC sync word: disabled
#define SX128X_FLRC_SYNC_WORD_ON 0x04 // 7 0 enabled
#define SX128X_LORA_HEADER_EXPLICIT 0x00 // 7 0 LoRa header mode: explicit
#define SX128X_LORA_HEADER_IMPLICIT 0x80 // 7 0 implicit
#define SX128X_LORA_CRC_OFF 0x00 // 7 0 LoRa packet CRC: disabled
#define SX128X_LORA_CRC_ON 0x20 // 7 0 enabled
#define SX128X_LORA_IQ_STANDARD 0x40 // 7 0 LoRa IQ: standard
#define SX128X_LORA_IQ_INVERTED 0x00 // 7 0 inverted
//RADIOLIB_SX128X_CMD_SET_PACKET_PARAMS
#define RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_OFF 0x00 // 7 0 GFSK/FLRC sync word used: none
#define RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_1 0x10 // 7 0 sync word 1
#define RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_2 0x20 // 7 0 sync word 2
#define RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_1_2 0x30 // 7 0 sync words 1 and 2
#define RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_3 0x40 // 7 0 sync word 3
#define RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_1_3 0x50 // 7 0 sync words 1 and 3
#define RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_2_3 0x60 // 7 0 sync words 2 and 3
#define RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_1_2_3 0x70 // 7 0 sync words 1, 2 and 3
#define RADIOLIB_SX128X_GFSK_FLRC_PACKET_FIXED 0x00 // 7 0 GFSK/FLRC packet length mode: fixed
#define RADIOLIB_SX128X_GFSK_FLRC_PACKET_VARIABLE 0x20 // 7 0 variable
#define RADIOLIB_SX128X_GFSK_FLRC_CRC_OFF 0x00 // 7 0 GFSK/FLRC packet CRC: none
#define RADIOLIB_SX128X_GFSK_FLRC_CRC_1_BYTE 0x10 // 7 0 1 byte
#define RADIOLIB_SX128X_GFSK_FLRC_CRC_2_BYTE 0x20 // 7 0 2 bytes
#define RADIOLIB_SX128X_GFSK_FLRC_CRC_3_BYTE 0x30 // 7 0 3 bytes (FLRC only)
#define RADIOLIB_SX128X_GFSK_BLE_WHITENING_ON 0x00 // 7 0 GFSK/BLE whitening: enabled
#define RADIOLIB_SX128X_GFSK_BLE_WHITENING_OFF 0x08 // 7 0 disabled
#define RADIOLIB_SX128X_BLE_PAYLOAD_LENGTH_MAX_31 0x00 // 7 0 BLE maximum payload length: 31 bytes
#define RADIOLIB_SX128X_BLE_PAYLOAD_LENGTH_MAX_37 0x20 // 7 0 37 bytes
#define RADIOLIB_SX128X_BLE_PAYLOAD_LENGTH_TEST 0x40 // 7 0 63 bytes (test mode)
#define RADIOLIB_SX128X_BLE_PAYLOAD_LENGTH_MAX_255 0x80 // 7 0 255 bytes (Bluetooth 4.2 and above)
#define RADIOLIB_SX128X_BLE_CRC_OFF 0x00 // 7 0 BLE packet CRC: none
#define RADIOLIB_SX128X_BLE_CRC_3_BYTE 0x10 // 7 0 3 byte
#define RADIOLIB_SX128X_BLE_PRBS_9 0x00 // 7 0 BLE test payload contents: PRNG sequence using x^9 + x^5 + x
#define RADIOLIB_SX128X_BLE_EYELONG 0x04 // 7 0 repeated 0xF0
#define RADIOLIB_SX128X_BLE_EYESHORT 0x08 // 7 0 repeated 0xAA
#define RADIOLIB_SX128X_BLE_PRBS_15 0x0C // 7 0 PRNG sequence using x^15 + x^14 + x^13 + x^12 + x^2 + x + 1
#define RADIOLIB_SX128X_BLE_ALL_1 0x10 // 7 0 repeated 0xFF
#define RADIOLIB_SX128X_BLE_ALL_0 0x14 // 7 0 repeated 0x00
#define RADIOLIB_SX128X_BLE_EYELONG_INV 0x18 // 7 0 repeated 0x0F
#define RADIOLIB_SX128X_BLE_EYESHORT_INV 0x1C // 7 0 repeated 0x55
#define RADIOLIB_SX128X_FLRC_SYNC_WORD_OFF 0x00 // 7 0 FLRC sync word: disabled
#define RADIOLIB_SX128X_FLRC_SYNC_WORD_ON 0x04 // 7 0 enabled
#define RADIOLIB_SX128X_LORA_HEADER_EXPLICIT 0x00 // 7 0 LoRa header mode: explicit
#define RADIOLIB_SX128X_LORA_HEADER_IMPLICIT 0x80 // 7 0 implicit
#define RADIOLIB_SX128X_LORA_CRC_OFF 0x00 // 7 0 LoRa packet CRC: disabled
#define RADIOLIB_SX128X_LORA_CRC_ON 0x20 // 7 0 enabled
#define RADIOLIB_SX128X_LORA_IQ_STANDARD 0x40 // 7 0 LoRa IQ: standard
#define RADIOLIB_SX128X_LORA_IQ_INVERTED 0x00 // 7 0 inverted
//SX128X_CMD_GET_PACKET_STATUS
#define SX128X_PACKET_STATUS_SYNC_ERROR 0b01000000 // 6 6 packet status errors byte: sync word error
#define SX128X_PACKET_STATUS_LENGTH_ERROR 0b00100000 // 5 5 packet length error
#define SX128X_PACKET_STATUS_CRC_ERROR 0b00010000 // 4 4 CRC error
#define SX128X_PACKET_STATUS_ABORT_ERROR 0b00001000 // 3 3 packet reception aborted
#define SX128X_PACKET_STATUS_HEADER_RECEIVED 0b00000100 // 2 2 header received
#define SX128X_PACKET_STATUS_PACKET_RECEIVED 0b00000010 // 1 1 packet received
#define SX128X_PACKET_STATUS_PACKET_CTRL_BUSY 0b00000001 // 0 0 packet controller is busy
#define SX128X_PACKET_STATUS_RX_PID 0b11000000 // 7 6 packet status status byte: PID field of the received packet
#define SX128X_PACKET_STATUS_NO_ACK 0b00100000 // 5 5 NO_ACK field of the received packet
#define SX128X_PACKET_STATUS_RX_PID_ERROR 0b00010000 // 4 4 PID field error
#define SX128X_PACKET_STATUS_PACKET_SENT 0b00000001 // 0 0 packet sent
#define SX128X_PACKET_STATUS_SYNC_DET_ERROR 0b00000000 // 2 0 packet status sync byte: sync word detection error
#define SX128X_PACKET_STATUS_SYNC_DET_1 0b00000001 // 2 0 detected sync word 1
#define SX128X_PACKET_STATUS_SYNC_DET_2 0b00000010 // 2 0 detected sync word 2
#define SX128X_PACKET_STATUS_SYNC_DET_3 0b00000100 // 2 0 detected sync word 3
//RADIOLIB_SX128X_CMD_GET_PACKET_STATUS
#define RADIOLIB_SX128X_PACKET_STATUS_SYNC_ERROR 0b01000000 // 6 6 packet status errors byte: sync word error
#define RADIOLIB_SX128X_PACKET_STATUS_LENGTH_ERROR 0b00100000 // 5 5 packet length error
#define RADIOLIB_SX128X_PACKET_STATUS_CRC_ERROR 0b00010000 // 4 4 CRC error
#define RADIOLIB_SX128X_PACKET_STATUS_ABORT_ERROR 0b00001000 // 3 3 packet reception aborted
#define RADIOLIB_SX128X_PACKET_STATUS_HEADER_RECEIVED 0b00000100 // 2 2 header received
#define RADIOLIB_SX128X_PACKET_STATUS_PACKET_RECEIVED 0b00000010 // 1 1 packet received
#define RADIOLIB_SX128X_PACKET_STATUS_PACKET_CTRL_BUSY 0b00000001 // 0 0 packet controller is busy
#define RADIOLIB_SX128X_PACKET_STATUS_RX_PID 0b11000000 // 7 6 packet status status byte: PID field of the received packet
#define RADIOLIB_SX128X_PACKET_STATUS_NO_ACK 0b00100000 // 5 5 NO_ACK field of the received packet
#define RADIOLIB_SX128X_PACKET_STATUS_RX_PID_ERROR 0b00010000 // 4 4 PID field error
#define RADIOLIB_SX128X_PACKET_STATUS_PACKET_SENT 0b00000001 // 0 0 packet sent
#define RADIOLIB_SX128X_PACKET_STATUS_SYNC_DET_ERROR 0b00000000 // 2 0 packet status sync byte: sync word detection error
#define RADIOLIB_SX128X_PACKET_STATUS_SYNC_DET_1 0b00000001 // 2 0 detected sync word 1
#define RADIOLIB_SX128X_PACKET_STATUS_SYNC_DET_2 0b00000010 // 2 0 detected sync word 2
#define RADIOLIB_SX128X_PACKET_STATUS_SYNC_DET_3 0b00000100 // 2 0 detected sync word 3
//SX128X_CMD_SET_DIO_IRQ_PARAMS
#define SX128X_IRQ_PREAMBLE_DETECTED 0x8000 // 15 15 interrupt source: preamble detected
#define SX128X_IRQ_ADVANCED_RANGING_DONE 0x8000 // 15 15 advanced ranging done
#define SX128X_IRQ_RX_TX_TIMEOUT 0x4000 // 14 14 Rx or Tx timeout
#define SX128X_IRQ_CAD_DETECTED 0x2000 // 13 13 channel activity detected
#define SX128X_IRQ_CAD_DONE 0x1000 // 12 12 CAD finished
#define SX128X_IRQ_RANGING_SLAVE_REQ_VALID 0x0800 // 11 11 ranging request valid (slave)
#define SX128X_IRQ_RANGING_MASTER_TIMEOUT 0x0400 // 10 10 ranging timeout (master)
#define SX128X_IRQ_RANGING_MASTER_RES_VALID 0x0200 // 9 9 ranging result valid (master)
#define SX128X_IRQ_RANGING_SLAVE_REQ_DISCARD 0x0100 // 8 8 ranging result valid (master)
#define SX128X_IRQ_RANGING_SLAVE_RESP_DONE 0x0080 // 7 7 ranging response complete (slave)
#define SX128X_IRQ_CRC_ERROR 0x0040 // 6 6 CRC error
#define SX128X_IRQ_HEADER_ERROR 0x0020 // 5 5 header error
#define SX128X_IRQ_HEADER_VALID 0x0010 // 4 4 header valid
#define SX128X_IRQ_SYNC_WORD_ERROR 0x0008 // 3 3 sync word error
#define SX128X_IRQ_SYNC_WORD_VALID 0x0004 // 2 2 sync word valid
#define SX128X_IRQ_RX_DONE 0x0002 // 1 1 Rx done
#define SX128X_IRQ_TX_DONE 0x0001 // 0 0 Tx done
#define SX128X_IRQ_NONE 0x0000 // 15 0 none
#define SX128X_IRQ_ALL 0xFFFF // 15 0 all
//RADIOLIB_SX128X_CMD_SET_DIO_IRQ_PARAMS
#define RADIOLIB_SX128X_IRQ_RADIOLIB_PREAMBLE_DETECTED 0x8000 // 15 15 interrupt source: preamble detected
#define RADIOLIB_SX128X_IRQ_ADVANCED_RANGING_DONE 0x8000 // 15 15 advanced ranging done
#define RADIOLIB_SX128X_IRQ_RX_TX_TIMEOUT 0x4000 // 14 14 Rx or Tx timeout
#define RADIOLIB_SX128X_IRQ_CAD_DETECTED 0x2000 // 13 13 channel activity detected
#define RADIOLIB_SX128X_IRQ_CAD_DONE 0x1000 // 12 12 CAD finished
#define RADIOLIB_SX128X_IRQ_RANGING_SLAVE_REQ_VALID 0x0800 // 11 11 ranging request valid (slave)
#define RADIOLIB_SX128X_IRQ_RANGING_MASTER_TIMEOUT 0x0400 // 10 10 ranging timeout (master)
#define RADIOLIB_SX128X_IRQ_RANGING_MASTER_RES_VALID 0x0200 // 9 9 ranging result valid (master)
#define RADIOLIB_SX128X_IRQ_RANGING_SLAVE_REQ_DISCARD 0x0100 // 8 8 ranging result valid (master)
#define RADIOLIB_SX128X_IRQ_RANGING_SLAVE_RESP_DONE 0x0080 // 7 7 ranging response complete (slave)
#define RADIOLIB_SX128X_IRQ_CRC_ERROR 0x0040 // 6 6 CRC error
#define RADIOLIB_SX128X_IRQ_HEADER_ERROR 0x0020 // 5 5 header error
#define RADIOLIB_SX128X_IRQ_HEADER_VALID 0x0010 // 4 4 header valid
#define RADIOLIB_SX128X_IRQ_SYNC_WORD_ERROR 0x0008 // 3 3 sync word error
#define RADIOLIB_SX128X_IRQ_SYNC_WORD_VALID 0x0004 // 2 2 sync word valid
#define RADIOLIB_SX128X_IRQ_RX_DONE 0x0002 // 1 1 Rx done
#define RADIOLIB_SX128X_IRQ_TX_DONE 0x0001 // 0 0 Tx done
#define RADIOLIB_SX128X_IRQ_NONE 0x0000 // 15 0 none
#define RADIOLIB_SX128X_IRQ_ALL 0xFFFF // 15 0 all
//SX128X_CMD_SET_REGULATOR_MODE
#define SX128X_REGULATOR_LDO 0x00 // 7 0 set regulator mode: LDO (default)
#define SX128X_REGULATOR_DC_DC 0x01 // 7 0 DC-DC
//RADIOLIB_SX128X_CMD_SET_REGULATOR_MODE
#define RADIOLIB_SX128X_REGULATOR_LDO 0x00 // 7 0 set regulator mode: LDO (default)
#define RADIOLIB_SX128X_REGULATOR_DC_DC 0x01 // 7 0 DC-DC
//SX128X_CMD_SET_RANGING_ROLE
#define SX128X_RANGING_ROLE_MASTER 0x01 // 7 0 ranging role: master
#define SX128X_RANGING_ROLE_SLAVE 0x00 // 7 0 slave
//RADIOLIB_SX128X_CMD_SET_RANGING_ROLE
#define RADIOLIB_SX128X_RANGING_ROLE_MASTER 0x01 // 7 0 ranging role: master
#define RADIOLIB_SX128X_RANGING_ROLE_SLAVE 0x00 // 7 0 slave
//SX128X_REG_LORA_SYNC_WORD_1 - SX128X_REG_LORA_SYNC_WORD_2
#define SX128X_SYNC_WORD_PRIVATE 0x12
//RADIOLIB_SX128X_REG_LORA_SYNC_WORD_1 - RADIOLIB_SX128X_REG_LORA_SYNC_WORD_2
#define RADIOLIB_SX128X_SYNC_WORD_PRIVATE 0x12
/*!
\class SX128x
@ -362,6 +362,8 @@ class SX128x: public PhysicalLayer {
*/
SX128x(Module* mod);
Module* getMod();
// basic methods
/*!
@ -375,7 +377,7 @@ class SX128x: public PhysicalLayer {
\param cr LoRa coding rate denominator. Defaults to 7 (coding rate 4/7).
\param syncWord 2-byte LoRa sync word. Defaults to SX128X_SYNC_WORD_PRIVATE (0x12).
\param syncWord 2-byte LoRa sync word. Defaults to RADIOLIB_SX128X_SYNC_WORD_PRIVATE (0x12).
\param power Output power in dBm. Defaults to 10 dBm.
@ -383,7 +385,7 @@ class SX128x: public PhysicalLayer {
\returns \ref status_codes
*/
int16_t begin(float freq = 2400.0, float bw = 812.5, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX128X_SYNC_WORD_PRIVATE, int8_t power = 10, uint16_t preambleLength = 12);
int16_t begin(float freq = 2400.0, float bw = 812.5, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = RADIOLIB_SX128X_SYNC_WORD_PRIVATE, int8_t power = 10, uint16_t preambleLength = 12);
/*!
\brief Initialization method for GFSK modem.
@ -485,7 +487,7 @@ class SX128x: public PhysicalLayer {
/*!
\brief Starts direct mode reception. Only implemented for PhysicalLayer compatibility, as %SX128x series does not support direct mode reception.
Will always return ERR_UNKNOWN.
Will always return RADIOLIB_ERR_UNKNOWN.
\returns \ref status_codes
*/
@ -517,7 +519,7 @@ class SX128x: public PhysicalLayer {
/*!
\brief Sets the module to standby mode.
\param mode Oscillator to be used in standby mode. Can be set to SX128X_STANDBY_RC (13 MHz RC oscillator) or SX128X_STANDBY_XOSC (52 MHz external crystal oscillator).
\param mode Oscillator to be used in standby mode. Can be set to RADIOLIB_SX128X_STANDBY_RC (13 MHz RC oscillator) or RADIOLIB_SX128X_STANDBY_XOSC (52 MHz external crystal oscillator).
\returns \ref status_codes
*/
@ -554,11 +556,11 @@ class SX128x: public PhysicalLayer {
/*!
\brief Interrupt-driven receive method. DIO1 will be activated when full packet is received.
\param timeout Raw timeout value, expressed as multiples of 15.625 us. Defaults to SX128X_RX_TIMEOUT_INF for infinite timeout (Rx continuous mode), set to SX128X_RX_TIMEOUT_NONE for no timeout (Rx single mode).
\param timeout Raw timeout value, expressed as multiples of 15.625 us. Defaults to RADIOLIB_SX128X_RX_TIMEOUT_INF for infinite timeout (Rx continuous mode), set to RADIOLIB_SX128X_RX_TIMEOUT_NONE for no timeout (Rx single mode).
\returns \ref status_codes
*/
int16_t startReceive(uint16_t timeout = SX128X_RX_TIMEOUT_INF);
int16_t startReceive(uint16_t timeout = RADIOLIB_SX128X_RX_TIMEOUT_INF);
/*!
\brief Reads data received after calling startReceive method.
@ -818,20 +820,20 @@ class SX128x: public PhysicalLayer {
int16_t readRegister(uint16_t addr, uint8_t* data, uint8_t numBytes);
int16_t writeBuffer(uint8_t* data, uint8_t numBytes, uint8_t offset = 0x00);
int16_t readBuffer(uint8_t* data, uint8_t numBytes);
int16_t setTx(uint16_t periodBaseCount = SX128X_TX_TIMEOUT_NONE, uint8_t periodBase = SX128X_PERIOD_BASE_15_625_US);
int16_t setRx(uint16_t periodBaseCount, uint8_t periodBase = SX128X_PERIOD_BASE_15_625_US);
int16_t setTx(uint16_t periodBaseCount = RADIOLIB_SX128X_TX_TIMEOUT_NONE, uint8_t periodBase = RADIOLIB_SX128X_PERIOD_BASE_15_625_US);
int16_t setRx(uint16_t periodBaseCount, uint8_t periodBase = RADIOLIB_SX128X_PERIOD_BASE_15_625_US);
int16_t setCad();
uint8_t getPacketType();
int16_t setRfFrequency(uint32_t frf);
int16_t setTxParams(uint8_t power, uint8_t rampTime = SX128X_PA_RAMP_10_US);
int16_t setTxParams(uint8_t power, uint8_t rampTime = RADIOLIB_SX128X_PA_RAMP_10_US);
int16_t setBufferBaseAddress(uint8_t txBaseAddress = 0x00, uint8_t rxBaseAddress = 0x00);
int16_t setModulationParams(uint8_t modParam1, uint8_t modParam2, uint8_t modParam3);
int16_t setPacketParamsGFSK(uint8_t preambleLen, uint8_t syncWordLen, uint8_t syncWordMatch, uint8_t crcLen, uint8_t whitening, uint8_t payloadLen = 0xFF, uint8_t headerType = SX128X_GFSK_FLRC_PACKET_VARIABLE);
int16_t setPacketParamsGFSK(uint8_t preambleLen, uint8_t syncWordLen, uint8_t syncWordMatch, uint8_t crcLen, uint8_t whitening, uint8_t payloadLen = 0xFF, uint8_t headerType = RADIOLIB_SX128X_GFSK_FLRC_PACKET_VARIABLE);
int16_t setPacketParamsBLE(uint8_t connState, uint8_t crcLen, uint8_t bleTestPayload, uint8_t whitening);
int16_t setPacketParamsLoRa(uint8_t preambleLen, uint8_t headerType, uint8_t payloadLen, uint8_t crc, uint8_t invertIQ = SX128X_LORA_IQ_STANDARD);
int16_t setDioIrqParams(uint16_t irqMask, uint16_t dio1Mask, uint16_t dio2Mask = SX128X_IRQ_NONE, uint16_t dio3Mask = SX128X_IRQ_NONE);
int16_t setPacketParamsLoRa(uint8_t preambleLen, uint8_t headerType, uint8_t payloadLen, uint8_t crc, uint8_t invertIQ = RADIOLIB_SX128X_LORA_IQ_STANDARD);
int16_t setDioIrqParams(uint16_t irqMask, uint16_t dio1Mask, uint16_t dio2Mask = RADIOLIB_SX128X_IRQ_NONE, uint16_t dio3Mask = RADIOLIB_SX128X_IRQ_NONE);
uint16_t getIrqStatus();
int16_t clearIrqStatus(uint16_t clearIrqParams = SX128X_IRQ_ALL);
int16_t clearIrqStatus(uint16_t clearIrqParams = RADIOLIB_SX128X_IRQ_ALL);
int16_t setRangingRole(uint8_t role);
int16_t setPacketType(uint8_t type);