This commit is contained in:
Eduard Iten 2025-06-29 16:16:13 +02:00
parent 4e87357519
commit ab6954902a
3 changed files with 42 additions and 4 deletions

View File

@ -25,9 +25,18 @@
aliases { aliases {
sw0 = &user_button1; sw0 = &user_button1;
led0 = &green_led;
watchdog0 = &wdt0; watchdog0 = &wdt0;
}; };
leds: leds {
compatible = "gpio-leds";
green_led: led_0 {
gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
label = "User LED1";
};
};
gpio_keys { gpio_keys {
compatible = "gpio-keys"; compatible = "gpio-keys";
user_button1: button_1 { user_button1: button_1 {
@ -71,6 +80,10 @@
status = "okay"; status = "okay";
}; };
&usb_serial {
status = "okay";
};
&wifi { &wifi {
status = "okay"; status = "okay";
}; };

View File

@ -1,5 +1 @@
CONFIG_PRINTK=y CONFIG_PRINTK=y
CONFIG_SERIAL=n
CONFIG_UART_CONSOLE=n
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_CDC_ACM=y

View File

@ -1,7 +1,36 @@
#include <zephyr/kernel.h> #include <zephyr/kernel.h>
#include <zephyr/drivers/gpio.h>
#define LED0_NODE DT_ALIAS(led0)
void main(void) void main(void)
{ {
const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios);
int ret;
if (!gpio_is_ready_dt(&led)) {
return;
}
ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
if (ret < 0) {
return;
}
printk("Hello World! %s\n", CONFIG_BOARD); printk("Hello World! %s\n", CONFIG_BOARD);
while (1) {
ret = gpio_pin_toggle_dt(&led);
if (ret < 0) {
return;
}
k_msleep(100);
ret = gpio_pin_toggle_dt(&led);
if (ret < 0) {
return;
}
k_msleep(300);
}
} }