Rust Embedded

嵌入式与 no_std 专家。处理 no_std, embedded-hal, 裸机开发, 中断, DMA, 资源受限环境等问题。触发词:no_std, embedded, embedded-hal, microcontroller, firmware, ISR, DMA, 嵌入式, 裸机--- # 嵌入式与 no_std 开发 ## 核心问题 如何在资源受限环境或没有标准库的情况下编程? no_std 不是 Rust 的子集,而是一种不同的编程模式。

49 stars 7 forksSoftware Development

Install

skills CLI (Claude Code, Cursor, Codex and more)
npx skills add huiali/rust-skills --skill rust-embedded
Manual install
git clone --depth 1 https://github.com/huiali/rust-skills.git /tmp/rust-skills
mkdir -p ~/.claude/skills
cp -r /tmp/rust-skills/.codex/skills/rust-embedded ~/.claude/skills/rust-embedded

Personal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.

From the SKILL.md

## no_std 基础

```rust
#![no_std]
// 不能使用 std, alloc, test

use core::panic::PanicMessage;

// 必须实现 panic handler
#[panic_handler]
fn panic(info: &PanicMessage) -> ! {
    loop {}
}

// 可选:定义全局分配器
#[global_allocator]
static ALLOC: some_allocator::Allocator = some_allocator::Allocator;
```

### 可用模块

| 模块 | 用途 |
|-----|------|
| `core` | 基本语言特性 |
| `alloc` | 堆分配(需 allocator) |
| `compiler_builtins` | 编译器内置函数 |

## 嵌入式-hal

```rust
use embedded_hal as hal;
use hal::digital::v2::OutputPin;

// 抽象硬件访问
fn blink_led<L: OutputPin>(mut led: L) -> ! {
    loop {
        led.set_high().unwrap();
        delay_ms(1000);
        led.set_low().unwrap();
        delay_ms(1000);
    }
}
```

### 常用 trait

| trait | 操作 |
|-------|------|
| `OutputPin` | 设置高低电平 |
| `InputPin` | 读取引脚 |
| `SpiBus` | SPI 通信 |
| `I2c` | I2C 通信 |
| `Serial` | 串口 |

## 中断处理

```rust
#![no_std]
#![feature(abi_vectorcall)]

use cortex_m::interrupt::{free, Mutex};
use cortex_m::peripheral::NVIC;

// 共享状态
static MY_DEVICE: Mutex<Cell<Option<MyDevice>>> = Mutex::new(None);

#[interrupt]
fn TIM2() {
    free(|cs| {
        let device = MY_DEVICE.borrow(cs).take();
        if let Some(dev) = device {
            // 处理中断
            dev.handle();
            MY_DEVICE.borrow(cs).set(Some(dev));
        }
    });
}

// 启用中断
fn enable_interrupt(nvic: &mut NVIC, irq: interrupt::TIM2) {
    nvic.enable(irq);
}
```

## 内存管理

### 栈大小
Read the full skill on GitHub

Details

Skill name
rust-embedded
Path
.codex/skills/rust-embedded/SKILL.md
License
MIT
Repo updated
9 February 2026

FAQ

What does the Rust Embedded skill do?

嵌入式与 no_std 专家。处理 no_std, embedded-hal, 裸机开发, 中断, DMA, 资源受限环境等问题。触发词:no_std, embedded, embedded-hal, microcontroller, firmware, ISR, DMA, 嵌入式, 裸机--- # 嵌入式与 no_std 开发 ## 核心问题 **如何在资源受限环境或没有标准库的情况下编程?** no_std 不是 Rust 的子集,而是一种不同的编程模式。

How do I install the Rust Embedded skill?

skills CLI (Claude Code, Cursor, Codex and more): npx skills add huiali/rust-skills --skill rust-embedded. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.

Is Rust Embedded popular?

It lives in huiali/rust-skills, which has 49 GitHub stars and 7 forks.

Related skills

Browse the most popular Claude skills, all software development skills, or write your own with the skills generator.