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
b491480d
Commit
b491480d
authored
Jul 16, 2011
by
Greg Copeland
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reverted constructor changes. Changed SPI bus speed. Fixed setAutoAck
for specific pipelines per suggestion.
parent
059efa5f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
23 deletions
+15
-23
RF24.cpp
RF24.cpp
+11
-11
RF24.h
RF24.h
+4
-12
No files found.
RF24.cpp
View file @
b491480d
...
...
@@ -35,9 +35,9 @@ void RF24::csn(const int mode) const
/******************************************************************/
void
RF24
::
ce
(
const
int
mode
)
const
void
RF24
::
ce
(
const
int
level
)
const
{
digitalWrite
(
ce_pin
,
mode
);
digitalWrite
(
ce_pin
,
level
);
}
/******************************************************************/
...
...
@@ -208,14 +208,11 @@ void RF24::print_observe_tx(uint8_t value) const
/******************************************************************/
RF24
::
RF24
(
const
uint8_t
_cepin
,
const
uint8_t
_cspin
,
const
rf24_datarate_e
speed
,
const
uint8_t
channel
)
:
RF24
::
RF24
(
const
uint8_t
_cepin
,
const
uint8_t
_cspin
)
:
ce_pin
(
_cepin
),
csn_pin
(
_cspin
),
wide_band
(
true
),
p_variant
(
false
),
payload_size
(
32
),
ack_payload_available
(
false
)
{
begin
()
;
setDataRate
(
speed
)
;
setChannel
(
channel
)
;
}
/******************************************************************/
...
...
@@ -305,13 +302,12 @@ void RF24::begin(void)
pinMode
(
ce_pin
,
OUTPUT
);
pinMode
(
csn_pin
,
OUTPUT
);
SPI
.
begin
();
ce
(
LOW
);
csn
(
HIGH
);
SPI
.
begin
();
SPI
.
setBitOrder
(
MSBFIRST
);
SPI
.
setDataMode
(
SPI_MODE0
);
SPI
.
setClockDivider
(
SPI_CLOCK_DIV
8
);
SPI
.
setClockDivider
(
SPI_CLOCK_DIV
2
);
// Set 1500uS (minimum for 32B payload in ESB@250KBPS) timeouts, to make testing a little easier
// WARNING: If this is ever lowered, either 250KBS mode with AA is broken or maximum packet
...
...
@@ -331,7 +327,7 @@ void RF24::begin(void)
// Determine if this is a p or non-p RF24 module and then
// reset our data rate back to default value. This works
// because a non-P variant won't allow the data rate to
// be set to 250K
BS
.
// be set to 250K
bps
.
if
(
setDataRate
(
RF24_250KBPS
)
)
{
p_variant
=
true
;
}
...
...
@@ -636,7 +632,11 @@ void RF24::setAutoAck(const bool enable) const
void
RF24
::
setAutoAck
(
const
uint8_t
pipe
,
const
bool
enable
)
const
{
uint8_t
en_aa
=
read_register
(
EN_AA
)
;
en_aa
&=
~
((
enable
?
0
:
1
)
<<
pipe
)
;
// inverted logic here (1=off, 0=on)
if
(
enable
)
{
en_aa
|=
_BV
(
pipe
)
;
}
else
{
en_aa
&=
~
_BV
(
pipe
)
;
}
write_register
(
EN_AA
,
en_aa
)
;
}
...
...
RF24.h
View file @
b491480d
...
...
@@ -43,7 +43,7 @@ protected:
/**
* Set chip select pin
* Running SPI bus at PI_CLOCK_DIV2 so we don't wa
ist
time transferring data
* Running SPI bus at PI_CLOCK_DIV2 so we don't wa
ste
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.
...
...
@@ -55,10 +55,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
(
const
int
mode
)
const
;
void
ce
(
const
int
level
)
const
;
/**
* Read a chunk of data in from a register
...
...
@@ -193,17 +193,9 @@ public:
*
* @param _cepin The pin attached to Chip Enable on the RF module
* @param _cspin The pin attached to Chip Select
* @param speed The desired data rate of this network; default is 2Mbs
* @param channel The channel to use for this network; default is 64
*
* @warning Addition features enabled/set in the begin method should be
* migrated into our constructor. Basically features which are network
* specific should be variable and assignable here; including timeouts,
* retries, and CRC length.
*/
RF24
(
const
uint8_t
_cepin
,
const
uint8_t
_cspin
,
const
rf24_datarate_e
speed
=
RF24_2MBPS
,
const
uint8_t
channel
=
64
)
;
RF24
(
const
uint8_t
_cepin
,
const
uint8_t
_cspin
)
;
/**
* Begin operation of the chip
...
...
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