Skip to content

Commit 513dc45

Browse files
committed
openReadingPipe(0) should not overwrite TX address in TX mode
1 parent 7125fb4 commit 513dc45

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

RF24.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -1198,7 +1198,7 @@ void RF24::stopListening(void)
11981198
void RF24::stopListening(const uint8_t* tx_address)
11991199
{
12001200
memcpy(txAddress, tx_address, addr_width);
1201-
startListening();
1201+
stopListening();
12021202
write_register(TX_ADDR, txAddress, addr_width);
12031203
}
12041204

@@ -1606,12 +1606,12 @@ void RF24::openReadingPipe(uint8_t child, uint64_t address)
16061606

16071607
if (child <= 5) {
16081608
// For pipes 2-5, only write the LSB
1609-
if (child < 2) {
1610-
write_register(pgm_read_byte(&child_pipe[child]), reinterpret_cast<const uint8_t*>(&address), addr_width);
1611-
}
1612-
else {
1609+
if (child > 1) {
16131610
write_register(pgm_read_byte(&child_pipe[child]), reinterpret_cast<const uint8_t*>(&address), 1);
16141611
}
1612+
else if (static_cast<bool>(config_reg & _BV(PRIM_RX)) || child != 0) {
1613+
write_register(pgm_read_byte(&child_pipe[child]), reinterpret_cast<const uint8_t*>(&address), addr_width);
1614+
}
16151615

16161616
// Note it would be more efficient to set all of the bits for all open
16171617
// pipes at once. However, I thought it would make the calling code
@@ -1648,12 +1648,12 @@ void RF24::openReadingPipe(uint8_t child, const uint8_t* address)
16481648
}
16491649
if (child <= 5) {
16501650
// For pipes 2-5, only write the LSB
1651-
if (child < 2) {
1652-
write_register(pgm_read_byte(&child_pipe[child]), address, addr_width);
1653-
}
1654-
else {
1651+
if (child > 1) {
16551652
write_register(pgm_read_byte(&child_pipe[child]), address, 1);
16561653
}
1654+
else if (static_cast<bool>(config_reg & _BV(PRIM_RX)) || child != 0) {
1655+
write_register(pgm_read_byte(&child_pipe[child]), address, addr_width);
1656+
}
16571657

16581658
// Note it would be more efficient to set all of the bits for all open
16591659
// pipes at once. However, I thought it would make the calling code

0 commit comments

Comments
 (0)