← 返回 Skills 市场
zzz-pinking

Embedded Dev

作者 ZZZ-pinking · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
213
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install embedded-dev
功能描述
单片机嵌入式全栈开发技能,覆盖从底层硬件到上层应用的全链路技术问题。当用户询问嵌入式开发、微控制器、RTOS、电机控制、传感器接口、固件编写、调试上线等任何软硬件相关问题时应调用此技能。
使用说明 (SKILL.md)

Embedded Dev Skill

单片机嵌入式全栈开发技能,掌握从芯片底层到产品上层的全链路知识。

技能范围

  • 主流 MCU 架构(ARM Cortex-M、RISC-V、8051、AVR、ESP32、STM32)
  • 外设驱动开发(GPIO、UART、I2C、SPI、ADC、PWM、Timer、CRC 等)
  • 嵌入式C语言与汇编优化
  • RTOS(FreeRTOS/RT-Thread/Zephyr)任务调度与进程间通信
  • 有线/无线通信协议(UART、SPI、I2C、CAN、Modbus、RS485、LoRa、BLE、WiFi)
  • 传感器与执行器接口(I2C/SPI 传感器、电机驱动、PWM 控制)
  • 底层调试(JTAG/SWD、逻辑分析仪、示波器、printf 调试)
  • 硬件原理图与 PCB 设计基础
  • 固件架构(模块化设计、状态机、事件驱动)
  • OTA 升级与 bootloader
  • 低功耗设计
  • 嵌入式 Linux(树莓派/全志/TI/NXP)基础

工作流程

遇到嵌入式问题时,按以下步骤处理:

  1. 明确硬件平台 — 确认 MCU 型号、时钟配置、电源环境
  2. 定位问题层级 — 硬件层/驱动层/RTOS层/应用层/通信层
  3. 查参考文件 — 根据问题类型加载对应 reference 文件
  4. 给出完整解答 — 包含代码示例(寄存器配置/C语言/驱动)、接线图要点、调试方法

Reference 文件索引

  • references/mcu-architectures.md — 主流 MCU 架构对比与选型
  • references/peripherals.md — 外设驱动开发手册(GPIO/UART/I2C/SPI/ADC/PWM)
  • references/embedded-c.md — 嵌入式C语言编程规范与技巧
  • references/rtos.md — RTOS 实战(任务/队列/信号量/内存)
  • references/communication-protocols.md — 通信协议对比与实现
  • references/debugging.md — 硬件/软件调试方法与工具
  • references/hardware-design.md — 原理图/PCB 设计要点
  • references/firmware-dev.md — 固件架构与 OTA 升级

常用代码模板

GPIO 配置(STM32 HAL 风格)

// 配置 PB0 为推挽输出
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_SET);  // 输出高
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_RESET);  // 输出低
// 读取 PA1
GPIO_PinState state = HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_1);

UART 中断接收(轮询+中断混合)

uint8_t rx_buf[64];
volatile uint8_t rx_len = 0;
void USART1_IRQHandler(void) {
    if (USART->SR & USART_SR_RXNE) {
        rx_buf[rx_len++] = USART->DR;
    }
}

I2C 传感器读取(示例:MPU6050)

void I2C_WriteReg(uint8_t addr, uint8_t reg, uint8_t val) {
    I2C_Start();
    I2C_SendAddr(addr \x3C\x3C 1);
    I2C_SendByte(reg);
    I2C_SendByte(val);
    I2C_Stop();
}
uint8_t I2C_ReadReg(uint8_t addr, uint8_t reg) {
    I2C_Start();
    I2C_SendAddr(addr \x3C\x3C 1 | 0);
    I2C_SendByte(reg);
    I2C_RepeatedStart();
    I2C_SendAddr(addr \x3C\x3C 1 | 1);
    uint8_t val = I2C_RecvByte(NACK);
    I2C_Stop();
    return val;
}

FreeRTOS 任务创建

void sensor_task(void *arg) {
    while (1) {
        float temp = read_temperature();
        xQueueSend(temp_queue, &temp, portMAX_DELAY);
        vTaskDelay(pdMS_TO_TICKS(1000));
    }
}
xTaskCreate(sensor_task, "Sensor", 512, NULL, 2, &sensor_handle);

PWM 电机控制

// 配置 TIM3 CH2 (PB5) PWM 50Hz
void Motor_PWM_Init(void) {
    TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
    TIM_OCInitTypeDef TIM_OCInitStructure;
    // 72MHz / 720 => 100kHz, 100kHz / 2000 => 50Hz
    TIM_TimeBaseStructure.TIM_Period = 2000 - 1;   // ARR
    TIM_TimeBaseStructure.TIM_Prescaler = 72 - 1;   // PSC
    TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
    TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
    TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
    TIM_OCInitStructure.TIM_Pulse = 1500;  // 占空比 75%
    TIM_OC2Init(TIM3, &TIM_OCInitStructure);
    TIM_Cmd(TIM3, ENABLE);
}
// 设置速度 0~100%
void Motor_SetSpeed(uint8_t speed) {
    TIM3->CCR2 = (speed * 20);  // 0-2000
}

