[Si443x] Add CRC configuration (#1430)
This commit is contained in:
parent
416f52d92a
commit
f0e686eaa9
2 changed files with 23 additions and 3 deletions
|
@ -54,10 +54,13 @@ int16_t Si443x::begin(float br, float freqDev, float rxBw, uint8_t preambleLen)
|
||||||
state = packetMode();
|
state = packetMode();
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
state = setDataShaping(0);
|
state = setDataShaping(RADIOLIB_SHAPING_NONE);
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
state = setEncoding(0);
|
state = setEncoding(RADIOLIB_ENCODING_NRZ);
|
||||||
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
|
state = setCRC(true);
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
state = variablePacketLengthMode();
|
state = variablePacketLengthMode();
|
||||||
|
@ -293,7 +296,8 @@ int16_t Si443x::startReceive() {
|
||||||
this->mod->setRfSwitchState(Module::MODE_RX);
|
this->mod->setRfSwitchState(Module::MODE_RX);
|
||||||
|
|
||||||
// set interrupt mapping
|
// set interrupt mapping
|
||||||
this->mod->SPIwriteRegister(RADIOLIB_SI443X_REG_INTERRUPT_ENABLE_1, RADIOLIB_SI443X_VALID_PACKET_RECEIVED_ENABLED | RADIOLIB_SI443X_CRC_ERROR_ENABLED);
|
uint8_t irq = this->crcEnabled ? (RADIOLIB_SI443X_VALID_PACKET_RECEIVED_ENABLED | RADIOLIB_SI443X_CRC_ERROR_ENABLED) : RADIOLIB_SI443X_VALID_PACKET_RECEIVED_ENABLED;
|
||||||
|
this->mod->SPIwriteRegister(RADIOLIB_SI443X_REG_INTERRUPT_ENABLE_1, irq);
|
||||||
this->mod->SPIwriteRegister(RADIOLIB_SI443X_REG_INTERRUPT_ENABLE_2, 0x00);
|
this->mod->SPIwriteRegister(RADIOLIB_SI443X_REG_INTERRUPT_ENABLE_2, 0x00);
|
||||||
|
|
||||||
// set mode to receive
|
// set mode to receive
|
||||||
|
@ -654,6 +658,13 @@ int16_t Si443x::clearIrqFlags(uint32_t irq) {
|
||||||
return(RADIOLIB_ERR_NONE);
|
return(RADIOLIB_ERR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int16_t Si443x::setCRC(bool enable, bool mode) {
|
||||||
|
this->crcEnabled = enable;
|
||||||
|
uint8_t crcEn = enable ? RADIOLIB_SI443X_CRC_ON : RADIOLIB_SI443X_CRC_OFF;
|
||||||
|
uint8_t crcCfg = mode ? RADIOLIB_SI443X_CRC_IBM_CRC16 : RADIOLIB_SI443X_CRC_CCITT;
|
||||||
|
return(this->mod->SPIsetRegValue(RADIOLIB_SI443X_REG_DATA_ACCESS_CONTROL, crcEn | crcCfg, 2, 0));
|
||||||
|
}
|
||||||
|
|
||||||
Module* Si443x::getMod() {
|
Module* Si443x::getMod() {
|
||||||
return(this->mod);
|
return(this->mod);
|
||||||
}
|
}
|
||||||
|
|
|
@ -836,6 +836,14 @@ class Si443x: public PhysicalLayer {
|
||||||
*/
|
*/
|
||||||
int16_t clearIrqFlags(uint32_t irq) override;
|
int16_t clearIrqFlags(uint32_t irq) override;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Enables/disables CRC of transmitted or received packets.
|
||||||
|
\param enable Enable (true) or disable (false) CRC.
|
||||||
|
\param mode Set CRC mode
|
||||||
|
\returns \ref status_codes
|
||||||
|
*/
|
||||||
|
int16_t setCRC(bool enable, bool mode = false);
|
||||||
|
|
||||||
#if !RADIOLIB_GODMODE && !RADIOLIB_LOW_LEVEL
|
#if !RADIOLIB_GODMODE && !RADIOLIB_LOW_LEVEL
|
||||||
protected:
|
protected:
|
||||||
#endif
|
#endif
|
||||||
|
@ -858,6 +866,7 @@ class Si443x: public PhysicalLayer {
|
||||||
size_t packetLength = 0;
|
size_t packetLength = 0;
|
||||||
bool packetLengthQueried = false;
|
bool packetLengthQueried = false;
|
||||||
uint8_t packetLengthConfig = RADIOLIB_SI443X_FIXED_PACKET_LENGTH_ON;
|
uint8_t packetLengthConfig = RADIOLIB_SI443X_FIXED_PACKET_LENGTH_ON;
|
||||||
|
bool crcEnabled = false;
|
||||||
|
|
||||||
bool findChip();
|
bool findChip();
|
||||||
void clearIrqStatus();
|
void clearIrqStatus();
|
||||||
|
|
Loading…
Add table
Reference in a new issue