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

revise MRAA driver's GPIO #965

Closed
6 tasks done
2bndy5 opened this issue Mar 23, 2024 · 0 comments · Fixed by #966
Closed
6 tasks done

revise MRAA driver's GPIO #965

2bndy5 opened this issue Mar 23, 2024 · 0 comments · Fixed by #966

Comments

@2bndy5
Copy link
Member

2bndy5 commented Mar 23, 2024

The MRAA driver's GPIO implementation hasn't seen many updates for years. While it doesn't work well with newer RPi4 (and above), it could still get updated to conform with other drivers' GPIO implementations. The following will allow for a more robust and less-specific implementation of Arduino wrappers for the MRAA lib:

  • cache the mraa::Gpio* instances
  • make GPIO member functions static

Solution

I'll submit a PR as a proposal. Basically, just

  • use a std::map<rf24_gpio_t, mraa::Gpio*> as a cache.
  • convert class functions into static
  • remove the non-static class (private) members:

    RF24/utility/MRAA/gpio.h

    Lines 29 to 33 in af7fbec

    private:
    int gpio_ce_pin; /** ce_pin value of the RF24 device **/
    // int gpio_cs_pin; /** cs_pin value of the RF24 device **/
    mraa::Gpio* gpio_0; /** gpio object for ce_pin **/
    // mraa::Gpio* gpio_1; /** gpio object for cs_pin **/
  • remove this:
    void GPIO::begin(uint8_t ce_pin, uint8_t cs_pin)
  • cleanup this:

    RF24/RF24.cpp

    Lines 1033 to 1036 in af7fbec

    #if defined(MRAA)
    GPIO();
    gpio.begin(ce_pin, csn_pin);
    #endif
    and this:

    RF24/RF24.h

    Lines 130 to 132 in af7fbec

    #if defined(MRAA)
    GPIO gpio;
    #endif
  • address this:
    // WARNING: use of memory mapped file system is deprecated in MRAA lib
    gpio_0->useMmap(true); // `false` (or just not calling `useMmap()`) uses default file system?

Additional context

I want this because I'm working to expose the GPIO and interrupt functions in the pyRF24 project, but the MRAA driver requires special context that seems unnecessary (in both RF24 lib and python bindings).

PS - I've already done much of this work in my CirquePinnacle lib, so it would be mostly copy-n-paste from there.

2bndy5 added a commit that referenced this issue Mar 23, 2024
2bndy5 added a commit that referenced this issue Mar 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant