This repository provides a driver layer for the Py32f030 chip. It currently supports most peripherals and provides many friendly interfaces. By calling the upper-level interfaces, the peripherals of the microcontroller can be easily put into operation.
Installing the Rust embedded compilation environment for Py32F030 is very simple. You need to install the Rust compilation chain and some tools
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
The installation of Rust on Windows is a little bit complicated. You can read this website to learn how to install it.
After installing rust, you need to switch to the night version to compile some embedded rust code
rustup default nightly
rustup target add thumbv6m-none-eabi
Execute the following command. If there is no error, it means that the rust compilation environment is installed normally.
git clone https://github.com/hysonglet/py32f030-hal.git
cd py32f030-hal
cargo build
➜ py32f030-hal git:(main) ✗ rustup --version
rustup 1.27.1 (54dd3d00f 2024-04-24)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.82.0-nightly (6de928dce 2024-08-18)`
安装 Probe-rs
Probe-rs is an excellent firmware download and log debugging tool. For detailed of installation and how to use, please click this link to see more。
curl --proto '=https' --tlsv1.2 -LsSf \
https://github.com/probe-rs/probe-rs/releases/latest/download/probe-rs-tools-installer.sh \
| sh
cargo install cargo-binstall
cargo binstall probe-rs-tools
cargo install cargo-get
brew install llvm
There are two tools here, you can choose a tool written in Python or a serial port tool written in Rust.
- python sccript: puyaisp
pip install puyaisp
pip install pyusb pyserial hid
burn:
# Press the boot and RST buttons at the same time, then release RST first, then release Boot, and then execute the following command
puyaisp -f blink.bin
- rust tools: pyisp Use pyisp rust serial port tool to burn bin file,
# One-time download
pyisp -s tty.usbserial-130 -g -f test.bin
# Repeated download
pyisp -s COM4 -g -c -f test.bin
Of course, it is not limited to jlink, stlink is also a good choice. Sometimes we use the following two methods to download and view the running logs
- cargo run
cargo r --example embassy_uart
- probe-rs run
probe-rs run --chip PY32F030x8 target/thumbv6m-none-eabi/debug/examples/embassy_uart
- gpio
- exit
- timer
- i2c
- clock
- embassy
- dma
- usart
- adc
- flash
- spi
- crc
- rtc
- iwatchdog
- Flash
- LPTimer
- Clock -> 48M
- spi
# run
cargo run --example blinky
# build
cargo build --release --example blinky
py32f030-hal git:(main) ✗ cargo r --example
error: "--example" takes one argument.
Available examples:
adc_block
advanced_timer_block
advanced_timer_block_2
bit_test
blinky
block_uart
clock
crc
dma_mem2mem
embassy_adc
embassy_delay
embassy_dma_mem2mem
embassy_exit
embassy_i2c
embassy_iwdg
embassy_pwm
embassy_rtc
embassy_ssd1309
embassy_uart
hello_world
i2c_master_block
key
rtc_block
uart
We currently provide Taobao links, you can choose any one to buy