Add my_led
This commit is contained in:
1 parent
a6c62e56d8
commit
c8fe95e63b
5 files changed
+86
No files matched your search
@@ -0,0 +1,35 @@
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/drivers/gpio.h>
|
||||
|
||||
#define LED_NODE DT_ALIAS(myled)
|
||||
|
||||
#define BLINK_DELAY_MS DT_PROP(LED_NODE, my_delay_ms)
|
||||
|
||||
const struct gpio_dt_spec led =
|
||||
GPIO_DT_SPEC_GET(LED_NODE, custom_gpios);
|
||||
|
||||
int main(void) {
|
||||
|
||||
int ret;
|
||||
|
||||
if (!device_is_ready(led.port)) {
|
||||
printk("LED GPIO device not ready\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_INACTIVE);
|
||||
if (ret != 0) {
|
||||
printk("Failed to configure LED: %d\n", ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
printk("Blinking with delay %d ms\n", BLINK_DELAY_MS);
|
||||
|
||||
while (1) {
|
||||
gpio_pin_toggle_dt(&led);
|
||||
k_sleep(K_MSEC(BLINK_DELAY_MS));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user