Olimex Support Forum

ARM => ST => Topic started by: sachinkum0009 on March 10, 2023, 05:18:20 PM

Title: How to use Arduino Headers in Zephyr RTOS
Post by: sachinkum0009 on March 10, 2023, 05:18:20 PM
Hi,
Greetings

I am stuck in an issue where I want to use the Arduino Header of the STM32 E407 using the Zephyr RTOS.

#define PORT    "GPIOA"
#define PIN_A   11
dev = device_get_binding(PORT);
gpio_pin_configure(dev, PIN_A, GPIO_OUTPUT);
gpio_pin_set(dev, PIN_A, 1);

But it is not giving any output. I also tried with reading the input, but still it also does not work. Can you please guide me and correct me what am doing wrong.

Thanks
Title: Re: How to use Arduino Headers in Zephyr RTOS
Post by: sachinkum0009 on March 13, 2023, 06:47:08 PM
Can someone please help me with this?
Title: Re: How to use Arduino Headers in Zephyr RTOS
Post by: LubOlimex on March 14, 2023, 09:39:09 AM
Not sure if anyone around here is familiar with Zephyr RTOS... Maybe also post in the Zephyr forums, if you haven't already.
Title: Re: How to use Arduino Headers in Zephyr RTOS
Post by: KloudJack on March 24, 2023, 06:08:03 PM
You'll need to create a devicetree overlay (https://docs.zephyrproject.org/latest/build/dts/howtos.html#set-devicetree-overlays) with the GPIO pins you want to use for your board, and reference that devicetree node when configuring the GPIO pin.

The button (https://docs.zephyrproject.org/latest/samples/basic/button/README.html) sample (https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/basic/button) is a good example of both input and output GPIO usage.

Since the STM32 GPIO banks are labeled with letters instead of numbers, your devicetree overlay GPIO node configuration would have to look something like the following example for driving an LED:

/ {
leds {
    compatible = "gpio-leds";
    green_led_1: led_0 {
      gpios = <&gpioa 11 GPIO_ACTIVE_HIGH>;
      label = "User LED1";
    };
  };
};