ch58x-hal
ch58x-hal copied to clipboard
Portability
Is it possible to make this HAL library compatible with both CH57x (RISC-V), CH58x and CH59x? My idea is to use different implementations for different MCUs on the lower layer, but provide the same interface to the user on the upper layer, and the user selects the MCU they use through Rust features.
Yes. They are sharing almost the same register block. The initial version is copied from my CH592 work at https://github.com/ch32-rs/ch59x-hal since I found CH58x is more available than CH59x. You can just flash the same firmware for these 3 families. (blinky, uart, and embassy demo works)
The difference:
- CH58x has 80Mhz highest clk
- They differ in clk setting
- CH59x has a segment LCD peripheral
- GPIO port differs (pin assignment, pin remap, interrupt remap)
- SRAM size
- BLE version
This crate is at an early stage. I need some investigation on how to get BLE to work. (if not, then the whole crate is meaningless)
When the BLE part is landed. I'll try to introduce feature gates for different devices.
Thank you for your contribution to Rust on WCH MCUs! If I have time, I will try to join this project's development.
Confirmed almost all of CH582's BLE lib can be highly integrated into the Embassy framework. (BLE MESH is not tested yet)
@za-songguo I'll start the refactoring work this weekend.
I'm planning to create a new ch5xx-hal-common
crate to handle this.
+CC @Slappy2022
@andelf Good job! The Rust ecosystem on WCH MCUs is getting better and better!