[nRF24] 2 bytes addrWidth

This commit is contained in:
Andrea Guglielmini 2019-11-25 16:11:55 +01:00
parent a6106b4e63
commit a82002b56e
2 changed files with 8 additions and 2 deletions

View file

@ -19,7 +19,7 @@ int16_t nRF24::begin(int16_t freq, int16_t dataRate, int8_t power, uint8_t addrW
// check SPI connection
int16_t val = _mod->SPIgetRegValue(NRF24_REG_SETUP_AW);
if(!((val >= 1) && (val <= 3))) {
if(!((val >= 0) && (val <= 3))) {
RADIOLIB_DEBUG_PRINTLN(F("No nRF24 found!"));
_mod->term();
return(ERR_CHIP_NOT_FOUND);
@ -339,6 +339,11 @@ int16_t nRF24::setAddressWidth(uint8_t addrWidth) {
// set address width
switch(addrWidth) {
case 2:
// Even if marked as 'Illegal' on the datasheet this will work:
// http://travisgoodspeed.blogspot.com/2011/02/promiscuity-is-nrf24l01s-duty.html
state = _mod->SPIsetRegValue(NRF24_REG_SETUP_AW, NRF24_ADDRESS_2_BYTES, 1, 0);
break;
case 3:
state = _mod->SPIsetRegValue(NRF24_REG_SETUP_AW, NRF24_ADDRESS_3_BYTES, 1, 0);
break;

View file

@ -99,7 +99,8 @@
#define NRF24_P0_ON 0b00000001 // 0 0 enabled (default)
// NRF24_REG_SETUP_AW
#define NRF24_ADDRESS_3_BYTES 0b00000001 // 1 0 address width: 3 bytes
#define NRF24_ADDRESS_2_BYTES 0b00000000 // 1 0 address width: 2 bytes
#define NRF24_ADDRESS_3_BYTES 0b00000001 // 1 0 3 bytes
#define NRF24_ADDRESS_4_BYTES 0b00000010 // 1 0 4 bytes
#define NRF24_ADDRESS_5_BYTES 0b00000011 // 1 0 5 bytes (default)