spi-i2c-baremetal

spi-i2c-baremetal is a skill for Claude Code, Codex from mohitmishra786/low-level-dev-skills. It costs 65 tokens per session (874 once invoked), scanned A, original, MIT.

A low-level guide for writing SPI and I2C communication code for microcontrollers. SPI and I2C are common hardware communication methods used to talk to parts such as sensors, memory chips, and displays.

In plain words
What is it for?
Use it to implement master-mode SPI or I2C transfers, read and write device registers, bring up an SPI flash chip or display, read an I2C sensor, or debug errors such as a missing acknowledgement or stuck clock line.
Why use it?
It helps when a project must communicate directly with hardware instead of relying on a ready-made hardware library. It addresses details such as clock settings, device registers, acknowledgements, and stalled connections.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to implement master-mode SPI or I2C transfers, read and write device registers, bring up an SPI flash chip or display, read an I2C sensor, or debug errors such as a missing acknowledgement or stuck clock line.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/mohitmishra786/low-level-dev-skills/spi-i2c-baremetal
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add mohitmishra786/low-level-dev-skills --skill spi-i2c-baremetal
Clone the repo
git clone --depth 1 https://github.com/mohitmishra786/low-level-dev-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for spi-i2c-baremetal

README.md
[![agentmods](https://agentmods.dev/badge/skills/mohitmishra786/low-level-dev-skills/spi-i2c-baremetal/github.svg)](https://agentmods.dev/skills/mohitmishra786/low-level-dev-skills/spi-i2c-baremetal)
Your own site
<a href="https://agentmods.dev/skills/mohitmishra786/low-level-dev-skills/spi-i2c-baremetal"><img src="https://agentmods.dev/badge/skills/mohitmishra786/low-level-dev-skills/spi-i2c-baremetal/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for spi-i2c-baremetal

Your own site · 80×15
<a href="https://agentmods.dev/skills/mohitmishra786/low-level-dev-skills/spi-i2c-baremetal"><img src="https://agentmods.dev/badge/skills/mohitmishra786/low-level-dev-skills/spi-i2c-baremetal.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 65 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 874 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00065 $0.00874
Opus 5 $0.00032 $0.00437
Sonnet 5 $0.00013 $0.00175
Haiku 4.5 $0.00006 $0.00087

Measured 12d ago against content hash f542e8f28792, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

spi-i2c-baremetal scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 12d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/baremetal/spi-i2c-baremetal/SKILL.md · 93 lines

How it starts

The opening of the file, as written. The whole thing — 93 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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)

/* 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):

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

2. I2C master — register read

/* 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)
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

Read the full file on GitHub · 93 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 12d ago First seen · 93 lines · 65 tokens per session scan A f542e8f28792

Subscribe to this mod's changes

spi-i2c-baremetal is a skill published in the GitHub repository mohitmishra786/low-level-dev-skills (203 stars, last pushed 2mo ago), licensed MIT. It adds 65 tokens to every session and 874 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.