On Tue 2019-04-02 12:23:29, Alexander Dahl wrote: > Hello everyone, > > on my desk lies a piece of hardware with some dual color LEDs connected to > some IO ports. The LEDs shine green or red depending on polarity and are > connected in between two data output lines or GPIO ports like this: > > ------. > | LED > P1 |---->|-------. > | ___ | > P2 |---|___|-----' > | > ------' > > The logic table is this one: > > P1 | P2 | LED > -- + -- + ----- > 0 | 0 | off > 0 | 1 | green > 1 | 0 | red > 1 | 1 | off > > So there are three states: red, green and off, red and green are mutual > exclusive, both colors can not be switched on independently at the same time. > > I guess this is a quite common setup in embedded electronics, but how would > one model that with Linux? How would I describe it in device tree and how > would the sysfs interface for trigger etc. look like? Fortunately, that is not too common setup. You still need two output pins and two LEDs, AFAICT only advantage is that you save one resistor. Don't do it. That said, driver that takes two GPIOs and exposes one LED with aditional color attribute should be acceptable. Best regards, Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Attachment:
signature.asc
Description: Digital signature