-
Notifications
You must be signed in to change notification settings - Fork 1k
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
IRQ support using Linux kernel Character Device + Posix threads #961
Conversation
- Add timeout to interrupt example
remove unused `#include` and reorder so that std/external libs are pre-processed first
- switch RPi driver to char-dev IRQ - wrap wiringPiIsr() into attachInterrupt() - adjust build system generators (lib and examples) - use IRQException instead of GPIOException - make defined RF24_LINUX_GPIO_CHIP more agnostic of selected driver (applied to RPi and SPIDEV drivers) - fix compiling wiringPi with examples using old makefile - update URL in examples_linux/README - remove explicit wiringPi from list of linked libs in pyRF24/setup.py
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
I am not going to try cross-compiling dependencies of dependencies. WiringPi needs libs: crypt and rt compiled for the target system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice work! Still needs some testing on my part, but we can hold off on doing a release for a little bit.
The 2 drivers mainly effected by this are SPIDEV and RPi. We've tested SPIDEV rather well. I tested RPi with expected results. I don't expect RPi to have different IRQ behavior because the code is pretty much copied from SPIDEV's gpio and interrupt sources. Most other changes should only affect the build/compilation process. But, wiringPi SPI wrapper should be re-tested. |
this should fix the issue with loading pyRF24 modules( downstream) when building docs. There should be negligible performance hit as most of this init stuff (`pinMode()` and `attachInterrupt()`) only takes place at user space startup. Although, devs that dynamically allocate pins (with `RF24::begin(CE, CSN)`) will see a performance cost.
I just went through another round of hardware tests. Caution The interruptConfigure example doesn't work with wiringPi because wiringPi doesn't like using GPIO24 (wiringPi # 5) for the radio's IRQ pin.
On RPi3All drivers still work on RPi3. On RPi4RPi, SPIDEV, wiringPi, and pigpio still work on RP4. MRAA doesn't work on RPi4, but I think that was known already. |
I think I'm finally ready to merge this. I reviewed the code 3 times since opening this PR. Hardware tested all drivers twice on both my RPi setups. This one was so ambitious, I'm pretty sure there's something I'm missing... |
Just FYI been testing on RPi5, 4, 3 and 2 for speed, stability & functionality and have found 0 problems. |
I want to add a bool to the |
resolves #943
I think its ready. Given the fact that nRF24/RF24Gateway#32 relies on these changes, I'm ready to move forward and patch things up as (or if) they occur.
Interrupt changes
attachInterrupt()
anddetachInterrupt()
for both SPIDEV and RPi drivers. Combined with Posix threads, this gives a very quick and reliable behavior that one would expect from microcontroller platforms.wiringPiISR()
intoattachInterrupt()
for better compatibility with interruptConfigure Linux example. NodetachInterrupt()
is provided as the wiringPi does not implement that functionality (to my knowledge).IRQ_PIN
to 24 in examples_linux/interruptConfigure.cpp along with a TX timeout and improved stdout displayattachInterrupt()
anddetachInterrrupt()
are not exposed in the python bindings, so python user are still left to find other opportunities to use the radio's IRQ pin in python (RPi.GPIO, pigpio, gpiod, etc).This means we can also re-enable wiringPi driver in Linux CI using the old static makefiles.Cross-compiling wiringPi requires cross-compiled dependencies (crypt
andrt
in this case); I re-disabled wiringPi in CI builds that are cross-compiled.Changes that follow-up #959
GPIO::open
(for SPIDEV driver).attachInterrupt()
also does GPIO chip verification and info fetching for both RPi and SPIDEV drivers. (see Bump RF24 from9eca153
to05efe34
pyRF24#41 (comment))RF24_SPIDEV_GPIO_CHIP
macro definition is renamed toRF24_LINUX_GPIO_CHIP
because it affects the GPIO/IRQ support for SPIDEV driver and the IRQ support for RPi driver.Additional changes
In reviewing the Linux drivers for interrupt support, I also went through and
#include
statements, presumably from unchecked copy-and-paste of utility/Template files.SPIException
messages in SPIDEV driver to be a bit more helpful/descriptive./dev/spidev0.1
(previously hard-coded to/dev/spidev0.0
)