Expand description
§ws63-hal — Hardware Abstraction Layer for HiSilicon WS63 (RISC-V).
A comprehensive HAL providing safe, idiomatic Rust APIs for all WS63 peripherals. Modeled on esp-hal patterns with type-state GPIO, RAII clock guards, DMA typing, and embedded-hal trait implementations.
§Clock gating
Most peripherals need their CLDO_CRG clock gate enabled before register
access. The gates default to enabled out of reset; clock_init::init_clocks()
sets up the system clocks for firmware that does not boot through flashboot.
Constructors like I2c::new_i2c0(), Uart::new_uart0(), and Watchdog::new()
write configuration registers immediately. WDT/RTC/TCXO are always-on.
ⓘ
let clocks = clock_init::init_clocks(&system.sys_ctl0, &system.cldo_crg);
// Now safe to construct peripheral drivers
let uart = Uart::new_uart0(peripherals.UART0, Config::default());Re-exports§
pub use peripherals::Peripherals;pub use system::System;
Modules§
- clock
- Clock definitions for WS63.
- clock_
init - Clock initialization for WS63.
- delay
- Blocking delay driver for WS63.
- dma
- DMA (Direct Memory Access) driver for WS63.
- efuse
- eFuse (OTP) driver for WS63 — v151 controller.
- gpio
- GPIO driver for WS63 (19 pins: GPIO0 bits 7-0, GPIO1 bits 15-8, GPIO2 bits 18-16).
- i2c
- I2C master driver for WS63 (I2C0/1, FIFO-capable).
- i2s
- I2S (Inter-IC Sound) / PCM audio interface driver for WS63.
- interrupt
- WS63 interrupt controller — riscv31 custom local interrupts (NOT a PLIC).
- io_
config - IO Configuration (Pin Mux and Pad Control) driver for WS63.
- km
- KM (Key Management) driver for WS63.
- lsadc
- Low-Speed ADC (LSADC) driver for WS63 — v154 controller.
- macros
- Utility macros for the WS63 HAL.
- peripherals
- Peripheral singletons wrapping the WS63 PAC.
- pke
- PKE (Public Key Engine) driver for WS63.
- prelude
- Prelude — re-exports commonly used traits and types.
- private
- Private module for sealed traits.
- pwm
- PWM driver for WS63 (8 channels, 32-bit).
- rtc
- Real-Time Clock (RTC) driver for WS63.
- safety
- Compile-time safety checks for ws63-hal.
- sfc
- SFC (SPI Flash Controller) driver for WS63.
- soc
- spacc
- SPACC (Security Accelerator) driver for WS63.
- spi
- SPI master driver for WS63 (SPI0/1, SSI v151).
DesignWare SSI: SCK = SSI_CLK / SCKDV. Two-stage clock: a CLDO_CRG divider sets
SSI_CLK = 160MHz off the 480MHz PLL (
configure_spi_source_clock, mirrors the vendorspi_porting_clock_init), then SCKDV divides to SCK. SSI_CLK =crate::soc::ws63::SPI_CLOCK_HZ(NOT the 240MHz CPU clock; SCKDV is even, >= 2). - system
- System control — clock enables, resets, and power management.
- tcxo
- TCXO 64-bit Free-Running Counter driver for WS63.
- time
- Timekeeping types for WS63 HAL.
- timer
- Timer driver for WS63 (3 independent 32-bit timers).
- trng
- True Random Number Generator (TRNG) driver for WS63.
- tsensor
- Temperature Sensor (TSENSOR) driver for WS63.
- uart
- UART driver for WS63 (UART0/1/2, 16C550-compatible with FIFO).
- ulp_
gpio - Ultra-Low-Power GPIO (ULP_GPIO) driver for WS63.
- wdt
- Watchdog Timer (WDT) driver for WS63.
Macros§
- any_
peripheral - Create a type-erased enum for a peripheral type. Example:
- infallible
- Infallible conversion — used when a conversion cannot fail.
- unstable_
driver - Declare a driver that requires the
unstablefeature. Without it, the driver is not compiled at all. - unstable_
module - Declare a driver as unstable (only available with the
unstablefeature). When the feature is not enabled, the module ispub(crate).