Skip to main content
skill CX Codex

spi-i2c-baremetal — Claude Code skill: setup and install

The spi-i2c-baremetal skill guides bare-metal SPI and I2C driver work, from register reads to bus troubleshooting. Use it when bringing up sensors, flash, or displays.

MIT 384 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 spi-i2c-baremetal -a claude-code
Open on GitHub

What spi-i2c-baremetal does

The skill covers master-mode transfers: SPI clock polarity and phase, byte exchange, and chip-select control; plus I2C register reads with START, ACK, repeated START, and STOP. It includes STM32 code and common transaction patterns for sensors and SPI flash.

For debugging, it connects symptoms to likely causes: an I2C NACK can point to an address-format mistake, while garbled SPI data can come from a CPOL/CPHA mismatch. A low SCL line may involve clock stretching or a slave fault. Check the microcontroller reference manual for SPI and I2C status-flag handling. SPI mode must match the slave datasheet; a mismatch can corrupt reads.

What it helps with

  • configure SPI master timing for a peripheral
  • read a sensor register over I2C
  • trace an I2C NACK or a stuck SCL line
  • replace HAL_I2C or HAL_SPI with minimal code

Example prompts for the agent

  • Implement a bare-metal I2C read of register 0x0F on device 0x68.
  • Set up SPI master mode to read a sensor register using its CPOL and CPHA requirements.
  • Investigate why an I2C register read returns NACK.

How to install spi-i2c-baremetal

1Skills CLI (Vercel)

npx skills add mohitmishra786/low-level-dev-skills --skill spi-i2c-baremetal -a claude-code

2Manually: put the files in place

~/.claude/skills/spi-i2c-baremetal/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/spi-i2c-baremetal/

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

Questions about spi-i2c-baremetal

How do I install spi-i2c-baremetal in Claude Code?

Run npx skills add mohitmishra786/low-level-dev-skills --skill spi-i2c-baremetal -a claude-code. The skill file is at ~/.claude/skills/spi-i2c-baremetal/SKILL.md.

What does spi-i2c-baremetal do?

It assists with bare-metal SPI and I2C master drivers, including register-oriented transfers and bus debugging. Its examples cover STM32 and common sensor or flash transactions.

Which platforms support this skill?

It is available for Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, and OpenCode.

Source text

SKILL.md · MIT
---
name: spi-i2c-baremetal
description: Bare-metal SPI and I2C skill for serial peripheral buses. Use when implementing master-mode transfers, register read/write protocols, or debugging bus stalls. Activates on queries about SPI bare-metal, I2C START/STOP, sensor register read, or clock phase/polarity.
---

# SPI and I2C (Bare-Metal)

## Purpose

Implement SPI and I2C master drivers for sensor and memory chips: clock configuration, phase/polarity (SPI), START/ACK sequences (I2C), and common register-oriented transaction patterns.

## When to Use

- Reading an I2C sensor (WHO_AM_I register)
- SPI flash or display bring-up
- Debugging NACK or stuck SCL
- Replacing HAL_I2C/SPI with minimal code

## Workflow

### 1. SPI master (STM32)

```c
/* Mode 0: CPOL=0, CPHA=0 — check slave datasheet */
SPI1->CR1 = SPI_CR1_MSTR | SPI_CR1_SSM | SPI_CR1_SSI
          | (3 << SPI_CR1_BR_Pos);  /* baud divider */
SPI1->CR1 |= SPI_CR1_SPE;

uint8_t spi_xfer(SPI_TypeDef *spi, uint8_t tx) {
    while (!(spi->SR & SPI_SR_TXE))
        ;
    *(volatile uint8_t *)&spi->DR = tx;
    while (!(spi->SR & SPI_SR_RXNE))
        ;
    return *(volatile uint8_t *)&spi->DR;
}
```

CS (GPIO bit-bang):

```c
GPIO_CS_LOW();
spi_xfer(SPI1, reg | 0x80);  /* read */
uint8_t val = spi_xfer(SPI1, 0xFF);
GPIO_CS_HIGH();
```

### 2. I2C master — register read

```c
/* START → addr+W → reg → repeated START → addr+R → data → STOP */
bool i2c_read_reg(I2C_TypeDef *i2c, uint8_t dev7, uint8_t reg, uint8_t *out) {
    if (!i2c_start(i2c)) return false;
    if (!i2c_tx(i2c, (dev7 << 1) | 0)) return false;
    if (!i2c_tx(i2c, reg)) return false;
    if (!i2c_restart(i2c)) return false;
    if (!i2c_tx(i2c, (dev7 << 1) | 1)) return false;
    *out = i2c_rx(i2c, false);  /* NACK last byte */
    i2c_stop(i2c);
    return true;
}
```

