Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions app/Kconfig
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions app/app.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/ {
aliases {
app-led = &led0;
};

leds {
compatible = "gpio-leds";

led0: ext_led {
gpios = <&gpio0 17 GPIO_ACTIVE_LOW>;
label = "External LED";
};
};
};
1 change: 1 addition & 0 deletions app/prj.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
CONFIG_CPP=y
CONFIG_GPIO=y
CONFIG_LOG=y
28 changes: 16 additions & 12 deletions app/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
#include <zephyr/drivers/gpio.h>
#include <zephyr/kernel.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/logging/log.h>

#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;
}
6 changes: 2 additions & 4 deletions west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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