8 releases
0.3.3 | Sep 10, 2024 |
---|---|
0.3.2 | Aug 15, 2024 |
0.2.1 | Aug 13, 2024 |
0.1.1 | Aug 12, 2024 |
0.1.0 | Jul 19, 2024 |
#99 in No standard library
37 downloads per month
68KB
1.5K
SLoC
bind-hal
This crate has been separated and moved to py32-bind-hal
This crate is no longer updated, please see py32-bind-hal
This project aims to provide a more complete HAL (Hardware Abstraction Layer).
The project uses the vendor-provided C SDK and operates peripherals through bindings, then wraps these C APIs for easy use in Rust.
Users can also directly use FFI to perform complex operations without manipulating registers.
Supported MCU:
---PY32F0xx Series---
Puya PY32F002A, PY32F003, PY32F030
Xinlinggo XL32F003*, XL32F002A*
Luat AIR001
Peripherals/Functions | Bindings | Easy-to-use func | Embedded-Hal |
---|---|---|---|
GPIO | ✔ | ✔ | ✔ |
RCC | ✔ | ✔ | ✖ |
Power | ✔ | ✔(only sleep/stop) | ✖ |
PWM/TIMER | ✔ | ||
RTC | ✔ | ||
WDG | ✔ |
Peripherals/Functions | Bindings | Easy-to-use func | Embedded-Hal | Embedded-Async | Polling | DMA | IT |
---|---|---|---|---|---|---|---|
EXTI | ✔ | ✔ | ✔ | ✔ | ✖ | ✖ | ✔ |
I2C | ✔ | ✔ | ✔ | ✔ | |||
ADC | ✔ | ✔(only polling) | ✖ | ✖ | ✔ | ✔ | |
USART | ✔ | WIP | |||||
SPI | ✔ | ||||||
LED | ✔ | ||||||
✖: mcu or embedded-hal not support
WIP: work in progress
Others:
Interrupt(cortex-m-rt) | Embassy Time-Driver | HAL-Ticks |
---|
Why use bindings?
Taking STM32 as an example, there are many excellent HALs available: embassy stm32-rs
This crate’s performance, ROM, and RAM usage are far inferior to these HALs.
However, most Rust HALs are maintained by the community or enthusiasts and do not receive vendor support. Especially for microcontrollers with fewer users, there are not enough people to maintain the HAL, or in the end, only basic functions can be used.
This crate requires little maintenance and does not require dealing with registers. Even if there are unwrapped functions, others can easily supplement or directly call FFI.
In the near future, this crate will primarily update SDKs for microcontrollers similar to STM32 HAL CSDK
aiming to reuse code on similar SDKs.
py32csdk-hal-sys
The CSDK and bindings for py32 are maintained here: py32csdk-hal-sys, and this package already includes precompiled static library file and bindings.rs
for quick use. However, if you want to recompile and generate bindings, it will be troublesome, please check its Docs. You need to enable the recompile
feature.
Dependencies
~6.5MB
~96K SLoC