Commit 602d9626 authored by maniacbug's avatar maniacbug

Merge gcopeland/constremove

parents d436895f 0c2515df
This diff is collapsed.
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
#include <stddef.h> #include <stddef.h>
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
typedef enum { RF24_1MBPS = 0, RF24_2MBPS } rf24_datarate_e; typedef enum { RF24_PA_MIN = 0,RF24_PA_LOW, RF24_PA_HIGH, RF24_PA_MAX, RF24_PA_ERROR } rf24_pa_dbm_e ;
typedef enum { RF24_1MBPS = 0, RF24_2MBPS, RF24_250KBPS } rf24_datarate_e;
typedef enum { RF24_CRC_8 = 0, RF24_CRC_16 } rf24_crclength_e; typedef enum { RF24_CRC_8 = 0, RF24_CRC_16 } rf24_crclength_e;
/** /**
...@@ -24,6 +25,8 @@ class RF24 ...@@ -24,6 +25,8 @@ class RF24
private: private:
uint8_t ce_pin; /**< "Chip Enable" pin, activates the RX or TX role */ uint8_t ce_pin; /**< "Chip Enable" pin, activates the RX or TX role */
uint8_t csn_pin; /**< SPI Chip select */ uint8_t csn_pin; /**< SPI Chip select */
bool wide_band; /* 2Mbs data rate in use? */
bool p_variant; /* False for RF24L01 and true for RF24L01P */
uint8_t payload_size; /**< Fixed size of payloads */ uint8_t payload_size; /**< Fixed size of payloads */
bool ack_payload_available; /**< Whether there is an ack payload waiting */ bool ack_payload_available; /**< Whether there is an ack payload waiting */
uint8_t ack_payload_length; /**< Dynamic size of pending ack payload. Note: not used. */ uint8_t ack_payload_length; /**< Dynamic size of pending ack payload. Note: not used. */
...@@ -42,6 +45,11 @@ protected: ...@@ -42,6 +45,11 @@ protected:
/** /**
* Set chip select pin * Set chip select pin
* *
* Running SPI bus at PI_CLOCK_DIV2 so we don't waste time transferring data
* and best of all, we make use of the radio's FIFO buffers. A lower speed
* means we're less likely to effectively leverage our FIFOs and pay a higher
* AVR runtime cost as toll.
*
* @param mode HIGH to take this unit off the SPI bus, LOW to put it on * @param mode HIGH to take this unit off the SPI bus, LOW to put it on
*/ */
void csn(int mode); void csn(int mode);
...@@ -49,10 +57,10 @@ protected: ...@@ -49,10 +57,10 @@ protected:
/** /**
* Set chip enable * Set chip enable
* *
* @param mode HIGH to actively begin transmission or LOW to put in standby. Please see data sheet * @param level HIGH to actively begin transmission or LOW to put in standby. Please see data sheet
* for a much more detailed description of this pin. * for a much more detailed description of this pin.
*/ */
void ce(int mode); void ce(int level);
/** /**
* Read a chunk of data in from a register * Read a chunk of data in from a register
...@@ -390,6 +398,13 @@ public: ...@@ -390,6 +398,13 @@ public:
*/ */
void powerDown(void); void powerDown(void);
/**
* Leave low-power mode - making radio more responsive
*
* To return to low power mode, call powerDown().
*/
void powerUp(void) ;
/** /**
* Test whether there are bytes available to be read * Test whether there are bytes available to be read
* *
...@@ -467,6 +482,14 @@ public: ...@@ -467,6 +482,14 @@ public:
*/ */
bool isAckPayloadAvailable(void); bool isAckPayloadAvailable(void);
/**
* Determine whether the hardware is an nRF24L01+ or not.
*
* @return true if the hardware is nRF24L01+ (or compatible) and false
* if its not.
*/
boolean isPVariant(void) ;
/** /**
* Call this when you get an interrupt to find out why * Call this when you get an interrupt to find out why
* *
...@@ -489,6 +512,17 @@ public: ...@@ -489,6 +512,17 @@ public:
*/ */
void setAutoAck(bool enable); void setAutoAck(bool enable);
/**
* Enable or disable auto-acknowlede packets on a per pipeline basis.
*
* AA is enabled by default, so it's only needed if you want to turn
* it off/on for some reason on a per pipeline basis.
*
* @param which pipeline to modify
* @param enable Whether to enable (true) or disable (false) auto-acks
*/
void setAutoAck( uint8_t pipe, bool enable ) ;
/** /**
* Test whether there was a carrier on the line for the * Test whether there was a carrier on the line for the
* previous listening period. * previous listening period.
...@@ -499,10 +533,43 @@ public: ...@@ -499,10 +533,43 @@ public:
*/ */
bool testCarrier(void); bool testCarrier(void);
/**
* Test whether a signal (carrier or otherwise) greater than
* or equal to -64dBm is present on the channel. Valid only
* on nRF24L01P (+) hardware. On nRF24L01, use testCarrier().
*
* Useful to check for interference on the current channel and
* channel hopping strategies.
*
* @return true if signal => -64dBm, false if not
*/
boolean testRPD(void) ;
/**
* Set Power Amplifier (PA) level to one of four levels.
* Relative mnemonics have been used to allow for future PA level
* changes. According to 6.5 of the nRF24L01+ specification sheet,
* they translate to: RF24_PA_MIN=-18dBm, RF24_PA_LOW=-12dBm,
* RF24_PA_MED=-6dBM, and RF24_PA_HIGH=0dBm.
*
* @param Desired PA level.
*/
void setPALevel( rf24_pa_dbm_e level ) ;
/**
* Fetches the current PA level.
*
* @return Returns a value from the rf24_pa_dbm_e enum describing
* the current PA setting. Please remember, all values represented
* by the enum mnemonics are negative dBm. See setPALevel for
* return value descriptions.
*/
rf24_pa_dbm_e getPALevel( void ) ;
/** /**
* Set the transmission data rate * Set the transmission data rate
* *
* @param speed RF24_1MBPS for 1Mbps or RF24_2MBPS for 2Mbps * @param speed RF24_250KBPS for 250kbs, RF24_1MBPS for 1Mbps, or RF24_2MBPS for 2Mbps
*/ */
void setDataRate(rf24_datarate_e speed); void setDataRate(rf24_datarate_e speed);
...@@ -513,6 +580,12 @@ public: ...@@ -513,6 +580,12 @@ public:
*/ */
void setCRCLength(rf24_crclength_e length); void setCRCLength(rf24_crclength_e length);
/**
* Disable CRC validation
*
*/
void disableCRC( void ) ;
/**@}*/ /**@}*/
}; };
......
...@@ -75,8 +75,7 @@ ...@@ -75,8 +75,7 @@
#define ARC 0 #define ARC 0
#define PLL_LOCK 4 #define PLL_LOCK 4
#define RF_DR 3 #define RF_DR 3
#define RF_PWR 1 #define RF_PWR 6
#define LNA_HCURR 0
#define RX_DR 6 #define RX_DR 6
#define TX_DS 5 #define TX_DS 5
#define MAX_RT 4 #define MAX_RT 4
...@@ -112,3 +111,15 @@ ...@@ -112,3 +111,15 @@
#define FLUSH_RX 0xE2 #define FLUSH_RX 0xE2
#define REUSE_TX_PL 0xE3 #define REUSE_TX_PL 0xE3
#define NOP 0xFF #define NOP 0xFF
/* Non-P omissions */
#define LNA_HCURR 0
/* P model memory Map */
#define RPD 0x09
/* P model bit Mnemonics */
#define RF_DR_LOW 5
#define RF_DR_HIGH 3
#define RF_PWR_LOW 1
#define RF_PWR_HIGH 2
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment