Skip to main content
skill CX Codex

peripherals-from-datasheet — Claude Code skill: setup and usage

peripherals-from-datasheet guides driver development directly from MCU reference manuals. Helpful when writing bare-metal register code without a vendor HAL or migrating peripherals across chips.

MIT 380 installs ★ 298 updated 2026-06-27

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add mohitmishra786/low-level-dev-skills --skill peripherals-from-datasheet -a claude-code
Open on GitHub

What peripherals-from-datasheet does

This skill enforces a step-by-step workflow for writing hardware drivers from vendor reference manuals. It covers locating peripheral base addresses, declaring register map structs with exact offset padding, defining bitfields, and executing peripheral bring-up in the correct sequence.

Clock setup order is critical here. Writing control bits before turning on the bus clock in the RCC or APB/AHB registers produces no effect. The skill also enforces safe busy-wait loops for PLL stabilization, pin multiplexing checks, and correct flag clearing sequences for interrupt handlers.

What it helps with

  • Generate C register layout structs matching reference manual offsets
  • Determine peripheral initialization order across bus clocks and GPIO
  • Verify vendor HAL routines against official datasheet specifications
  • Diagnose stuck interrupt flags and incorrect baud rate calculations

Example prompts for the agent

  • /peripherals-from-datasheet Walk me through USART init from STM32 RM
  • /peripherals-from-datasheet What sections of the ref manual matter for SPI timing?
  • /peripherals-from-datasheet Review my register struct padding and clock enable sequence

How to install peripherals-from-datasheet

1Skills CLI (Vercel)

npx skills add mohitmishra786/low-level-dev-skills --skill peripherals-from-datasheet -a claude-code

2Manually: put the files in place

~/.claude/skills/peripherals-from-datasheet/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/peripherals-from-datasheet/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about peripherals-from-datasheet

How to install peripherals-from-datasheet in Claude Code?

Run npx skills add mohitmishra786/low-level-dev-skills --skill peripherals-from-datasheet -a claude-code. This installs the definition to ~/.claude/skills/peripherals-from-datasheet/SKILL.md.

What does the peripherals-from-datasheet skill do?

It provides a structured checklist for writing register-level MCU drivers, guiding agents through memory maps, bit definitions, peripheral bring-up orders, and timing constraints.

Why does register configuration fail during peripheral bring-up?

Writing to peripheral control registers while the peripheral bus clock remains disabled in RCC has zero effect. Enabling the bus clock must always happen before configuring modes or pins.

Source text

SKILL.md · MIT
---
name: peripherals-from-datasheet
description: Peripheral driver methodology skill from MCU reference manuals. Use when reading register maps, timing diagrams, and writing drivers from vendor documentation. Activates on queries about reference manual, register map, peripheral init sequence, or datasheet-driven driver design.
---

# Peripherals from Datasheet

## Purpose

Guide agents through a repeatable methodology for writing peripheral drivers from MCU reference manuals: locating register maps, interpreting bit definitions, following init sequences, respecting timing constraints, and producing maintainable register-level code. Pair with `skills/baremetal/datasheet-and-refmanual-reading` for doc-navigation methodology (kept as separate skills).

## When to Use

- Starting a driver without vendor HAL
- Porting a peripheral between MCU families
- Verifying HAL behavior against the reference manual
- Debugging a peripheral that "should work" per examples

## Workflow

### 1. Reference manual navigation

```
Typical RM structure
├── Memory map (peripheral base addresses)
├── Peripheral chapter (UART, SPI, GPIO, ...)
│   ├── Functional description
│   ├── Register map (table of offsets)
│   ├── Register bit definitions
│   └── Timing / electrical notes
└── Electrical characteristics (clock limits, setup/hold)
```

Start with the **programming model** section before copying register writes.

### 2. Extract register map

```c
/* From RM — USART base 0x40004400 */
typedef struct {
    volatile uint32_t SR;   /* 0x00 status */
    volatile uint32_t DR;   /* 0x04 data */
    volatile uint32_t BRR;  /* 0x08 baud */
    volatile uint32_t CR1;  /* 0x0C control */
    /* ... */
} USART_TypeDef;

#define USART2 ((USART_TypeDef *)0x40004400UL)
```

Verify offset column matches struct layout (padding for reserved words).

### 3. Init sequence checklist

```
Peripheral bring-up order
├── 1. Enable bus clock (RCC/APB/AHB register)
├── 2. Reset peripheral (if RM requires)
├── 3. Configure pins (GPIO alternate function)
├── 4. Configure peripheral registers (mode, baud, etc.)
├── 5. Enable peripheral (UE, TE, RE bits)
├── 6. Enable NVIC IRQ (if interrupt-driven)
└── 7. Verify status flags before first transaction
```

**Bad** — enable UART before clock:

```c
USART2->CR1 |= USART_CR1_UE;  /* USART clock still off — no effect */
```

### 4. Bit definition discipline

```c
/* From RM: CR1 M[1:0], PCE, PS, TE, RE, UE */
#define USART_CR1_UE   (1U << 13)
#define USART_CR1_TE   (1U << 3)
#define USART_CR1_RE   (1U << 2)
```

Document RM section number in comment for audit trail.

### 5. Timing and busy-wait

```c
/* RM: poll BUSY flag until reset complete */
while (RCC->CR & RCC_CR_PLLRDY == 0)
    ;
```

Respect startup times (oscillator settle, PLL lock) from electrical characteristics chapter.

### 6. Good vs bad driver structure

**Good** — layered, RM-referenced:

```c
void usart2_init(uint32_t baud) {
    rcc_enable_usart2();
    gpio_config_usart2_pins();
    usart2_set_baud(baud);
    USART2->CR1 = USART_CR1_TE | USART_CR1_RE | USART_CR1_UE;
}
```

**Bad** — magic numbers, no clock enable:

```c
*(uint32_t*)0x4000440C = 0x2000;  /* what peripheral? which bit? */
```

### 7. Agent usage examples

```
/peripherals-from-datasheet Walk me through USART init from STM32 RM
/peripherals-from-datasheet What sections of the ref manual matter for SPI timing?
```

## Common Problems

| Symptom | Cause | Fix |
|---------|-------|-----|
| Peripheral dead | Clock not enabled | RCC/APB enable bit first |
| Wrong baud rate | PCLK assumption wrong | Recompute using actual clock tree |
| GPIO AF wrong | MUX value from wrong table | Cross-check pinout + AF table |
| IRQ stuck | Status flag clear sequence wrong | RM "clearing flags" subsection |
| Silent data corruption | Endian or width mismatch | Match register access size |

## Related Skills

- `skills/baremetal/datasheet-and-refmanual-reading` — fast RM navigation
- `skills/baremetal/mmio-and-bit-manipulation` — register access patterns
- `skills/baremetal/gpio-baremetal` — pin mux before peripheral enable
- `skills/embedded/linker-scripts` — memory map alignment

© mohitmishra786 · MIT · mohitmishra786/low-level-dev-skills

Similar skills

All skills for Agent setup: memory, context, orchestration →

From the same set140

The whole set →
kernel-testing Skill for Linux kernel testing: KUnit for unit tests, kselftest for regression checks, syzkaller for fuzzing, and LTP for syscall compatibility. Activates on kunit.py queries, syzkaller config, or KernelCI setup. CX Codex +1 382installs branch-prediction-and-speculation branch-prediction-and-speculation is a Claude Code skill that explains CPU branch prediction and speculative execution to help optimize hot loops and protect code from cache timing leaks. CX Codex +1 382installs os-dev-scratch os-dev-scratch is a Claude Code skill for building a minimal x86-64 OS, from boot stages to drivers and context switching. It activates on questions about kernel boot, interrupts, page tables, or QEMU. CX Codex +1 381installs kernel-security kernel-security — a skill for SELinux and AppArmor policies, seccomp-bpf sandboxing, KASLR, Intel CET, ARM PAC and BTI. Write LSM rules, triage kernel CVEs, and configure kernel mitigations. CX Codex +1 381installs platform-device-model The platform-device-model skill explains Linux platform-driver binding, probe and remove, sysfs, device properties, and deferred probing for kernel work. CX Codex +1 378installs writing-char-drivers writing-char-drivers — a skill for writing Linux character drivers: cdev registration, file_operations implementation, safe userspace copies, ioctl and mmap. CX Codex +1 378installs adc-dac-baremetal adc-dac-baremetal — a skill for bare-metal ADC and DAC setup on MCUs: channel selection, sampling time, calibration, DMA buffers, and voltage output. Essential when working with analog sensors, audio signals, or control voltages. CX Codex +1 378installs resource-optimization-lowend The resource-optimization-lowend skill helps trim flash and RAM use in MCU firmware, inspect linker maps, and measure stack depth when embedded resources are tight. CX Codex +1 376installs

Project sponsors

Companies that keep this analytics open