本项目是一个由 AI Agent 深度驱动的嵌入式开发实践,旨在探索利用长链推理解决复杂硬件时序控制与空间逻辑映射。
本项目基于 STM32F103 核心控制器,通过级联 6 片 74HC595 移位寄存器,实现了对 4x4x4 空间矢量光立方的精确驱动。项目核心亮点在于引入了基于 Cursor 与 Claude Code 协同的 Agent 自动化开发工作流。
核心价值: 探索 AI Agent 在底层硬件开发中的深度介入 -- 从数据手册解析到时序逻辑合成,再到三维坐标映射的全链路自动化。
| Component | Specification |
|---|---|
| MCU | STM32F103 (Cortex-M3, 72 MHz) |
| Shift Register | SN74HC595 x6 (cascaded, 48-bit) |
| Display | 4x4x4 LED Matrix (64 voxels) |
| Communication | Bitbang SPI (GPIO PB0-PB4) |
| Scanning | Layer POV, 50 Hz refresh |
- HC#1-HC#2: Column anode control (16 bits, 4x4 grid columns)
- HC#3: Layer cathode select (4 bits, active-low scanning)
- HC#4-HC#6: Reserved / expansion interface
本项目通过构建多 Agent 协作链条,实现了从需求到代码的自动化推理与生成:
[Hardware Spec] --> [Architect Agent] --> [Logic Agent] --> [Code Agent]
| | |
解析 Datasheet 时序 Chain-of-Thought 代码生成
提取引脚约束 坐标映射推理 驱动 + 动画
| | |
+---------> [Review Agent] <-------------+
静态时序分析
逻辑冲突检测
-
Hardware Spec Parsing: AI Agent 自动解析 74HC595 数据手册,提取纳秒级时序约束 (t_W >= 100 ns, t_SU >= 40 ns),生成对应 NOP 延迟循环。
-
Timing Logic Synthesis (Long-Chain Reasoning): 利用 Chain-of-Thought 推理,将 48 位级联拓扑分解为逐字节移位策略,自动计算 MSB-first 级联协议下的数据对齐方案。
-
Coordinate Mapping: 将三维空间坐标 (x, y, z) 转换为串行位移指令,实现 64 个 voxel 的零误差映射。
- Driver development: 3-5 days (manual) -> 4 hours (AI-assisted)
- Timing logic error rate: reduced by 90%+
- Static analysis caught 2 potential timing conflicts pre-hardware
- HAL boilerplate code reduced by 65%
drivers/ 74HC595 bitbang driver + SysTick delay
src/ Main control logic, animation engine, SPI timing
docs/ Hardware schematic, AI prompt records
logs/ Multi-agent collaboration workflow log
- STM32F103 development board
- 6x SN74HC595, 64x LEDs
- ARM GCC toolchain or Keil MDK
- ST-Link programmer
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb \
-I drivers -I src \
src/*.c drivers/*.c \
-o build/lightcube.elf \
-T stm32f103c8t6.ld
openocd -f interface/stlink.cfg -f target/stm32f1x.cfg \
-c "program build/lightcube.elf verify reset exit"
All AI agent interactions are recorded in logs/agent_workflow_log.txt,
demonstrating the multi-step reasoning, code generation, and review
process used throughout this project.