I have this as nrf52840dk_nrf52840.overlay in my application directory:
10 | const struct gpio_dt_spec blah = GPIO_DT_SPEC_GET(DT_ALIAS(lightString0), gpios);
| ^~~~~~~~~~~~~~~~
And, what is:
I have this as nrf52840dk_nrf52840.overlay in my application directory:
Hi jahess,
Try to use the code snippet below inside your nrf52840dk_nrf52840.overlay. It makes use of GPIO P0.28.
/{
custom_gpios {
compatible = "gpio-keys";
cusgpio0: cusgpio_0 {
gpios = <&gpio0 28 GPIO_ACTIVE_HIGH>;
label = "My custom GPIO";
};
};
aliases {
mycusgpio = &cusgpio0;
};
Highlighted in red are names which you can change as you prefer. I suggest to leave what remains de-highlighted (in black) as it is. Eventually substitute &gpio0 28 with another pin (i.e. &gpio0 4 or &gpio1 11).
For what concerns the main program, I am not very keen on DT_SPECS apis. I prefer to enable my gpio pin in the following way:
#define GPIO028_NODE DT_ALIAS(mycusgpio)
#define GPIO028 DT_GPIO_LABEL(GPIO028_NODE, gpios)
const struct device *dev_gpio0;
dev_gpio0 = device_get_binding(GPIO028);
Now you are ready to use GPIO028.
Note: I omitted any possible sanity check to make things as simple as possible.
Hope this can help!
Have a nice day,
Gianmarco
From a comment I made to https://www.youtube.com/watch?v=AMwxj4yUXDQ I learned "the trailing s in latch-en-gpios is required and that the DT... macro support converts any capitals in device tree names to lower case." The last part means device tree names must be lowercase.
With that, I was able to use:
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), lightstring0_gpios)
From a comment I made to https://www.youtube.com/watch?v=AMwxj4yUXDQ I learned "the trailing s in latch-en-gpios is required and that the DT... macro support converts any capitals in device tree names to lower case." The last part means device tree names must be lowercase.
With that, I was able to use:
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), lightstring0_gpios)