Skip to main content

ws63_hal/
lib.rs

1//! # ws63-hal — Hardware Abstraction Layer for HiSilicon WS63 (RISC-V).
2//!
3//! A comprehensive HAL providing safe, idiomatic Rust APIs for all WS63
4//! peripherals. Modeled on esp-hal patterns with type-state GPIO, RAII
5//! clock guards, DMA typing, and embedded-hal trait implementations.
6//!
7//! ## Clock gating
8//!
9//! Most peripherals need their CLDO_CRG clock gate enabled before register
10//! access. The gates default to enabled out of reset; `clock_init::init_clocks()`
11//! sets up the system clocks for firmware that does not boot through flashboot.
12//! Constructors like `I2c::new_i2c0()`, `Uart::new_uart0()`, and `Watchdog::new()`
13//! write configuration registers immediately. WDT/RTC/TCXO are always-on.
14//!
15//! ```ignore
16//! let clocks = clock_init::init_clocks(&system.sys_ctl0, &system.cldo_crg);
17//! // Now safe to construct peripheral drivers
18//! let uart = Uart::new_uart0(peripherals.UART0, Config::default());
19//! ```
20// `no_std` for firmware builds; `std` is linked under `cfg(test)` so the host
21// unit tests can use the standard test harness (run via `cargo test --target x86_64`).
22#![cfg_attr(not(test), no_std)]
23#![allow(non_camel_case_types)]
24#![allow(rustdoc::broken_intra_doc_links)]
25
26#[cfg(feature = "async")]
27pub mod asynch;
28pub mod clock;
29pub mod clock_init;
30pub mod delay;
31pub mod dma;
32pub mod efuse;
33#[cfg(feature = "embassy")]
34pub mod embassy;
35pub mod gpio;
36pub mod i2c;
37pub mod i2s;
38pub mod interrupt;
39pub mod io_config;
40pub mod lsadc;
41pub mod macros;
42pub mod peripherals;
43pub mod prelude;
44pub mod private;
45pub mod pwm;
46pub mod rtc;
47pub mod safety;
48pub mod sfc;
49pub mod spi;
50pub mod system;
51pub mod tcxo;
52pub mod time;
53pub mod timer;
54pub mod trng;
55pub mod tsensor;
56pub mod uart;
57pub mod ulp_gpio;
58pub mod wdt;
59
60// Crypto modules
61pub mod km;
62pub mod pke;
63pub mod spacc;
64
65pub mod soc;
66
67pub use peripherals::Peripherals;
68pub use system::System;