MCPInstall

peripheral-driver

当需要为外部设备(传感器、存储器、显示屏等)开发 BSP 驱动时使用。提供开源驱动搜索策略、质量评估、代码适配工具和常见设备适配要点。

Installs
263
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/leokemp223/embed-ai-tool --skill peripheral-driver
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads peripheral-driver automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

外设驱动开发(基于开源库适配)

适用场景

  • 需要为外部设备(AT24C02、MPU6050、SSD1306 等)开发 BSP 驱动。
  • 想找到成熟的开源驱动库并适配到项目的 BSP 架构中。
  • 已有开源驱动代码,需要重命名、整理、注入 HAL handle 以符合项目规范。
  • 设备较简单,不需要开源库,需要生成 BSP 骨架文件快速起步。

必要输入

  • 目标设备名称(如 AT24C02、MPU6050)。
  • 通信总线类型(I2C / SPI / UART / 1-Wire / GPIO)。
  • HAL handle 名称(如 hi2c1、hspi2),通常来自 CubeMX 生成的代码。
  • 可选:设备 I2C 地址、已下载的开源驱动目录路径。

自动探测

  • 脚本 --scan 模式自动分析输入目录中的 C/H 文件,识别函数签名、HAL 调用模式、命名风格和 include 依赖。
  • --list-devices 模式列出 device-adaptation.md 中已记录的设备和推荐库。
  • 如果目标设备在 device-adaptation.md 中有记录,直接提供推荐库和适配要点。

执行步骤

  1. 确认目标设备和总线类型。如果设备在 references/device-adaptation.md 中有记录,直接参考推荐库和适配要点。
  2. 阅读 references/search-and-evaluate.md,按搜索策略在 GitHub/Gitee 上寻找候选开源驱动库。
  3. 按评估清单对候选库打分,选择最合适的库。如果没有合适的库,跳到步骤 6。
  4. 下载选定的开源库代码到本地临时目录。
  5. 运行 --scan 分析开源代码,查看适配建议报告:
    python3 scripts/bsp_adapter.py --scan ./downloaded_driver/
    
  6. 执行适配(二选一):
    • 有开源库:运行 --adapt 将代码适配到 BSP 规范:
      python3 scripts/bsp_adapter.py \
        --adapt ./downloaded_driver/ \
        --device <device_name> --handle <hal_handle> \
        --output ./Hardware/bsp_<device>/
      
    • 无合适库:运行 --scaffold 生成 BSP 骨架文件:
      python3 scripts/bsp_adapter.py \
        --scaffold --device <device_name> --bus <bus_type> \
        --handle <hal_handle> --addr <i2c_addr> \
        --output ./Hardware/bsp_<device>/
      
  7. 将生成的 BSP 文件集成到 main.c 的 USER CODE 区域,参考脚本输出的集成指南。
  8. 编译验证,交给 build-* skill。

驱动架构设计和实现最佳实践参考 stm32-hal-development/references/peripheral-driver-guide.md。

失败分流

  • 当搜索不到任何可用的开源驱动库时,使用 --scaffold 生成骨架并提示用户参考规格书手动实现。
  • 当开源库使用裸寄存器操作或非 STM32 平台 API 时,返回 project-config-error,建议手动适配通信层。
  • 当开源库许可证为 GPL 或无许可证时,提醒用户许可证风险,建议寻找替代库或自行实现。
  • 当适配后编译失败时,交给 build-* skill 处理构建错误。

平台说明

  • 自带脚本使用 Python 标准库(os、re、pathlib、argparse),无额外依赖。
  • 生成的 C 代码遵循 STM32 HAL BSP 规范,兼容 GCC、IAR、Keil 工具链。
  • 路径格式遵循 platform-compatibility.md。

输出约定

  • --scan 输出适配建议报告:检测到的函数、HAL 调用、命名风格、适配难度评估。
  • --adapt 输出适配后的 BSP 文件和 main.c 集成指南。
  • --scaffold 输出符合 BSP 模板规范的骨架文件。
  • --list-devices 输出已记录设备的推荐库和适配难度。
  • 所有模式的详细用法见 references/usage.md。

交接关系

  • 上游:stm32-hal-development(提供方法论和 BSP 模板)。
  • 下游:build-cmake、build-iar、build-keil(编译验证)。

FAQ

What does the peripheral-driver skill do?

当需要为外部设备(传感器、存储器、显示屏等)开发 BSP 驱动时使用。提供开源驱动搜索策略、质量评估、代码适配工具和常见设备适配要点。

How do I install peripheral-driver?

Run npx skills add https://github.com/leokemp223/embed-ai-tool --skill peripheral-driver in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/peripheral-driver/ (personal) or .claude/skills/peripheral-driver/ (project).

Which AI agents can use peripheral-driver?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is peripheral-driver safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains peripheral-driver?

It is published by leokemp223 in leokemp223/embed-ai-tool. It has 263 recorded installs.

More from leokemp223/embed-ai-tool

View all →

serial-monitor

leokemp223/embed-ai-tool

当需要识别正确串口、调用自带脚本抓取日志,并分析嵌入式固件运行状态时使用。

585 installs

build-keil

leokemp223/embed-ai-tool

当需要通过 Keil MDK 命令行编译嵌入式工程,调用自带脚本解析工程文件、执行构建并定位固件产物时使用。

572 installs

build-platformio

leokemp223/embed-ai-tool

当需要通过 PlatformIO 命令行编译嵌入式工程,调用自带脚本解析环境配置、执行构建并定位固件产物时使用。

568 installs

workflow

leokemp223/embed-ai-tool

当需要串联多个 skill 完成编译+烧录+监控或编译+烧录+调试等流水线任务时使用。

flash-keil

leokemp223/embed-ai-tool

当需要通过 Keil MDK 内置调试器烧录固件到目标板时使用,利用工程中已配置的调试器和 Flash 算法执行下载。

566 installs

build-cmake

leokemp223/embed-ai-tool

当需要配置或构建基于 CMake 的嵌入式固件工程,调用自带脚本执行构建并定位固件产物时使用。

564 installs

Popular other skills

View category →

hyperframes-cli

heygen-com/hyperframes

The HyperFrames CLI by job - scaffold, check, look at frames, edit the timeline, preview, render locally or in the cloud, publish, project history - plus reading its JSON and recovering from build or render failures.

1.3M installs

triage

mattpocock/skills

Move issues and external PRs through a state machine of triage roles, categorise, verify, grill if needed, and write agent-ready briefs.

1M installs

ask-matt

mattpocock/skills

Ask which skill or flow fits your situation. A router over the skills in this repo.

778.4K installs

to-questionnaire

mattpocock/skills

Turn a decision you can't fully answer into a questionnaire for someone else to fill in.

508.9K installs

wait-what

mattpocock/skills

Stop. That last message did not land: re-pitch it.

459.7K installs

loop-me

mattpocock/skills

Grill me about specs for the workflows I want to build, within this workspace.

447.9K installs