Variable PreambleLength for CC1101

This commit is contained in:
Andrea Guglielmini 2019-11-18 17:01:37 +01:00
parent fc27b5a427
commit 7d7af7ac0b
2 changed files with 46 additions and 0 deletions

View file

@ -448,6 +448,43 @@ int16_t CC1101::setSyncWord(uint8_t syncH, uint8_t syncL) {
return(state);
}
int16_t CC1101::setPreambleLength(uint8_t preambleLength) {
// check allowed values
uint8_t value;
switch(preambleLength){
case 2:
value = CC1101_NUM_PREAMBLE_2;
break;
case 3:
value = CC1101_NUM_PREAMBLE_3;
break;
case 4:
value = CC1101_NUM_PREAMBLE_4;
break;
case 6:
value = CC1101_NUM_PREAMBLE_6;
break;
case 8:
value = CC1101_NUM_PREAMBLE_8;
break;
case 12:
value = CC1101_NUM_PREAMBLE_12;
break;
case 16:
value = CC1101_NUM_PREAMBLE_16;
break;
case 24:
value = CC1101_NUM_PREAMBLE_24;
break;
default:
return(ERR_INVALID_PREAMBLE_LENGTH);
}
return SPIsetRegValue(CC1101_REG_MDMCFG1, value, 6, 4);
}
int16_t CC1101::setNodeAddress(uint8_t nodeAddr, uint8_t numBroadcastAddrs) {
if(!(numBroadcastAddrs > 0) && (numBroadcastAddrs <= 2)) {
return(ERR_INVALID_NUM_BROAD_ADDRS);

View file

@ -698,6 +698,15 @@ class CC1101: public PhysicalLayer {
*/
int16_t setSyncWord(uint8_t syncH, uint8_t syncL);
/*!
\brief Sets preamble length.
\param preambleLength Preamble length to be set, allowed values: 2, 3, 4, 6, 8, 12, 16, 24
\returns \ref status_codes
*/
int16_t setPreambleLength(uint8_t preambleLength);
/*!
\brief Sets node and broadcast addresses. Calling this method will also enable address filtering.