Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
RF24
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
RF24
Commits
602d9626
Commit
602d9626
authored
Jul 31, 2011
by
maniacbug
Browse files
Options
Browse Files
Download
Plain Diff
Merge gcopeland/constremove
parents
d436895f
0c2515df
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
345 additions
and
47 deletions
+345
-47
RF24.cpp
RF24.cpp
+255
-41
RF24.h
RF24.h
+77
-4
nRF24L01.h
nRF24L01.h
+13
-2
No files found.
RF24.cpp
View file @
602d9626
This diff is collapsed.
Click to expand it.
RF24.h
View file @
602d9626
...
...
@@ -12,7 +12,8 @@
#include <stddef.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
;
/**
...
...
@@ -24,6 +25,8 @@ class RF24
private:
uint8_t
ce_pin
;
/**< "Chip Enable" pin, activates the RX or TX role */
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 */
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. */
...
...
@@ -42,6 +45,11 @@ protected:
/**
* 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
*/
void
csn
(
int
mode
);
...
...
@@ -49,10 +57,10 @@ protected:
/**
* 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.
*/
void
ce
(
int
mode
);
void
ce
(
int
level
);
/**
* Read a chunk of data in from a register
...
...
@@ -390,6 +398,13 @@ public:
*/
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
*
...
...
@@ -467,6 +482,14 @@ public:
*/
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
*
...
...
@@ -489,6 +512,17 @@ public:
*/
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
* previous listening period.
...
...
@@ -499,10 +533,43 @@ public:
*/
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
*
* @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
);
...
...
@@ -513,6 +580,12 @@ public:
*/
void
setCRCLength
(
rf24_crclength_e
length
);
/**
* Disable CRC validation
*
*/
void
disableCRC
(
void
)
;
/**@}*/
};
...
...
nRF24L01.h
View file @
602d9626
...
...
@@ -75,8 +75,7 @@
#define ARC 0
#define PLL_LOCK 4
#define RF_DR 3
#define RF_PWR 1
#define LNA_HCURR 0
#define RF_PWR 6
#define RX_DR 6
#define TX_DS 5
#define MAX_RT 4
...
...
@@ -112,3 +111,15 @@
#define FLUSH_RX 0xE2
#define REUSE_TX_PL 0xE3
#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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment