Skip to content

Commit

Permalink
Nrf24 lowlevel (#1192)
Browse files Browse the repository at this point in the history
* Implemented nRF24 constant carrier wave

For testing purposes only! Not used by regular MySensors stack.

* Please Jenkins for unused functions

* Add RPD retrieval
  • Loading branch information
Yveaux authored and tekka007 committed Aug 30, 2018
1 parent cff3696 commit 966c5d7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
7 changes: 7 additions & 0 deletions drivers/RF24/RF24.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,13 @@ LOCAL void RF24_disableConstantCarrierWave(void)
RF24_setRFSetup(RF24_RF_SETUP);
}

LOCAL bool RF24_getReceivedPowerDetector(void)
{
// nRF24L01+ only. nRF24L01 contains a carrier detect function (same register & bit) which works
// slightly different and takes at least 128us to become active.
return (RF24_readByteRegister(RF24_REG_RPD) & _BV(RF24_RPD)) != 0;
}

#if defined(MY_RX_MESSAGE_BUFFER_FEATURE)
LOCAL void RF24_irqHandler(void)
{
Expand Down
6 changes: 5 additions & 1 deletion drivers/RF24/RF24.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,11 @@ LOCAL void RF24_enableConstantCarrierWave(void) __attribute__((unused));
* @brief Stop generating a constant carrier wave (for testing only).
*/
LOCAL void RF24_disableConstantCarrierWave(void) __attribute__((unused));

/**
* @brief Retrieve latched RPD power level, in receive mode (for testing, nRF24L01+ only).
* @return True when power level >-64dBm for more than 40us.
*/
LOCAL bool RF24_getReceivedPowerDetector(void) __attribute__((unused));

#if defined(MY_RX_MESSAGE_BUFFER_FEATURE)
/**
Expand Down
6 changes: 4 additions & 2 deletions drivers/RF24/RF24registers.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
#define RF24_REG_RF_SETUP (0x06)
#define RF24_REG_STATUS (0x07)
#define RF24_REG_OBSERVE_TX (0x08)
#define RF24_REG_CD (0x09)
#define RF24_REG_RPD (0x09) // nRF24L01+
#define RF24_REG_CD (RF24_REG_RPD) // nRF24L01
#define RF24_REG_RX_ADDR_P0 (0x0A)
#define RF24_REG_RX_ADDR_P1 (0x0B)
#define RF24_REG_RX_ADDR_P2 (0x0C)
Expand All @@ -79,7 +80,6 @@

// instructions
#define RF24_CMD_READ_REGISTER (0x00)
#define RF24_CMD_RPD (0x09)
#define RF24_CMD_WRITE_REGISTER (0x20)
#define RF24_CMD_ACTIVATE (0x50)
#define RF24_CMD_READ_RX_PL_WID (0x60)
Expand Down Expand Up @@ -144,6 +144,8 @@
#define RF24_TX_EMPTY (4)
#define RF24_RX_FULL (1)
#define RF24_RX_EMPTY (0)
#define RF24_RPD (0) // nRF24L01+
#define RF24_CD (RF24_RPD) // nRF24L01

// features
#define RF24_EN_DPL (2)
Expand Down

0 comments on commit 966c5d7

Please sign in to comment.