常用调试命令

# OpenOCD + ST-Link 调试
openocd -f interface/stlink.cfg -f target/stm32f1x.cfg

# JLink GDB Server
JLinkGDBServer -if SWD -device STM32F103RC

# 逻辑分析仪(Saleae 协议)
sigrok-cli -d saleae-logic16 --channels 1,2,3,4 -o capture.sr

# 串口查看
minicom -b 115200 -D /dev/ttyUSB0
screen /dev/ttyUSB0 115200

常见问题速查

问题 常见原因 解决方案
I2C 无响应 地址错误/未接上拉/SCL被占用 用逻辑仪确认 SDA/SCL 波形
UART 乱码 波特率不匹配/电平不匹配 示波器检查波特率
PWM 无输出 时钟未使能/IO复用错误 检查 TIM_EN 和 AFIO 配置
程序跑飞 堆栈溢出/看门狗未喂狗 减小堆栈/加看门狗
OTA 升级失败 Flash 偏移地址错误/签名校验失败 确认 bootloader 大小配置
低功耗电流大 未关闭未用外设时钟/LDO功耗高 逐个禁用外设定位
安全使用建议
This skill is a documentation/reference pack for MCU/embedded work and appears coherent. It does include low‑level code examples (bootloader jump, watchdog, direct register writes, radio TX sequences) and developer commands (openocd, JLink, sigrok-cli, minicom). Those are normal for embedded development but can, if used incorrectly, brick hardware or violate radio regulations — review and test any code on hardware in a safe environment before flashing. Because the skill can be invoked by the agent, ensure your agent runtime environment does not grant it arbitrary shell access or network access you wouldn't expect; absent such platform privileges, the skill is low risk.
功能分析
Type: OpenClaw Skill Name: embedded-dev Version: 1.0.0 The 'embedded-dev' skill bundle is a comprehensive and legitimate resource for embedded systems development. It provides accurate technical documentation and code examples for MCU architectures, peripheral drivers (GPIO, UART, I2C, SPI, ADC, PWM), RTOS (FreeRTOS, RT-Thread), and firmware architecture (OTA, bootloaders). The shell commands provided in SKILL.md and debugging.md are standard industry tools (OpenOCD, GDB, minicom, sigrok-cli) used for hardware debugging. No evidence of data exfiltration, malicious execution, or harmful prompt injection was found.
能力评估
Purpose & Capability
Name/description match the provided content: an embedded full‑stack MCU reference. There are no unrelated env vars, binaries, or install steps requested — what the skill contains is appropriate for the stated purpose.
Instruction Scope
SKILL.md and the reference files confine themselves to embedded development guidance, code examples, wiring/debug commands and diagnostics. They only reference the skill's own reference files and do not instruct the agent to read host secrets, system config, or send data to external endpoints.
Install Mechanism
No install specification or external downloads; this is instruction-only so nothing is written to disk or fetched during install.
Credentials
The skill requests no environment variables, credentials, or config paths — the level of access requested is minimal and appropriate for a documentation/assist skill.
Persistence & Privilege
always is false and default autonomous invocation is allowed (platform default). The skill does not request persistent system privileges or modify other skill/system configs.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install embedded-dev
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /embedded-dev 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release of embedded-dev skill, providing a comprehensive embedded systems development toolkit. - Covers full-stack embedded development from MCU hardware to application layer. - Supports mainstream MCU architectures, peripheral driver development, RTOS usage, communication protocols, and debugging techniques. - Includes reference file index for quick access to core topics. - Provides common code templates for GPIO, UART, I2C, FreeRTOS, and PWM motor control. - Offers troubleshooting guidance for frequent embedded engineering issues. - Features hardware schematic, PCB basics, and OTA upgrade practices.
元数据
Slug embedded-dev
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Embedded Dev 是什么?

单片机嵌入式全栈开发技能,覆盖从底层硬件到上层应用的全链路技术问题。当用户询问嵌入式开发、微控制器、RTOS、电机控制、传感器接口、固件编写、调试上线等任何软硬件相关问题时应调用此技能。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 213 次。

如何安装 Embedded Dev?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install embedded-dev」即可一键安装,无需额外配置。

Embedded Dev 是免费的吗?

是的,Embedded Dev 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Embedded Dev 支持哪些平台?

Embedded Dev 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Embedded Dev?

由 ZZZ-pinking(@zzz-pinking)开发并维护,当前版本 v1.0.0。

💬 留言讨论