I need a gpio to control an external peripheral.
I thought to code should be similar to controlling one of the leds.
board overlay:
&gpio17 {
status = "okay"
gpio17: gpio_17 {
gpios = <&gpio0 17 0>;
label = "PUP";
};
}
Source:
#define PUP_NODE DT_ALIAS(gpio17)
#if DT_NODE_HAS_STATUS(PUP_NODE, okay)
#define PUP DT_GPIO_LABEL(PUP_NODE, gpios)
#define PUP_PIN DT_GPIO_PIN(PUP_NODE, gpios)
#define PUP_FLAGS DT_GPIO_FLAGS(PUP_NODE, gpios)
#else
#error "Unsupported board: gpio17 devicetree alias is not defined"
#endif
const struct device *power_up = device_get_binding(PUP);
gpio_pin_configure(power_up, PUP_PIN, GPIO_OUTPUT_ACTIVE | PUP_FLAGS);
gpio_pin_set(power_up, PUP_PIN, (int)power_up_is_on);
building this with west gives me a syntax error related to the overlay
I don't understand how overlays should define additional gpios beyond the standard ones for leds.
Any advice please?