Skip to content

hysonglet/py32f030-hal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

💁 Overview

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.

💻 Development environment

Installing the Rust embedded compilation environment for Py32F030 is very simple. You need to install the Rust compilation chain and some tools

Mac/Linux

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.

Rust nightly version

After installing rust, you need to switch to the night version to compile some embedded rust code

rustup default nightly

Installing the Cortex-M0 Compiler Tools

rustup target add thumbv6m-none-eabi

Check the environment

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

Check Rust version

➜  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。

Mac/Linux

curl --proto '=https' --tlsv1.2 -LsSf \
    https://github.com/probe-rs/probe-rs/releases/latest/download/probe-rs-tools-installer.sh \
    | sh

Windows

cargo install cargo-binstall
cargo binstall probe-rs-tools

Other tools (not required for now)

cargo tools

cargo install cargo-get
brew install llvm

Serial port burning tool

There are two tools here, you can choose a tool written in Python or a serial port tool written in Rust.

  1. 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
  1. 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

Jlink connection operation and view log

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

  1. cargo run
cargo r  --example embassy_uart
  1. probe-rs run
probe-rs run --chip PY32F030x8 target/thumbv6m-none-eabi/debug/examples/embassy_uart

Supported peripheral drivers

  • gpio
  • exit
  • timer
  • i2c
  • clock
  • embassy
  • dma
  • usart
  • adc
  • flash
  • spi
  • crc
  • rtc
  • iwatchdog
  • Flash

TODO

  • LPTimer
  • Clock -> 48M
  • spi

Examples

Run

# run
cargo run --example blinky
# build
cargo build --release --example blinky

Example list

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

Py32_Rust_Dev 1.2

Wechat blog

公众号:Rust嵌入式 Rust嵌入式

How to buy

We currently provide Taobao links, you can choose any one to buy

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages