Hi
I want to set P0.01 as gpio high, how do I configure in overlay file?
so that it remain high whenever I used overlay file.
Thanks !!
Hi
I want to set P0.01 as gpio high, how do I configure in overlay file?
so that it remain high whenever I used overlay file.
Thanks !!
Hello
You can configure the pins for extra flags using GPIO.H functions
like:
gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
where the label led is obtained from the overlay using
GPIO_DT_SPEC_GET(DT_ALIAS(led0), gpios);
Hello
You can configure the pins for extra flags using GPIO.H functions
like:
gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
where the label led is obtained from the overlay using
GPIO_DT_SPEC_GET(DT_ALIAS(led0), gpios);
Thanks for reply !!
I do want to change the application code,
using overlay file want to modify the pin status.
In which location/section of overlay file I have to use below line
gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
This line should be used in main code, not in the overlay.
Hi
I want to set p0.21 pin high/low on every boot.
How to configure it?
Thanks and regards,
Amol
Hi Amol,
The following code would do the work. It would set pin 14 high whenever the mcu is booted. (I have tested with the pin number 14 that is connected to the led1).
#include <zephyr/kernel.h> #include <zephyr/device.h> #include <zephyr/devicetree.h> #include <zephyr/drivers/gpio.h> #define PORT gpio0 #define PIN 14 #define DIRFLAG 1 static const struct device * DEV = DEVICE_DT_GET(DT_NODELABEL(PORT)); int main(void) { struct gpio_dt_spec pinspec = {.port=DEV, .pin=PIN, .dt_flags=DIRFLAG}; gpio_pin_configure_dt(&pinspec, GPIO_OUTPUT_ACTIVE); gpio_pin_set_dt(&pinspec,1); }