Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added compatibility for RFM7X and bk242x-style nRF24 clones including… #754

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions RF24.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,17 @@ bool RF24::txStandBy()
#if defined(FAILURE_HANDLING) || defined(RF24_LINUX)
uint32_t timeout = millis();
#endif

#if defined(RF24_COMPATIBILITY_MODE_FOR_RFM7X_BK242X)
while (!((read_register(FIFO_STATUS)) & _BV(TX_EMPTY)) || !(status & _BV(TX_DS))) { //rfm75 might set TX_EMPTY although a packet is in transmission
if (status & _BV(TX_DS)) { //at least one packet has been sent
if (!(read_register(FIFO_STATUS) & _BV(TX_EMPTY))) { //check fifo again, because rfm75 might set tx_empty although packet in transmission
write_register(NRF_STATUS, _BV(TX_DS)); //this is not the last payload, so clear data sent flag
}
}
#else
while (!(read_register(FIFO_STATUS) & _BV(TX_EMPTY))) {
#endif
if (status & _BV(MAX_RT)) {
write_register(NRF_STATUS, _BV(MAX_RT));
ce(LOW);
Expand Down Expand Up @@ -1097,7 +1107,16 @@ bool RF24::txStandBy(uint32_t timeout, bool startTx)
}
uint32_t start = millis();

#if defined(RF24_COMPATIBILITY_MODE_FOR_RFM7X_BK242X)
while (!((read_register(FIFO_STATUS)) & _BV(TX_EMPTY)) || !(status & _BV(TX_DS))) { //rfm75 might set TX_EMPTY although a packet is in transmission
if (status & _BV(TX_DS)) { //at least one packet has been sent
if (!(read_register(FIFO_STATUS) & _BV(TX_EMPTY))) { //check fifo again, because rfm75 might set tx_empty although packet in transmission
write_register(NRF_STATUS, _BV(TX_DS)); //this is not the last payload, so clear data sent flag
}
}
#else
while (!(read_register(FIFO_STATUS) & _BV(TX_EMPTY))) {
#endif
if (status & _BV(MAX_RT)) {
write_register(NRF_STATUS, _BV(MAX_RT));
ce(LOW); // Set re-transmit
Expand Down
4 changes: 4 additions & 0 deletions RF24_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
//#define SPI_UART // Requires library from https://github.com/TMRh20/Sketches/tree/master/SPI_UART
//#define SOFTSPI // Requires library from https://github.com/greiman/DigitalIO

//This introduces some changes to make the library work with RFM73/75 and other bk242x derivates. See examples/rfm7xAndBk242xCompatiblity
//Those modules require additional initialization which can be done with https://github.com/jnk0le/RFM7x-lib
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this PR still requires the RFM7x lib then it should be listed as a dependency, but RFM7X is not able to install in the Arduino IDE (nor its Library Manager).

If the RFM7X lib is just a reference to originating work, then this needs to be re-worded to avoid confusion.

//#define RF24_COMPATIBILITY_MODE_FOR_RFM7X_BK242X
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to use RF24_FOR_RFM7X_BK242X as the macro name. I know some would prefer wordiness, but think of the beginners who would have to memorize and declare this in their project.


/**
* User access to internally used delay time (in microseconds) during RF24::powerUp()
* @warning This default value compensates for all supported hardware. Only adjust this if you
Expand Down
Loading