Expand description
§ch57x-hal
HAL for CH57x RISC-V BLE microcontrollers from WCH.
This crate is under active development and should currently be treated as experimental.
§What This Crate Provides
- CH57x peripheral abstractions built on top of
ch57x-pac - Runtime integration via
qingke-rt - Optional Embassy support (
embassyfeature) - Optional BLE bindings (
blefeature, backed by vendor libraries invendor/)
§Development Setup
-
Install Rust target:
rustup target add riscv32imac-unknown-none-elf -
Optional nightly toolchain (needed by several examples using
#![feature(type_alias_impl_trait)]):rustup toolchain install nightly -
Install a flasher tool used by
.cargo/config.toml:
- default runner:
wlink -v flash - alternatives are commented in
.cargo/config.toml
- Validate baseline:
- library:
cargo check - one example at a time:
cargo check --example blinky - flash one example:
cargo run --release --example blinky
§Current Status
- Library crate compiles on stable with warnings.
- Many examples are still mid-migration from CH58x style APIs to CH57x and do not all compile yet.
- Migration tracking docs:
progress.mdplan.mdlearnings.mddocs/ch572ds1-mapping.md
§Features
-
Basic: clock init, delay, interrupt, etc.
-
Dedicated runtime: interrupt table, hardware stack push, highcode support, critical section implementation
-
embassy support
- time driver with SysTick, defaults to 32KHz tick
- about 7k flash rom overhead
-
GPIO, with async support
-
UART, basic blocking tx, rx
-
RTC, with datetime support
-
SysTick delay (conflicts with embassy time driver)
-
ADC, with Temperature sensor, VBAT sensor
-
SPI
-
libISP ROM functions
-
Basic BLE library support
§Usage
[dependencies]
ch57x-hal = { package = "ch57x-hal-raynhardt", version = "0.0.6" }Feature examples:
[dependencies]
ch57x-hal = { package = "ch57x-hal-raynhardt", version = "0.0.6", default-features = false, features = ["embassy", "ble"] }See the examples/ directory for end-to-end usage.
§Crates.io
Add dependency:
[dependencies]
ch57x-hal = { package = "ch57x-hal-raynhardt", version = "0.0.6" }Release process is tracked in RELEASING.md.
§Notes
UNDOCUMENTED:tags in code comments means the information is not from official documents.
§References
- ch32-rs/ch58x-hal (original)
- Slappy2022/ch58x-ble-rt
Re-exports§
pub use self::peripherals::Peripherals;pub use ch57x_pac as pac;
Modules§
- adc
- ble
- delay
- Simple busy-loop delay provider
- dma
- embassy
- gpio
- GPIO_ModeIN_Floating, // floating input GPIO_ModeIN_PU, // pull-up input GPIO_ModeIN_PD, // pull-down input GPIO_ModeOut_PP_5mA, // push-pull output (max 5mA) GPIO_ModeOut_PP_20mA, // push-pull output (max 20mA)
- interrupt
- isp
- The libISP583 library.
- peripherals
- prelude
- rtc
- Real time clock
- signature
- spi
- SPI, Serial Peripheral Interface
- sysctl
- timer
- TMRx Timer.
- uart
- UART, Universal Asynchronous Receiver/Transmitter
Macros§
Structs§
- Config
- Peripheral
Ref - An exclusive reference to a peripheral.
Statics§
Traits§
- Peripheral
- Trait for any type that can be used as a peripheral of type
P. - U32Ext
- Extension trait that adds convenience methods to the
u32type
Functions§
- delay_
ms - delay_
us - init
- reset⚠
- System reset
- set_
default_ ⚠serial - soft_
reset ⚠ - Software reset
- stack_
free - with_
safe_ access
Type Aliases§
- Bits
PerSecond - Bits per second