November 23, 2024, 05:21:07 AM

How to use Arduino Headers in Zephyr RTOS

Started by sachinkum0009, March 10, 2023, 05:18:20 PM

Previous topic - Next topic

sachinkum0009

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

sachinkum0009


LubOlimex

Not sure if anyone around here is familiar with Zephyr RTOS... Maybe also post in the Zephyr forums, if you haven't already.
Technical support and documentation manager at Olimex

KloudJack

You'll need to create a devicetree overlay with the GPIO pins you want to use for your board, and reference that devicetree node when configuring the GPIO pin.

The button sample 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";
    };
  };
};