Poll `SB`, `ADDR`, `TXE`, `RXNE`, `BTF` per reference manual.

### 3. Common protocols

| Pattern | Bus |
|---------|-----|
| `reg + write data` | I2C/SPI |
| `0x80|reg` read (MSB set) | SPI sensors |
| 16-bit big-endian length prefix | SPI flash |

### 4. Agent usage

```
/spi-i2c-baremetal I2C read of register 0x0F from device 0x68
```

## Common Problems

| Symptom | Cause | Fix |
|---------|-------|-----|
| I2C NACK | Wrong 7-bit addr (8-bit in datasheet) | Shift addr; check R/W bit |
| SPI garbage | CPOL/CPHA mismatch | Match slave mode table |
| Bus stuck SCL low | Slave clock stretch / fault | Bus recovery (clock pulses) |
| CS glitch | CS timing vs clock | Assert CS before first SCK |

## Related Skills

- `skills/baremetal/gpio-baremetal` — CS, SDA, SCL pins
- `skills/baremetal/peripherals-from-datasheet` — timing requirements
- `skills/kernel-dev/bus-drivers-i2c-spi` — Linux kernel side

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

Similar skills

SKILL.md skills catalog →
i2c-bringup-diagnostician wedsamuel1230 i2c-bringup-diagnostician diagnoses I2C bring-up failures on Arduino and ESP32 boards, covering wiring, scanner mismatches, and driver bugs. CX Codex +1 134installs find-skills vercel-labs find-skills is a Claude Code skill that locates agent skills for a task and helps assess the results. It activates when someone asks for a capability that may already be installable. CX Codex +1 4,400,000installs frontend-design official anthropics The frontend-design skill guides intentional visual design for new interfaces and redesigns. Use it when a generic generated UI is not enough. CX Codex +1 1,025,790installs agent-browser vercel-labs This Claude Code skill automates browser interaction for tasks like navigating sites, filling forms, and testing web apps. It also supports exploratory QA and Electron app automation. CX Codex +1 1,600,000installs design-taste-frontend Leonxlnx The design-taste-frontend Claude Code skill sets design rules and checks for websites. It activates for new pages, redesigns, and requests to fix a generic-looking site. CX Codex +1 802,600installs grill-me Matt Pocock grill-me interviews you about a plan or design to expose gaps and sharpen decisions. Use it before implementation starts. CX Codex +1 1,424,476installs grill-with-docs Matt Pocock The grill-with-docs skill interviews you about a plan or design and creates ADRs and a glossary along the way. Use it when decisions need sharper definition. CX Codex +1 1,219,756installs

From the same set140

The whole set →
qemu-embedded-simulation The qemu-embedded-simulation skill guides QEMU runs of bare-metal ARM and RISC-V firmware and GDB sessions. Use it to test firmware without a board. CX Codex +1 389installs kernel-memory-management kernel-memory-management — a skill that walks an AI agent through Linux kernel allocation: kmalloc vs vmalloc vs page allocator, GFP flags, zones and OOM debugging. CX Codex +1 388installs cuda-debugging Walks the agent through CUDA debugging: cuda-gdb, Compute Sanitizer, GPU core dumps, error codes 700 and 702. Useful when a kernel crashes or returns wrong values. CX Codex +1 386installs llvm-ir-and-passes llvm-ir-and-passes teaches the agent to read LLVM IR, understand SSA form, and navigate optimization passes. Useful when tracing what -O2 changed or preparing to write a custom pass. CX Codex +1 384installs protocol-analysis protocol-analysis is a Claude Code skill that decodes I2C, SPI, and UART captures with sigrok and PulseView, then checks them against driver code. It handles silent-sensor bus analysis. CX Codex +1 383installs gpio-baremetal gpio-baremetal configures GPIO modes, alternate functions, pull resistors, and EXTI interrupts on bare-metal microcontrollers without HAL. CX Codex +1 383installs apple-silicon A skill for developers building on Apple Silicon: tuning code for unified memory, Metal Performance Shaders, Instruments profiling, Rosetta 2 behavior, and 16KB page size quirks. CX Codex +1 383installs code-generation-and-backends code-generation-and-backends explains LLVM backend stages, from IR legalization to assembly output. Use it to investigate llc, TableGen patterns, or the outline of a new target port. CX Codex +1 382installs

Project sponsors

Companies that keep this analytics open