[CC1101] General reformatting
This commit is contained in:
parent
78a576df12
commit
5c6628b6eb
2 changed files with 667 additions and 702 deletions
|
@ -3,19 +3,19 @@
|
||||||
#if !defined(RADIOLIB_EXCLUDE_CC1101)
|
#if !defined(RADIOLIB_EXCLUDE_CC1101)
|
||||||
|
|
||||||
CC1101::CC1101(Module* module) : PhysicalLayer(RADIOLIB_CC1101_FREQUENCY_STEP_SIZE, RADIOLIB_CC1101_MAX_PACKET_LENGTH) {
|
CC1101::CC1101(Module* module) : PhysicalLayer(RADIOLIB_CC1101_FREQUENCY_STEP_SIZE, RADIOLIB_CC1101_MAX_PACKET_LENGTH) {
|
||||||
_mod = module;
|
this->mod = module;
|
||||||
}
|
}
|
||||||
|
|
||||||
Module* CC1101::getMod() {
|
Module* CC1101::getMod() {
|
||||||
return(_mod);
|
return(this->mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t CC1101::begin(float freq, float br, float freqDev, float rxBw, int8_t power, uint8_t preambleLength) {
|
int16_t CC1101::begin(float freq, float br, float freqDev, float rxBw, int8_t power, uint8_t preambleLength) {
|
||||||
// set module properties
|
// set module properties
|
||||||
_mod->SPIreadCommand = RADIOLIB_CC1101_CMD_READ;
|
this->mod->SPIreadCommand = RADIOLIB_CC1101_CMD_READ;
|
||||||
_mod->SPIwriteCommand = RADIOLIB_CC1101_CMD_WRITE;
|
this->mod->SPIwriteCommand = RADIOLIB_CC1101_CMD_WRITE;
|
||||||
_mod->init();
|
this->mod->init();
|
||||||
_mod->hal->pinMode(_mod->getIrq(), _mod->hal->GpioModeInput);
|
this->mod->hal->pinMode(this->mod->getIrq(), this->mod->hal->GpioModeInput);
|
||||||
|
|
||||||
// try to find the CC1101 chip
|
// try to find the CC1101 chip
|
||||||
uint8_t i = 0;
|
uint8_t i = 0;
|
||||||
|
@ -26,14 +26,14 @@ int16_t CC1101::begin(float freq, float br, float freqDev, float rxBw, int8_t po
|
||||||
flagFound = true;
|
flagFound = true;
|
||||||
} else {
|
} else {
|
||||||
RADIOLIB_DEBUG_PRINTLN("CC1101 not found! (%d of 10 tries) RADIOLIB_CC1101_REG_VERSION == 0x%04X, expected 0x0004/0x0014", i + 1, version);
|
RADIOLIB_DEBUG_PRINTLN("CC1101 not found! (%d of 10 tries) RADIOLIB_CC1101_REG_VERSION == 0x%04X, expected 0x0004/0x0014", i + 1, version);
|
||||||
_mod->hal->delay(10);
|
this->mod->hal->delay(10);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!flagFound) {
|
if(!flagFound) {
|
||||||
RADIOLIB_DEBUG_PRINTLN("No CC1101 found!");
|
RADIOLIB_DEBUG_PRINTLN("No CC1101 found!");
|
||||||
_mod->term();
|
this->mod->term();
|
||||||
return(RADIOLIB_ERR_CHIP_NOT_FOUND);
|
return(RADIOLIB_ERR_CHIP_NOT_FOUND);
|
||||||
} else {
|
} else {
|
||||||
RADIOLIB_DEBUG_PRINTLN("M\tCC1101");
|
RADIOLIB_DEBUG_PRINTLN("M\tCC1101");
|
||||||
|
@ -68,7 +68,7 @@ int16_t CC1101::begin(float freq, float br, float freqDev, float rxBw, int8_t po
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// configure default preamble length
|
// configure default preamble length
|
||||||
state = setPreambleLength(preambleLength);
|
state = setPreambleLength(preambleLength, preambleLength - 4);
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// set default data shaping
|
// set default data shaping
|
||||||
|
@ -85,37 +85,48 @@ int16_t CC1101::begin(float freq, float br, float freqDev, float rxBw, int8_t po
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// flush FIFOs
|
// flush FIFOs
|
||||||
SPIsendCommand(RADIOLIB_CC1101_CMD_FLUSH_RX);
|
SPIsendCommand(RADIOLIB_CC1101_CMD_FLUSH_RX | RADIOLIB_CC1101_CMD_READ);
|
||||||
SPIsendCommand(RADIOLIB_CC1101_CMD_FLUSH_TX);
|
SPIsendCommand(RADIOLIB_CC1101_CMD_FLUSH_TX);
|
||||||
|
|
||||||
return(state);
|
return(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CC1101::reset() {
|
||||||
|
// this is the manual power-on-reset sequence
|
||||||
|
this->mod->hal->digitalWrite(this->mod->getCs(), LOW);
|
||||||
|
this->mod->hal->delayMicroseconds(5);
|
||||||
|
this->mod->hal->digitalWrite(this->mod->getCs(), HIGH);
|
||||||
|
this->mod->hal->delayMicroseconds(40);
|
||||||
|
this->mod->hal->digitalWrite(this->mod->getCs(), LOW);
|
||||||
|
this->mod->hal->delay(10);
|
||||||
|
SPIsendCommand(RADIOLIB_CC1101_CMD_RESET);
|
||||||
|
}
|
||||||
|
|
||||||
int16_t CC1101::transmit(uint8_t* data, size_t len, uint8_t addr) {
|
int16_t CC1101::transmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||||
// calculate timeout (5ms + 500 % of expected time-on-air)
|
// calculate timeout (5ms + 500 % of expected time-on-air)
|
||||||
uint32_t timeout = 5000000 + (uint32_t)((((float)(len * 8)) / (_br * 1000.0)) * 5000000.0);
|
uint32_t timeout = 5000000 + (uint32_t)((((float)(len * 8)) / (this->bitRate * 1000.0)) * 5000000.0);
|
||||||
|
|
||||||
// start transmission
|
// start transmission
|
||||||
int16_t state = startTransmit(data, len, addr);
|
int16_t state = startTransmit(data, len, addr);
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// wait for transmission start or timeout
|
// wait for transmission start or timeout
|
||||||
uint32_t start = _mod->hal->micros();
|
uint32_t start = this->mod->hal->micros();
|
||||||
while(!_mod->hal->digitalRead(_mod->getGpio())) {
|
while(!this->mod->hal->digitalRead(this->mod->getGpio())) {
|
||||||
_mod->hal->yield();
|
this->mod->hal->yield();
|
||||||
|
|
||||||
if(_mod->hal->micros() - start > timeout) {
|
if(this->mod->hal->micros() - start > timeout) {
|
||||||
finishTransmit();
|
finishTransmit();
|
||||||
return(RADIOLIB_ERR_TX_TIMEOUT);
|
return(RADIOLIB_ERR_TX_TIMEOUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait for transmission end or timeout
|
// wait for transmission end or timeout
|
||||||
start = _mod->hal->micros();
|
start = this->mod->hal->micros();
|
||||||
while(_mod->hal->digitalRead(_mod->getGpio())) {
|
while(this->mod->hal->digitalRead(this->mod->getGpio())) {
|
||||||
_mod->hal->yield();
|
this->mod->hal->yield();
|
||||||
|
|
||||||
if(_mod->hal->micros() - start > timeout) {
|
if(this->mod->hal->micros() - start > timeout) {
|
||||||
finishTransmit();
|
finishTransmit();
|
||||||
return(RADIOLIB_ERR_TX_TIMEOUT);
|
return(RADIOLIB_ERR_TX_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
@ -126,18 +137,18 @@ int16_t CC1101::transmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||||
|
|
||||||
int16_t CC1101::receive(uint8_t* data, size_t len) {
|
int16_t CC1101::receive(uint8_t* data, size_t len) {
|
||||||
// calculate timeout (500 ms + 400 full max-length packets at current bit rate)
|
// calculate timeout (500 ms + 400 full max-length packets at current bit rate)
|
||||||
uint32_t timeout = 500000 + (1.0/(_br*1000.0))*(RADIOLIB_CC1101_MAX_PACKET_LENGTH*400.0);
|
uint32_t timeout = 500000 + (1.0/(this->bitRate*1000.0))*(RADIOLIB_CC1101_MAX_PACKET_LENGTH*400.0);
|
||||||
|
|
||||||
// start reception
|
// start reception
|
||||||
int16_t state = startReceive();
|
int16_t state = startReceive();
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// wait for packet or timeout
|
// wait for packet or timeout
|
||||||
uint32_t start = _mod->hal->micros();
|
uint32_t start = this->mod->hal->micros();
|
||||||
while(!_mod->hal->digitalRead(_mod->getIrq())) {
|
while(!this->mod->hal->digitalRead(this->mod->getIrq())) {
|
||||||
_mod->hal->yield();
|
this->mod->hal->yield();
|
||||||
|
|
||||||
if(_mod->hal->micros() - start > timeout) {
|
if(this->mod->hal->micros() - start > timeout) {
|
||||||
standby();
|
standby();
|
||||||
SPIsendCommand(RADIOLIB_CC1101_CMD_FLUSH_RX);
|
SPIsendCommand(RADIOLIB_CC1101_CMD_FLUSH_RX);
|
||||||
return(RADIOLIB_ERR_RX_TIMEOUT);
|
return(RADIOLIB_ERR_RX_TIMEOUT);
|
||||||
|
@ -153,7 +164,7 @@ int16_t CC1101::standby() {
|
||||||
SPIsendCommand(RADIOLIB_CC1101_CMD_IDLE);
|
SPIsendCommand(RADIOLIB_CC1101_CMD_IDLE);
|
||||||
|
|
||||||
// set RF switch (if present)
|
// set RF switch (if present)
|
||||||
_mod->setRfSwitchState(Module::MODE_IDLE);
|
this->mod->setRfSwitchState(Module::MODE_IDLE);
|
||||||
return(RADIOLIB_ERR_NONE);
|
return(RADIOLIB_ERR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +183,7 @@ int16_t CC1101::transmitDirectAsync(uint32_t frf) {
|
||||||
|
|
||||||
int16_t CC1101::transmitDirect(bool sync, uint32_t frf) {
|
int16_t CC1101::transmitDirect(bool sync, uint32_t frf) {
|
||||||
// set RF switch (if present)
|
// set RF switch (if present)
|
||||||
_mod->setRfSwitchState(Module::MODE_TX);
|
this->mod->setRfSwitchState(Module::MODE_TX);
|
||||||
|
|
||||||
// user requested to start transmitting immediately (required for RTTY)
|
// user requested to start transmitting immediately (required for RTTY)
|
||||||
if(frf != 0) {
|
if(frf != 0) {
|
||||||
|
@ -202,7 +213,7 @@ int16_t CC1101::receiveDirectAsync() {
|
||||||
|
|
||||||
int16_t CC1101::receiveDirect(bool sync) {
|
int16_t CC1101::receiveDirect(bool sync) {
|
||||||
// set RF switch (if present)
|
// set RF switch (if present)
|
||||||
_mod->setRfSwitchState(Module::MODE_RX);
|
this->mod->setRfSwitchState(Module::MODE_RX);
|
||||||
|
|
||||||
// activate direct mode
|
// activate direct mode
|
||||||
int16_t state = directMode(sync);
|
int16_t state = directMode(sync);
|
||||||
|
@ -216,31 +227,33 @@ int16_t CC1101::receiveDirect(bool sync) {
|
||||||
int16_t CC1101::packetMode() {
|
int16_t CC1101::packetMode() {
|
||||||
int16_t state = SPIsetRegValue(RADIOLIB_CC1101_REG_PKTCTRL1, RADIOLIB_CC1101_CRC_AUTOFLUSH_OFF | RADIOLIB_CC1101_APPEND_STATUS_ON | RADIOLIB_CC1101_ADR_CHK_NONE, 3, 0);
|
int16_t state = SPIsetRegValue(RADIOLIB_CC1101_REG_PKTCTRL1, RADIOLIB_CC1101_CRC_AUTOFLUSH_OFF | RADIOLIB_CC1101_APPEND_STATUS_ON | RADIOLIB_CC1101_ADR_CHK_NONE, 3, 0);
|
||||||
state |= SPIsetRegValue(RADIOLIB_CC1101_REG_PKTCTRL0, RADIOLIB_CC1101_WHITE_DATA_OFF | RADIOLIB_CC1101_PKT_FORMAT_NORMAL, 6, 4);
|
state |= SPIsetRegValue(RADIOLIB_CC1101_REG_PKTCTRL0, RADIOLIB_CC1101_WHITE_DATA_OFF | RADIOLIB_CC1101_PKT_FORMAT_NORMAL, 6, 4);
|
||||||
state |= SPIsetRegValue(RADIOLIB_CC1101_REG_PKTCTRL0, RADIOLIB_CC1101_CRC_ON | _packetLengthConfig, 2, 0);
|
state |= SPIsetRegValue(RADIOLIB_CC1101_REG_PKTCTRL0, RADIOLIB_CC1101_CRC_ON | this->packetLengthConfig, 2, 0);
|
||||||
return(state);
|
return(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CC1101::setGdo0Action(void (*func)(void), uint32_t dir) {
|
void CC1101::setGdo0Action(void (*func)(void), uint32_t dir) {
|
||||||
_mod->hal->attachInterrupt(_mod->hal->pinToInterrupt(_mod->getIrq()), func, dir);
|
this->mod->hal->attachInterrupt(this->mod->hal->pinToInterrupt(this->mod->getIrq()), func, dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CC1101::clearGdo0Action() {
|
void CC1101::clearGdo0Action() {
|
||||||
_mod->hal->detachInterrupt(_mod->hal->pinToInterrupt(_mod->getIrq()));
|
this->mod->hal->detachInterrupt(this->mod->hal->pinToInterrupt(this->mod->getIrq()));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CC1101::setGdo2Action(void (*func)(void), uint32_t dir) {
|
void CC1101::setGdo2Action(void (*func)(void), uint32_t dir) {
|
||||||
if(_mod->getGpio() == RADIOLIB_NC) {
|
if(this->mod->getGpio() == RADIOLIB_NC) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_mod->hal->pinMode(_mod->getGpio(), _mod->hal->GpioModeInput);
|
this->mod->hal->pinMode(this->mod->getGpio(), this->mod->hal->GpioModeInput);
|
||||||
_mod->hal->attachInterrupt(_mod->hal->pinToInterrupt(_mod->getGpio()), func, dir);
|
this->mod->hal->attachInterrupt(this->mod->hal->pinToInterrupt(this->mod->getGpio()), func, dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CC1101::clearGdo2Action() {
|
void CC1101::clearGdo2Action() {
|
||||||
if(_mod->getGpio() == RADIOLIB_NC) {
|
if(this->mod->getGpio() == RADIOLIB_NC) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_mod->hal->detachInterrupt(_mod->hal->pinToInterrupt(_mod->getGpio()));
|
this->mod->hal->detachInterrupt(this->mod->hal->pinToInterrupt(this->mod->getGpio()));
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t CC1101::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
int16_t CC1101::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||||
|
@ -256,16 +269,16 @@ int16_t CC1101::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||||
SPIsendCommand(RADIOLIB_CC1101_CMD_FLUSH_TX);
|
SPIsendCommand(RADIOLIB_CC1101_CMD_FLUSH_TX);
|
||||||
|
|
||||||
// set GDO0 mapping
|
// set GDO0 mapping
|
||||||
int16_t state = SPIsetRegValue(RADIOLIB_CC1101_REG_IOCFG2, RADIOLIB_CC1101_GDOX_SYNC_WORD_SENT_OR_RECEIVED, 5, 0);
|
int16_t state = SPIsetRegValue(RADIOLIB_CC1101_REG_IOCFG2, RADIOLIB_CC1101_GDOX_SYNC_WORD_SENT_OR_PKT_RECEIVED, 5, 0);
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// data put on FIFO.
|
// data put on FIFO
|
||||||
uint8_t dataSent = 0;
|
uint8_t dataSent = 0;
|
||||||
|
|
||||||
// optionally write packet length
|
// optionally write packet length
|
||||||
if (_packetLengthConfig == RADIOLIB_CC1101_LENGTH_CONFIG_VARIABLE) {
|
if (this->packetLengthConfig == RADIOLIB_CC1101_LENGTH_CONFIG_VARIABLE) {
|
||||||
|
|
||||||
// enforce variable len limit.
|
// enforce variable len limit
|
||||||
if (len > RADIOLIB_CC1101_MAX_PACKET_LENGTH - 1) {
|
if (len > RADIOLIB_CC1101_MAX_PACKET_LENGTH - 1) {
|
||||||
return (RADIOLIB_ERR_PACKET_TOO_LONG);
|
return (RADIOLIB_ERR_PACKET_TOO_LONG);
|
||||||
}
|
}
|
||||||
|
@ -281,36 +294,37 @@ int16_t CC1101::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||||
dataSent += 1;
|
dataSent += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill the FIFO.
|
// fill the FIFO
|
||||||
uint8_t initialWrite = min((uint8_t)len, (uint8_t)(RADIOLIB_CC1101_FIFO_SIZE - dataSent));
|
uint8_t initialWrite = min((uint8_t)len, (uint8_t)(RADIOLIB_CC1101_FIFO_SIZE - dataSent));
|
||||||
SPIwriteRegisterBurst(RADIOLIB_CC1101_REG_FIFO, data, initialWrite);
|
SPIwriteRegisterBurst(RADIOLIB_CC1101_REG_FIFO, data, initialWrite);
|
||||||
dataSent += initialWrite;
|
dataSent += initialWrite;
|
||||||
|
|
||||||
// set RF switch (if present)
|
// set RF switch (if present)
|
||||||
_mod->setRfSwitchState(Module::MODE_TX);
|
this->mod->setRfSwitchState(Module::MODE_TX);
|
||||||
|
|
||||||
// set mode to transmit
|
// set mode to transmit
|
||||||
SPIsendCommand(RADIOLIB_CC1101_CMD_TX);
|
SPIsendCommand(RADIOLIB_CC1101_CMD_TX);
|
||||||
|
|
||||||
// keep feeding the FIFO until the packet is over.
|
|
||||||
|
// keep feeding the FIFO until the packet is over
|
||||||
while (dataSent < len) {
|
while (dataSent < len) {
|
||||||
// get number of bytes in FIFO.
|
// get number of bytes in FIFO
|
||||||
uint8_t bytesInFIFO = SPIgetRegValue(RADIOLIB_CC1101_REG_TXBYTES, 6, 0);
|
uint8_t bytesInFIFO = SPIgetRegValue(RADIOLIB_CC1101_REG_TXBYTES, 6, 0);
|
||||||
|
|
||||||
// if there's room then put other data.
|
// if there's room then put other data
|
||||||
if (bytesInFIFO < RADIOLIB_CC1101_FIFO_SIZE) {
|
if (bytesInFIFO < RADIOLIB_CC1101_FIFO_SIZE) {
|
||||||
uint8_t bytesToWrite = min((uint8_t)(RADIOLIB_CC1101_FIFO_SIZE - bytesInFIFO), (uint8_t)(len - dataSent));
|
uint8_t bytesToWrite = min((uint8_t)(RADIOLIB_CC1101_FIFO_SIZE - bytesInFIFO), (uint8_t)(len - dataSent));
|
||||||
SPIwriteRegisterBurst(RADIOLIB_CC1101_REG_FIFO, &data[dataSent], bytesToWrite);
|
SPIwriteRegisterBurst(RADIOLIB_CC1101_REG_FIFO, &data[dataSent], bytesToWrite);
|
||||||
dataSent += bytesToWrite;
|
dataSent += bytesToWrite;
|
||||||
} else {
|
} else {
|
||||||
// wait for radio to send some data.
|
// wait for radio to send some data
|
||||||
/*
|
/*
|
||||||
* Does this work for all rates? If 1 ms is longer than the 1ms delay
|
* Does this work for all rates? If 1 ms is longer than the 1ms delay
|
||||||
* then the entire FIFO will be transmitted during that delay.
|
* then the entire FIFO will be transmitted during that delay.
|
||||||
*
|
*
|
||||||
* TODO: test this on real hardware
|
* TODO: test this on real hardware
|
||||||
*/
|
*/
|
||||||
_mod->hal->delayMicroseconds(250);
|
this->mod->hal->delayMicroseconds(250);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,6 +334,7 @@ int16_t CC1101::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||||
int16_t CC1101::finishTransmit() {
|
int16_t CC1101::finishTransmit() {
|
||||||
// set mode to standby to disable transmitter/RF switch
|
// set mode to standby to disable transmitter/RF switch
|
||||||
int16_t state = standby();
|
int16_t state = standby();
|
||||||
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// flush Tx FIFO
|
// flush Tx FIFO
|
||||||
SPIsendCommand(RADIOLIB_CC1101_CMD_FLUSH_TX);
|
SPIsendCommand(RADIOLIB_CC1101_CMD_FLUSH_TX);
|
||||||
|
@ -329,18 +344,19 @@ int16_t CC1101::finishTransmit() {
|
||||||
|
|
||||||
int16_t CC1101::startReceive() {
|
int16_t CC1101::startReceive() {
|
||||||
// set mode to standby
|
// set mode to standby
|
||||||
standby();
|
int16_t state = standby();
|
||||||
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// flush Rx FIFO
|
// flush Rx FIFO
|
||||||
SPIsendCommand(RADIOLIB_CC1101_CMD_FLUSH_RX);
|
SPIsendCommand(RADIOLIB_CC1101_CMD_FLUSH_RX);
|
||||||
|
|
||||||
// set GDO0 mapping: Asserted when RX FIFO > 4 bytes.
|
// set GDO0 mapping: Asserted when RX FIFO > 4 bytes.
|
||||||
int16_t state = SPIsetRegValue(RADIOLIB_CC1101_REG_IOCFG0, RADIOLIB_CC1101_GDOX_RX_FIFO_FULL_OR_PKT_END);
|
state = SPIsetRegValue(RADIOLIB_CC1101_REG_IOCFG0, RADIOLIB_CC1101_GDOX_RX_FIFO_FULL_OR_PKT_END);
|
||||||
state |= SPIsetRegValue(RADIOLIB_CC1101_REG_FIFOTHR, RADIOLIB_CC1101_FIFO_THR_TX_61_RX_4, 3, 0);
|
state |= SPIsetRegValue(RADIOLIB_CC1101_REG_FIFOTHR, RADIOLIB_CC1101_FIFO_THR_TX_61_RX_4, 3, 0);
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// set RF switch (if present)
|
// set RF switch (if present)
|
||||||
_mod->setRfSwitchState(Module::MODE_RX);
|
this->mod->setRfSwitchState(Module::MODE_RX);
|
||||||
|
|
||||||
// set mode to receive
|
// set mode to receive
|
||||||
SPIsendCommand(RADIOLIB_CC1101_CMD_RX);
|
SPIsendCommand(RADIOLIB_CC1101_CMD_RX);
|
||||||
|
@ -372,17 +388,17 @@ int16_t CC1101::readData(uint8_t* data, size_t len) {
|
||||||
|
|
||||||
uint8_t bytesInFIFO = SPIgetRegValue(RADIOLIB_CC1101_REG_RXBYTES, 6, 0);
|
uint8_t bytesInFIFO = SPIgetRegValue(RADIOLIB_CC1101_REG_RXBYTES, 6, 0);
|
||||||
size_t readBytes = 0;
|
size_t readBytes = 0;
|
||||||
uint32_t lastPop = _mod->hal->millis();
|
uint32_t lastPop = this->mod->hal->millis();
|
||||||
|
|
||||||
// keep reading from FIFO until we get all the packet.
|
// keep reading from FIFO until we get all the packet.
|
||||||
while (readBytes < length) {
|
while (readBytes < length) {
|
||||||
if (bytesInFIFO == 0) {
|
if (bytesInFIFO == 0) {
|
||||||
if (_mod->hal->millis() - lastPop > 5) {
|
if (this->mod->hal->millis() - lastPop > 5) {
|
||||||
// readData was required to read a packet longer than the one received.
|
// readData was required to read a packet longer than the one received.
|
||||||
RADIOLIB_DEBUG_PRINTLN("No data for more than 5mS. Stop here.");
|
RADIOLIB_DEBUG_PRINTLN("No data for more than 5mS. Stop here.");
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
_mod->hal->delay(1);
|
this->mod->hal->delay(1);
|
||||||
bytesInFIFO = SPIgetRegValue(RADIOLIB_CC1101_REG_RXBYTES, 6, 0);
|
bytesInFIFO = SPIgetRegValue(RADIOLIB_CC1101_REG_RXBYTES, 6, 0);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -392,7 +408,7 @@ int16_t CC1101::readData(uint8_t* data, size_t len) {
|
||||||
uint8_t bytesToRead = min((uint8_t)(length - readBytes), bytesInFIFO);
|
uint8_t bytesToRead = min((uint8_t)(length - readBytes), bytesInFIFO);
|
||||||
SPIreadRegisterBurst(RADIOLIB_CC1101_REG_FIFO, bytesToRead, &(data[readBytes]));
|
SPIreadRegisterBurst(RADIOLIB_CC1101_REG_FIFO, bytesToRead, &(data[readBytes]));
|
||||||
readBytes += bytesToRead;
|
readBytes += bytesToRead;
|
||||||
lastPop = _mod->hal->millis();
|
lastPop = this->mod->hal->millis();
|
||||||
|
|
||||||
// Get how many bytes are left in FIFO.
|
// Get how many bytes are left in FIFO.
|
||||||
bytesInFIFO = SPIgetRegValue(RADIOLIB_CC1101_REG_RXBYTES, 6, 0);
|
bytesInFIFO = SPIgetRegValue(RADIOLIB_CC1101_REG_RXBYTES, 6, 0);
|
||||||
|
@ -402,26 +418,26 @@ int16_t CC1101::readData(uint8_t* data, size_t len) {
|
||||||
bool isAppendStatus = SPIgetRegValue(RADIOLIB_CC1101_REG_PKTCTRL1, 2, 2) == RADIOLIB_CC1101_APPEND_STATUS_ON;
|
bool isAppendStatus = SPIgetRegValue(RADIOLIB_CC1101_REG_PKTCTRL1, 2, 2) == RADIOLIB_CC1101_APPEND_STATUS_ON;
|
||||||
|
|
||||||
// for some reason, we need this delay here to get the correct status bytes
|
// for some reason, we need this delay here to get the correct status bytes
|
||||||
_mod->hal->delay(3);
|
this->mod->hal->delay(3);
|
||||||
|
|
||||||
// If status byte is enabled at least 2 bytes (2 status bytes + any following packet) will remain in FIFO.
|
// If status byte is enabled at least 2 bytes (2 status bytes + any following packet) will remain in FIFO.
|
||||||
if (isAppendStatus) {
|
if (isAppendStatus) {
|
||||||
// read RSSI byte
|
// read RSSI byte
|
||||||
_rawRSSI = SPIgetRegValue(RADIOLIB_CC1101_REG_FIFO);
|
this->rawRSSI = SPIgetRegValue(RADIOLIB_CC1101_REG_FIFO);
|
||||||
|
|
||||||
// read LQI and CRC byte
|
// read LQI and CRC byte
|
||||||
uint8_t val = SPIgetRegValue(RADIOLIB_CC1101_REG_FIFO);
|
uint8_t val = SPIgetRegValue(RADIOLIB_CC1101_REG_FIFO);
|
||||||
_rawLQI = val & 0x7F;
|
this->rawLQI = val & 0x7F;
|
||||||
|
|
||||||
// check CRC
|
// check CRC
|
||||||
if (_crcOn && (val & RADIOLIB_CC1101_CRC_OK) == RADIOLIB_CC1101_CRC_ERROR) {
|
if (this->crcOn && (val & RADIOLIB_CC1101_CRC_OK) == RADIOLIB_CC1101_CRC_ERROR) {
|
||||||
_packetLengthQueried = false;
|
this->packetLengthQueried = false;
|
||||||
return (RADIOLIB_ERR_CRC_MISMATCH);
|
return (RADIOLIB_ERR_CRC_MISMATCH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear internal flag so getPacketLength can return the new packet length
|
// clear internal flag so getPacketLength can return the new packet length
|
||||||
_packetLengthQueried = false;
|
this->packetLengthQueried = false;
|
||||||
|
|
||||||
// Flush then standby according to RXOFF_MODE (default: RADIOLIB_CC1101_RXOFF_IDLE)
|
// Flush then standby according to RXOFF_MODE (default: RADIOLIB_CC1101_RXOFF_IDLE)
|
||||||
if (SPIgetRegValue(RADIOLIB_CC1101_REG_MCSM1, 3, 2) == RADIOLIB_CC1101_RXOFF_IDLE) {
|
if (SPIgetRegValue(RADIOLIB_CC1101_REG_MCSM1, 3, 2) == RADIOLIB_CC1101_RXOFF_IDLE) {
|
||||||
|
@ -455,11 +471,11 @@ int16_t CC1101::setFrequency(float freq) {
|
||||||
state |= SPIsetRegValue(RADIOLIB_CC1101_REG_FREQ0, FRF & 0x0000FF, 7, 0);
|
state |= SPIsetRegValue(RADIOLIB_CC1101_REG_FREQ0, FRF & 0x0000FF, 7, 0);
|
||||||
|
|
||||||
if(state == RADIOLIB_ERR_NONE) {
|
if(state == RADIOLIB_ERR_NONE) {
|
||||||
_freq = freq;
|
this->freq = freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the TX power accordingly to new freq. (PA values depend on chosen freq)
|
// Update the TX power accordingly to new freq. (PA values depend on chosen freq)
|
||||||
return(setOutputPower(_power));
|
return(setOutputPower(this->power));
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t CC1101::setBitRate(float br) {
|
int16_t CC1101::setBitRate(float br) {
|
||||||
|
@ -477,7 +493,7 @@ int16_t CC1101::setBitRate(float br) {
|
||||||
int16_t state = SPIsetRegValue(RADIOLIB_CC1101_REG_MDMCFG4, e, 3, 0);
|
int16_t state = SPIsetRegValue(RADIOLIB_CC1101_REG_MDMCFG4, e, 3, 0);
|
||||||
state |= SPIsetRegValue(RADIOLIB_CC1101_REG_MDMCFG3, m);
|
state |= SPIsetRegValue(RADIOLIB_CC1101_REG_MDMCFG3, m);
|
||||||
if(state == RADIOLIB_ERR_NONE) {
|
if(state == RADIOLIB_ERR_NONE) {
|
||||||
_br = br;
|
this->bitRate = br;
|
||||||
}
|
}
|
||||||
return(state);
|
return(state);
|
||||||
}
|
}
|
||||||
|
@ -536,7 +552,7 @@ int16_t CC1101::getFrequencyDeviation(float *freqDev) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// if ASK/OOK, deviation makes no sense
|
// if ASK/OOK, deviation makes no sense
|
||||||
if (_modulation == RADIOLIB_CC1101_MOD_FORMAT_ASK_OOK) {
|
if (this->modulation == RADIOLIB_CC1101_MOD_FORMAT_ASK_OOK) {
|
||||||
*freqDev = 0.0;
|
*freqDev = 0.0;
|
||||||
|
|
||||||
return(RADIOLIB_ERR_NONE);
|
return(RADIOLIB_ERR_NONE);
|
||||||
|
@ -558,13 +574,13 @@ int16_t CC1101::getFrequencyDeviation(float *freqDev) {
|
||||||
int16_t CC1101::setOutputPower(int8_t power) {
|
int16_t CC1101::setOutputPower(int8_t power) {
|
||||||
// round to the known frequency settings
|
// round to the known frequency settings
|
||||||
uint8_t f;
|
uint8_t f;
|
||||||
if(_freq < 374.0) {
|
if(this->freq < 374.0) {
|
||||||
// 315 MHz
|
// 315 MHz
|
||||||
f = 0;
|
f = 0;
|
||||||
} else if(_freq < 650.5) {
|
} else if(this->freq < 650.5) {
|
||||||
// 434 MHz
|
// 434 MHz
|
||||||
f = 1;
|
f = 1;
|
||||||
} else if(_freq < 891.5) {
|
} else if(this->freq < 891.5) {
|
||||||
// 868 MHz
|
// 868 MHz
|
||||||
f = 2;
|
f = 2;
|
||||||
} else {
|
} else {
|
||||||
|
@ -613,9 +629,9 @@ int16_t CC1101::setOutputPower(int8_t power) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// store the value
|
// store the value
|
||||||
_power = power;
|
this->power = power;
|
||||||
|
|
||||||
if(_modulation == RADIOLIB_CC1101_MOD_FORMAT_ASK_OOK){
|
if(this->modulation == RADIOLIB_CC1101_MOD_FORMAT_ASK_OOK){
|
||||||
// Amplitude modulation:
|
// Amplitude modulation:
|
||||||
// PA_TABLE[0] is the power to be used when transmitting a 0 (no power)
|
// PA_TABLE[0] is the power to be used when transmitting a 0 (no power)
|
||||||
// PA_TABLE[1] is the power to be used when transmitting a 1 (full power)
|
// PA_TABLE[1] is the power to be used when transmitting a 1 (full power)
|
||||||
|
@ -659,7 +675,7 @@ int16_t CC1101::setSyncWord(uint8_t syncH, uint8_t syncL, uint8_t maxErrBits, bo
|
||||||
return(setSyncWord(syncWord, sizeof(syncWord), maxErrBits, requireCarrierSense));
|
return(setSyncWord(syncWord, sizeof(syncWord), maxErrBits, requireCarrierSense));
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t CC1101::setPreambleLength(uint8_t preambleLength) {
|
int16_t CC1101::setPreambleLength(uint8_t preambleLength, uint8_t qualityThreshold) {
|
||||||
// check allowed values
|
// check allowed values
|
||||||
uint8_t value;
|
uint8_t value;
|
||||||
switch(preambleLength) {
|
switch(preambleLength) {
|
||||||
|
@ -691,7 +707,14 @@ int16_t CC1101::setPreambleLength(uint8_t preambleLength) {
|
||||||
return(RADIOLIB_ERR_INVALID_PREAMBLE_LENGTH);
|
return(RADIOLIB_ERR_INVALID_PREAMBLE_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(SPIsetRegValue(RADIOLIB_CC1101_REG_MDMCFG1, value, 6, 4));
|
// set preabmble quality threshold and the actual length
|
||||||
|
uint8_t pqt = qualityThreshold/4;
|
||||||
|
if(pqt > 7) {
|
||||||
|
pqt = 7;
|
||||||
|
}
|
||||||
|
int16_t state = SPIsetRegValue(RADIOLIB_CC1101_REG_PKTCTRL1, pqt << 5, 7, 5);
|
||||||
|
state |= SPIsetRegValue(RADIOLIB_CC1101_REG_MDMCFG1, value, 6, 4);
|
||||||
|
return(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t CC1101::setNodeAddress(uint8_t nodeAddr, uint8_t numBroadcastAddrs) {
|
int16_t CC1101::setNodeAddress(uint8_t nodeAddr, uint8_t numBroadcastAddrs) {
|
||||||
|
@ -727,7 +750,7 @@ int16_t CC1101::setOOK(bool enableOOK) {
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// update current modulation
|
// update current modulation
|
||||||
_modulation = RADIOLIB_CC1101_MOD_FORMAT_ASK_OOK;
|
this->modulation = RADIOLIB_CC1101_MOD_FORMAT_ASK_OOK;
|
||||||
} else {
|
} else {
|
||||||
int16_t state = SPIsetRegValue(RADIOLIB_CC1101_REG_MDMCFG2, RADIOLIB_CC1101_MOD_FORMAT_2_FSK, 6, 4);
|
int16_t state = SPIsetRegValue(RADIOLIB_CC1101_REG_MDMCFG2, RADIOLIB_CC1101_MOD_FORMAT_2_FSK, 6, 4);
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
@ -737,21 +760,21 @@ int16_t CC1101::setOOK(bool enableOOK) {
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// update current modulation
|
// update current modulation
|
||||||
_modulation = RADIOLIB_CC1101_MOD_FORMAT_2_FSK;
|
this->modulation = RADIOLIB_CC1101_MOD_FORMAT_2_FSK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update PA_TABLE values according to the new _modulation.
|
// Update PA_TABLE values according to the new this->modulation.
|
||||||
return(setOutputPower(_power));
|
return(setOutputPower(this->power));
|
||||||
}
|
}
|
||||||
|
|
||||||
float CC1101::getRSSI() {
|
float CC1101::getRSSI() {
|
||||||
float rssi;
|
float rssi;
|
||||||
|
|
||||||
if (_directMode) {
|
if (this->directModeEnabled) {
|
||||||
if(_rawRSSI >= 128) {
|
if(this->rawRSSI >= 128) {
|
||||||
rssi = (((float)_rawRSSI - 256.0)/2.0) - 74.0;
|
rssi = (((float)this->rawRSSI - 256.0)/2.0) - 74.0;
|
||||||
} else {
|
} else {
|
||||||
rssi = (((float)_rawRSSI)/2.0) - 74.0;
|
rssi = (((float)this->rawRSSI)/2.0) - 74.0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
uint8_t rawRssi = SPIreadRegister(RADIOLIB_CC1101_REG_RSSI);
|
uint8_t rawRssi = SPIreadRegister(RADIOLIB_CC1101_REG_RSSI);
|
||||||
|
@ -768,21 +791,25 @@ float CC1101::getRSSI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t CC1101::getLQI() const {
|
uint8_t CC1101::getLQI() const {
|
||||||
return(_rawLQI);
|
return(this->rawLQI);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t CC1101::getPacketLength(bool update) {
|
size_t CC1101::getPacketLength(bool update) {
|
||||||
if(!_packetLengthQueried && update) {
|
if(!this->packetLengthQueried && update) {
|
||||||
if (_packetLengthConfig == RADIOLIB_CC1101_LENGTH_CONFIG_VARIABLE) {
|
if (this->packetLengthConfig == RADIOLIB_CC1101_LENGTH_CONFIG_VARIABLE) {
|
||||||
_packetLength = SPIreadRegister(RADIOLIB_CC1101_REG_FIFO);
|
this->packetLength = 0;
|
||||||
|
while(this->packetLength == 0) {
|
||||||
|
this->packetLength = SPIreadRegister(RADIOLIB_CC1101_REG_FIFO);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_packetLength = SPIreadRegister(RADIOLIB_CC1101_REG_PKTLEN);
|
this->packetLength = SPIreadRegister(RADIOLIB_CC1101_REG_PKTLEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
_packetLengthQueried = true;
|
this->packetLengthQueried = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(_packetLength);
|
return(this->packetLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t CC1101::fixedPacketLengthMode(uint8_t len) {
|
int16_t CC1101::fixedPacketLengthMode(uint8_t len) {
|
||||||
|
@ -794,20 +821,27 @@ int16_t CC1101::variablePacketLengthMode(uint8_t maxLen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t CC1101::enableSyncWordFiltering(uint8_t maxErrBits, bool requireCarrierSense) {
|
int16_t CC1101::enableSyncWordFiltering(uint8_t maxErrBits, bool requireCarrierSense) {
|
||||||
|
int16_t state = RADIOLIB_ERR_NONE;
|
||||||
|
|
||||||
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(RADIOLIB_CC1101_REG_MDMCFG2, (requireCarrierSense ? RADIOLIB_CC1101_SYNC_MODE_16_16_THR : RADIOLIB_CC1101_SYNC_MODE_16_16), 2, 0));
|
state |= SPIsetRegValue(RADIOLIB_CC1101_REG_MDMCFG2, (requireCarrierSense ? RADIOLIB_CC1101_SYNC_MODE_16_16_THR : RADIOLIB_CC1101_SYNC_MODE_16_16), 2, 0);
|
||||||
|
break;
|
||||||
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(RADIOLIB_CC1101_REG_MDMCFG2, (requireCarrierSense ? RADIOLIB_CC1101_SYNC_MODE_15_16_THR : RADIOLIB_CC1101_SYNC_MODE_15_16), 2, 0));
|
state |= SPIsetRegValue(RADIOLIB_CC1101_REG_MDMCFG2, (requireCarrierSense ? RADIOLIB_CC1101_SYNC_MODE_15_16_THR : RADIOLIB_CC1101_SYNC_MODE_15_16), 2, 0);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return(RADIOLIB_ERR_INVALID_SYNC_WORD);
|
state = RADIOLIB_ERR_INVALID_SYNC_WORD;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
return(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t CC1101::disableSyncWordFiltering(bool requireCarrierSense) {
|
int16_t CC1101::disableSyncWordFiltering(bool requireCarrierSense) {
|
||||||
return(SPIsetRegValue(RADIOLIB_CC1101_REG_MDMCFG2, (requireCarrierSense ? RADIOLIB_CC1101_SYNC_MODE_NONE_THR : RADIOLIB_CC1101_SYNC_MODE_NONE), 2, 0));
|
int16_t state = SPIsetRegValue(RADIOLIB_CC1101_REG_MDMCFG2, (requireCarrierSense ? RADIOLIB_CC1101_SYNC_MODE_NONE_THR : RADIOLIB_CC1101_SYNC_MODE_NONE), 2, 0);
|
||||||
|
return(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t CC1101::setCrcFiltering(bool crcOn) {
|
int16_t CC1101::setCrcFiltering(bool crcOn) {
|
||||||
|
@ -820,14 +854,14 @@ int16_t CC1101::setCrcFiltering(bool crcOn) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t CC1101::setPromiscuousMode(bool promiscuous) {
|
int16_t CC1101::setPromiscuousMode(bool enable) {
|
||||||
int16_t state = RADIOLIB_ERR_NONE;
|
int16_t state = RADIOLIB_ERR_NONE;
|
||||||
|
|
||||||
if (_promiscuous == promiscuous) {
|
if(this->promiscuous == enable) {
|
||||||
return(state);
|
return(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (promiscuous == true) {
|
if(enable) {
|
||||||
// disable sync word filtering and insertion
|
// disable sync word filtering and insertion
|
||||||
// this also disables preamble
|
// this also disables preamble
|
||||||
state = disableSyncWordFiltering();
|
state = disableSyncWordFiltering();
|
||||||
|
@ -836,7 +870,7 @@ int16_t CC1101::setPromiscuousMode(bool promiscuous) {
|
||||||
// disable CRC filtering
|
// disable CRC filtering
|
||||||
state = setCrcFiltering(false);
|
state = setCrcFiltering(false);
|
||||||
} else {
|
} else {
|
||||||
state = setPreambleLength(RADIOLIB_CC1101_DEFAULT_PREAMBLELEN);
|
state = setPreambleLength(RADIOLIB_CC1101_DEFAULT_PREAMBLELEN, RADIOLIB_CC1101_DEFAULT_PREAMBLELEN/4);
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// enable sync word filtering and insertion
|
// enable sync word filtering and insertion
|
||||||
|
@ -847,13 +881,13 @@ int16_t CC1101::setPromiscuousMode(bool promiscuous) {
|
||||||
state = setCrcFiltering(true);
|
state = setCrcFiltering(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
_promiscuous = promiscuous;
|
this->promiscuous = enable;
|
||||||
|
|
||||||
return(state);
|
return(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CC1101::getPromiscuousMode() {
|
bool CC1101::getPromiscuousMode() {
|
||||||
return (_promiscuous);
|
return (this->promiscuous);
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t CC1101::setDataShaping(uint8_t sh) {
|
int16_t CC1101::setDataShaping(uint8_t sh) {
|
||||||
|
@ -900,11 +934,11 @@ int16_t CC1101::setEncoding(uint8_t encoding) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CC1101::setRfSwitchPins(uint32_t rxEn, uint32_t txEn) {
|
void CC1101::setRfSwitchPins(uint32_t rxEn, uint32_t txEn) {
|
||||||
_mod->setRfSwitchPins(rxEn, txEn);
|
this->mod->setRfSwitchPins(rxEn, txEn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CC1101::setRfSwitchTable(const uint32_t (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]) {
|
void CC1101::setRfSwitchTable(const uint32_t (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]) {
|
||||||
_mod->setRfSwitchTable(pins, table);
|
this->mod->setRfSwitchTable(pins, table);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t CC1101::randomByte() {
|
uint8_t CC1101::randomByte() {
|
||||||
|
@ -913,7 +947,7 @@ uint8_t CC1101::randomByte() {
|
||||||
RADIOLIB_DEBUG_PRINTLN("CC1101::randomByte");
|
RADIOLIB_DEBUG_PRINTLN("CC1101::randomByte");
|
||||||
|
|
||||||
// wait a bit for the RSSI reading to stabilise
|
// wait a bit for the RSSI reading to stabilise
|
||||||
_mod->hal->delay(10);
|
this->mod->hal->delay(10);
|
||||||
|
|
||||||
// read RSSI value 8 times, always keep just the least significant bit
|
// read RSSI value 8 times, always keep just the least significant bit
|
||||||
uint8_t randByte = 0x00;
|
uint8_t randByte = 0x00;
|
||||||
|
@ -933,30 +967,39 @@ int16_t CC1101::getChipVersion() {
|
||||||
|
|
||||||
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
|
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
|
||||||
void CC1101::setDirectAction(void (*func)(void)) {
|
void CC1101::setDirectAction(void (*func)(void)) {
|
||||||
setGdo0Action(func, _mod->hal->GpioInterruptRising);
|
setGdo0Action(func, this->mod->hal->GpioInterruptRising);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CC1101::readBit(uint32_t pin) {
|
void CC1101::readBit(uint32_t pin) {
|
||||||
updateDirectBuffer((uint8_t)_mod->hal->digitalRead(pin));
|
updateDirectBuffer((uint8_t)this->mod->hal->digitalRead(pin));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int16_t CC1101::setDIOMapping(uint32_t pin, uint32_t value) {
|
int16_t CC1101::setDIOMapping(uint32_t pin, uint32_t value) {
|
||||||
if (pin > 2)
|
if(pin > 2) {
|
||||||
return RADIOLIB_ERR_INVALID_DIO_PIN;
|
return(RADIOLIB_ERR_INVALID_DIO_PIN);
|
||||||
|
}
|
||||||
|
|
||||||
return(SPIsetRegValue(RADIOLIB_CC1101_REG_IOCFG0 - pin, value));
|
return(SPIsetRegValue(RADIOLIB_CC1101_REG_IOCFG0 - pin, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t CC1101::config() {
|
int16_t CC1101::config() {
|
||||||
// Reset the radio. Registers may be dirty from previous usage.
|
// Reset the radio. Registers may be dirty from previous usage.
|
||||||
SPIsendCommand(RADIOLIB_CC1101_CMD_RESET);
|
reset();
|
||||||
|
|
||||||
// Wait a ridiculous amount of time to be sure radio is ready.
|
// Wait a ridiculous amount of time to be sure radio is ready.
|
||||||
_mod->hal->delay(150);
|
this->mod->hal->delay(150);
|
||||||
|
|
||||||
// enable automatic frequency synthesizer calibration
|
standby();
|
||||||
|
|
||||||
|
// enable automatic frequency synthesizer calibration and disable pin control
|
||||||
int16_t state = SPIsetRegValue(RADIOLIB_CC1101_REG_MCSM0, RADIOLIB_CC1101_FS_AUTOCAL_IDLE_TO_RXTX, 5, 4);
|
int16_t state = SPIsetRegValue(RADIOLIB_CC1101_REG_MCSM0, RADIOLIB_CC1101_FS_AUTOCAL_IDLE_TO_RXTX, 5, 4);
|
||||||
|
state |= SPIsetRegValue(RADIOLIB_CC1101_REG_MCSM0, RADIOLIB_CC1101_PIN_CTRL_OFF, 1, 1);
|
||||||
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
|
// set GDOs to Hi-Z so that it doesn't output clock on startup (might confuse GDO0 action)
|
||||||
|
state = SPIsetRegValue(RADIOLIB_CC1101_REG_IOCFG0, RADIOLIB_CC1101_GDOX_HIGH_Z, 5, 0);
|
||||||
|
state |= SPIsetRegValue(RADIOLIB_CC1101_REG_IOCFG2, RADIOLIB_CC1101_GDOX_HIGH_Z, 5, 0);
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// set packet mode
|
// set packet mode
|
||||||
|
@ -970,7 +1013,7 @@ int16_t CC1101::directMode(bool sync) {
|
||||||
SPIsendCommand(RADIOLIB_CC1101_CMD_IDLE);
|
SPIsendCommand(RADIOLIB_CC1101_CMD_IDLE);
|
||||||
|
|
||||||
int16_t state = 0;
|
int16_t state = 0;
|
||||||
_directMode = sync;
|
this->directModeEnabled = sync;
|
||||||
if(sync) {
|
if(sync) {
|
||||||
// set GDO0 and GDO2 mapping
|
// set GDO0 and GDO2 mapping
|
||||||
state |= SPIsetRegValue(RADIOLIB_CC1101_REG_IOCFG0, RADIOLIB_CC1101_GDOX_SERIAL_CLOCK , 5, 0);
|
state |= SPIsetRegValue(RADIOLIB_CC1101_REG_IOCFG0, RADIOLIB_CC1101_GDOX_SERIAL_CLOCK , 5, 0);
|
||||||
|
@ -978,8 +1021,7 @@ int16_t CC1101::directMode(bool sync) {
|
||||||
|
|
||||||
// set continuous mode
|
// set continuous mode
|
||||||
state |= SPIsetRegValue(RADIOLIB_CC1101_REG_PKTCTRL0, RADIOLIB_CC1101_PKT_FORMAT_SYNCHRONOUS, 5, 4);
|
state |= SPIsetRegValue(RADIOLIB_CC1101_REG_PKTCTRL0, RADIOLIB_CC1101_PKT_FORMAT_SYNCHRONOUS, 5, 4);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// set GDO0 mapping
|
// set GDO0 mapping
|
||||||
state |= SPIsetRegValue(RADIOLIB_CC1101_REG_IOCFG0, RADIOLIB_CC1101_GDOX_SERIAL_DATA_ASYNC , 5, 0);
|
state |= SPIsetRegValue(RADIOLIB_CC1101_REG_IOCFG0, RADIOLIB_CC1101_GDOX_SERIAL_DATA_ASYNC , 5, 0);
|
||||||
|
|
||||||
|
@ -1032,8 +1074,8 @@ int16_t CC1101::setPacketMode(uint8_t mode, uint16_t len) {
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// update the cached value
|
// update the cached value
|
||||||
_packetLength = len;
|
this->packetLength = len;
|
||||||
_packetLengthConfig = mode;
|
this->packetLengthConfig = mode;
|
||||||
return(state);
|
return(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1043,7 +1085,7 @@ int16_t CC1101::SPIgetRegValue(uint8_t reg, uint8_t msb, uint8_t lsb) {
|
||||||
reg |= RADIOLIB_CC1101_CMD_ACCESS_STATUS_REG;
|
reg |= RADIOLIB_CC1101_CMD_ACCESS_STATUS_REG;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(_mod->SPIgetRegValue(reg, msb, lsb));
|
return(this->mod->SPIgetRegValue(reg, msb, lsb));
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t CC1101::SPIsetRegValue(uint8_t reg, uint8_t value, uint8_t msb, uint8_t lsb, uint8_t checkInterval) {
|
int16_t CC1101::SPIsetRegValue(uint8_t reg, uint8_t value, uint8_t msb, uint8_t lsb, uint8_t checkInterval) {
|
||||||
|
@ -1052,11 +1094,11 @@ int16_t CC1101::SPIsetRegValue(uint8_t reg, uint8_t value, uint8_t msb, uint8_t
|
||||||
reg |= RADIOLIB_CC1101_CMD_ACCESS_STATUS_REG;
|
reg |= RADIOLIB_CC1101_CMD_ACCESS_STATUS_REG;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(_mod->SPIsetRegValue(reg, value, msb, lsb, checkInterval));
|
return(this->mod->SPIsetRegValue(reg, value, msb, lsb, checkInterval));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CC1101::SPIreadRegisterBurst(uint8_t reg, uint8_t numBytes, uint8_t* inBytes) {
|
void CC1101::SPIreadRegisterBurst(uint8_t reg, uint8_t numBytes, uint8_t* inBytes) {
|
||||||
_mod->SPIreadRegisterBurst(reg | RADIOLIB_CC1101_CMD_BURST, numBytes, inBytes);
|
this->mod->SPIreadRegisterBurst(reg | RADIOLIB_CC1101_CMD_BURST, numBytes, inBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t CC1101::SPIreadRegister(uint8_t reg) {
|
uint8_t CC1101::SPIreadRegister(uint8_t reg) {
|
||||||
|
@ -1065,7 +1107,7 @@ uint8_t CC1101::SPIreadRegister(uint8_t reg) {
|
||||||
reg |= RADIOLIB_CC1101_CMD_ACCESS_STATUS_REG;
|
reg |= RADIOLIB_CC1101_CMD_ACCESS_STATUS_REG;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(_mod->SPIreadRegister(reg));
|
return(this->mod->SPIreadRegister(reg));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CC1101::SPIwriteRegister(uint8_t reg, uint8_t data) {
|
void CC1101::SPIwriteRegister(uint8_t reg, uint8_t data) {
|
||||||
|
@ -1074,26 +1116,28 @@ void CC1101::SPIwriteRegister(uint8_t reg, uint8_t data) {
|
||||||
reg |= RADIOLIB_CC1101_CMD_ACCESS_STATUS_REG;
|
reg |= RADIOLIB_CC1101_CMD_ACCESS_STATUS_REG;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(_mod->SPIwriteRegister(reg, data));
|
return(this->mod->SPIwriteRegister(reg, data));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CC1101::SPIwriteRegisterBurst(uint8_t reg, uint8_t* data, size_t len) {
|
void CC1101::SPIwriteRegisterBurst(uint8_t reg, uint8_t* data, size_t len) {
|
||||||
_mod->SPIwriteRegisterBurst(reg | RADIOLIB_CC1101_CMD_BURST, data, len);
|
this->mod->SPIwriteRegisterBurst(reg | RADIOLIB_CC1101_CMD_BURST, data, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CC1101::SPIsendCommand(uint8_t cmd) {
|
void CC1101::SPIsendCommand(uint8_t cmd) {
|
||||||
// pull NSS low
|
// pull NSS low
|
||||||
_mod->hal->digitalWrite(_mod->getCs(), _mod->hal->GpioLevelLow);
|
this->mod->hal->digitalWrite(this->mod->getCs(), this->mod->hal->GpioLevelLow);
|
||||||
|
|
||||||
// start transfer
|
// start transfer
|
||||||
_mod->hal->spiBeginTransaction();
|
this->mod->hal->spiBeginTransaction();
|
||||||
|
|
||||||
// send the command byte
|
// send the command byte
|
||||||
_mod->hal->spiTransfer(cmd);
|
uint8_t status = this->mod->hal->spiTransfer(cmd);
|
||||||
|
|
||||||
// stop transfer
|
// stop transfer
|
||||||
_mod->hal->spiEndTransaction();
|
this->mod->hal->spiEndTransaction();
|
||||||
_mod->hal->digitalWrite(_mod->getCs(), _mod->hal->GpioLevelHigh);
|
this->mod->hal->digitalWrite(this->mod->getCs(), this->mod->hal->GpioLevelHigh);
|
||||||
|
RADIOLIB_VERBOSE_PRINTLN("CMD\tW\t%02X\t%02X", cmd, status);
|
||||||
|
(void)status;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -99,30 +99,42 @@
|
||||||
#define RADIOLIB_CC1101_REG_PATABLE 0x3E
|
#define RADIOLIB_CC1101_REG_PATABLE 0x3E
|
||||||
#define RADIOLIB_CC1101_REG_FIFO 0x3F
|
#define RADIOLIB_CC1101_REG_FIFO 0x3F
|
||||||
|
|
||||||
// CC1101_REG_IOCFG2 MSB LSB DESCRIPTION
|
// status byte (returned during SPI transactions) MSB LSB DESCRIPTION
|
||||||
|
#define RADIOLIB_CC1101_STATUS_CHIP_READY 0b00000000 // 7 7 chip ready
|
||||||
|
#define RADIOLIB_CC1101_STATUS_CHIP_NOT_READY 0b10000000 // 7 7 chip not ready (power/crystal not stable)
|
||||||
|
#define RADIOLIB_CC1101_STATUS_IDLE 0b00000000 // 6 4 idle
|
||||||
|
#define RADIOLIB_CC1101_STATUS_RX 0b00010000 // 6 4 Rx
|
||||||
|
#define RADIOLIB_CC1101_STATUS_TX 0b00100000 // 6 4 Tx
|
||||||
|
#define RADIOLIB_CC1101_STATUS_FSTXON 0b00110000 // 6 4 Fast Tx ready
|
||||||
|
#define RADIOLIB_CC1101_STATUS_CALIBRATE 0b01000000 // 6 4 synthesizer calibration running
|
||||||
|
#define RADIOLIB_CC1101_STATUS_SETTLING 0b01010000 // 6 4 PLL settling
|
||||||
|
#define RADIOLIB_CC1101_STATUS_RXFIFO_OVERFLOW 0b01100000 // 6 4 Rx FIFO overflow
|
||||||
|
#define RADIOLIB_CC1101_STATUS_TXFIFO_UNDERFLOW 0b01110000 // 6 4 Tx FIFO underflow
|
||||||
|
|
||||||
|
// RADIOLIB_CC1101_REG_IOCFG2
|
||||||
#define RADIOLIB_CC1101_GDO2_NORM 0b00000000 // 6 6 GDO2 output: active high (default)
|
#define RADIOLIB_CC1101_GDO2_NORM 0b00000000 // 6 6 GDO2 output: active high (default)
|
||||||
#define RADIOLIB_CC1101_GDO2_INV 0b01000000 // 6 6 active low
|
#define RADIOLIB_CC1101_GDO2_INV 0b01000000 // 6 6 active low
|
||||||
|
|
||||||
// CC1101_REG_IOCFG1
|
// RADIOLIB_CC1101_REG_IOCFG1
|
||||||
#define RADIOLIB_CC1101_GDO1_DS_LOW 0b00000000 // 7 7 GDO1 output drive strength: low (default)
|
#define RADIOLIB_CC1101_GDO1_DS_LOW 0b00000000 // 7 7 GDO1 output drive strength: low (default)
|
||||||
#define RADIOLIB_CC1101_GDO1_DS_HIGH 0b10000000 // 7 7 high
|
#define RADIOLIB_CC1101_GDO1_DS_HIGH 0b10000000 // 7 7 high
|
||||||
#define RADIOLIB_CC1101_GDO1_NORM 0b00000000 // 6 6 GDO1 output: active high (default)
|
#define RADIOLIB_CC1101_GDO1_NORM 0b00000000 // 6 6 GDO1 output: active high (default)
|
||||||
#define RADIOLIB_CC1101_GDO1_INV 0b01000000 // 6 6 active low
|
#define RADIOLIB_CC1101_GDO1_INV 0b01000000 // 6 6 active low
|
||||||
|
|
||||||
// CC1101_REG_IOCFG0
|
// RADIOLIB_CC1101_REG_IOCFG0
|
||||||
#define RADIOLIB_CC1101_GDO0_TEMP_SENSOR_OFF 0b00000000 // 7 7 analog temperature sensor output: disabled (default)
|
#define RADIOLIB_CC1101_GDO0_TEMP_SENSOR_OFF 0b00000000 // 7 7 analog temperature sensor output: disabled (default)
|
||||||
#define RADIOLIB_CC1101_GDO0_TEMP_SENSOR_ON 0b10000000 // 7 7 enabled
|
#define RADIOLIB_CC1101_GDO0_TEMP_SENSOR_ON 0b10000000 // 7 7 enabled
|
||||||
#define RADIOLIB_CC1101_GDO0_NORM 0b00000000 // 6 6 GDO0 output: active high (default)
|
#define RADIOLIB_CC1101_GDO0_NORM 0b00000000 // 6 6 GDO0 output: active high (default)
|
||||||
#define RADIOLIB_CC1101_GDO0_INV 0b01000000 // 6 6 active low
|
#define RADIOLIB_CC1101_GDO0_INV 0b01000000 // 6 6 active low
|
||||||
|
|
||||||
// CC1101_REG_IOCFG2 + REG_IOCFG1 + REG_IOCFG0
|
// RADIOLIB_CC1101_REG_IOCFG2 + REG_IOCFG1 + REG_IOCFG0
|
||||||
#define RADIOLIB_CC1101_GDOX_RX_FIFO_FULL 0x00 // 5 0 Rx FIFO full or above threshold
|
#define RADIOLIB_CC1101_GDOX_RX_FIFO_FULL 0x00 // 5 0 Rx FIFO full or above threshold
|
||||||
#define RADIOLIB_CC1101_GDOX_RX_FIFO_FULL_OR_PKT_END 0x01 // 5 0 Rx FIFO full or above threshold or reached packet end
|
#define RADIOLIB_CC1101_GDOX_RX_FIFO_FULL_OR_PKT_END 0x01 // 5 0 Rx FIFO full or above threshold or reached packet end
|
||||||
#define RADIOLIB_CC1101_GDOX_TX_FIFO_ABOVE_THR 0x02 // 5 0 Tx FIFO above threshold
|
#define RADIOLIB_CC1101_GDOX_TX_FIFO_ABOVE_THR 0x02 // 5 0 Tx FIFO above threshold
|
||||||
#define RADIOLIB_CC1101_GDOX_TX_FIFO_FULL 0x03 // 5 0 Tx FIFO full
|
#define RADIOLIB_CC1101_GDOX_TX_FIFO_FULL 0x03 // 5 0 Tx FIFO full
|
||||||
#define RADIOLIB_CC1101_GDOX_RX_FIFO_OVERFLOW 0x04 // 5 0 Rx FIFO overflowed
|
#define RADIOLIB_CC1101_GDOX_RX_FIFO_OVERFLOW 0x04 // 5 0 Rx FIFO overflowed
|
||||||
#define RADIOLIB_CC1101_GDOX_TX_FIFO_UNDERFLOW 0x05 // 5 0 Tx FIFO underflowed
|
#define RADIOLIB_CC1101_GDOX_TX_FIFO_UNDERFLOW 0x05 // 5 0 Tx FIFO underflowed
|
||||||
#define RADIOLIB_CC1101_GDOX_SYNC_WORD_SENT_OR_RECEIVED 0x06 // 5 0 sync word was sent or received
|
#define RADIOLIB_CC1101_GDOX_SYNC_WORD_SENT_OR_PKT_RECEIVED 0x06 // 5 0 sync word was sent or packet was received
|
||||||
#define RADIOLIB_CC1101_GDOX_PKT_RECEIVED_CRC_OK 0x07 // 5 0 packet received and CRC check passed
|
#define RADIOLIB_CC1101_GDOX_PKT_RECEIVED_CRC_OK 0x07 // 5 0 packet received and CRC check passed
|
||||||
#define RADIOLIB_CC1101_GDOX_PREAMBLE_QUALITY_REACHED 0x08 // 5 0 received preamble quality is above threshold
|
#define RADIOLIB_CC1101_GDOX_PREAMBLE_QUALITY_REACHED 0x08 // 5 0 received preamble quality is above threshold
|
||||||
#define RADIOLIB_CC1101_GDOX_CHANNEL_CLEAR 0x09 // 5 0 RSSI level below threshold (channel is clear)
|
#define RADIOLIB_CC1101_GDOX_CHANNEL_CLEAR 0x09 // 5 0 RSSI level below threshold (channel is clear)
|
||||||
|
@ -162,7 +174,7 @@
|
||||||
#define RADIOLIB_CC1101_GDOX_CLOCK_XOSC_128 0x3E // 5 0 f = f(XOSC)/128
|
#define RADIOLIB_CC1101_GDOX_CLOCK_XOSC_128 0x3E // 5 0 f = f(XOSC)/128
|
||||||
#define RADIOLIB_CC1101_GDOX_CLOCK_XOSC_192 0x3F // 5 0 f = f(XOSC)/192 (default for GDO0)
|
#define RADIOLIB_CC1101_GDOX_CLOCK_XOSC_192 0x3F // 5 0 f = f(XOSC)/192 (default for GDO0)
|
||||||
|
|
||||||
// CC1101_REG_FIFOTHR
|
// RADIOLIB_CC1101_REG_FIFOTHR
|
||||||
#define RADIOLIB_CC1101_ADC_RETENTION_OFF 0b00000000 // 6 6 do not retain ADC settings in sleep mode (default)
|
#define RADIOLIB_CC1101_ADC_RETENTION_OFF 0b00000000 // 6 6 do not retain ADC settings in sleep mode (default)
|
||||||
#define RADIOLIB_CC1101_ADC_RETENTION_ON 0b01000000 // 6 6 retain ADC settings in sleep mode
|
#define RADIOLIB_CC1101_ADC_RETENTION_ON 0b01000000 // 6 6 retain ADC settings in sleep mode
|
||||||
#define RADIOLIB_CC1101_RX_ATTEN_0_DB 0b00000000 // 5 4 Rx attenuation: 0 dB (default)
|
#define RADIOLIB_CC1101_RX_ATTEN_0_DB 0b00000000 // 5 4 Rx attenuation: 0 dB (default)
|
||||||
|
@ -170,17 +182,20 @@
|
||||||
#define RADIOLIB_CC1101_RX_ATTEN_12_DB 0b00100000 // 5 4 12 dB
|
#define RADIOLIB_CC1101_RX_ATTEN_12_DB 0b00100000 // 5 4 12 dB
|
||||||
#define RADIOLIB_CC1101_RX_ATTEN_18_DB 0b00110000 // 5 4 18 dB
|
#define RADIOLIB_CC1101_RX_ATTEN_18_DB 0b00110000 // 5 4 18 dB
|
||||||
#define RADIOLIB_CC1101_FIFO_THR_TX_61_RX_4 0b00000000 // 3 0 TX fifo threshold: 61, RX fifo threshold: 4
|
#define RADIOLIB_CC1101_FIFO_THR_TX_61_RX_4 0b00000000 // 3 0 TX fifo threshold: 61, RX fifo threshold: 4
|
||||||
|
#define RADIOLIB_CC1101_FIFO_THR_TX_33_RX_32 0b00000111 // 3 0 TX fifo threshold: 33, RX fifo threshold: 32
|
||||||
|
#define RADIOLIB_CC1101_FIFO_THRESH_TX 33
|
||||||
|
#define RADIOLIB_CC1101_FIFO_THRESH_RX 32
|
||||||
|
|
||||||
// CC1101_REG_SYNC1
|
// RADIOLIB_CC1101_REG_SYNC1
|
||||||
#define RADIOLIB_CC1101_SYNC_WORD_MSB 0xD3 // 7 0 sync word MSB
|
#define RADIOLIB_CC1101_SYNC_WORD_MSB 0xD3 // 7 0 sync word MSB
|
||||||
|
|
||||||
// CC1101_REG_SYNC0
|
// RADIOLIB_CC1101_REG_SYNC0
|
||||||
#define RADIOLIB_CC1101_SYNC_WORD_LSB 0x91 // 7 0 sync word LSB
|
#define RADIOLIB_CC1101_SYNC_WORD_LSB 0x91 // 7 0 sync word LSB
|
||||||
|
|
||||||
// CC1101_REG_PKTLEN
|
// RADIOLIB_CC1101_REG_PKTLEN
|
||||||
#define RADIOLIB_CC1101_PACKET_LENGTH 0xFF // 7 0 packet length in bytes
|
#define RADIOLIB_CC1101_PACKET_LENGTH 0xFF // 7 0 packet length in bytes
|
||||||
|
|
||||||
// CC1101_REG_PKTCTRL1
|
// RADIOLIB_CC1101_REG_PKTCTRL1
|
||||||
#define RADIOLIB_CC1101_PQT 0x00 // 7 5 preamble quality threshold
|
#define RADIOLIB_CC1101_PQT 0x00 // 7 5 preamble quality threshold
|
||||||
#define RADIOLIB_CC1101_CRC_AUTOFLUSH_OFF 0b00000000 // 3 3 automatic Rx FIFO flush on CRC check fail: disabled (default)
|
#define RADIOLIB_CC1101_CRC_AUTOFLUSH_OFF 0b00000000 // 3 3 automatic Rx FIFO flush on CRC check fail: disabled (default)
|
||||||
#define RADIOLIB_CC1101_CRC_AUTOFLUSH_ON 0b00001000 // 3 3 enabled
|
#define RADIOLIB_CC1101_CRC_AUTOFLUSH_ON 0b00001000 // 3 3 enabled
|
||||||
|
@ -191,7 +206,7 @@
|
||||||
#define RADIOLIB_CC1101_ADR_CHK_SINGLE_BROADCAST 0b00000010 // 1 0 broadcast address 0x00
|
#define RADIOLIB_CC1101_ADR_CHK_SINGLE_BROADCAST 0b00000010 // 1 0 broadcast address 0x00
|
||||||
#define RADIOLIB_CC1101_ADR_CHK_DOUBLE_BROADCAST 0b00000011 // 1 0 broadcast addresses 0x00 and 0xFF
|
#define RADIOLIB_CC1101_ADR_CHK_DOUBLE_BROADCAST 0b00000011 // 1 0 broadcast addresses 0x00 and 0xFF
|
||||||
|
|
||||||
// CC1101_REG_PKTCTRL0
|
// RADIOLIB_CC1101_REG_PKTCTRL0
|
||||||
#define RADIOLIB_CC1101_WHITE_DATA_OFF 0b00000000 // 6 6 data whitening: disabled
|
#define RADIOLIB_CC1101_WHITE_DATA_OFF 0b00000000 // 6 6 data whitening: disabled
|
||||||
#define RADIOLIB_CC1101_WHITE_DATA_ON 0b01000000 // 6 6 enabled (default)
|
#define RADIOLIB_CC1101_WHITE_DATA_ON 0b01000000 // 6 6 enabled (default)
|
||||||
#define RADIOLIB_CC1101_PKT_FORMAT_NORMAL 0b00000000 // 5 4 packet format: normal (FIFOs)
|
#define RADIOLIB_CC1101_PKT_FORMAT_NORMAL 0b00000000 // 5 4 packet format: normal (FIFOs)
|
||||||
|
@ -204,32 +219,32 @@
|
||||||
#define RADIOLIB_CC1101_LENGTH_CONFIG_VARIABLE 0b00000001 // 1 0 variable (default)
|
#define RADIOLIB_CC1101_LENGTH_CONFIG_VARIABLE 0b00000001 // 1 0 variable (default)
|
||||||
#define RADIOLIB_CC1101_LENGTH_CONFIG_INFINITE 0b00000010 // 1 0 infinite
|
#define RADIOLIB_CC1101_LENGTH_CONFIG_INFINITE 0b00000010 // 1 0 infinite
|
||||||
|
|
||||||
// CC1101_REG_ADDR
|
// RADIOLIB_CC1101_REG_ADDR
|
||||||
#define RADIOLIB_CC1101_DEVICE_ADDR 0x00 // 7 0 device address
|
#define RADIOLIB_CC1101_DEVICE_ADDR 0x00 // 7 0 device address
|
||||||
|
|
||||||
// CC1101_REG_CHANNR
|
// RADIOLIB_CC1101_REG_CHANNR
|
||||||
#define RADIOLIB_CC1101_CHAN 0x00 // 7 0 channel number
|
#define RADIOLIB_CC1101_CHAN 0x00 // 7 0 channel number
|
||||||
|
|
||||||
// CC1101_REG_FSCTRL1
|
// RADIOLIB_CC1101_REG_FSCTRL1
|
||||||
#define RADIOLIB_CC1101_FREQ_IF 0x0F // 4 0 IF frequency setting; f_IF = (f(XOSC) / 2^10) * CC1101_FREQ_IF
|
#define RADIOLIB_CC1101_FREQ_IF 0x0F // 4 0 IF frequency setting; f_IF = (f(XOSC) / 2^10) * CC1101_FREQ_IF
|
||||||
|
|
||||||
// CC1101_REG_FSCTRL0
|
// CC1101_REG_FSCTRL0
|
||||||
#define RADIOLIB_CC1101_FREQOFF 0x00 // 7 0 base frequency offset (2s-compliment)
|
#define RADIOLIB_CC1101_FREQOFF 0x00 // 7 0 base frequency offset (2s-compliment)
|
||||||
|
|
||||||
// CC1101_REG_FREQ2 + REG_FREQ1 + REG_FREQ0
|
// RADIOLIB_CC1101_REG_FREQ2 + REG_FREQ1 + REG_FREQ0
|
||||||
#define RADIOLIB_CC1101_FREQ_MSB 0x1E // 5 0 base frequency setting: f_carrier = (f(XOSC) / 2^16) * FREQ
|
#define RADIOLIB_CC1101_FREQ_MSB 0x1E // 5 0 base frequency setting: f_carrier = (f(XOSC) / 2^16) * FREQ
|
||||||
#define RADIOLIB_CC1101_FREQ_MID 0xC4 // 7 0 where f(XOSC) = 26 MHz
|
#define RADIOLIB_CC1101_FREQ_MID 0xC4 // 7 0 where f(XOSC) = 26 MHz
|
||||||
#define RADIOLIB_CC1101_FREQ_LSB 0xEC // 7 0 FREQ = 3-byte value of FREQ registers
|
#define RADIOLIB_CC1101_FREQ_LSB 0xEC // 7 0 FREQ = 3-byte value of FREQ registers
|
||||||
|
|
||||||
// CC1101_REG_MDMCFG4
|
// RADIOLIB_CC1101_REG_MDMCFG4
|
||||||
#define RADIOLIB_CC1101_CHANBW_E 0b10000000 // 7 6 channel bandwidth: BW_channel = f(XOSC) / (8 * (4 + CHANBW_M)*2^CHANBW_E) [Hz]
|
#define RADIOLIB_CC1101_CHANBW_E 0b10000000 // 7 6 channel bandwidth: BW_channel = f(XOSC) / (8 * (4 + CHANBW_M)*2^CHANBW_E) [Hz]
|
||||||
#define RADIOLIB_CC1101_CHANBW_M 0b00000000 // 5 4 default value for 26 MHz crystal: 203 125 Hz
|
#define RADIOLIB_CC1101_CHANBW_M 0b00000000 // 5 4 default value for 26 MHz crystal: 203 125 Hz
|
||||||
#define RADIOLIB_CC1101_DRATE_E 0x0C // 3 0 symbol rate: R_data = (((256 + DRATE_M) * 2^DRATE_E) / 2^28) * f(XOSC) [Baud]
|
#define RADIOLIB_CC1101_DRATE_E 0x0C // 3 0 symbol rate: R_data = (((256 + DRATE_M) * 2^DRATE_E) / 2^28) * f(XOSC) [Baud]
|
||||||
|
|
||||||
// CC1101_REG_MDMCFG3
|
// RADIOLIB_CC1101_REG_MDMCFG3
|
||||||
#define RADIOLIB_CC1101_DRATE_M 0x22 // 7 0 default value for 26 MHz crystal: 115 051 Baud
|
#define RADIOLIB_CC1101_DRATE_M 0x22 // 7 0 default value for 26 MHz crystal: 115 051 Baud
|
||||||
|
|
||||||
// CC1101_REG_MDMCFG2
|
// RADIOLIB_CC1101_REG_MDMCFG2
|
||||||
#define RADIOLIB_CC1101_DEM_DCFILT_OFF 0b10000000 // 7 7 digital DC filter: disabled
|
#define RADIOLIB_CC1101_DEM_DCFILT_OFF 0b10000000 // 7 7 digital DC filter: disabled
|
||||||
#define RADIOLIB_CC1101_DEM_DCFILT_ON 0b00000000 // 7 7 enabled - only for data rates above 250 kBaud (default)
|
#define RADIOLIB_CC1101_DEM_DCFILT_ON 0b00000000 // 7 7 enabled - only for data rates above 250 kBaud (default)
|
||||||
#define RADIOLIB_CC1101_MOD_FORMAT_2_FSK 0b00000000 // 6 4 modulation format: 2-FSK (default)
|
#define RADIOLIB_CC1101_MOD_FORMAT_2_FSK 0b00000000 // 6 4 modulation format: 2-FSK (default)
|
||||||
|
@ -248,7 +263,7 @@
|
||||||
#define RADIOLIB_CC1101_SYNC_MODE_16_16_THR 0b00000110 // 2 0 16/16 sync word bits, carrier sense above threshold
|
#define RADIOLIB_CC1101_SYNC_MODE_16_16_THR 0b00000110 // 2 0 16/16 sync word bits, carrier sense above threshold
|
||||||
#define RADIOLIB_CC1101_SYNC_MODE_30_32_THR 0b00000111 // 2 0 30/32 sync word bits, carrier sense above threshold
|
#define RADIOLIB_CC1101_SYNC_MODE_30_32_THR 0b00000111 // 2 0 30/32 sync word bits, carrier sense above threshold
|
||||||
|
|
||||||
// CC1101_REG_MDMCFG1
|
// RADIOLIB_CC1101_REG_MDMCFG1
|
||||||
#define RADIOLIB_CC1101_FEC_OFF 0b00000000 // 7 7 forward error correction: disabled (default)
|
#define RADIOLIB_CC1101_FEC_OFF 0b00000000 // 7 7 forward error correction: disabled (default)
|
||||||
#define RADIOLIB_CC1101_FEC_ON 0b10000000 // 7 7 enabled - only for fixed packet length
|
#define RADIOLIB_CC1101_FEC_ON 0b10000000 // 7 7 enabled - only for fixed packet length
|
||||||
#define RADIOLIB_CC1101_NUM_PREAMBLE_2 0b00000000 // 6 4 number of preamble bytes: 2
|
#define RADIOLIB_CC1101_NUM_PREAMBLE_2 0b00000000 // 6 4 number of preamble bytes: 2
|
||||||
|
@ -261,15 +276,15 @@
|
||||||
#define RADIOLIB_CC1101_NUM_PREAMBLE_24 0b01110000 // 6 4 24
|
#define RADIOLIB_CC1101_NUM_PREAMBLE_24 0b01110000 // 6 4 24
|
||||||
#define RADIOLIB_CC1101_CHANSPC_E 0x02 // 1 0 channel spacing: df_channel = (f(XOSC) / 2^18) * (256 + CHANSPC_M) * 2^CHANSPC_E [Hz]
|
#define RADIOLIB_CC1101_CHANSPC_E 0x02 // 1 0 channel spacing: df_channel = (f(XOSC) / 2^18) * (256 + CHANSPC_M) * 2^CHANSPC_E [Hz]
|
||||||
|
|
||||||
// CC1101_REG_MDMCFG0
|
// RADIOLIB_CC1101_REG_MDMCFG0
|
||||||
#define RADIOLIB_CC1101_CHANSPC_M 0xF8 // 7 0 default value for 26 MHz crystal: 199 951 kHz
|
#define RADIOLIB_CC1101_CHANSPC_M 0xF8 // 7 0 default value for 26 MHz crystal: 199 951 kHz
|
||||||
|
|
||||||
// CC1101_REG_DEVIATN
|
// RADIOLIB_CC1101_REG_DEVIATN
|
||||||
#define RADIOLIB_CC1101_DEVIATION_E 0b01000000 // 6 4 frequency deviation: f_dev = (f(XOSC) / 2^17) * (8 + DEVIATION_M) * 2^DEVIATION_E [Hz]
|
#define RADIOLIB_CC1101_DEVIATION_E 0b01000000 // 6 4 frequency deviation: f_dev = (f(XOSC) / 2^17) * (8 + DEVIATION_M) * 2^DEVIATION_E [Hz]
|
||||||
#define RADIOLIB_CC1101_DEVIATION_M 0b00000111 // 2 0 default value for 26 MHz crystal: +- 47 607 Hz
|
#define RADIOLIB_CC1101_DEVIATION_M 0b00000111 // 2 0 default value for 26 MHz crystal: +- 47 607 Hz
|
||||||
#define RADIOLIB_CC1101_MSK_PHASE_CHANGE_PERIOD 0x07 // 2 0 phase change symbol period fraction: 1 / (MSK_PHASE_CHANGE_PERIOD + 1)
|
#define RADIOLIB_CC1101_MSK_PHASE_CHANGE_PERIOD 0x07 // 2 0 phase change symbol period fraction: 1 / (MSK_PHASE_CHANGE_PERIOD + 1)
|
||||||
|
|
||||||
// CC1101_REG_MCSM2
|
// RADIOLIB_CC1101_REG_MCSM2
|
||||||
#define RADIOLIB_CC1101_RX_TIMEOUT_RSSI_OFF 0b00000000 // 4 4 Rx timeout based on RSSI value: disabled (default)
|
#define RADIOLIB_CC1101_RX_TIMEOUT_RSSI_OFF 0b00000000 // 4 4 Rx timeout based on RSSI value: disabled (default)
|
||||||
#define RADIOLIB_CC1101_RX_TIMEOUT_RSSI_ON 0b00010000 // 4 4 enabled
|
#define RADIOLIB_CC1101_RX_TIMEOUT_RSSI_ON 0b00010000 // 4 4 enabled
|
||||||
#define RADIOLIB_CC1101_RX_TIMEOUT_QUAL_OFF 0b00000000 // 3 3 check for sync word on Rx timeout
|
#define RADIOLIB_CC1101_RX_TIMEOUT_QUAL_OFF 0b00000000 // 3 3 check for sync word on Rx timeout
|
||||||
|
@ -277,7 +292,7 @@
|
||||||
#define RADIOLIB_CC1101_RX_TIMEOUT_OFF 0b00000111 // 2 0 Rx timeout: disabled (default)
|
#define RADIOLIB_CC1101_RX_TIMEOUT_OFF 0b00000111 // 2 0 Rx timeout: disabled (default)
|
||||||
#define RADIOLIB_CC1101_RX_TIMEOUT_MAX 0b00000000 // 2 0 max value (actual value depends on WOR_RES, EVENT0 and f(XOSC))
|
#define RADIOLIB_CC1101_RX_TIMEOUT_MAX 0b00000000 // 2 0 max value (actual value depends on WOR_RES, EVENT0 and f(XOSC))
|
||||||
|
|
||||||
// CC1101_REG_MCSM1
|
// RADIOLIB_CC1101_REG_MCSM1
|
||||||
#define RADIOLIB_CC1101_CCA_MODE_ALWAYS 0b00000000 // 5 4 clear channel indication: always
|
#define RADIOLIB_CC1101_CCA_MODE_ALWAYS 0b00000000 // 5 4 clear channel indication: always
|
||||||
#define RADIOLIB_CC1101_CCA_MODE_RSSI_THR 0b00010000 // 5 4 RSSI below threshold
|
#define RADIOLIB_CC1101_CCA_MODE_RSSI_THR 0b00010000 // 5 4 RSSI below threshold
|
||||||
#define RADIOLIB_CC1101_CCA_MODE_RX_PKT 0b00100000 // 5 4 unless receiving packet
|
#define RADIOLIB_CC1101_CCA_MODE_RX_PKT 0b00100000 // 5 4 unless receiving packet
|
||||||
|
@ -291,7 +306,7 @@
|
||||||
#define RADIOLIB_CC1101_TXOFF_TX 0b00000010 // 1 0 Tx
|
#define RADIOLIB_CC1101_TXOFF_TX 0b00000010 // 1 0 Tx
|
||||||
#define RADIOLIB_CC1101_TXOFF_RX 0b00000011 // 1 0 Rx
|
#define RADIOLIB_CC1101_TXOFF_RX 0b00000011 // 1 0 Rx
|
||||||
|
|
||||||
// CC1101_REG_MCSM0
|
// RADIOLIB_CC1101_REG_MCSM0
|
||||||
#define RADIOLIB_CC1101_FS_AUTOCAL_NEVER 0b00000000 // 5 4 automatic calibration: never (default)
|
#define RADIOLIB_CC1101_FS_AUTOCAL_NEVER 0b00000000 // 5 4 automatic calibration: never (default)
|
||||||
#define RADIOLIB_CC1101_FS_AUTOCAL_IDLE_TO_RXTX 0b00010000 // 5 4 every transition from idle to Rx/Tx
|
#define RADIOLIB_CC1101_FS_AUTOCAL_IDLE_TO_RXTX 0b00010000 // 5 4 every transition from idle to Rx/Tx
|
||||||
#define RADIOLIB_CC1101_FS_AUTOCAL_RXTX_TO_IDLE 0b00100000 // 5 4 every transition from Rx/Tx to idle
|
#define RADIOLIB_CC1101_FS_AUTOCAL_RXTX_TO_IDLE 0b00100000 // 5 4 every transition from Rx/Tx to idle
|
||||||
|
@ -305,7 +320,7 @@
|
||||||
#define RADIOLIB_CC1101_XOSC_FORCE_OFF 0b00000000 // 0 0 do not force XOSC to remain on in sleep (default)
|
#define RADIOLIB_CC1101_XOSC_FORCE_OFF 0b00000000 // 0 0 do not force XOSC to remain on in sleep (default)
|
||||||
#define RADIOLIB_CC1101_XOSC_FORCE_ON 0b00000001 // 0 0 force XOSC to remain on in sleep
|
#define RADIOLIB_CC1101_XOSC_FORCE_ON 0b00000001 // 0 0 force XOSC to remain on in sleep
|
||||||
|
|
||||||
// CC1101_REG_FOCCFG
|
// RADIOLIB_CC1101_REG_FOCCFG
|
||||||
#define RADIOLIB_CC1101_FOC_BS_CS_GATE_OFF 0b00000000 // 5 5 do not freeze frequency compensation until CS goes high
|
#define RADIOLIB_CC1101_FOC_BS_CS_GATE_OFF 0b00000000 // 5 5 do not freeze frequency compensation until CS goes high
|
||||||
#define RADIOLIB_CC1101_FOC_BS_CS_GATE_ON 0b00100000 // 5 5 freeze frequency compensation until CS goes high (default)
|
#define RADIOLIB_CC1101_FOC_BS_CS_GATE_ON 0b00100000 // 5 5 freeze frequency compensation until CS goes high (default)
|
||||||
#define RADIOLIB_CC1101_FOC_PRE_K 0b00000000 // 4 3 frequency compensation loop gain before sync word: K
|
#define RADIOLIB_CC1101_FOC_PRE_K 0b00000000 // 4 3 frequency compensation loop gain before sync word: K
|
||||||
|
@ -319,7 +334,7 @@
|
||||||
#define RADIOLIB_CC1101_FOC_LIMIT_BW_CHAN_4 0b00000010 // 1 0 +- BW_chan/4 (default)
|
#define RADIOLIB_CC1101_FOC_LIMIT_BW_CHAN_4 0b00000010 // 1 0 +- BW_chan/4 (default)
|
||||||
#define RADIOLIB_CC1101_FOC_LIMIT_BW_CHAN_2 0b00000011 // 1 0 +- BW_chan/2
|
#define RADIOLIB_CC1101_FOC_LIMIT_BW_CHAN_2 0b00000011 // 1 0 +- BW_chan/2
|
||||||
|
|
||||||
// CC1101_REG_BSCFG
|
// RADIOLIB_CC1101_REG_BSCFG
|
||||||
#define RADIOLIB_CC1101_BS_PRE_KI 0b00000000 // 7 6 clock recovery integral gain before sync word: Ki
|
#define RADIOLIB_CC1101_BS_PRE_KI 0b00000000 // 7 6 clock recovery integral gain before sync word: Ki
|
||||||
#define RADIOLIB_CC1101_BS_PRE_2KI 0b01000000 // 7 6 2Ki (default)
|
#define RADIOLIB_CC1101_BS_PRE_2KI 0b01000000 // 7 6 2Ki (default)
|
||||||
#define RADIOLIB_CC1101_BS_PRE_3KI 0b10000000 // 7 6 3Ki
|
#define RADIOLIB_CC1101_BS_PRE_3KI 0b10000000 // 7 6 3Ki
|
||||||
|
@ -337,7 +352,7 @@
|
||||||
#define RADIOLIB_CC1101_BS_LIMIT_6_25 0b00000010 // 1 0 +- 6.25 %
|
#define RADIOLIB_CC1101_BS_LIMIT_6_25 0b00000010 // 1 0 +- 6.25 %
|
||||||
#define RADIOLIB_CC1101_BS_LIMIT_12_5 0b00000011 // 1 0 +- 12.5 %
|
#define RADIOLIB_CC1101_BS_LIMIT_12_5 0b00000011 // 1 0 +- 12.5 %
|
||||||
|
|
||||||
// CC1101_REG_AGCCTRL2
|
// RADIOLIB_CC1101_REG_AGCCTRL2
|
||||||
#define RADIOLIB_CC1101_MAX_DVGA_GAIN_0 0b00000000 // 7 6 reduce maximum available DVGA gain: no reduction (default)
|
#define RADIOLIB_CC1101_MAX_DVGA_GAIN_0 0b00000000 // 7 6 reduce maximum available DVGA gain: no reduction (default)
|
||||||
#define RADIOLIB_CC1101_MAX_DVGA_GAIN_1 0b01000000 // 7 6 disable top gain setting
|
#define RADIOLIB_CC1101_MAX_DVGA_GAIN_1 0b01000000 // 7 6 disable top gain setting
|
||||||
#define RADIOLIB_CC1101_MAX_DVGA_GAIN_2 0b10000000 // 7 6 disable top two gain setting
|
#define RADIOLIB_CC1101_MAX_DVGA_GAIN_2 0b10000000 // 7 6 disable top two gain setting
|
||||||
|
@ -359,7 +374,7 @@
|
||||||
#define RADIOLIB_CC1101_MAGN_TARGET_40_DB 0b00000110 // 2 0 40 dB
|
#define RADIOLIB_CC1101_MAGN_TARGET_40_DB 0b00000110 // 2 0 40 dB
|
||||||
#define RADIOLIB_CC1101_MAGN_TARGET_42_DB 0b00000111 // 2 0 42 dB
|
#define RADIOLIB_CC1101_MAGN_TARGET_42_DB 0b00000111 // 2 0 42 dB
|
||||||
|
|
||||||
// CC1101_REG_AGCCTRL1
|
// RADIOLIB_CC1101_REG_AGCCTRL1
|
||||||
#define RADIOLIB_CC1101_AGC_LNA_PRIORITY_LNA2 0b00000000 // 6 6 LNA priority setting: LNA2 first
|
#define RADIOLIB_CC1101_AGC_LNA_PRIORITY_LNA2 0b00000000 // 6 6 LNA priority setting: LNA2 first
|
||||||
#define RADIOLIB_CC1101_AGC_LNA_PRIORITY_LNA 0b01000000 // 6 6 LNA first (default)
|
#define RADIOLIB_CC1101_AGC_LNA_PRIORITY_LNA 0b01000000 // 6 6 LNA first (default)
|
||||||
#define RADIOLIB_CC1101_CARRIER_SENSE_REL_THR_OFF 0b00000000 // 5 4 RSSI relative change to assert carrier sense: disabled (default)
|
#define RADIOLIB_CC1101_CARRIER_SENSE_REL_THR_OFF 0b00000000 // 5 4 RSSI relative change to assert carrier sense: disabled (default)
|
||||||
|
@ -368,7 +383,7 @@
|
||||||
#define RADIOLIB_CC1101_CARRIER_SENSE_REL_THR_14_DB 0b00110000 // 5 4 14 dB
|
#define RADIOLIB_CC1101_CARRIER_SENSE_REL_THR_14_DB 0b00110000 // 5 4 14 dB
|
||||||
#define RADIOLIB_CC1101_CARRIER_SENSE_ABS_THR 0x00 // 3 0 RSSI threshold to assert carrier sense in 2s compliment, Thr = MAGN_TARGET + CARRIER_SENSE_ABS_TH [dB]
|
#define RADIOLIB_CC1101_CARRIER_SENSE_ABS_THR 0x00 // 3 0 RSSI threshold to assert carrier sense in 2s compliment, Thr = MAGN_TARGET + CARRIER_SENSE_ABS_TH [dB]
|
||||||
|
|
||||||
// CC1101_REG_AGCCTRL0
|
// RADIOLIB_CC1101_REG_AGCCTRL0
|
||||||
#define RADIOLIB_CC1101_HYST_LEVEL_NONE 0b00000000 // 7 6 AGC hysteresis level: none
|
#define RADIOLIB_CC1101_HYST_LEVEL_NONE 0b00000000 // 7 6 AGC hysteresis level: none
|
||||||
#define RADIOLIB_CC1101_HYST_LEVEL_LOW 0b01000000 // 7 6 low
|
#define RADIOLIB_CC1101_HYST_LEVEL_LOW 0b01000000 // 7 6 low
|
||||||
#define RADIOLIB_CC1101_HYST_LEVEL_MEDIUM 0b10000000 // 7 6 medium (default)
|
#define RADIOLIB_CC1101_HYST_LEVEL_MEDIUM 0b10000000 // 7 6 medium (default)
|
||||||
|
@ -390,11 +405,11 @@
|
||||||
#define RADIOLIB_CC1101_ASK_OOK_BOUNDARY_12_DB 0b00000010 // 1 0 12 dB
|
#define RADIOLIB_CC1101_ASK_OOK_BOUNDARY_12_DB 0b00000010 // 1 0 12 dB
|
||||||
#define RADIOLIB_CC1101_ASK_OOK_BOUNDARY_16_DB 0b00000011 // 1 0 16 dB
|
#define RADIOLIB_CC1101_ASK_OOK_BOUNDARY_16_DB 0b00000011 // 1 0 16 dB
|
||||||
|
|
||||||
// CC1101_REG_WOREVT1 + REG_WOREVT0
|
// RADIOLIB_CC1101_REG_WOREVT1 + REG_WOREVT0
|
||||||
#define RADIOLIB_CC1101_EVENT0_TIMEOUT_MSB 0x87 // 7 0 EVENT0 timeout: t_event0 = (750 / f(XOSC)) * EVENT0_TIMEOUT * 2^(5 * WOR_RES) [s]
|
#define RADIOLIB_CC1101_EVENT0_TIMEOUT_MSB 0x87 // 7 0 EVENT0 timeout: t_event0 = (750 / f(XOSC)) * EVENT0_TIMEOUT * 2^(5 * WOR_RES) [s]
|
||||||
#define RADIOLIB_CC1101_EVENT0_TIMEOUT_LSB 0x6B // 7 0 default value for 26 MHz crystal: 1.0 s
|
#define RADIOLIB_CC1101_EVENT0_TIMEOUT_LSB 0x6B // 7 0 default value for 26 MHz crystal: 1.0 s
|
||||||
|
|
||||||
// CC1101_REG_WORCTRL
|
// RADIOLIB_CC1101_REG_WORCTRL
|
||||||
#define RADIOLIB_CC1101_RC_POWER_UP 0b00000000 // 7 7 power up RC oscillator
|
#define RADIOLIB_CC1101_RC_POWER_UP 0b00000000 // 7 7 power up RC oscillator
|
||||||
#define RADIOLIB_CC1101_RC_POWER_DOWN 0b10000000 // 7 7 power down RC oscillator
|
#define RADIOLIB_CC1101_RC_POWER_DOWN 0b10000000 // 7 7 power down RC oscillator
|
||||||
#define RADIOLIB_CC1101_EVENT1_TIMEOUT_4 0b00000000 // 6 4 EVENT1 timeout: 4 RC periods
|
#define RADIOLIB_CC1101_EVENT1_TIMEOUT_4 0b00000000 // 6 4 EVENT1 timeout: 4 RC periods
|
||||||
|
@ -412,55 +427,55 @@
|
||||||
#define RADIOLIB_CC1101_WOR_RES_2_10 0b00000010 // 1 0 2^10 periods
|
#define RADIOLIB_CC1101_WOR_RES_2_10 0b00000010 // 1 0 2^10 periods
|
||||||
#define RADIOLIB_CC1101_WOR_RES_2_15 0b00000011 // 1 0 2^15 periods
|
#define RADIOLIB_CC1101_WOR_RES_2_15 0b00000011 // 1 0 2^15 periods
|
||||||
|
|
||||||
// CC1101_REG_FREND1
|
// RADIOLIB_CC1101_REG_FREND1
|
||||||
#define RADIOLIB_CC1101_LNA_CURRENT 0x01 // 7 6 front-end LNA PTAT current output adjustment
|
#define RADIOLIB_CC1101_LNA_CURRENT 0x01 // 7 6 front-end LNA PTAT current output adjustment
|
||||||
#define RADIOLIB_CC1101_LNA2MIX_CURRENT 0x01 // 5 4 front-end PTAT output adjustment
|
#define RADIOLIB_CC1101_LNA2MIX_CURRENT 0x01 // 5 4 front-end PTAT output adjustment
|
||||||
#define RADIOLIB_CC1101_LODIV_BUF_CURRENT_RX 0x01 // 3 2 Rx LO buffer current adjustment
|
#define RADIOLIB_CC1101_LODIV_BUF_CURRENT_RX 0x01 // 3 2 Rx LO buffer current adjustment
|
||||||
#define RADIOLIB_CC1101_MIX_CURRENT 0x02 // 1 0 mixer current adjustment
|
#define RADIOLIB_CC1101_MIX_CURRENT 0x02 // 1 0 mixer current adjustment
|
||||||
|
|
||||||
// CC1101_REG_FREND0
|
// RADIOLIB_CC1101_REG_FREND0
|
||||||
#define RADIOLIB_CC1101_LODIV_BUF_CURRENT_TX 0x01 // 5 4 Tx LO buffer current adjustment
|
#define RADIOLIB_CC1101_LODIV_BUF_CURRENT_TX 0x01 // 5 4 Tx LO buffer current adjustment
|
||||||
#define RADIOLIB_CC1101_PA_POWER 0x00 // 2 0 set power amplifier power according to PATABLE
|
#define RADIOLIB_CC1101_PA_POWER 0x00 // 2 0 set power amplifier power according to PATABLE
|
||||||
|
|
||||||
// CC1101_REG_FSCAL3
|
// RADIOLIB_CC1101_REG_FSCAL3
|
||||||
#define RADIOLIB_CC1101_CHP_CURR_CAL_OFF 0b00000000 // 5 4 disable charge pump calibration
|
#define RADIOLIB_CC1101_CHP_CURR_CAL_OFF 0b00000000 // 5 4 disable charge pump calibration
|
||||||
#define RADIOLIB_CC1101_CHP_CURR_CAL_ON 0b00100000 // 5 4 enable charge pump calibration (default)
|
#define RADIOLIB_CC1101_CHP_CURR_CAL_ON 0b00100000 // 5 4 enable charge pump calibration (default)
|
||||||
#define RADIOLIB_CC1101_FSCAL3 0x09 // 3 0 charge pump output current: I_out = I_0 * 2^(FSCAL3/4) [A]
|
#define RADIOLIB_CC1101_FSCAL3 0x09 // 3 0 charge pump output current: I_out = I_0 * 2^(FSCAL3/4) [A]
|
||||||
|
|
||||||
// CC1101_REG_FSCAL2
|
// RADIOLIB_CC1101_REG_FSCAL2
|
||||||
#define RADIOLIB_CC1101_VCO_CORE_LOW 0b00000000 // 5 5 VCO: low (default)
|
#define RADIOLIB_CC1101_VCO_CORE_LOW 0b00000000 // 5 5 VCO: low (default)
|
||||||
#define RADIOLIB_CC1101_VCO_CORE_HIGH 0b00100000 // 5 5 high
|
#define RADIOLIB_CC1101_VCO_CORE_HIGH 0b00100000 // 5 5 high
|
||||||
#define RADIOLIB_CC1101_FSCAL2 0x0A // 4 0 VCO current result/override
|
#define RADIOLIB_CC1101_FSCAL2 0x0A // 4 0 VCO current result/override
|
||||||
|
|
||||||
// CC1101_REG_FSCAL1
|
// RADIOLIB_CC1101_REG_FSCAL1
|
||||||
#define RADIOLIB_CC1101_FSCAL1 0x20 // 5 0 capacitor array setting for coarse VCO tuning
|
#define RADIOLIB_CC1101_FSCAL1 0x20 // 5 0 capacitor array setting for coarse VCO tuning
|
||||||
|
|
||||||
// CC1101_REG_FSCAL0
|
// RADIOLIB_CC1101_REG_FSCAL0
|
||||||
#define RADIOLIB_CC1101_FSCAL0 0x0D // 6 0 frequency synthesizer calibration setting
|
#define RADIOLIB_CC1101_FSCAL0 0x0D // 6 0 frequency synthesizer calibration setting
|
||||||
|
|
||||||
// CC1101_REG_RCCTRL1
|
// RADIOLIB_CC1101_REG_RCCTRL1
|
||||||
#define RADIOLIB_CC1101_RCCTRL1 0x41 // 6 0 RC oscillator configuration
|
#define RADIOLIB_CC1101_RCCTRL1 0x41 // 6 0 RC oscillator configuration
|
||||||
|
|
||||||
// CC1101_REG_RCCTRL0
|
// RADIOLIB_CC1101_REG_RCCTRL0
|
||||||
#define RADIOLIB_CC1101_RCCTRL0 0x00 // 6 0 RC oscillator configuration
|
#define RADIOLIB_CC1101_RCCTRL0 0x00 // 6 0 RC oscillator configuration
|
||||||
|
|
||||||
// CC1101_REG_PTEST
|
// RADIOLIB_CC1101_REG_PTEST
|
||||||
#define RADIOLIB_CC1101_TEMP_SENS_IDLE_OFF 0x7F // 7 0 temperature sensor will not be available in idle mode (default)
|
#define RADIOLIB_CC1101_TEMP_SENS_IDLE_OFF 0x7F // 7 0 temperature sensor will not be available in idle mode (default)
|
||||||
#define RADIOLIB_CC1101_TEMP_SENS_IDLE_ON 0xBF // 7 0 temperature sensor will be available in idle mode
|
#define RADIOLIB_CC1101_TEMP_SENS_IDLE_ON 0xBF // 7 0 temperature sensor will be available in idle mode
|
||||||
|
|
||||||
// CC1101_REG_TEST0
|
// RADIOLIB_CC1101_REG_TEST0
|
||||||
#define RADIOLIB_CC1101_VCO_SEL_CAL_OFF 0b00000000 // 1 1 disable VCO selection calibration stage
|
#define RADIOLIB_CC1101_VCO_SEL_CAL_OFF 0b00000000 // 1 1 disable VCO selection calibration stage
|
||||||
#define RADIOLIB_CC1101_VCO_SEL_CAL_ON 0b00000010 // 1 1 enable VCO selection calibration stage
|
#define RADIOLIB_CC1101_VCO_SEL_CAL_ON 0b00000010 // 1 1 enable VCO selection calibration stage
|
||||||
|
|
||||||
// CC1101_REG_PARTNUM
|
// RADIOLIB_CC1101_REG_PARTNUM
|
||||||
#define RADIOLIB_CC1101_PARTNUM 0x00
|
#define RADIOLIB_CC1101_PARTNUM 0x00
|
||||||
|
|
||||||
// CC1101_REG_VERSION
|
// RADIOLIB_CC1101_REG_VERSION
|
||||||
#define RADIOLIB_CC1101_VERSION_CURRENT 0x14
|
#define RADIOLIB_CC1101_VERSION_CURRENT 0x14
|
||||||
#define RADIOLIB_CC1101_VERSION_LEGACY 0x04
|
#define RADIOLIB_CC1101_VERSION_LEGACY 0x04
|
||||||
#define RADIOLIB_CC1101_VERSION_CLONE 0x17
|
#define RADIOLIB_CC1101_VERSION_CLONE 0x17
|
||||||
|
|
||||||
// CC1101_REG_MARCSTATE
|
// RADIOLIB_CC1101_REG_MARCSTATE
|
||||||
#define RADIOLIB_CC1101_MARC_STATE_SLEEP 0x00 // 4 0 main radio control state: sleep
|
#define RADIOLIB_CC1101_MARC_STATE_SLEEP 0x00 // 4 0 main radio control state: sleep
|
||||||
#define RADIOLIB_CC1101_MARC_STATE_IDLE 0x01 // 4 0 idle
|
#define RADIOLIB_CC1101_MARC_STATE_IDLE 0x01 // 4 0 idle
|
||||||
#define RADIOLIB_CC1101_MARC_STATE_XOFF 0x02 // 4 0 XOFF
|
#define RADIOLIB_CC1101_MARC_STATE_XOFF 0x02 // 4 0 XOFF
|
||||||
|
@ -485,11 +500,11 @@
|
||||||
#define RADIOLIB_CC1101_MARC_STATE_RXTX_SWITCH 0x15 // 4 0 RXTX_SWITCH
|
#define RADIOLIB_CC1101_MARC_STATE_RXTX_SWITCH 0x15 // 4 0 RXTX_SWITCH
|
||||||
#define RADIOLIB_CC1101_MARC_STATE_TXFIFO_UNDERFLOW 0x16 // 4 0 TXFIFO_UNDERFLOW
|
#define RADIOLIB_CC1101_MARC_STATE_TXFIFO_UNDERFLOW 0x16 // 4 0 TXFIFO_UNDERFLOW
|
||||||
|
|
||||||
// CC1101_REG_WORTIME1 + REG_WORTIME0
|
// RADIOLIB_CC1101_REG_WORTIME1 + REG_WORTIME0
|
||||||
#define RADIOLIB_CC1101_WORTIME_MSB 0x00 // 7 0 WOR timer value
|
#define RADIOLIB_CC1101_WORTIME_MSB 0x00 // 7 0 WOR timer value
|
||||||
#define RADIOLIB_CC1101_WORTIME_LSB 0x00 // 7 0
|
#define RADIOLIB_CC1101_WORTIME_LSB 0x00 // 7 0
|
||||||
|
|
||||||
// CC1101_REG_PKTSTATUS
|
// RADIOLIB_CC1101_REG_PKTSTATUS
|
||||||
#define RADIOLIB_CC1101_CRC_OK 0b10000000 // 7 7 CRC check passed
|
#define RADIOLIB_CC1101_CRC_OK 0b10000000 // 7 7 CRC check passed
|
||||||
#define RADIOLIB_CC1101_CRC_ERROR 0b00000000 // 7 7 CRC check failed
|
#define RADIOLIB_CC1101_CRC_ERROR 0b00000000 // 7 7 CRC check failed
|
||||||
#define RADIOLIB_CC1101_CS 0b01000000 // 6 6 carrier sense
|
#define RADIOLIB_CC1101_CS 0b01000000 // 6 6 carrier sense
|
||||||
|
@ -499,7 +514,7 @@
|
||||||
#define RADIOLIB_CC1101_GDO2_ACTIVE 0b00000100 // 2 2 GDO2 is active/asserted
|
#define RADIOLIB_CC1101_GDO2_ACTIVE 0b00000100 // 2 2 GDO2 is active/asserted
|
||||||
#define RADIOLIB_CC1101_GDO0_ACTIVE 0b00000001 // 0 0 GDO0 is active/asserted
|
#define RADIOLIB_CC1101_GDO0_ACTIVE 0b00000001 // 0 0 GDO0 is active/asserted
|
||||||
|
|
||||||
//Defaults
|
// RadioLib defaults
|
||||||
#define RADIOLIB_CC1101_DEFAULT_FREQ 434.0
|
#define RADIOLIB_CC1101_DEFAULT_FREQ 434.0
|
||||||
#define RADIOLIB_CC1101_DEFAULT_BR 4.8
|
#define RADIOLIB_CC1101_DEFAULT_BR 4.8
|
||||||
#define RADIOLIB_CC1101_DEFAULT_FREQDEV 5.0
|
#define RADIOLIB_CC1101_DEFAULT_FREQDEV 5.0
|
||||||
|
@ -511,7 +526,6 @@
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class CC1101
|
\class CC1101
|
||||||
|
|
||||||
\brief Control class for %CC1101 module.
|
\brief Control class for %CC1101 module.
|
||||||
*/
|
*/
|
||||||
class CC1101: public PhysicalLayer {
|
class CC1101: public PhysicalLayer {
|
||||||
|
@ -524,7 +538,6 @@ class CC1101: public PhysicalLayer {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Default constructor.
|
\brief Default constructor.
|
||||||
|
|
||||||
\param mod Instance of Module that will be used to communicate with the radio.
|
\param mod Instance of Module that will be used to communicate with the radio.
|
||||||
*/
|
*/
|
||||||
CC1101(Module* module);
|
CC1101(Module* module);
|
||||||
|
@ -535,19 +548,12 @@ class CC1101: public PhysicalLayer {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Initialization method.
|
\brief Initialization method.
|
||||||
|
|
||||||
\param freq Carrier frequency in MHz. Defaults to 434 MHz.
|
\param freq Carrier frequency in MHz. Defaults to 434 MHz.
|
||||||
|
|
||||||
\param br Bit rate to be used in kbps. Defaults to 4.8 kbps.
|
\param br Bit rate to be used in kbps. Defaults to 4.8 kbps.
|
||||||
|
|
||||||
\param freqDev Frequency deviation from carrier frequency in kHz Defaults to 5.0 kHz.
|
\param freqDev Frequency deviation from carrier frequency in kHz Defaults to 5.0 kHz.
|
||||||
|
|
||||||
\param rxBw Receiver bandwidth in kHz. Defaults to 135.0 kHz.
|
\param rxBw Receiver bandwidth in kHz. Defaults to 135.0 kHz.
|
||||||
|
|
||||||
\param power Output power in dBm. Defaults to 10 dBm.
|
\param power Output power in dBm. Defaults to 10 dBm.
|
||||||
|
|
||||||
\param preambleLength Preamble Length in bits. Defaults to 16 bits.
|
\param preambleLength Preamble Length in bits. Defaults to 16 bits.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t begin(
|
int16_t begin(
|
||||||
|
@ -558,16 +564,17 @@ class CC1101: public PhysicalLayer {
|
||||||
int8_t power = RADIOLIB_CC1101_DEFAULT_POWER,
|
int8_t power = RADIOLIB_CC1101_DEFAULT_POWER,
|
||||||
uint8_t preambleLength = RADIOLIB_CC1101_DEFAULT_PREAMBLELEN);
|
uint8_t preambleLength = RADIOLIB_CC1101_DEFAULT_PREAMBLELEN);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Reset method - resets the chip using manual reset sequence (without RESET pin).
|
||||||
|
*/
|
||||||
|
void reset();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Blocking binary transmit method.
|
\brief Blocking binary transmit method.
|
||||||
Overloads for string-based transmissions are implemented in PhysicalLayer.
|
Overloads for string-based transmissions are implemented in PhysicalLayer.
|
||||||
|
|
||||||
\param data Binary data to be sent.
|
\param data Binary data to be sent.
|
||||||
|
|
||||||
\param len Number of bytes to send.
|
\param len Number of bytes to send.
|
||||||
|
|
||||||
\param addr Address to send the data to. Will only be added if address filtering was enabled.
|
\param addr Address to send the data to. Will only be added if address filtering was enabled.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t transmit(uint8_t* data, size_t len, uint8_t addr = 0) override;
|
int16_t transmit(uint8_t* data, size_t len, uint8_t addr = 0) override;
|
||||||
|
@ -575,65 +582,54 @@ class CC1101: public PhysicalLayer {
|
||||||
/*!
|
/*!
|
||||||
\brief Blocking binary receive method.
|
\brief Blocking binary receive method.
|
||||||
Overloads for string-based transmissions are implemented in PhysicalLayer.
|
Overloads for string-based transmissions are implemented in PhysicalLayer.
|
||||||
|
|
||||||
\param data Binary data to be sent.
|
\param data Binary data to be sent.
|
||||||
|
|
||||||
\param len Number of bytes to send.
|
\param len Number of bytes to send.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t receive(uint8_t* data, size_t len) override;
|
int16_t receive(uint8_t* data, size_t len) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Sets the module to standby mode.
|
\brief Sets the module to standby mode.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t standby() override;
|
int16_t standby() override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Sets the module to standby.
|
\brief Sets the module to standby.
|
||||||
|
|
||||||
\param mode Standby mode to be used. No effect, implemented only for PhysicalLayer compatibility.
|
\param mode Standby mode to be used. No effect, implemented only for PhysicalLayer compatibility.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t standby(uint8_t mode) override;
|
int16_t standby(uint8_t mode) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Starts direct mode transmission.
|
\brief Starts direct mode transmission.
|
||||||
|
|
||||||
\param frf Raw RF frequency value. Defaults to 0, required for quick frequency shifts in RTTY.
|
\param frf Raw RF frequency value. Defaults to 0, required for quick frequency shifts in RTTY.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t transmitDirect(uint32_t frf = 0) override;
|
int16_t transmitDirect(uint32_t frf = 0) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Starts direct mode reception.
|
\brief Starts direct mode reception.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t receiveDirect() override;
|
int16_t receiveDirect() override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Starts asynchronous direct mode transmission.
|
\brief Starts asynchronous direct mode transmission.
|
||||||
|
|
||||||
\param frf Raw RF frequency value. Defaults to 0, required for quick frequency shifts in RTTY.
|
\param frf Raw RF frequency value. Defaults to 0, required for quick frequency shifts in RTTY.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t transmitDirectAsync(uint32_t frf = 0);
|
int16_t transmitDirectAsync(uint32_t frf = 0);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Starts asynchronous direct mode reception.
|
\brief Starts asynchronous direct mode reception.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t receiveDirectAsync();
|
int16_t receiveDirectAsync();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Stops direct mode. It is required to call this method to switch from direct transmissions to packet-based transmissions.
|
\brief Stops direct mode. It is required to call this method to switch from direct transmissions
|
||||||
|
to packet-based transmissions.
|
||||||
*/
|
*/
|
||||||
int16_t packetMode();
|
int16_t packetMode();
|
||||||
|
|
||||||
|
@ -641,9 +637,7 @@ class CC1101: public PhysicalLayer {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Sets interrupt service routine to call when GDO0 activates.
|
\brief Sets interrupt service routine to call when GDO0 activates.
|
||||||
|
|
||||||
\param func ISR to call.
|
\param func ISR to call.
|
||||||
|
|
||||||
\param dir Signal change direction.
|
\param dir Signal change direction.
|
||||||
*/
|
*/
|
||||||
void setGdo0Action(void (*func)(void), uint32_t dir);
|
void setGdo0Action(void (*func)(void), uint32_t dir);
|
||||||
|
@ -655,9 +649,7 @@ class CC1101: public PhysicalLayer {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Sets interrupt service routine to call when GDO2 activates.
|
\brief Sets interrupt service routine to call when GDO2 activates.
|
||||||
|
|
||||||
\param func ISR to call.
|
\param func ISR to call.
|
||||||
|
|
||||||
\param dir Signal change direction.
|
\param dir Signal change direction.
|
||||||
*/
|
*/
|
||||||
void setGdo2Action(void (*func)(void), uint32_t dir);
|
void setGdo2Action(void (*func)(void), uint32_t dir);
|
||||||
|
@ -670,54 +662,40 @@ class CC1101: public PhysicalLayer {
|
||||||
/*!
|
/*!
|
||||||
\brief Interrupt-driven binary transmit method.
|
\brief Interrupt-driven binary transmit method.
|
||||||
Overloads for string-based transmissions are implemented in PhysicalLayer.
|
Overloads for string-based transmissions are implemented in PhysicalLayer.
|
||||||
|
|
||||||
\param data Binary data to be sent.
|
\param data Binary data to be sent.
|
||||||
|
|
||||||
\param len Number of bytes to send.
|
\param len Number of bytes to send.
|
||||||
|
|
||||||
\param addr Address to send the data to. Will only be added if address filtering was enabled.
|
\param addr Address to send the data to. Will only be added if address filtering was enabled.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr = 0) override;
|
int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr = 0) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Clean up after transmission is done.
|
\brief Clean up after transmission is done.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t finishTransmit() override;
|
int16_t finishTransmit() override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Interrupt-driven receive method. GDO0 will be activated when full packet is received.
|
\brief Interrupt-driven receive method. GDO0 will be activated when full packet is received.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t startReceive();
|
int16_t startReceive();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Interrupt-driven receive method, implemented for compatibility with PhysicalLayer.
|
\brief Interrupt-driven receive method, implemented for compatibility with PhysicalLayer.
|
||||||
|
|
||||||
\param timeout Ignored.
|
\param timeout Ignored.
|
||||||
|
|
||||||
\param irqFlags Ignored.
|
\param irqFlags Ignored.
|
||||||
|
|
||||||
\param irqMask Ignored.
|
\param irqMask Ignored.
|
||||||
|
|
||||||
\param len Ignored.
|
\param len Ignored.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t startReceive(uint32_t timeout, uint16_t irqFlags, uint16_t irqMask, size_t len);
|
int16_t startReceive(uint32_t timeout, uint16_t irqFlags, uint16_t irqMask, size_t len);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Reads data received after calling startReceive method.
|
\brief Reads data received after calling startReceive method.
|
||||||
|
|
||||||
\param data Pointer to array to save the received binary data.
|
\param data Pointer to array to save the received binary data.
|
||||||
|
|
||||||
\param len Number of bytes that will be read. When set to 0, the packet length will be retreived automatically.
|
\param len Number of bytes that will be read. When set to 0, the packet length will be retreived automatically.
|
||||||
When more bytes than received are requested, only the number of bytes requested will be returned.
|
When more bytes than received are requested, only the number of bytes requested will be returned.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t readData(uint8_t* data, size_t len) override;
|
int16_t readData(uint8_t* data, size_t len) override;
|
||||||
|
@ -725,219 +703,171 @@ class CC1101: public PhysicalLayer {
|
||||||
// configuration methods
|
// configuration methods
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Sets carrier frequency. Allowed values are in bands 300.0 to 348.0 MHz, 387.0 to 464.0 MHz and 779.0 to 928.0 MHz.
|
\brief Sets carrier frequency. Allowed values are in bands 300.0 to 348.0 MHz,
|
||||||
|
387.0 to 464.0 MHz and 779.0 to 928.0 MHz.
|
||||||
\param freq Carrier frequency to be set in MHz.
|
\param freq Carrier frequency to be set in MHz.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t setFrequency(float freq);
|
int16_t setFrequency(float freq);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Sets bit rate. Allowed values range from 0.025 to 600.0 kbps.
|
\brief Sets bit rate. Allowed values range from 0.025 to 600.0 kbps.
|
||||||
|
|
||||||
\param br Bit rate to be set in kbps.
|
\param br Bit rate to be set in kbps.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t setBitRate(float br);
|
int16_t setBitRate(float br);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Sets receiver bandwidth. Allowed values range from 58.0 to 812.0 kHz.
|
\brief Sets receiver bandwidth. Allowed values range from 58.0 to 812.0 kHz.
|
||||||
|
|
||||||
\param rxBw Receiver bandwidth to be set in kHz.
|
\param rxBw Receiver bandwidth to be set in kHz.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t setRxBandwidth(float rxBw);
|
int16_t setRxBandwidth(float rxBw);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Sets frequency deviation. Allowed values range from 1.587 to 380.8 kHz.
|
\brief Sets frequency deviation. Allowed values range from 1.587 to 380.8 kHz.
|
||||||
|
|
||||||
\param freqDev Frequency deviation to be set in kHz.
|
\param freqDev Frequency deviation to be set in kHz.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t setFrequencyDeviation(float freqDev) override;
|
int16_t setFrequencyDeviation(float freqDev) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Gets frequency deviation.
|
\brief Gets frequency deviation.
|
||||||
|
|
||||||
\param[out] freqDev Pointer to variable where to save the frequency deviation.
|
\param[out] freqDev Pointer to variable where to save the frequency deviation.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t getFrequencyDeviation(float *freqDev);
|
int16_t getFrequencyDeviation(float *freqDev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Sets output power. Allowed values are -30, -20, -15, -10, 0, 5, 7 or 10 dBm.
|
\brief Sets output power. Allowed values are -30, -20, -15, -10, 0, 5, 7 or 10 dBm.
|
||||||
|
|
||||||
\param power Output power to be set in dBm.
|
\param power Output power to be set in dBm.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t setOutputPower(int8_t power);
|
int16_t setOutputPower(int8_t power);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Sets 16-bit sync word as a two byte value.
|
\brief Sets 16-bit sync word as a two byte value.
|
||||||
|
|
||||||
\param syncH MSB of the sync word.
|
\param syncH MSB of the sync word.
|
||||||
|
|
||||||
\param syncL LSB of the sync word.
|
\param syncL LSB of the sync word.
|
||||||
|
|
||||||
\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.
|
\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, bool requireCarrierSense = false);
|
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.
|
||||||
|
|
||||||
\param syncWord Pointer to the array of sync word bytes.
|
\param syncWord Pointer to the array of sync word bytes.
|
||||||
|
|
||||||
\param len Sync word length in bytes.
|
\param len Sync word length in bytes.
|
||||||
|
|
||||||
\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.
|
\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, bool requireCarrierSense = false);
|
int16_t setSyncWord(uint8_t* syncWord, uint8_t len, uint8_t maxErrBits = 0, bool requireCarrierSense = false);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Sets preamble length.
|
\brief Sets preamble length.
|
||||||
|
|
||||||
\param preambleLength Preamble length to be set (in bits), allowed values: 16, 24, 32, 48, 64, 96, 128 and 192.
|
\param preambleLength Preamble length to be set (in bits), allowed values: 16, 24, 32, 48, 64, 96, 128 and 192.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t setPreambleLength(uint8_t preambleLength);
|
int16_t setPreambleLength(uint8_t preambleLength, uint8_t qualityThreshold);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Sets node and broadcast addresses. Calling this method will also enable address filtering.
|
\brief Sets node and broadcast addresses. Calling this method will also enable address filtering.
|
||||||
|
|
||||||
\param nodeAddr Node address to be set.
|
\param nodeAddr Node address to be set.
|
||||||
|
\param numBroadcastAddrs Number of broadcast addresses to be used. Can be set to 0 (no broadcast),
|
||||||
\param numBroadcastAddrs Number of broadcast addresses to be used. Can be set to 0 (no broadcast), 1 (broadcast at 0x00) or 2 (broadcast at 0x00 and 0xFF).
|
1 (broadcast at 0x00) or 2 (broadcast at 0x00 and 0xFF).
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t setNodeAddress(uint8_t nodeAddr, uint8_t numBroadcastAddrs = 0);
|
int16_t setNodeAddress(uint8_t nodeAddr, uint8_t numBroadcastAddrs = 0);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Disables address filtering. Calling this method will also erase previously set addresses.
|
\brief Disables address filtering. Calling this method will also erase previously set addresses.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t disableAddressFiltering();
|
int16_t disableAddressFiltering();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Enables/disables OOK modulation instead of FSK.
|
\brief Enables/disables OOK modulation instead of FSK.
|
||||||
|
|
||||||
\param enableOOK Enable (true) or disable (false) OOK.
|
\param enableOOK Enable (true) or disable (false) OOK.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t setOOK(bool enableOOK);
|
int16_t setOOK(bool enableOOK);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Gets RSSI (Recorded Signal Strength Indicator) of the last received packet.
|
\brief Gets RSSI (Recorded Signal Strength Indicator) of the last received packet.
|
||||||
|
In asynchronous direct mode, returns the current RSSI level.
|
||||||
or in asynchronous direct mode the current RSSI level
|
|
||||||
|
|
||||||
\returns RSSI in dBm.
|
\returns RSSI in dBm.
|
||||||
*/
|
*/
|
||||||
float getRSSI();
|
float getRSSI();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Gets LQI (Link Quality Indicator) of the last received packet.
|
\brief Gets LQI (Link Quality Indicator) of the last received packet.
|
||||||
|
|
||||||
\returns Last packet LQI (lower is better).
|
\returns Last packet LQI (lower is better).
|
||||||
*/
|
*/
|
||||||
uint8_t getLQI() const;
|
uint8_t getLQI() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Query modem for the packet length of received payload.
|
\brief Query modem for the packet length of received payload.
|
||||||
|
|
||||||
\param update Update received packet length. Will return cached value when set to false.
|
\param update Update received packet length. Will return cached value when set to false.
|
||||||
|
|
||||||
\returns Length of last received packet in bytes.
|
\returns Length of last received packet in bytes.
|
||||||
*/
|
*/
|
||||||
size_t getPacketLength(bool update = true) override;
|
size_t getPacketLength(bool update = true) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Set modem in fixed packet length mode.
|
\brief Set modem in fixed packet length mode.
|
||||||
|
|
||||||
\param len Packet length.
|
\param len Packet length.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t fixedPacketLengthMode(uint8_t len = RADIOLIB_CC1101_MAX_PACKET_LENGTH);
|
int16_t fixedPacketLengthMode(uint8_t len = RADIOLIB_CC1101_MAX_PACKET_LENGTH);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Set modem in variable packet length mode.
|
\brief Set modem in variable packet length mode.
|
||||||
|
|
||||||
\param len Maximum packet length.
|
\param len Maximum packet length.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t variablePacketLengthMode(uint8_t maxLen = RADIOLIB_CC1101_MAX_PACKET_LENGTH);
|
int16_t variablePacketLengthMode(uint8_t maxLen = RADIOLIB_CC1101_MAX_PACKET_LENGTH);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Enable sync word filtering and generation.
|
\brief Enable sync word filtering and generation.
|
||||||
|
|
||||||
\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.
|
\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, bool requireCarrierSense = false);
|
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.
|
\param requireCarrierSense Require carrier sense above threshold.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t disableSyncWordFiltering(bool requireCarrierSense = false);
|
int16_t disableSyncWordFiltering(bool requireCarrierSense = false);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Enable CRC filtering and generation.
|
\brief Enable CRC filtering and generation.
|
||||||
|
\param enable Set or unset CRC generation and filtering.
|
||||||
\param crcOn Set or unset CRC generation and filtering.
|
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t setCrcFiltering(bool crcOn = true);
|
int16_t setCrcFiltering(bool enable = true);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Set modem in "sniff" mode: no packet filtering (e.g., no preamble, sync word, address, CRC).
|
\brief Set modem in "sniff" mode: no packet filtering (e.g., no preamble, sync word, address, CRC).
|
||||||
|
\param enable Set or unset promiscuous mode.
|
||||||
\param promiscuous Set or unset promiscuous mode.
|
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t setPromiscuousMode(bool promiscuous = true);
|
int16_t setPromiscuousMode(bool enable = true);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Get whether the modem is in promiscuous mode: no packet filtering (e.g., no preamble, sync word, address, CRC).
|
\brief Get whether the modem is in promiscuous mode: no packet filtering
|
||||||
|
(e.g., no preamble, sync word, address, CRC).
|
||||||
\returns Whether the modem is in promiscuous mode
|
\returns Whether the modem is in promiscuous mode.
|
||||||
*/
|
*/
|
||||||
bool getPromiscuousMode();
|
bool getPromiscuousMode();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Sets Gaussian filter bandwidth-time product that will be used for data shaping.
|
\brief Sets Gaussian filter bandwidth-time product that will be used for data shaping.
|
||||||
Allowed value is RADIOLIB_SHAPING_0_5. Set to RADIOLIB_SHAPING_NONE to disable data shaping.
|
Allowed value is RADIOLIB_SHAPING_0_5. Set to RADIOLIB_SHAPING_NONE to disable data shaping.
|
||||||
|
|
||||||
\param sh Gaussian shaping bandwidth-time product that will be used for data shaping.
|
\param sh Gaussian shaping bandwidth-time product that will be used for data shaping.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t setDataShaping(uint8_t sh) override;
|
int16_t setDataShaping(uint8_t sh) override;
|
||||||
|
@ -945,9 +875,7 @@ class CC1101: public PhysicalLayer {
|
||||||
/*!
|
/*!
|
||||||
\brief Sets transmission encoding. Allowed values are RADIOLIB_ENCODING_NRZ, RADIOLIB_ENCODING_MANCHESTER, and RADIOLIB_ENCODING_WHITENING.
|
\brief Sets transmission encoding. Allowed values are RADIOLIB_ENCODING_NRZ, RADIOLIB_ENCODING_MANCHESTER, and RADIOLIB_ENCODING_WHITENING.
|
||||||
Note that encoding on CC1101 is applied to the entire stream including preamble, sync word, and CRC.
|
Note that encoding on CC1101 is applied to the entire stream including preamble, sync word, and CRC.
|
||||||
|
|
||||||
\param encoding Encoding to be used.
|
\param encoding Encoding to be used.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t setEncoding(uint8_t encoding) override;
|
int16_t setEncoding(uint8_t encoding) override;
|
||||||
|
@ -960,14 +888,13 @@ class CC1101: public PhysicalLayer {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Get one truly random byte from RSSI noise.
|
\brief Get one truly random byte from RSSI noise.
|
||||||
|
|
||||||
\returns TRNG byte.
|
\returns TRNG byte.
|
||||||
*/
|
*/
|
||||||
uint8_t randomByte();
|
uint8_t randomByte();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Read version SPI register. Should return CC1101_VERSION_LEGACY (0x04) or CC1101_VERSION_CURRENT (0x14) if CC1101 is connected and working.
|
\brief Read version SPI register. Should return CC1101_VERSION_LEGACY (0x04) or
|
||||||
|
CC1101_VERSION_CURRENT (0x14) if CC1101 is connected and working.
|
||||||
\returns Version register contents or \ref status_codes
|
\returns Version register contents or \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t getChipVersion();
|
int16_t getChipVersion();
|
||||||
|
@ -975,14 +902,12 @@ class CC1101: public PhysicalLayer {
|
||||||
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
|
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
|
||||||
/*!
|
/*!
|
||||||
\brief Set interrupt service routine function to call when data bit is receveid in direct mode.
|
\brief Set interrupt service routine function to call when data bit is receveid in direct mode.
|
||||||
|
|
||||||
\param func Pointer to interrupt service routine.
|
\param func Pointer to interrupt service routine.
|
||||||
*/
|
*/
|
||||||
void setDirectAction(void (*func)(void));
|
void setDirectAction(void (*func)(void));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Function to read and process data bit in direct reception mode.
|
\brief Function to read and process data bit in direct reception mode.
|
||||||
|
|
||||||
\param pin Pin on which to read.
|
\param pin Pin on which to read.
|
||||||
*/
|
*/
|
||||||
void readBit(uint32_t pin);
|
void readBit(uint32_t pin);
|
||||||
|
@ -990,11 +915,8 @@ class CC1101: public PhysicalLayer {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Configure DIO pin mapping to get a given signal on a DIO pin (if available).
|
\brief Configure DIO pin mapping to get a given signal on a DIO pin (if available).
|
||||||
|
|
||||||
\param pin Pin number onto which a signal is to be placed.
|
\param pin Pin number onto which a signal is to be placed.
|
||||||
|
|
||||||
\param value The value that indicates which function to place on that pin. See chip datasheet for details.
|
\param value The value that indicates which function to place on that pin. See chip datasheet for details.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t setDIOMapping(uint32_t pin, uint32_t value);
|
int16_t setDIOMapping(uint32_t pin, uint32_t value);
|
||||||
|
@ -1002,7 +924,7 @@ class CC1101: public PhysicalLayer {
|
||||||
#if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL)
|
#if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL)
|
||||||
protected:
|
protected:
|
||||||
#endif
|
#endif
|
||||||
Module* _mod;
|
Module* mod;
|
||||||
|
|
||||||
// SPI read overrides to set bit for burst write and status registers access
|
// SPI read overrides to set bit for burst write and status registers access
|
||||||
int16_t SPIgetRegValue(uint8_t reg, uint8_t msb = 7, uint8_t lsb = 0);
|
int16_t SPIgetRegValue(uint8_t reg, uint8_t msb = 7, uint8_t lsb = 0);
|
||||||
|
@ -1018,22 +940,21 @@ class CC1101: public PhysicalLayer {
|
||||||
protected:
|
protected:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
float _freq = RADIOLIB_CC1101_DEFAULT_FREQ;
|
float freq = RADIOLIB_CC1101_DEFAULT_FREQ;
|
||||||
float _br = RADIOLIB_CC1101_DEFAULT_BR;
|
float bitRate = RADIOLIB_CC1101_DEFAULT_BR;
|
||||||
uint8_t _rawRSSI = 0;
|
uint8_t rawRSSI = 0;
|
||||||
uint8_t _rawLQI = 0;
|
uint8_t rawLQI = 0;
|
||||||
uint8_t _modulation = RADIOLIB_CC1101_MOD_FORMAT_2_FSK;
|
uint8_t modulation = RADIOLIB_CC1101_MOD_FORMAT_2_FSK;
|
||||||
|
|
||||||
size_t _packetLength = 0;
|
size_t packetLength = 0;
|
||||||
bool _packetLengthQueried = false;
|
bool packetLengthQueried = false;
|
||||||
uint8_t _packetLengthConfig = RADIOLIB_CC1101_LENGTH_CONFIG_VARIABLE;
|
uint8_t packetLengthConfig = RADIOLIB_CC1101_LENGTH_CONFIG_VARIABLE;
|
||||||
|
|
||||||
bool _promiscuous = false;
|
bool promiscuous = false;
|
||||||
bool _crcOn = true;
|
bool crcOn = true;
|
||||||
bool _directMode = true;
|
bool directModeEnabled = true;
|
||||||
|
|
||||||
int8_t _power = RADIOLIB_CC1101_DEFAULT_POWER;
|
|
||||||
|
|
||||||
|
int8_t power = RADIOLIB_CC1101_DEFAULT_POWER;
|
||||||
|
|
||||||
int16_t config();
|
int16_t config();
|
||||||
int16_t transmitDirect(bool sync, uint32_t frf);
|
int16_t transmitDirect(bool sync, uint32_t frf);
|
||||||
|
|
Loading…
Add table
Reference in a new issue