Non-static GPIO Pin Possible? #1104
Replies: 1 comment
-
We don't have a runtime version of the GPIO implementation. You need to pass all GPIOs as template parameters, like all drivers do it (the CS for SPI drivers for example). This obviously doesn't scale well, therefore we investigated implementing a runtime version as well, but I got distracted with other stuff. We particularly wanted an interface that we can stuff GPIO expanders into transparently, which only works with fiber support though (for transparent scheduling). For now you can take function pointers of all static methods, something like |
Beta Was this translation helpful? Give feedback.
-
Disclaimer: I know this goes against the grain of MODM...
I wrote a small LED class to control the blinking and blink rates for the LEDs on the Nucleo H723 dev board. I know there is already a simple LED class in MODM with animations, which appears to be configurable to do this. But I rolled my own in order to see if I could write a MODM-style class from scratch (borrowing from examples). After a little bit of trial-and-error, I succeeded (see below). Next, I wanted to make the same class in the old C++ style, where I pass the LED's GPIO pin to the class constructor at run-time. I don't really need this ability, I just wanted to know how to do it for possible future things.
The problem is that I cannot figure out what "non-static" type to call a generic GPIO output pin. In all the examples and board description files, LEDs are defined explicitly and hard-wired to the exact pin. For example, for the yellow LED on this board which is found on PE1, we have
using LedYellow = GpioOutputE1;
in theboard.hpp
file.But what is the class for a generic GPIO output pin? I would like to be able to do this, at least for the purposes of this learning exercise:
Obviously
modm::GpioIO
doesn't work, but neither do any of the other likely candidates, either.Note: here is my take on a MODM-style LED blinking class, which does work:
Beta Was this translation helpful? Give feedback.
All reactions