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

wrap MRAA lib's Gpio::isr() for IRQ support #970

Merged
merged 4 commits into from
Mar 31, 2024
Merged

wrap MRAA lib's Gpio::isr() for IRQ support #970

merged 4 commits into from
Mar 31, 2024

Conversation

2bndy5
Copy link
Member

@2bndy5 2bndy5 commented Mar 26, 2024

I also removed MRAA exclusion from examples build. Previously, interruptConfigure.cpp was not built for MRAA driver.

github-actions[bot]

This comment was marked as resolved.

I also removed MRAA exclusion from examples build. Previously, interruptConfigure.cpp was not built for MRAA driver.
github-actions[bot]

This comment was marked as duplicate.

@github-actions github-actions bot dismissed their stale review March 26, 2024 23:47

outdated suggestion

github-actions[bot]

This comment was marked as resolved.

@github-actions github-actions bot dismissed their stale review March 26, 2024 23:48

outdated suggestion

@2bndy5
Copy link
Member Author

2bndy5 commented Mar 26, 2024

This seems to work on my RPi3 if example_linux/interruptConfigure.cpp does not call pinMode(IRQ_PIN, INPUT). If pinMode(IRQ_PIN, INPUT) is called, I get

terminate called after throwing an instance of 'GPIOException'
  what():  [GPIO::open] Could not set the pin direction; Invalid resource
Aborted

@2bndy5
Copy link
Member Author

2bndy5 commented Mar 29, 2024

stranger and stranger.

with this example patch

diff --git a/examples_linux/interruptConfigure.cpp b/examples_linux/interruptConfigure.cpp
index ec71b7a..378b79f 100644
--- a/examples_linux/interruptConfigure.cpp
+++ b/examples_linux/interruptConfigure.cpp
@@ -119,8 +119,10 @@ int main(int argc, char** argv)
     // radio.printDetails();       // (smaller) function that prints raw register values
     // radio.printPrettyDetails(); // (larger) function that prints human readable data
 
+#ifndef MRAA
     // setup the digital input pin connected to the nRF24L01's IRQ pin
-    pinMode(IRQ_PIN, INPUT);
+    pinMode(IRQ_PIN, INPUT); // not needed for MRAA driver (causes error in most cases)
+#endif
 
     // register the interrupt request (IRQ) to call our
     // Interrupt Service Routine (ISR) callback function interruptHandler()

I get the following prompts:

brendan@rpi3-64bit:~/github/RF24/examples_linux/build $ ./interruptConfigure 
terminate called after throwing an instance of 'GPIOException'
  what():  [GPIO::open] Could not set the pin direction; Invalid resource
Aborted
brendan@rpi3-64bit:~/github/RF24/examples_linux/build $ ./interruptConfigure 
./interruptConfigure
Which radio is this? Enter '0' or '1'. Defaults to '0' 
terminate called after throwing an instance of 'IRQException'
  what():  [attachInterrupt] Could not set the pin as an input; Invalid resource
Aborted
brendan@rpi3-64bit:~/github/RF24/examples_linux/build $ ./interruptConfigure 
./interruptConfigure
Which radio is this? Enter '0' or '1'. Defaults to '0' 
*** PRESS 'T' to begin transmitting to the other node
*** PRESS 'R' to begin receiving from the other node
*** PRESS 'Q' to exit

and yet the example still works when it finally initializes the hardware as expected.

@2bndy5
Copy link
Member Author

2bndy5 commented Mar 29, 2024

When I leave the pinMode() call in (for MRAA driver), it still works. It seems the MRAA lib is just having trouble initializing the hardware some how. 🤷🏼‍♂️ I should note that the TX role of the interrupt example is noticeably slower using MRAA, compared to any other driver. And this only works on my RPi3, MRAA doesn't seem to support the RPi4 very well.

@TMRh20
Copy link
Member

TMRh20 commented Mar 31, 2024

This tests OK on my RPi model B with all tested examples with no error msgs.

@2bndy5
Copy link
Member Author

2bndy5 commented Mar 31, 2024

I'm not happy with the performance, but it's better than no interrupt support using mraa driver.

The hardware unit problem is still perplexing though.

@2bndy5 2bndy5 merged commit c0cff53 into master Mar 31, 2024
23 checks passed
@2bndy5 2bndy5 deleted the mraa-isr branch March 31, 2024 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants