pi_pico/cmake/cmake_config/sources_config.cmake
Mohamed Salem b49c7f60bb Add WS2812B LED support via PIO with rainbow and color commands
MCU_PIO: generic PIO driver with config-driven program loading,
function-pointer init callbacks, blocking put, and DMA async put.
ws2812.pio written from scratch — 800 kHz, 10 cycles/bit, side-set.

HAL_LED: pixel buffer with intensity scaling, RGB byte order for
RP2040-Zero WS2812 variant. SetColor immediately pushes the strip.

APP_CLSW: rainbow HSV hue rotation on startup (auto-mode). Color
commands (red/green/blue/off/rainbow) stop the rainbow and set the
LED to a static color. Integer-only HSV-to-RGB conversion.

CMake: added hardware_pio link and pico_generate_pio_header for
ws2812.pio compilation. SYS_ECU init sequence updated.
2026-04-13 03:32:18 +02:00

72 lines
3.2 KiB
CMake

# ============================================================================
# sources_config.cmake
# ----------------------------------------------------------------------------
# Collects the list of source files and include directories for the build.
# Does NOT declare the executable - the top-level CMakeLists.txt handles
# add_executable() so the build target is visible in one obvious place.
#
# Exported variables:
# PROJECT_SOURCES - list of every .c file under src/
# PROJECT_INCLUDE_DIRS - list of include paths for each component
# ============================================================================
# NOTE: all source/header paths below are rooted at PROJECT_ROOT_DIR, which
# the top-level CMakeLists.txt computes as the parent of its own directory
# (i.e. one level above cmake/). We do NOT use CMAKE_SOURCE_DIR here because
# that variable points at the cmake/ folder itself, not at the project root.
# Recursively collect every .c file under src/. CONFIGURE_DEPENDS makes
# CMake re-check the glob on every build, so newly added .c files are
# picked up without having to manually re-run cmake. The trade-off is a
# tiny build-time stat check on each file, which is well worth it for a
# small project where we add files often.
file(GLOB_RECURSE PROJECT_SOURCES CONFIGURE_DEPENDS
"${PROJECT_ROOT_DIR}/src/*.c")
# Every component follows the same folder convention:
# inc/ - public API headers (safe for any other component to include)
# prg/ - private headers and implementation files (component-internal)
# cfg/ - configuration headers and constants
#
# All three are added to the include path here so #include "MCU_UART.h"
# etc. resolves regardless of which translation unit is doing the include.
set(PROJECT_INCLUDE_DIRS
# Shared library layer - fundamental types used by every component
${PROJECT_ROOT_DIR}/src/STD_TYPES/inc
# MCU layer - hardware abstraction for the RP2040 UART peripheral
${PROJECT_ROOT_DIR}/src/MCU_UART/inc
${PROJECT_ROOT_DIR}/src/MCU_UART/prg
${PROJECT_ROOT_DIR}/src/MCU_UART/cfg
# MCU layer - PIO peripheral driver for programmable I/O state machines
${PROJECT_ROOT_DIR}/src/MCU_PIO/inc
${PROJECT_ROOT_DIR}/src/MCU_PIO/prg
${PROJECT_ROOT_DIR}/src/MCU_PIO/cfg
# MCU layer - hardware abstraction for the RP2040 USB-CDC peripheral
# (the Pico appears as a virtual serial port on the host computer)
${PROJECT_ROOT_DIR}/src/MCU_USB/inc
${PROJECT_ROOT_DIR}/src/MCU_USB/prg
${PROJECT_ROOT_DIR}/src/MCU_USB/cfg
# HAL layer - transport-agnostic communication abstraction that
# dispatches to MCU_UART, MCU_USB, or both depending on configuration
${PROJECT_ROOT_DIR}/src/HAL_COM/inc
${PROJECT_ROOT_DIR}/src/HAL_COM/prg
${PROJECT_ROOT_DIR}/src/HAL_COM/cfg
# HAL layer - LED strip/pixel abstraction over PIO-based WS2812 driver
${PROJECT_ROOT_DIR}/src/HAL_LED/inc
${PROJECT_ROOT_DIR}/src/HAL_LED/prg
${PROJECT_ROOT_DIR}/src/HAL_LED/cfg
# Application layer - color switcher application logic
${PROJECT_ROOT_DIR}/src/APP_CLSW/inc
${PROJECT_ROOT_DIR}/src/APP_CLSW/prg
${PROJECT_ROOT_DIR}/src/APP_CLSW/cfg
# Application layer - system ECU / top-level orchestrator
${PROJECT_ROOT_DIR}/src/SYS_ECU/prg
)