[SX126x] Added notes about DIO2 RF control
This commit is contained in:
parent
ee86ff8253
commit
c9b68163d5
5 changed files with 37 additions and 22 deletions
|
@ -65,6 +65,11 @@ void loop() {
|
|||
// no preamble was detected, channel is free
|
||||
Serial.println(F("channel is free!"));
|
||||
|
||||
} else if (state == ERR_CAD_UNAVAILABLE) {
|
||||
// no preamble was detected, channel is free
|
||||
Serial.println(F("unable to perform scan!"));
|
||||
Serial.println(F("[SX1262] Disable DIO2 RF control to run CAD."));
|
||||
|
||||
}
|
||||
|
||||
// wait 100 ms before new scan
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
- CRC
|
||||
- preamble length
|
||||
- TCXO voltage
|
||||
- DIO2 RF switch control
|
||||
|
||||
Other modules from SX126x family can also be used.
|
||||
|
||||
|
@ -146,6 +147,14 @@ void setup() {
|
|||
while (true);
|
||||
}
|
||||
|
||||
// Some SX126x modules use DIO2 as RF switch. To enable
|
||||
// this feature, the following method can be used.
|
||||
// NOTE: As long as DIO2 is configured to control RF switch,
|
||||
// Channel Activity Detection is disabled!
|
||||
if (loraSX1262.setDio2AsRfSwitch() != ERR_NONE) {
|
||||
Serial.println(F("Failed to set DIO2 as RF switch!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
Serial.println(F("All settings succesfully changed!"));
|
||||
}
|
||||
|
|
|
@ -232,3 +232,4 @@ ERR_INVALID_MODULATION_PARAMETERS LITERAL1
|
|||
ERR_SPI_CMD_TIMEOUT LITERAL1
|
||||
ERR_SPI_CMD_INVALID LITERAL1
|
||||
ERR_SPI_CMD_FAILED LITERAL1
|
||||
ERR_CAD_UNAVAILABLE LITERAL1
|
||||
|
|
|
@ -464,7 +464,7 @@
|
|||
/*!
|
||||
\brief SX126x scan channel not possible because DIO2 is used as RF antenna switch.
|
||||
*/
|
||||
#define ERR_DIO2_UNAVAIL_CAD_FAILED -708
|
||||
#define ERR_CAD_UNAVAILABLE -708
|
||||
|
||||
/*!
|
||||
\}
|
||||
|
|
|
@ -33,11 +33,6 @@ int16_t SX126x::begin(float bw, uint8_t sf, uint8_t cr, uint16_t syncWord, uint1
|
|||
}
|
||||
|
||||
// configure publicly accessible settings
|
||||
state = setDio2AsRfSwitch(false);
|
||||
if(state != ERR_NONE) {
|
||||
return(state);
|
||||
}
|
||||
|
||||
state = setSpreadingFactor(sf);
|
||||
if(state != ERR_NONE) {
|
||||
return(state);
|
||||
|
@ -59,6 +54,12 @@ int16_t SX126x::begin(float bw, uint8_t sf, uint8_t cr, uint16_t syncWord, uint1
|
|||
}
|
||||
|
||||
state = setPreambleLength(preambleLength);
|
||||
if(state != ERR_NONE) {
|
||||
return(state);
|
||||
}
|
||||
|
||||
// set publicly accessible settings that are not a part of begin method
|
||||
state = setDio2AsRfSwitch(false);
|
||||
|
||||
return(state);
|
||||
}
|
||||
|
@ -91,11 +92,6 @@ int16_t SX126x::beginFSK(float br, float freqDev, float rxBw, uint16_t preambleL
|
|||
}
|
||||
|
||||
// configure publicly accessible settings
|
||||
state = setDio2AsRfSwitch(false);
|
||||
if(state != ERR_NONE) {
|
||||
return(state);
|
||||
}
|
||||
|
||||
state = setBitRate(br);
|
||||
if(state != ERR_NONE) {
|
||||
return(state);
|
||||
|
@ -121,9 +117,14 @@ int16_t SX126x::beginFSK(float br, float freqDev, float rxBw, uint16_t preambleL
|
|||
return(state);
|
||||
}
|
||||
|
||||
// set default sync word 0x2D01 - not a beginFSK attribute
|
||||
// set publicly accessible settings that are not a part of begin method
|
||||
uint8_t sync[] = {0x2D, 0x01};
|
||||
state = setSyncWord(sync, 2);
|
||||
if(state != ERR_NONE) {
|
||||
return(state);
|
||||
}
|
||||
|
||||
state = setDio2AsRfSwitch(false);
|
||||
|
||||
return(state);
|
||||
}
|
||||
|
@ -286,7 +287,7 @@ int16_t SX126x::scanChannel() {
|
|||
|
||||
if (_dio2RfSwitch) {
|
||||
// If DIO2 is used as RF switch this function does not work
|
||||
return(ERR_DIO2_UNAVAIL_CAD_FAILED);
|
||||
return(ERR_CAD_UNAVAILABLE);
|
||||
}
|
||||
|
||||
// set mode to standby
|
||||
|
@ -1074,14 +1075,13 @@ int16_t SX126x::setFrequencyRaw(float freq) {
|
|||
}
|
||||
|
||||
int16_t SX126x::setDio2AsRfSwitch(bool enable) {
|
||||
uint8_t data[1];
|
||||
uint8_t data = 0;
|
||||
if(enable) {
|
||||
// set DIO2 as RF switch
|
||||
data[0] = SX126X_DIO2_AS_RF_SWITCH;
|
||||
data = SX126X_DIO2_AS_RF_SWITCH;
|
||||
} else {
|
||||
data[0] = SX126X_DIO2_AS_IRQ;
|
||||
data = SX126X_DIO2_AS_IRQ;
|
||||
}
|
||||
int16_t state = SPIwriteCommand(SX126X_CMD_SET_DIO2_AS_RF_SWITCH_CTRL, data, 1);
|
||||
int16_t state = SPIwriteCommand(SX126X_CMD_SET_DIO2_AS_RF_SWITCH_CTRL, &data, 1);
|
||||
|
||||
if(state == ERR_NONE) {
|
||||
_dio2RfSwitch = enable;
|
||||
|
|
Loading…
Add table
Reference in a new issue