Added some code snippets
All checks were successful
Build & Publish / build (push) Successful in 8m21s

This commit is contained in:
2023-08-03 08:20:34 +02:00
parent 7916bc84d6
commit 22d036515c
6 changed files with 221 additions and 40 deletions

21
snippets/led/code.txt Normal file
View File

@@ -0,0 +1,21 @@
int blink_led(void) {
int ret;
if (!gpio_is_ready_dt(&led)) {
return 0;
}
ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
if (ret < 0) {
return 0;
}
while (1) {
ret = gpio_pin_toggle_dt(&led);
if (ret < 0) {
return 0;
}
k_msleep(1000);
}
return 0;
}

2
snippets/led/imports.txt Normal file
View File

@@ -0,0 +1,2 @@
#include <zephyr/drivers/gpio.h>
#define LED0_NODE DT_ALIAS(led0)