And thank you very much for your quick answer.
I really appriciate the quick link to where I can find the documentation and also the example you have provided.
I am also aware of, that it will be in the code, that you configure the pin to be input or output.
But what is not so great is, that we would very much like to define the port and pin number at the dts level for the specific boards, that we support.
We want the code to be generic and not be changed, if a new board will use another pin for the same function.
This is what zephyr has achieved by making the gpio-leds.yaml and then setup the leds in the board specific dts files.
By doing this, along with using alias, you simply refer to the define LED0_GPIO_PIN in your code across all boards without knowing what pin it is and what port in the code, which we like.
We have actually made our own gpio-xxx.yaml, which looks similar to gpio-leds.yaml and placed it in the same location as gpio-leds.yaml.
Then we put the following lines in the dts file for the given board:
compatible = "gpio-xxx";
gpios = <&gpiob 22 0>;
label = "My test pin";
This will create the following in the auto generated header file:
/* test_pin */
#define DT_GPIO_OUT_TEST_PIN_GPIO_CONTROLLER "GPIO_1"
#define DT_GPIO_OUT_TEST_PIN_GPIO_FLAGS 0
#define DT_GPIO_OUT_TEST_PIN_GPIO_PIN 22
#define DT_GPIO_OUT_TEST_PIN_LABEL "My test pin"
The code will then have lines like this:
wdt_device = device_get_binding(DT_GPIO_OUT_TEST_PIN_GPIO_CONTROLLER);
gpio_pin_configure(wdt_device, DT_GPIO_OUT_TEST_PIN_GPIO_PIN, GPIO_DIR_OUT | DT_GPIO_OUT_TEST_PIN_GPIO_FLAGS);
gpio_pin_write(wdt_device, DT_GPIO_OUT_TEST_PIN_GPIO_PIN, 1);
Of course you have to write the dts lines with the exact same names in all dts files supporting this function.