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

refactor: set /dev/gpiochip0 as default #1018

Merged
merged 6 commits into from
Feb 1, 2025
Merged

refactor: set /dev/gpiochip0 as default #1018

merged 6 commits into from
Feb 1, 2025

Conversation

2bndy5
Copy link
Member

@2bndy5 2bndy5 commented Jan 27, 2025

resolves #1017

This also adds some info to the docs that was requested in #1017

@2bndy5 2bndy5 added the bugfix label Jan 27, 2025
@2bndy5 2bndy5 changed the title set default gpiochip to 0 refactor: set /dev/gpiochip0 as default Jan 27, 2025

This comment was marked as off-topic.

resolves #1017

This also adds some info to the docs that was requested in #1017
@2bndy5
Copy link
Member Author

2bndy5 commented Feb 1, 2025

I'm looking at this more in depth. I think we can get rid of the GPIOChipCache::chipInitialized member. Before this patch, chipInitialized was used to prevent changing the GPIOChipCache::chip string when using more than 1 radio object in the app (ie using multiple calls to pinMode()).

Furthermore, I think we can also get rid of GPIOChipCache::chip and just use RF24_LINUX_GPIO_CHIP directly.

@2bndy5
Copy link
Member Author

2bndy5 commented Feb 1, 2025

I also figured that the cached FD for the GPIO chip could be static (e8269f6). This allows the gpio.cpp and interrupt.cpp modules use the same exact FD for accessing the GPIO chip. 🎉

@2bndy5
Copy link
Member Author

2bndy5 commented Feb 1, 2025

LGTM

This works as expected on my RPi3 and RPi4 (both 64-bit). I specifically tested the interrupt example because it uses all the code changes in this patch. I also ran a modified getting-started example in which 2 radio objects were init'd (second radio obj failed as expected) and a third pinMode(21, OUTPUT) was called from the userspace.

Copy link
Member

@TMRh20 TMRh20 left a comment

Choose a reason for hiding this comment

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

Quick tests on RPi5: 64-bit & RPi4: 32-bit are working. Good job on these changes!

@2bndy5
Copy link
Member Author

2bndy5 commented Feb 1, 2025

I probably could've used the static trick before, but the pinMode() wrapper isn't intended to be used publicly; the main reason I think the drivers' implementation should be namespaced (#926).

@2bndy5 2bndy5 merged commit 929a5aa into master Feb 1, 2025
81 checks passed
@2bndy5 2bndy5 deleted the gpiochip0-default branch February 1, 2025 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CE pin and rockchip 3588 boards
2 participants