Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portability #1

Open
za-songguo opened this issue Nov 11, 2023 · 5 comments
Open

Portability #1

za-songguo opened this issue Nov 11, 2023 · 5 comments
Labels
question Further information is requested

Comments

@za-songguo
Copy link

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.

@andelf
Copy link
Contributor

andelf commented Nov 12, 2023

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.

@za-songguo
Copy link
Author

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

@andelf
Copy link
Contributor

andelf commented Nov 21, 2023

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
Copy link
Contributor

andelf commented Nov 21, 2023

+CC @Slappy2022

@za-songguo
Copy link
Author

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

@andelf andelf added the question Further information is requested label Jan 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants