build.sh runs inside Docker (mounted at /scripts/build.sh via
docker-compose volume). flash.sh runs on the host and takes the
project name as an argument, auto-detecting the .uf2 file.
Usage:
cd color_switcher && docker compose run --rm pico-build bash /scripts/build.sh
cd .. && ./flash.sh color_switcher
STD_TYPES, MCU_UART, MCU_USB, MCU_PIO, HAL_COM, HAL_LED moved to
separate repos under common/ as git submodules. Each submodule ships
with default config (cfg/) that projects can override.
color_switcher/src/ now contains only project-specific components
(APP_CLSW, SYS_ECU). CMake sources_config references common/ via
COMMON_DIR. Docker volume mounts ../common:/common so the container
sees the submodules. Build verified — zero errors.
Restructure repo so the root contains project folders. This allows
adding more Pico projects (e.g., another_project/) alongside
color_switcher/ in the same repository. All internal paths are
relative and unchanged — cd into color_switcher/ to build/flash.
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.
UART/USB now receive in the background and store into ring buffers.
Callers read from the buffer via non-blocking ReadByte/ReadBuffer.
Removed blocking ReceiveByte, async ReceiveBuffer with request
state and callbacks. MCU_USB uses lazy drain from SDK stdio into
its own ring buffer. MCU_UART ring buffer unchanged (ISR/DMA).
HAL_COM updated with ReadByte/ReadBuffer function pointer dispatch.
APP_CLSW updated to use new ReadByte API.
MCU_UART: full RX with ISR and DMA modes, ring buffer, blocking
ReceiveByte, async ReceiveBuffer with request fulfillment, blocking
ReceiveBufferBlocking. Per-byte RX callback (ISR mode).
MCU_USB: blocking ReceiveByte via getchar_timeout_us, cached-byte
peek for bIsRxDataAvailable.
HAL_COM: RX function pointer types + dispatch (ReceiveByte,
bIsRxDataAvailable) with USB wrappers in cfg.
APP_CLSW: interactive command parser. Accumulates input into a
buffer, parses on delimiter. Supports red/green/blue/help commands
with echo and response. SYS_ECU tick reduced to 10ms for responsive
input.
Multi-channel communication abstraction where each channel is wired
to an MCU driver via function pointers in the config array. Adding
a new transport (SPI, I2C, etc.) requires only a config entry — zero
changes to HAL_COM_prg.c. Channel 0 defaults to USB-CDC via thin
wrappers that normalize MCU_USB's signature. HAL_COM.h includes
HAL_COM_cfg.h so callers can reference channel names. APP_CLSW
updated to pass channel parameter.
Full hardware UART driver with config-driven per-instance setup.
Non-blocking SendBuffer supports DMA (zero-CPU) and ISR (FIFO-fill)
modes selectable per instance in MCU_UART_cfg.h. Both modes and
blocking SendBufferBlocking invoke a configurable TX-complete
callback (STD_NULL to ignore). All public functions take a u8
instance parameter. Config uses struct-of-arrays pattern for
runtime state, designated-initializer array for per-instance
settings, and value enums in the public header for parity/data
bits/stop bits/async mode. Added hardware_dma to CMake link list.
Dockerized build system (Dockerfile, docker-compose, build.sh) with
Pico SDK cross-compilation. Modular CMake split into project_config,
mcu_config, and sources_config under cmake/. Component architecture
following inc/prg/cfg convention: STD_TYPES, MCU_USB, HAL_COM,
APP_CLSW, SYS_ECU. Full call chain SYS_ECU -> APP_CLSW -> HAL_COM
-> MCU_USB verified end-to-end on RP2040-Zero hardware over USB-CDC.
Includes flash.sh for automated .uf2 flashing on macOS and
devcontainer config for VS Code.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>