[CC1101] Added carrier sense as sync word qualifier
This commit is contained in:
parent
c0f5ef922c
commit
293fba2656
2 changed files with 24 additions and 13 deletions
|
@ -470,7 +470,7 @@ int16_t CC1101::setOutputPower(int8_t power) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t CC1101::setSyncWord(uint8_t* syncWord, uint8_t len, uint8_t maxErrBits) {
|
int16_t CC1101::setSyncWord(uint8_t* syncWord, uint8_t len, uint8_t maxErrBits, bool requireCarrierSense) {
|
||||||
if((maxErrBits > 1) || (len != 2)) {
|
if((maxErrBits > 1) || (len != 2)) {
|
||||||
return(ERR_INVALID_SYNC_WORD);
|
return(ERR_INVALID_SYNC_WORD);
|
||||||
}
|
}
|
||||||
|
@ -485,7 +485,7 @@ int16_t CC1101::setSyncWord(uint8_t* syncWord, uint8_t len, uint8_t maxErrBits)
|
||||||
_syncWordLength = len;
|
_syncWordLength = len;
|
||||||
|
|
||||||
// enable sync word filtering
|
// enable sync word filtering
|
||||||
int16_t state = enableSyncWordFiltering(maxErrBits);
|
int16_t state = enableSyncWordFiltering(maxErrBits, requireCarrierSense);
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// set sync word register
|
// set sync word register
|
||||||
|
@ -495,9 +495,9 @@ int16_t CC1101::setSyncWord(uint8_t* syncWord, uint8_t len, uint8_t maxErrBits)
|
||||||
return(state);
|
return(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t CC1101::setSyncWord(uint8_t syncH, uint8_t syncL, uint8_t maxErrBits) {
|
int16_t CC1101::setSyncWord(uint8_t syncH, uint8_t syncL, uint8_t maxErrBits, bool requireCarrierSense) {
|
||||||
uint8_t syncWord[] = { syncH, syncL };
|
uint8_t syncWord[] = { syncH, syncL };
|
||||||
return(setSyncWord(syncWord, sizeof(syncWord), maxErrBits));
|
return(setSyncWord(syncWord, sizeof(syncWord), maxErrBits, requireCarrierSense));
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t CC1101::setPreambleLength(uint8_t preambleLength) {
|
int16_t CC1101::setPreambleLength(uint8_t preambleLength) {
|
||||||
|
@ -627,21 +627,24 @@ int16_t CC1101::variablePacketLengthMode(uint8_t maxLen) {
|
||||||
return(setPacketMode(CC1101_LENGTH_CONFIG_VARIABLE, maxLen));
|
return(setPacketMode(CC1101_LENGTH_CONFIG_VARIABLE, maxLen));
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t CC1101::enableSyncWordFiltering(uint8_t maxErrBits) {
|
int16_t CC1101::enableSyncWordFiltering(uint8_t maxErrBits, bool requireCarrierSense) {
|
||||||
switch (maxErrBits){
|
switch (maxErrBits){
|
||||||
case 0:
|
case 0:
|
||||||
// in 16 bit sync word, expect all 16 bits.
|
// in 16 bit sync word, expect all 16 bits.
|
||||||
return (SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_SYNC_MODE_16_16, 2, 0));
|
return (SPIsetRegValue(CC1101_REG_MDMCFG2,
|
||||||
|
requireCarrierSense ? CC1101_SYNC_MODE_16_16_THR : CC1101_SYNC_MODE_16_16, 2, 0));
|
||||||
case 1:
|
case 1:
|
||||||
// in 16 bit sync word, expect at least 15 bits.
|
// in 16 bit sync word, expect at least 15 bits.
|
||||||
return (SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_SYNC_MODE_15_16, 2, 0));
|
return (SPIsetRegValue(CC1101_REG_MDMCFG2,
|
||||||
|
requireCarrierSense ? CC1101_SYNC_MODE_15_16_THR : CC1101_SYNC_MODE_15_16, 2, 0));
|
||||||
default:
|
default:
|
||||||
return (ERR_INVALID_SYNC_WORD);
|
return (ERR_INVALID_SYNC_WORD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t CC1101::disableSyncWordFiltering() {
|
int16_t CC1101::disableSyncWordFiltering(bool requireCarrierSense) {
|
||||||
return(SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_SYNC_MODE_NONE, 2, 0));
|
return(SPIsetRegValue(CC1101_REG_MDMCFG2,
|
||||||
|
requireCarrierSense ? CC1101_SYNC_MODE_NONE_THR : CC1101_SYNC_MODE_NONE, 2, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t CC1101::setCrcFiltering(bool crcOn) {
|
int16_t CC1101::setCrcFiltering(bool crcOn) {
|
||||||
|
|
|
@ -709,9 +709,11 @@ class CC1101: public PhysicalLayer {
|
||||||
|
|
||||||
\param maxErrBits Maximum allowed number of bit errors in received sync word. Defaults to 0.
|
\param maxErrBits Maximum allowed number of bit errors in received sync word. Defaults to 0.
|
||||||
|
|
||||||
|
\param requireCarrierSense Require carrier sense above threshold in addition to sync word.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t setSyncWord(uint8_t syncH, uint8_t syncL, uint8_t maxErrBits = 0);
|
int16_t setSyncWord(uint8_t syncH, uint8_t syncL, uint8_t maxErrBits = 0, bool requireCarrierSense = false);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Sets 1 or 2 bytes of sync word.
|
\brief Sets 1 or 2 bytes of sync word.
|
||||||
|
@ -722,9 +724,11 @@ class CC1101: public PhysicalLayer {
|
||||||
|
|
||||||
\param maxErrBits Maximum allowed number of bit errors in received sync word. Defaults to 0.
|
\param maxErrBits Maximum allowed number of bit errors in received sync word. Defaults to 0.
|
||||||
|
|
||||||
|
\param requireCarrierSense Require carrier sense above threshold in addition to sync word.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t setSyncWord(uint8_t* syncWord, uint8_t len, uint8_t maxErrBits = 0);
|
int16_t setSyncWord(uint8_t* syncWord, uint8_t len, uint8_t maxErrBits = 0, bool requireCarrierSense = false);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Sets preamble length.
|
\brief Sets preamble length.
|
||||||
|
@ -808,16 +812,20 @@ class CC1101: public PhysicalLayer {
|
||||||
|
|
||||||
\param numBits Sync word length in bits.
|
\param numBits Sync word length in bits.
|
||||||
|
|
||||||
|
\param requireCarrierSense Require carrier sense above threshold in addition to sync word.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t enableSyncWordFiltering(uint8_t maxErrBits = 0);
|
int16_t enableSyncWordFiltering(uint8_t maxErrBits = 0, bool requireCarrierSense = false);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Disable preamble and sync word filtering and generation.
|
\brief Disable preamble and sync word filtering and generation.
|
||||||
|
|
||||||
|
\param requireCarrierSense Require carrier sense above threshold.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t disableSyncWordFiltering();
|
int16_t disableSyncWordFiltering(bool requireCarrierSense = false);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Enable CRC filtering and generation.
|
\brief Enable CRC filtering and generation.
|
||||||
|
|
Loading…
Add table
Reference in a new issue