ch58x-hal icon indicating copy to clipboard operation
ch58x-hal copied to clipboard

Portability

Open za-songguo opened this issue 1 year ago • 5 comments

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.

za-songguo avatar Nov 11 '23 17:11 za-songguo

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.

andelf avatar Nov 12 '23 02:11 andelf

Thank you for your contribution to Rust on WCH MCUs! If I have time, I will try to join this project's development.

za-songguo avatar Nov 12 '23 02:11 za-songguo

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.

image

andelf avatar Nov 21 '23 08:11 andelf

+CC @Slappy2022

andelf avatar Nov 21 '23 08:11 andelf

@andelf Good job! The Rust ecosystem on WCH MCUs is getting better and better!

za-songguo avatar Nov 25 '23 09:11 za-songguo