Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5190

Device Tree • Re: How to select a device tree on the basis of GPIOs?

$
0
0

Kinda. GPIO based conditional filters are XOR and last one wins. That means one GPIO per overlay or combination of overlays except for the default.

Code:

[gpio0=1]dtoverlay=foo[gpio1=1]dtoverly=bar[all]
If both GPIO0 and GPIO1 are high you only get the bar overlay loaded. If GPIO0 is high and GPIO1 is low you get nothing.

Similarly,

Code:

[gpio0=1][gpio1=1]dtoverlay=baz[all]
Will load baz if GPIO1 is high, not, as you might expect, only if both GPIO0 and GPIO1 are high.

Code:

[gpio0=1]dtoverlay=foo[all][gpio1=1]dtoverly=bar[all]
Might load both if both GPIO are high but you'd need to test that as it's been a long time since I tried.
This is not possible, only the last condition will win. For example, if case of gpio0 and gpio1, dtoverlay will only be equal to baz if gpio01=1

To which of those examples are you referring? If the second one, isn't that what I said (that's the only one where I used "baz")?

If you're referring to my last exmple (which does not use "baz"), I believe I said that it "might load both" and that "you'd need to test that".

Statistics: Posted by thagrol — Tue Jun 25, 2024 12:45 pm



Viewing all articles
Browse latest Browse all 5190

Trending Articles