Re: Syntax in dts file for defining a GPIO output based on nxp,kinetis-gpio.yaml #defines
Andrei Gansari
Hello Bo,
We have a general help page for Device Tree: https://docs.zephyrproject.org/latest/guides/dts/index.html
In your particular case, you need to set port b pin 22 as output.
Device Tree: The purpose of DT is to describe the HW of the board (boot time @ Linux, compile time @ Zephyr). K64F’s DT file is found in: boards/arm/frdm_k64f/frdm_k64f.dts I expect this is what you are looking at. It also includes file dts/arm/nxp/nxp_k6x.dtsi where port b is set using nxp,kinetis-gpio.yaml. Dtsi file is a generic dts include file that describes the SoC (we may have another board with the same SoC on it). Add the following to frdm_k64f.dts to use gpiob from nxp_k6x.dtsi: &gpiob { status = "ok"; }; You can comment out/remove the following to remove he led configuration on the same pin: red_led: led_0 { gpios = <&gpiob 22 0>; label = "User LD1"; };
Code: You can’t configure a pin as in/out, using DT, we have board’s pinmux.c (in boards/arm/frdm_k64f) to do that. This is because GPIO should be dynamic during the application. pinmux_pin_set(portb, 22, PORT_PCR_MUX(kPORT_MuxAsGpio)); The code above sets pin as GPIO (for the led in the case above). Then set pin to output and send a signal: #include <gpio.h>
pinmux_pin_set(portb, 22, PORT_PCR_MUX(kPORT_MuxAsGpio));
struct device *gpiob = device_get_binding(DT_NXP_KINETIS_GPIO_GPIO_B_LABEL);
gpio_pin_configure(gpiob, 22, GPIO_DIR_OUT); gpio_pin_write(gpiob, 22, 0);
DT_NXP_KINETIS_GPIO_GPIO_B_LABEL can be found in files zephyr/include/generated/generated_dts_board*** (relative to build folder) this is the effect of setting portb in dts.
Regards, Andrei Gânsari
From: devel@... <devel@...>
On Behalf Of Bo.Kragelund via Lists.Zephyrproject.Org
Sent: Thursday, March 28, 2019 12:57 PM To: devel@... Cc: devel@... Subject: [Zephyr-devel] Syntax in dts file for defining a GPIO output based on nxp,kinetis-gpio.yaml #defines
Hello developers! leds { compatible = "gpio-leds"; red_led: led_0 { gpios = <&gpiob 22 0>; label = "User LD1"; }; };
But in general, I believe the idea is to define GPIO in the dts file based on the
nxp,kinetis-gpio.yaml file created for this purpose, instead of the gpio-keys.yaml file. "#cells": - pin - flags
Since I am rather new in dts and yaml syntax, I hope someone can help me with the syntax for setting port b, pin 22, and no flags, based on the nxp,kinetis-gpio.yaml file...
|
|