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
8f17e63a
Commit
8f17e63a
authored
Aug 04, 2011
by
maniacbug
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add getDataRate, add DISABLED to data rate enum
parent
48336102
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
9 deletions
+40
-9
RF24.cpp
RF24.cpp
+32
-8
RF24.h
RF24.h
+8
-1
No files found.
RF24.cpp
View file @
8f17e63a
...
...
@@ -911,16 +911,22 @@ rf24_datarate_e RF24::getDataRate( void )
void
RF24
::
setCRCLength
(
rf24_crclength_e
length
)
{
uint8_t
config
=
read_register
(
CONFIG
)
&
~
_BV
(
CRCO
)
;
uint8_t
config
=
read_register
(
CONFIG
)
&
~
(
_BV
(
CRCO
)
|
_BV
(
EN_CRC
)
)
;
// Always make sure CRC hardware validation is actually on
config
|=
_BV
(
EN_CRC
)
;
// Now config 8 or 16 bit CRCs - only 16bit need be turned on
// 8b is the default.
if
(
length
==
RF24_CRC_16
)
switch
(
length
)
{
config
|=
_BV
(
CRCO
)
;
case
RF24_CRC_DISABLED
:
break
;
case
RF24_CRC_8
:
config
|=
_BV
(
EN_CRC
);
break
;
case
RF24_CRC_16
:
default:
config
|=
_BV
(
EN_CRC
);
config
|=
_BV
(
CRCO
);
break
;
}
write_register
(
CONFIG
,
config
)
;
...
...
@@ -928,6 +934,24 @@ void RF24::setCRCLength(rf24_crclength_e length)
/****************************************************************************/
rf24_crclength_e
RF24
::
getCRCLength
(
void
)
{
rf24_crclength_e
result
=
RF24_CRC_DISABLED
;
uint8_t
config
=
read_register
(
CONFIG
)
&
(
_BV
(
CRCO
)
|
_BV
(
EN_CRC
))
;
if
(
config
&
_BV
(
EN_CRC
)
)
{
if
(
config
&
_BV
(
CRCO
)
)
result
=
RF24_CRC_16
;
else
result
=
RF24_CRC_8
;
}
return
result
;
}
/****************************************************************************/
void
RF24
::
disableCRC
(
void
)
{
uint8_t
disable
=
read_register
(
CONFIG
)
&
~
_BV
(
EN_CRC
)
;
...
...
RF24.h
View file @
8f17e63a
...
...
@@ -14,7 +14,7 @@
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_
DISABLED
=
0
,
RF24_CRC_8
,
RF24_CRC_16
}
rf24_crclength_e
;
/**
* Driver for nRF24L01(+) 2.4GHz Wireless Transceiver
...
...
@@ -481,6 +481,13 @@ public:
*/
void
setCRCLength
(
rf24_crclength_e
length
);
/**
* Get the CRC length
*
* @return RF24_DISABLED if disabled or RF24_CRC_8 for 8-bit or RF24_CRC_16 for 16-bit
*/
rf24_crclength_e
getCRCLength
(
void
);
/**
* Disable CRC validation
*
...
...
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