Merge pull request #119 from Guglio95/radiolib-pr
nRF24 small improvements.
This commit is contained in:
commit
b7c21ffac6
2 changed files with 22 additions and 8 deletions
|
@ -230,14 +230,9 @@ int16_t nRF24::setFrequency(int16_t freq) {
|
|||
return(ERR_INVALID_FREQUENCY);
|
||||
}
|
||||
|
||||
// set mode to standby
|
||||
int16_t state = standby();
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// set frequency
|
||||
uint8_t freqRaw = freq - 2400;
|
||||
state = _mod->SPIsetRegValue(NRF24_REG_RF_CH, freqRaw, 6, 0);
|
||||
return(state);
|
||||
return _mod->SPIsetRegValue(NRF24_REG_RF_CH, freqRaw, 6, 0);
|
||||
}
|
||||
|
||||
int16_t nRF24::setDataRate(int16_t dataRate) {
|
||||
|
@ -332,6 +327,7 @@ int16_t nRF24::setTransmitPipe(uint8_t* addr) {
|
|||
|
||||
// set Rx pipe 0 address (for ACK)
|
||||
_mod->SPIwriteRegisterBurst(NRF24_REG_RX_ADDR_P0, addr, _addrWidth);
|
||||
state |= _mod->SPIsetRegValue(NRF24_REG_EN_RXADDR, NRF24_P0_ON, 0, 0);
|
||||
|
||||
return(state);
|
||||
}
|
||||
|
@ -423,6 +419,10 @@ int16_t nRF24::getStatus(uint8_t mask) {
|
|||
return(_mod->SPIgetRegValue(NRF24_REG_STATUS) & mask);
|
||||
}
|
||||
|
||||
bool nRF24::isCarrierDetected() {
|
||||
return(_mod->SPIgetRegValue(NRF24_REG_RPD, 0,0)) == 1;
|
||||
}
|
||||
|
||||
int16_t nRF24::setFrequencyDeviation(float freqDev) {
|
||||
// nRF24 is unable to set frequency deviation
|
||||
// this method is implemented only for PhysicalLayer compatibility
|
||||
|
@ -438,6 +438,13 @@ size_t nRF24::getPacketLength(bool update) {
|
|||
}
|
||||
|
||||
int16_t nRF24::setCrcFiltering(bool crcOn) {
|
||||
// Auto Ack needs to be disabled in order to disable CRC.
|
||||
if (!crcOn) {
|
||||
int16_t status = setAutoAck(false);
|
||||
RADIOLIB_ASSERT(status)
|
||||
}
|
||||
|
||||
// Disable CRC
|
||||
return _mod->SPIsetRegValue(NRF24_REG_CONFIG, crcOn ? NRF24_CRC_ON : NRF24_CRC_OFF, 3, 3);
|
||||
}
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@
|
|||
// NRF24_REG_STATUS
|
||||
#define NRF24_RX_DR 0b01000000 // 6 6 Rx data ready
|
||||
#define NRF24_TX_DS 0b00100000 // 5 5 Tx data sent
|
||||
#define NRF24_MAX_RT 0b00010000 // 4 4 maximum number of rentransmits reached (must be cleared to continue)
|
||||
#define NRF24_MAX_RT 0b00010000 // 4 4 maximum number of retransmits reached (must be cleared to continue)
|
||||
#define NRF24_RX_FIFO_EMPTY 0b00001110 // 3 1 Rx FIFO is empty
|
||||
#define NRF24_RX_P_NO 0b00000000 // 3 1 number of data pipe that received data
|
||||
#define NRF24_TX_FIFO_FULL 0b00000001 // 0 0 Tx FIFO is full
|
||||
|
@ -392,6 +392,13 @@ class nRF24: public PhysicalLayer {
|
|||
*/
|
||||
int16_t getStatus(uint8_t mask = 0xFF);
|
||||
|
||||
/*!
|
||||
\brief Checks if carrier was detected during last RX
|
||||
|
||||
\returns Whatever the carrier was above threshold.
|
||||
*/
|
||||
bool isCarrierDetected();
|
||||
|
||||
/*!
|
||||
\brief Dummy configuration method, to ensure PhysicalLayer compatibility.
|
||||
|
||||
|
@ -438,7 +445,7 @@ class nRF24: public PhysicalLayer {
|
|||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t setAutoAck(uint8_t pipeNum, bool autoAckOn = true);
|
||||
int16_t setAutoAck(uint8_t pipeNum, bool autoAckOn);
|
||||
|
||||
/*!
|
||||
\brief Dummy data shaping configuration method, to ensure PhysicalLayer compatibility.
|
||||
|
|
Loading…
Add table
Reference in a new issue