[Si443x] Synced parameters of all FSK modules
This commit is contained in:
parent
4d00170612
commit
8682357881
9 changed files with 50 additions and 13 deletions
|
@ -58,7 +58,8 @@ void setup() {
|
||||||
// frequency deviation: 60.0 kHz
|
// frequency deviation: 60.0 kHz
|
||||||
// Rx bandwidth: 335.5 kHz
|
// Rx bandwidth: 335.5 kHz
|
||||||
// output power: 17 dBm
|
// output power: 17 dBm
|
||||||
state = radio2.begin(868.0, 200.0, 60.0, 335.5, 17);
|
// preamble length: 32 bits
|
||||||
|
state = radio2.begin(868.0, 200.0, 60.0, 335.5, 17, 32);
|
||||||
if (state == ERR_NONE) {
|
if (state == ERR_NONE) {
|
||||||
Serial.println(F("success!"));
|
Serial.println(F("success!"));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -5,9 +5,9 @@ Si4430::Si4430(Module* mod) : Si4432(mod) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t Si4430::begin(float freq, float br, float freqDev, float rxBw, int8_t power) {
|
int16_t Si4430::begin(float freq, float br, float freqDev, float rxBw, int8_t power, uint8_t preambleLen) {
|
||||||
// execute common part
|
// execute common part
|
||||||
int16_t state = Si443x::begin(br, freqDev, rxBw);
|
int16_t state = Si443x::begin(br, freqDev, rxBw, preambleLen);
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// configure publicly accessible settings
|
// configure publicly accessible settings
|
||||||
|
|
|
@ -40,9 +40,11 @@ class Si4430: public Si4432 {
|
||||||
|
|
||||||
\param power Transmission output power in dBm. Allowed values range from -8 to 13 dBm in 3 dBm steps.
|
\param power Transmission output power in dBm. Allowed values range from -8 to 13 dBm in 3 dBm steps.
|
||||||
|
|
||||||
|
\param preambleLen Preamble Length in bits. Defaults to 16 bits.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t begin(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 181.1, int8_t power = 10);
|
int16_t begin(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 181.1, int8_t power = 10, uint8_t preambleLen = 16);
|
||||||
|
|
||||||
// configuration methods
|
// configuration methods
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,9 @@ Si4431::Si4431(Module* mod) : Si4432(mod) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t Si4431::begin(float freq, float br, float freqDev, float rxBw, int8_t power) {
|
int16_t Si4431::begin(float freq, float br, float freqDev, float rxBw, int8_t power, uint8_t preambleLen) {
|
||||||
// execute common part
|
// execute common part
|
||||||
int16_t state = Si443x::begin(br, freqDev, rxBw);
|
int16_t state = Si443x::begin(br, freqDev, rxBw, preambleLen);
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// configure publicly accessible settings
|
// configure publicly accessible settings
|
||||||
|
|
|
@ -40,9 +40,11 @@ class Si4431: public Si4432 {
|
||||||
|
|
||||||
\param power Transmission output power in dBm. Allowed values range from -8 to 13 dBm in 3 dBm steps.
|
\param power Transmission output power in dBm. Allowed values range from -8 to 13 dBm in 3 dBm steps.
|
||||||
|
|
||||||
|
\param preambleLen Preamble Length in bits. Defaults to 16 bits.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t begin(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 181.1, int8_t power = 10);
|
int16_t begin(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 181.1, int8_t power = 10, uint8_t preambleLen = 16);
|
||||||
|
|
||||||
// configuration methods
|
// configuration methods
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,9 @@ Si4432::Si4432(Module* mod) : Si443x(mod) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t Si4432::begin(float freq, float br, float freqDev, float rxBw, int8_t power) {
|
int16_t Si4432::begin(float freq, float br, float freqDev, float rxBw, int8_t power, uint8_t preambleLen) {
|
||||||
// execute common part
|
// execute common part
|
||||||
int16_t state = Si443x::begin(br, freqDev, rxBw);
|
int16_t state = Si443x::begin(br, freqDev, rxBw, preambleLen);
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// configure publicly accessible settings
|
// configure publicly accessible settings
|
||||||
|
|
|
@ -40,9 +40,11 @@ class Si4432: public Si443x {
|
||||||
|
|
||||||
\param power Transmission output power in dBm. Allowed values range from -1 to 20 dBm in 3 dBm steps.
|
\param power Transmission output power in dBm. Allowed values range from -1 to 20 dBm in 3 dBm steps.
|
||||||
|
|
||||||
|
\param preambleLen Preamble Length in bits. Defaults to 16 bits.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t begin(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 181.1, int8_t power = 11);
|
int16_t begin(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 181.1, int8_t power = 10, uint8_t preambleLen = 16);
|
||||||
|
|
||||||
// configuration methods
|
// configuration methods
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ Si443x::Si443x(Module* mod) : PhysicalLayer(SI443X_FREQUENCY_STEP_SIZE, SI443X_M
|
||||||
_mod = mod;
|
_mod = mod;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t Si443x::begin(float br, float freqDev, float rxBw) {
|
int16_t Si443x::begin(float br, float freqDev, float rxBw, uint8_t preambleLen) {
|
||||||
// set module properties
|
// set module properties
|
||||||
_mod->init(RADIOLIB_USE_SPI);
|
_mod->init(RADIOLIB_USE_SPI);
|
||||||
Module::pinMode(_mod->getIrq(), INPUT);
|
Module::pinMode(_mod->getIrq(), INPUT);
|
||||||
|
@ -38,7 +38,10 @@ int16_t Si443x::begin(float br, float freqDev, float rxBw) {
|
||||||
state = setRxBandwidth(rxBw);
|
state = setRxBandwidth(rxBw);
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
uint8_t syncWord[] = {0x2D, 0x01};
|
state = setPreambleLength(preambleLen);
|
||||||
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
|
uint8_t syncWord[] = {0x12, 0xAD};
|
||||||
state = setSyncWord(syncWord, sizeof(syncWord));
|
state = setSyncWord(syncWord, sizeof(syncWord));
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
|
@ -477,6 +480,22 @@ int16_t Si443x::setSyncWord(uint8_t* syncWord, size_t len) {
|
||||||
return(state);
|
return(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int16_t Si443x::setPreambleLength(uint8_t preambleLen) {
|
||||||
|
// Si443x configures preamble length in bytes
|
||||||
|
if(preambleLen % 8 != 0) {
|
||||||
|
return(ERR_INVALID_PREAMBLE_LENGTH);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set default preamble length
|
||||||
|
uint8_t preLenBytes = preambleLen / 8;
|
||||||
|
int16_t state = _mod->SPIsetRegValue(SI443X_REG_PREAMBLE_LENGTH, preLenBytes);
|
||||||
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
|
// set default preamble detection threshold to 50% of preamble length (in units of 4 bits)
|
||||||
|
uint8_t preThreshold = preambleLen / 4;
|
||||||
|
return(_mod->SPIsetRegValue(SI443X_REG_PREAMBLE_DET_CONTROL, preThreshold << 4, 3, 7));
|
||||||
|
}
|
||||||
|
|
||||||
size_t Si443x::getPacketLength(bool update) {
|
size_t Si443x::getPacketLength(bool update) {
|
||||||
// TODO variable length mode
|
// TODO variable length mode
|
||||||
if(!_packetLengthQueried && update) {
|
if(!_packetLengthQueried && update) {
|
||||||
|
|
|
@ -579,9 +579,11 @@ class Si443x: public PhysicalLayer {
|
||||||
|
|
||||||
\param rxBw Receiver bandwidth in kHz.
|
\param rxBw Receiver bandwidth in kHz.
|
||||||
|
|
||||||
|
\param preambleLen Preamble Length in bits.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t begin(float br, float freqDev, float rxBw);
|
int16_t begin(float br, float freqDev, float rxBw, uint8_t preambleLen);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Reset method. Will reset the chip to the default state using SDN pin.
|
\brief Reset method. Will reset the chip to the default state using SDN pin.
|
||||||
|
@ -735,6 +737,15 @@ class Si443x: public PhysicalLayer {
|
||||||
*/
|
*/
|
||||||
int16_t setSyncWord(uint8_t* syncWord, size_t len);
|
int16_t setSyncWord(uint8_t* syncWord, size_t len);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Sets preamble length.
|
||||||
|
|
||||||
|
\param preambleLen Preamble length to be set (in bits).
|
||||||
|
|
||||||
|
\returns \ref status_codes
|
||||||
|
*/
|
||||||
|
int16_t setPreambleLength(uint8_t preambleLen);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Query modem for the packet length of received payload.
|
\brief Query modem for the packet length of received payload.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue