diff --git a/app/Kconfig b/app/Kconfig new file mode 100644 index 00000000..2dcab7b9 --- /dev/null +++ b/app/Kconfig @@ -0,0 +1,81 @@ +menu "Zephyr" +source "Kconfig.zephyr" +endmenu + +menuconfig LED_SUBSYSTEM + bool "LED Subsystem" + default y + +if LED_SUBSYSTEM + +config APP_HEARTBEAT_PERIOD_MS + int "Period (in milliseconds) of the heartbeat LED" + default 500 + range 100 2000 + +choice + prompt "LED blinking sleep time" + default BLINKING_SPEED_MEDIUM + +config BLINKING_SPEED_SLOW + bool "2s (slow)" + +config BLINKING_SPEED_MEDIUM + bool "1s (medium)" + +config BLINKING_SPEED_FAST + bool "500ms (fast)" + +config BLINKING_LUDICROUS_SPEED + bool "250ms (ludicrous)" + +endchoice + +config LED_BLINK_PERIOD_MS + int + default 2000 if BLINKING_SPEED_SLOW + default 1000 if BLINKING_SPEED_MEDIUM + default 500 if BLINKING_SPEED_FAST + default 250 if BLINKING_LUDICROUS_SPEED + default 0 + +menuconfig ADVANCED_LED_SETTINGS + bool "Advanced LED settings" + default n + +if ADVANCED_LED_SETTINGS + +config LED_BRIGHTNESS + int "LED brightness (0-100)" + default 100 + range 0 100 + help + Brightness power in percentage (0 is off, 100 is full power). + +config LED_FADE_DURATION + int "LED fade duration (ms)" + default 500 + range 0 5000 + help + Duration of the fade effect in milliseconds. + +menu "Expert settings" + visible if GPIO + +config LED_DEBUGGING + bool "Enable LED debugging" + default n + help + Enable LED debugging. + +config CUSTOM_BLINK_PATTERN + bool "Custom blink pattern" + default n + help + Use a custom blink pattern. + +endmenu + +endif # ADVANCED_LED_SETTINGS + +endif # LED_SUBSYSTEM diff --git a/app/app.overlay b/app/app.overlay new file mode 100644 index 00000000..f69df84d --- /dev/null +++ b/app/app.overlay @@ -0,0 +1,14 @@ +/ { + aliases { + app-led = &led0; + }; + + leds { + compatible = "gpio-leds"; + + led0: ext_led { + gpios = <&gpio0 17 GPIO_ACTIVE_LOW>; + label = "External LED"; + }; + }; +}; diff --git a/app/prj.conf b/app/prj.conf index 244cc784..d54ba502 100644 --- a/app/prj.conf +++ b/app/prj.conf @@ -1,2 +1,3 @@ +CONFIG_CPP=y CONFIG_GPIO=y CONFIG_LOG=y diff --git a/app/src/main.cpp b/app/src/main.cpp index 5dfdde9c..5d918ae9 100644 --- a/app/src/main.cpp +++ b/app/src/main.cpp @@ -1,30 +1,34 @@ -#include #include +#include #include -#define SLEEP_TIME_MS 1000 - -/* The devicetree node identifier for the "led0" alias. */ -#define LED_NODE DT_ALIAS(led0) +LOG_MODULE_REGISTER(main, LOG_LEVEL_INF); +#define LED_NODE DT_ALIAS(app_led) static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED_NODE, gpios); -LOG_MODULE_REGISTER(main, LOG_LEVEL_INF); - int main(void) { bool led_state = true; - if (!gpio_is_ready_dt(&led)) return 0; + if (!gpio_is_ready_dt(&led)) { + LOG_ERR("LED not ready!"); + return -1; + } - if (gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE) < 0) return 0; + if (gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE) < 0) { + LOG_ERR("Unable to configure LED!"); + return -1; + } while (1) { - if (gpio_pin_toggle_dt(&led) < 0) return 0; - led_state = !led_state; + if (gpio_pin_toggle_dt(&led) < 0) { + LOG_ERR("Unable to toggle the LED!"); + return -1; + } LOG_INF("LED state: %s", led_state ? "ON" : "OFF"); - k_msleep(SLEEP_TIME_MS); + k_msleep(CONFIG_APP_HEARTBEAT_PERIOD_MS); } return 0; } diff --git a/west.yml b/west.yml index 8b525769..db8df41e 100644 --- a/west.yml +++ b/west.yml @@ -4,11 +4,9 @@ manifest: projects: - name: zephyr url: https://github.com/zephyrproject-rtos/zephyr - revision: v4.2.0 + revision: v4.4.0-rc1 import: name-allowlist: - cmsis_6 - - hal_nxp - - hal_stm32 - - hal_nordic + - hal_espressif path-prefix: deps