Skip to content

HAL: extend the async (embedded-hal-async) driver layer to chip-bs21 #25

@sanchuanhehe

Description

@sanchuanhehe

The embassy time-driver was made chip-neutral and now runs on BS2X (hisi-riscv-hal 0.3.1: embassy::ALARM_IRQ, embassy decoupled from async). But the broader async feature — the interrupt + waker driven embedded-hal-async / embedded-io-async driver layer — is still chip-ws63-only:

  • asynch (the wfi block_on + IrqSignal) — #[cfg(all(feature = "chip-ws63", feature = "async"))]
  • timer::AsyncDelay (DelayNs), gpio digital::Wait, uart Read/Write, spi SpiBus, i2c I2c

These reference the WS63-only asynch module + WS63 interrupt names (DMA_INT / GPIO_INT0.. / TIMER_INT0..) in their per-driver on_interrupt, so they don't compile under chip-bs21.

Task: make the async driver layer build + work on BS2X (chip-bs21):

  • Generalize the per-driver on_interrupt / IRQ references through soc::chip (BS2X IRQ numbers: GPIO_0=34, UART_0=39, TIMER_0=53, DMA=…) instead of WS63 literals.
  • Un-gate asynch + the per-driver async impls from chip-ws63 to just async where the register access is already chip-neutral (TCXO/TIMER/GPIO/UART/SPI/I2C blocks are register-identical across the family, as verified for the embassy driver).
  • Validate on qemu-system-riscv32 -M bs21/bs21e/bs22/bs20 (e.g. an async_delay / async_bus analogue under examples/bs21).

Today BS2X users get embassy (the common async path); this issue closes the gap for the lower-level embedded-hal-async drivers. Surfaced during the 2026-06-12 embassy-on-BS2X bring-up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions