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
14 changes: 14 additions & 0 deletions app/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
menu "Led Subsystem"

config APP_HEARTBEAT_PERIOD_MS
int "Configure Hearteab Period (ms)"
range 500 1000
default 500

endmenu

menu "Zephyr"

source "Kconfig.zephyr"

endmenu
39 changes: 39 additions & 0 deletions app/app.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <zephyr/dt-bindings/pinctrl/esp32s3-pinctrl.h>
#include <zephyr/dt-bindings/gpio/gpio.h>
#include <dt-bindings/led/led.h>

/ {

aliases {
app-led = &led_strip;
};
};

&pinctrl {
spim2_ws2812: spim2_ws2812 {
group1 {
pinmux = <SPIM2_MOSI_GPIO48>;
output-high;
};
};
};

&spi2 {
line-idle-low;
status = "okay";
pinctrl-0 = <&spim2_ws2812>;
pinctrl-names = "default";

led_strip: ws2812@0 {
compatible = "worldsemi,ws2812-spi";
reg = <0>;
spi-max-frequency = <6400000>;
chain-length = <1>;
color-mapping = <LED_COLOR_ID_GREEN
LED_COLOR_ID_RED
LED_COLOR_ID_BLUE>;
spi-one-frame = <0xf0>;
spi-zero-frame = <0xc0>;
reset-delay = <50>;
};
};
4 changes: 4 additions & 0 deletions app/prj.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
CONFIG_GPIO=y
CONFIG_LOG=y
CONFIG_APP_HEARTBEAT_PERIOD_MS=500
CONFIG_SPI=y
CONFIG_LED_STRIP=y
CONFIG_WS2812_STRIP_SPI=y
23 changes: 13 additions & 10 deletions app/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
#include <zephyr/drivers/gpio.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>

#define SLEEP_TIME_MS 1000
#include <zephyr/drivers/led_strip.h>
#include <zephyr/device.h>

/* The devicetree node identifier for the "led0" alias. */
#define LED_NODE DT_ALIAS(led0)
#define LED_NODE DT_ALIAS(app_led)

static const struct device *strip = DEVICE_DT_GET(LED_NODE);

struct led_rgb red[] = { {.r = 255, .g = 0, .b = 0} }; /* red */
struct led_rgb blue[] = { {.r = 0, .g = 0, .b = 255} }; /* red */

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_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE) < 0) return 0;

while (1) {
if (gpio_pin_toggle_dt(&led) < 0) return 0;

led_state = !led_state;

if (led_strip_update_rgb(strip, led_state ? red : blue, ARRAY_SIZE(red)) < 0) {
return 0;
};
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: 6 additions & 0 deletions app/tools/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/bash
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)

pushd $SCRIPT_DIR/..
west build -p always -b esp32s3_devkitc/esp32s3/procpu
popd
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.3.0
revision: v4.4.0-rc2
import:
name-allowlist:
- cmsis_6
- hal_nxp
- hal_stm32
- hal_nordic
- hal_espressif
path-prefix: deps