Skip to content
Back to skills

Embedded Hal Knowledge Patch

ASecurity

embedded-hal

  • 25 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added December 1, 2026
developmentrustgogit

Security analysis

A100/100

Pro scans all 7 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add Nevaberry/nevaberry-plugins --skill embedded-hal-knowledge-patch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Embedded Hal Knowledge Patch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Embedded Hal Knowledge Patch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nevaberry-embedded-hal-knowledge-patch-nevaberry-plugins/badge)](https://www.skillsdirectory.com/skills/nevaberry-embedded-hal-knowledge-patch-nevaberry-plugins)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: embedded-hal-knowledge-patch
description: embedded-hal
version: "1.0.0"
license: MIT
metadata:
  author: Nevaberry
---


# embedded-hal compatibility guidance

Use this skill when adapting peripheral drivers or HAL implementations to
changed trait paths, receivers, transactions, error classification, or delays.
Also load it when configuring shared bus adapters or checking the Rust
requirements of the core, async, and bus crates.

## Reference index

| Reference | Topics |
| --- | --- |
| [Trait migration](references/trait-migration.md) | Imports, digital pin receivers, toggling, async interrupt waits, PWM, removed traits, reference blanket implementations |
| [SPI transactions](references/spi.md) | Device transactions, chip select, dedicated and shared buses, raw bus completion, transaction delays |
| [I2C transactions](references/i2c.md) | Consolidated traits, transaction defaults, buffer slices, register-read example |
| [Errors, delays, and Rust](references/errors-delays-and-rust.md) | Portable error kinds, infallible delays, core and async Rust requirements |
| [Bus adapters](references/bus-adapters.md) | AtomicDevice feature requirement, reference-counted devices, bus error support, bus Rust requirement |

## Migration quick reference

### Blocking, async, and nonblocking imports

Blocking traits live directly under their peripheral modules, for example
`embedded_hal::i2c::I2c`; the old `::blocking` path segment is removed.

Use `embedded-hal-async` for native async traits and `embedded-hal-nb` for
nonblocking traits.

### Digital pin receivers and toggling

These methods take `&mut self`:

- `InputPin::is_high()` and `is_low()`.
- `StatefulOutputPin::is_set_high()` and `is_set_low()`.

Use `StatefulOutputPin::toggle()` in place of the removed
`ToggleableOutputPin` trait.

### PWM duty-cycle control

The old `Pwm` and `PwmPin` traits were removed.
Generic drivers can use `pwm::SetDutyCycle` for duty-cycle control.
Read the limit with `max_duty_cycle()`.

### Removed and relocated peripherals

Blocking and async UART byte streams use `embedded-io`.
CAN traits live in `embedded-can`.

The core HAL removed these traits:

- ADC `OneShot` and `Channel`.
- `IoPin`.
- `capture::Capture` and `qei::Qei`.
- `timer::{Cancel, CountDown, Periodic}`.
- `watchdog::{Disable, Enable, Watchdog}`.

### I2C transaction defaults and buffers

The blocking and async `I2c` traits consolidate the old separate traits
around `transaction()`.
That method supplies the defaults for `read()`, `write()`, and `write_read()`.

Use buffer slices in place of the removed iterator-based methods.
See [I2C transactions](references/i2c.md) for a register-read example.

## Transactions and async interrupt waits

### SPI devices and chip select

A driver that selects its peripheral with chip select can take a `SpiDevice`.
Its `transaction()` holds the bus and keeps chip select asserted across
a slice of operations.

`embedded-hal-bus` supplies `spi::ExclusiveDevice` for a dedicated bus and
mutex-backed adapters for sharing a bus.

```rust
use embedded_hal::spi::{Operation, SpiDevice};

fn read_register<S: SpiDevice<u8>>(
    device: &mut S,
    command: u8,
    turnaround_ns: u32,
    data: &mut [u8],
) -> Result<(), S::Error> {
    device.transaction(&mut [
        Operation::Write(&[command]),
        Operation::DelayNs(turnaround_ns),
        Operation::Read(data),
    ])
}
```

### Raw SPI bus completion

A `SpiBus` operation can return before the hardware finishes clocking out data.
Call `flush()` to wait for completion before deasserting a manually
controlled chip-select pin.

### Async GPIO interrupt waits

A generic async driver can bound its interrupt pin by
`embedded_hal_async::digital::Wait`.
Use `irq.wait_for_high().await?` or `irq.wait_for_low().await?` to wait
for the peripheral to signal readiness.

## Errors, delays, and generic bounds

### Portable error classification

HALs can keep their own `Debug` error types and implement the peripheral's
`Error::kind()` so generic drivers can handle common failures through `ErrorKind`.

Map failures outside the defined categories to `Other`.
In 1.0, `Other` is the only digital error kind.

### Infallible nanosecond delays

Blocking and async delay providers implement `delay::DelayNs` with an
infallible `delay_ns(u32)` method.
It supplies the defaults for `delay_us()` and `delay_ms()`.

SPI transaction delays in both crates use `Operation::DelayNs(u32)`.

### Reference blanket implementations

The core, async, and nonblocking crates support `?Sized` in their
reference blanket implementations.
For an object-safe trait, a value such as `&mut dyn InputPin<Error = E>`
also satisfies an `InputPin` generic bound.

## Shared bus configuration

### AtomicDevice without compare-and-swap

`AtomicDevice` requires the `portable-atomic` feature on
`thumbv6m-none-eabi` and other targets without atomic compare-and-swap.

### Reference-counted I2C and SPI devices

Enable the `alloc` feature to use `embedded_hal_bus::i2c::RcDevice`
or `embedded_hal_bus::spi::RcDevice`.

These are reference-counted equivalents of `RefCellDevice` that let
each device own a handle to the shared bus.
See [Bus adapters](references/bus-adapters.md) for dependency examples.

### Bus error support

Bus error types that previously implemented `std::error::Error` behind
the `std` feature now implement `core::error::Error` in `no_std` builds as well.

## Rust requirements

| Crate | Minimum Rust requirement |
| --- | --- |
| `embedded-hal` | Rust 1.60.0 |
| `embedded-hal-async` | Rust 1.75 on stable; uses native async trait methods |
| `embedded-hal-bus` | Rust 1.81 |

Files in this skill

  • SKILL.md5.5 KB
  • coverage.json421 B
  • references/bus-adapters.md1009 B
  • references/errors-delays-and-rust.md949 B
  • references/i2c.md699 B
  • references/spi.md1.1 KB
  • references/trait-migration.md1.6 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.