embedded dev

Other Community
Fluxly profile Runtime and permissions are inferred by Fluxly static checks, not author declarations or runtime test results.
Domain
Other
Author-declared agents
No explicit declaration found; this is not inferred or tested compatibility
Static check
88 / 100 · heuristic scan, not runtime safety proof
Runtime evidence
Not run; no isolated runtime test evidence is currently recorded
Author / version / license
@zhaoyanxiang125 · no license declared
Token usage
Lean
Setup complexity
Plug-and-play
External API key
Not required
Operating systems
Unspecified (assume cross-platform)
Runtime requirements
No explicit requirements detected
Detected file/system behavior
  • Read-only
  • Write / modify
Network behavior
Local-only
Install commands
None (reference only)

Heads up: Tool permissions are not declared; actual access depends on the runtime.

Author source file SKILL.md

# 嵌入式开发 Skill

## 使用本 Skill 的方式

根据用户问题的类型,优先阅读以下对应的参考文件:

| 场景 | 读取文件 |
|------|---------|
| 项目规划 / 流程 / 阶段管理 | `references/process.md` |
| 芯片选型 / 架构设计 | `references/architecture.md` |
| 驱动开发 / 外设接口 / 寄存器操作 | `references/drivers.md` |
| RTOS 使用 / 任务调度 / 同步 | `references/rtos.md` |
| 调试技巧 / 故障排查 | `references/debug.md` |
| 代码规范 / 工程最佳实践 | `references/coding-standards.md` |
| 量产 / 测试 / EMC | `references/production.md` |

如果问题横跨多个领域,可以同时阅读多个文件。

---

## 核心原则(每次回答都要牢记)

1. **资源约束优先**:嵌入式系统内存、Flash、CPU 算力都极为有限,任何建议都要考虑资源开销。
2. **确定性与实时性**:嵌入式系统需要可预期的时序行为,避免不确定延迟。
3. **硬件软件协同**:问题常出在软硬件交界处,调试时不能只看代码。
4. **防御性编程**:所有外部输入、硬件状态都可能出错,必须有保护机制。
5. **可测试性**:从一开始就设计测试点、调试接口,而非事后补救。

---

## 快速响应模板

### 用户问"XXX 怎么调试"时
1. 先确认硬件层面(电源、时钟、接口电平)是否正常
2. 再看通信协议层面(时序、帧格式、ACK)
3. 最后才看软件逻辑

### 用户问"XXX 怎么优化"时
先问:优化目标是什么?(功耗 / 速度 / Flash 大小 / RAM 占用),不同目标策略完全不同。

### 用户问"选什么芯片/方案"时
阅读 `references/architecture.md`,按需求维度逐一匹配。

---

## 常用代码片段(可直接使用)

### 安全的超时等待模板(裸机)
```c
#define TIMEOUT_MS  1000
uint32_t tick_start = HAL_GetTick();
while (!condition_met()) {
    if ((HAL_GetTick() - tick_start) > TIMEOUT_MS) {
        return ERR_TIMEOUT;
    }
}
```

### ISR 与主循环通信(标志位模式)
```c
// 在 ISR 中:
volatile uint8_t g_uart_rx_flag = 0;
void USART1_IRQHandler(void) {
    g_uart_rx_flag = 1;  // 只设标志,不做处理
}

// 在主循环中:
if (g_uart_rx_flag) {
    g_uart_rx_flag = 0;
    process_rx_data();
}
```

### FreeRTOS 队列通信模板
```c
// 创建
QueueHandle_t xQueue = xQueueCreate(10, sizeof(MyMsg_t));

// 发送(从 ISR)
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
xQueueSendFromISR(xQueue, &msg, &xHigherPriorityTaskWoken);
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);

// 接收(任务中)
MyMsg_t msg;
if (xQueueReceive(xQueue, &msg, pdMS_TO_TICKS(100)) == pdTRUE) {
    // 处理消息
}
```

---

阅读完本文件后,根据用户的具体问题,跳转到对应的 references/ 子文件获取更详细的内容。

Discussion

Powered by GitHub Discussions. Sign in with GitHub to comment, react, or subscribe.