#py32 #hardware-abstraction-layer #embedded-hal #abstraction-layer #mcu

no-std py32-bind-hal

MCU HALs using binding, currently supports PY32

4 releases

0.5.0 Sep 12, 2024
0.4.2 Sep 12, 2024
0.4.1 Sep 11, 2024
0.4.0 Sep 10, 2024

#216 in No standard library

Download history 232/week @ 2024-09-06 85/week @ 2024-09-13 12/week @ 2024-09-20 4/week @ 2024-09-27 2/week @ 2024-10-04

110 downloads per month

Custom license

79KB
1.5K SLoC

py32-bind-hal

Crates.io

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 N/C
Power ✔(only sleep/stop) N/C
DMA N/C
RTC N/C
WDG N/C
PWM/TIMER ✔(only PWM now) N/C
Peripherals/Functions Bindings Easy-to-use func embedded-hal/io embedded-hal/io-async Polling DMA IT
EXTI N/C N/C
I2C
ADC N/C N/C
UART
SPI

N/C: mcu hardware or embedded-hal not support

✖: no plan or hard to impl

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.

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.

Old Verisons

You can see old versions at bind-hal - crates.io and decaday/bind-hal (github.com) .

Dependencies

~6MB
~85K SLoC