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
92373ba7
Commit
92373ba7
authored
Jun 27, 2011
by
maniacbug
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor repeated parts of printDetails into own methods
parent
aa7a7c64
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
48 deletions
+55
-48
README.md
README.md
+2
-0
RF24.cpp
RF24.cpp
+37
-48
RF24.h
RF24.h
+16
-0
No files found.
README.md
View file @
92373ba7
# Arduino driver for nRF24L01 2.4GHz Wireless Transceiver
# Arduino driver for nRF24L01 2.4GHz Wireless Transceiver
CLEANUPS BRANCH: Bits and pieces of cleanup that I haven't tested on the radios yet.
Design Goals: This library is designed to be...
Design Goals: This library is designed to be...
*
Maximally compliant with the intended operation of the chip
*
Maximally compliant with the intended operation of the chip
...
...
RF24.cpp
View file @
92373ba7
...
@@ -208,6 +208,27 @@ void RF24::print_observe_tx(uint8_t value)
...
@@ -208,6 +208,27 @@ void RF24::print_observe_tx(uint8_t value)
/******************************************************************/
/******************************************************************/
void
RF24
::
print_byte_register
(
prog_char
*
name
,
uint8_t
reg
)
{
printf_P
(
PSTR
(
"%S
\t
= 0x%02x
\n\r
"
),
read_register
(
reg
));
}
/******************************************************************/
void
RF24
::
print_address_register
(
prog_char
*
name
,
uint8_t
reg
)
{
uint8_t
buffer
[
5
];
read_register
(
reg
,
buffer
,
sizeof
buffer
);
printf_P
(
PSTR
(
"%S
\t
= 0x"
),
name
);
uint8_t
*
bufptr
=
buffer
+
sizeof
buffer
;
while
(
bufptr
--
>
buffer
)
printf_P
(
PSTR
(
"%02x"
),
*
bufptr
);
printf_P
(
PSTR
(
"
\n\r
"
));
}
/******************************************************************/
RF24
::
RF24
(
uint8_t
_cepin
,
uint8_t
_cspin
)
:
RF24
::
RF24
(
uint8_t
_cepin
,
uint8_t
_cspin
)
:
ce_pin
(
_cepin
),
csn_pin
(
_cspin
),
payload_size
(
32
),
ack_payload_available
(
false
)
ce_pin
(
_cepin
),
csn_pin
(
_cspin
),
payload_size
(
32
),
ack_payload_available
(
false
)
{
{
...
@@ -238,54 +259,22 @@ uint8_t RF24::getPayloadSize(void)
...
@@ -238,54 +259,22 @@ uint8_t RF24::getPayloadSize(void)
void
RF24
::
printDetails
(
void
)
void
RF24
::
printDetails
(
void
)
{
{
uint8_t
buffer
[
5
];
print_status
(
get_status
());
uint8_t
status
=
read_register
(
RX_ADDR_P0
,
buffer
,
5
);
print_status
(
status
);
print_address_register
(
PSTR
(
"RX_ADDR_P0"
),
RX_ADDR_P0
);
printf_P
(
PSTR
(
"RX_ADDR_P0 = 0x"
));
print_address_register
(
PSTR
(
"RX_ADDR_P1"
),
RX_ADDR_P1
);
uint8_t
*
bufptr
=
buffer
+
5
;
print_byte_register
(
PSTR
(
"RX_ADDR_P2"
),
RX_ADDR_P2
);
while
(
bufptr
--
>
buffer
)
print_byte_register
(
PSTR
(
"RX_ADDR_P3"
),
RX_ADDR_P3
);
printf_P
(
PSTR
(
"%02x"
),
*
bufptr
);
print_byte_register
(
PSTR
(
"RX_ADDR_P4"
),
RX_ADDR_P4
);
printf_P
(
PSTR
(
"
\n\r
"
));
print_byte_register
(
PSTR
(
"RX_ADDR_P5"
),
RX_ADDR_P5
);
print_address_register
(
PSTR
(
"TX_ADDR"
),
TX_ADDR
);
status
=
read_register
(
RX_ADDR_P1
,
buffer
,
5
);
printf_P
(
PSTR
(
"RX_ADDR_P1 = 0x"
));
print_byte_register
(
PSTR
(
"RX_PW_P0"
),
RX_PW_P0
);
bufptr
=
buffer
+
5
;
print_byte_register
(
PSTR
(
"RX_PW_P1"
),
RX_PW_P1
);
while
(
bufptr
--
>
buffer
)
print_byte_register
(
PSTR
(
"EN_AA"
),
EN_AA
);
printf_P
(
PSTR
(
"%02x"
),
*
bufptr
);
print_byte_register
(
PSTR
(
"EN_RXADDR"
),
EN_RXADDR
);
printf_P
(
PSTR
(
"
\n\r
"
));
print_byte_register
(
PSTR
(
"RF_CH"
),
RF_CH
);
print_byte_register
(
PSTR
(
"RF_SETUP"
),
RF_SETUP
);
status
=
read_register
(
RX_ADDR_P2
,
buffer
,
1
);
printf_P
(
PSTR
(
"RX_ADDR_P2 = 0x%02x"
),
*
buffer
);
printf_P
(
PSTR
(
"
\n\r
"
));
status
=
read_register
(
RX_ADDR_P3
,
buffer
,
1
);
printf_P
(
PSTR
(
"RX_ADDR_P3 = 0x%02x"
),
*
buffer
);
printf_P
(
PSTR
(
"
\n\r
"
));
status
=
read_register
(
TX_ADDR
,
buffer
,
5
);
printf_P
(
PSTR
(
"TX_ADDR = 0x"
));
bufptr
=
buffer
+
5
;
while
(
bufptr
--
>
buffer
)
printf_P
(
PSTR
(
"%02x"
),
*
bufptr
);
printf_P
(
PSTR
(
"
\n\r
"
));
status
=
read_register
(
RX_PW_P0
,
buffer
,
1
);
printf_P
(
PSTR
(
"RX_PW_P0 = 0x%02x
\n\r
"
),
*
buffer
);
status
=
read_register
(
RX_PW_P1
,
buffer
,
1
);
printf_P
(
PSTR
(
"RX_PW_P1 = 0x%02x
\n\r
"
),
*
buffer
);
read_register
(
EN_AA
,
buffer
,
1
);
printf_P
(
PSTR
(
"EN_AA = %02x
\n\r
"
),
*
buffer
);
read_register
(
EN_RXADDR
,
buffer
,
1
);
printf_P
(
PSTR
(
"EN_RXADDR = %02x
\n\r
"
),
*
buffer
);
read_register
(
RF_CH
,
buffer
,
1
);
printf_P
(
PSTR
(
"RF_CH = %02x
\n\r
"
),
*
buffer
);
read_register
(
RF_SETUP
,
buffer
,
1
);
printf_P
(
PSTR
(
"RF_SETUP = %02x
\n\r
"
),
*
buffer
);
}
}
/******************************************************************/
/******************************************************************/
...
...
RF24.h
View file @
92373ba7
...
@@ -161,6 +161,22 @@ protected:
...
@@ -161,6 +161,22 @@ protected:
*/
*/
void
print_observe_tx
(
uint8_t
value
)
;
void
print_observe_tx
(
uint8_t
value
)
;
/**
* Print the name and value of an 8-bit register to stdout
*
* @param name Name of the register
* @param reg Which register. Use constants from nRF24L01.h
*/
void
print_byte_register
(
prog_char
*
name
,
uint8_t
reg
);
/**
* Print the name and value of a 40-bit address register to stdout
*
* @param name Name of the register
* @param reg Which register. Use constants from nRF24L01.h
*/
void
print_address_register
(
prog_char
*
name
,
uint8_t
reg
);
/**
/**
* Turn on or off the special features of the chip
* Turn on or off the special features 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