Skip to content

Commit

Permalink
replace reg | R_REGISTER with just reg
Browse files Browse the repository at this point in the history
`R_REGISTER` is defined as 0.
`reg | 0` always results in `reg`
  • Loading branch information
2bndy5 committed Jul 15, 2024
1 parent 76302fc commit 9c0ba58
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions RF24.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void RF24::read_register(uint8_t reg, uint8_t* buf, uint8_t len)
uint8_t* ptx = spi_txbuff;
uint8_t size = static_cast<uint8_t>(len + 1); // Add register value to transmit buffer

*ptx++ = (R_REGISTER | reg);
*ptx++ = (reg);

while (len--) {
*ptx++ = RF24_NOP; // Dummy operation, just for reading
Expand Down Expand Up @@ -206,7 +206,7 @@ uint8_t RF24::read_register(uint8_t reg)

uint8_t* prx = spi_rxbuff;
uint8_t* ptx = spi_txbuff;
*ptx++ = (R_REGISTER | reg);
*ptx++ = (reg);
*ptx++ = RF24_NOP; // Dummy operation, just for reading

#if defined(RF24_RP2)
Expand Down
2 changes: 1 addition & 1 deletion examples/rf24_ATTiny/timingSearch3pin/timingSearch3pin.ino
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void csn(bool mode) {
/****************************************************************************/
uint8_t read_register(uint8_t reg) {
csn(LOW);
SPI.transfer(R_REGISTER | reg);
SPI.transfer(reg);
uint8_t result = SPI.transfer(0xff);
csn(HIGH);
return result;
Expand Down

0 comments on commit 9c0ba58

Please sign in to comment.