Skip to content

Commit

Permalink
undo latest changes to SoftSPI & add patches (#771)
Browse files Browse the repository at this point in the history
* roll back all changes to SoftSPI

* release-ready patches from rp2xxx branch
  • Loading branch information
2bndy5 authored Jun 2, 2021
1 parent 0b60c0b commit 2819745
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 25 deletions.
4 changes: 0 additions & 4 deletions RF24.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,11 +509,7 @@ void RF24::_init_obj()
{
// Use a pointer on the Arduino platform
#if defined (RF24_SPI_PTR)
#if defined (SOFTSPI)
_spi = &spi;
#else // !defined(SOFTSPI)
_spi = &SPI;
#endif // !defined(SOFTSPI)
#endif // defined (RF24_SPI_PTR)

pipe0_reading_address[0] = 0;
Expand Down
4 changes: 2 additions & 2 deletions RF24_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@
#endif // SOFT_SPI_SCK_PIN

const uint8_t SPI_MODE = 0;
#define _SPI SoftSPI<SOFT_SPI_MISO_PIN, SOFT_SPI_MOSI_PIN, SOFT_SPI_SCK_PIN, SPI_MODE>
#define RF24_SPI_PTR
#define _SPI spi


#elif defined (ARDUINO_SAM_DUE)
#include <SPI.h>
Expand Down
4 changes: 2 additions & 2 deletions examples/AcknowledgementPayloads/AcknowledgementPayloads.ino
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void setup() {

memcpy(payload.message, "World ", 6); // set the payload message
// load the payload for the first received transmission on pipe 0
radio.writeAckPayload(1, &payload, sizeof(PayloadStruct));
radio.writeAckPayload(1, &payload, sizeof(payload));

radio.startListening(); // put radio in RX mode
}
Expand Down Expand Up @@ -201,7 +201,7 @@ void loop() {
memcpy(payload.message, "World ", 6); // change payload message

// load the payload for the first received transmission on pipe 0
radio.writeAckPayload(1, &payload, sizeof(PayloadStruct));
radio.writeAckPayload(1, &payload, sizeof(payload));
radio.startListening();
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/MulticeiverDemo/MulticeiverDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void loop() {
payload.payloadID++; // increment payload number

// to make this example readable in the serial monitor
delay(500); // slow transmissions down by 1 second
delay(1000); // slow transmissions down by 1 second

} else if (role == 'R') {
// This device is the RX node
Expand Down
12 changes: 6 additions & 6 deletions examples_linux/acknowledgementPayloads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ void master() {
uint8_t pipe;
if (radio.available(&pipe)) {
PayloadStruct received;
radio.read(&received, sizeof(received)); // get incoming ACK payload
radio.read(&received, sizeof(received)); // get incoming ACK payload
cout << " Received ";
cout << radio.getDynamicPayloadSize(); // print incoming payload size
cout << " bytes on pipe " << (unsigned int)pipe; // print pipe that received it
cout << ": " << received.message; // print incoming message
cout << (unsigned int)received.counter << endl; // print incoming counter
payload.counter = received.counter + 1; // save incoming counter & increment for next outgoing
cout << (unsigned int)radio.getDynamicPayloadSize(); // print incoming payload size
cout << " bytes on pipe " << (unsigned int)pipe; // print pipe that received it
cout << ": " << received.message; // print incoming message
cout << (unsigned int)received.counter << endl; // print incoming counter
payload.counter = received.counter + 1; // save incoming counter & increment for next outgoing
} // if got an ACK payload
else {
cout << " Received an empty ACK packet." << endl; // ACK had no payload
Expand Down
2 changes: 1 addition & 1 deletion examples_linux/acknowledgement_payloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def slave(timeout=6):
radio.writeAckPayload(1, buffer) # load ACK for next response
start_timer = time.monotonic() # reset timer

print("Nothing received in 6 seconds. Leaving RX role")
print("Nothing received in", timeout, "seconds. Leaving RX role")
# recommended behavior is to keep in TX mode while idle
radio.stopListening() # put radio in TX mode & flush unused ACK payloads

Expand Down
2 changes: 1 addition & 1 deletion examples_linux/getting_started.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def slave(timeout=6):
)
start_timer = time.monotonic() # reset the timeout timer

print("Nothing received in 6 seconds. Leaving RX role")
print("Nothing received in", timeout, "seconds. Leaving RX role")
# recommended behavior is to keep in TX mode while idle
radio.stopListening() # put the radio in TX mode

Expand Down
2 changes: 1 addition & 1 deletion examples_linux/manual_acknowledgements.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def slave(timeout=6):
print("Response failed or timed out")
start_timer = time.monotonic() # reset the timeout timer

print("Nothing received in 6 seconds. Leaving RX role")
print("Nothing received in", timeout, "seconds. Leaving RX role")
# recommended behavior is to keep in TX mode while idle
radio.stopListening() # put the radio in TX mode

Expand Down
2 changes: 1 addition & 1 deletion examples_linux/multiceiverDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ void master(unsigned int role) {
payload.payloadID++; // increment payload number

// to make this example readable in the terminal
delay(500); // slow transmissions down by 0.5 second
delay(1000); // slow transmissions down by 1 second
} // while
cout << failures << " failures detected. Leaving TX role." << endl;
} // master
Expand Down
9 changes: 7 additions & 2 deletions examples_linux/multiceiver_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ def master(node_number):
:param int node_number: the node's identifying index (from the
the `addresses` list). This is a required parameter
"""
# According to the datasheet, the auto-retry features's delay value should
# be "skewed" to allow the RX node to receive 1 transmission at a time.
# So, use varying delay between retry attempts and 15 (at most) retry attempts
radio.setRetries(((node_number * 3) % 12) + 3, 15); # maximum value is 15 for both args

radio.stopListening() # put radio in TX mode
# set the TX address to the address of the base station.
radio.openWritingPipe(addresses[node_number])
Expand Down Expand Up @@ -89,7 +94,7 @@ def master(node_number):
else:
failures += 1
print("failed or timed out")
time.sleep(0.5) # slow down the test for readability
time.sleep(1) # slow down the test for readability
print(failures, "failures detected. Leaving TX role.")


Expand Down Expand Up @@ -124,7 +129,7 @@ def slave(timeout=10):
)
start_timer = time.monotonic() # reset timer with every payload

print("Nothing received in 6 seconds. Leaving RX role")
print("Nothing received in", timeout, "seconds. Leaving RX role")
radio.stopListening()


Expand Down
1 change: 1 addition & 0 deletions examples_linux/streaming_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def slave(timeout=6):
print("Received: {} - {}".format(receive_payload, count))
start_timer = time.monotonic() # reset timer on every RX payload

print("Nothing received in", timeout, "seconds. Leaving RX role")
# recommended behavior is to keep in TX mode while idle
radio.stopListening() # put the radio in TX mode

Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "git",
"url": "https://github.com/nRF24/RF24.git"
},
"version": "1.4.0",
"version": "1.4.1",
"frameworks": "arduino",
"platforms": [
"atmelavr",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=RF24
version=1.4.0
version=1.4.1
author=TMRh20
maintainer=TMRh20,Avamander
sentence=Radio driver, OSI layer 2 library for nrf24L01(+) modules.
Expand Down
6 changes: 4 additions & 2 deletions utility/RPi/RF24_arch_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@

#define _SPI spi

#if defined SPI_HAS_TRANSACTION && !defined SPI_UART && !defined SOFTSPI
#if defined (SPI_HAS_TRANSACTION)
// this gets triggered as /utility/RPi/spi.h defines SPI_HAS_TRANSACTION (unless modified by end-user)
#define RF24_SPI_TRANSACTIONS
#endif

// GCC a Arduino Missing
#define _BV(x) (1<<(x))
#define pgm_read_word(p) (*(p))
Expand All @@ -39,7 +41,7 @@
#endif

#define digitalWrite(pin, value) bcm2835_gpio_write(pin, value)
#define pinMode(pin, value) bcm2835_gpio_fsel(pin,value)
#define pinMode(pin, value) bcm2835_gpio_fsel(pin, value)
#define OUTPUT BCM2835_GPIO_FSEL_OUTP
#define INPUT BCM2835_GPIO_FSEL_INPT
#endif

0 comments on commit 2819745

Please sign in to comment.