Crate gd32f1x0_hal
source ·Expand description
§HAL for the GD32F1x0 family of microcontrollers
This is an implementation of the embedded-hal
traits for the GD32F1x0 family of
microcontrollers.
§Usage
§Building an application (binary crate)
A detailed usage guide can be found in the README
§Variants
This crate supports multiple microcontrollers in the GD32F1x0 family. Which specific
microcontroller you want to build for has to be specified with a feature, for example
gd32f130x8
.
If no microcontroller is specified, the crate will not compile.
The currently supported variants are
gd32f130x4
(e.g. GD32F130F4, GD32F130G4, …)gd32f130x6
(e.g. GD32F130F6, GD32F130G6, …)gd32f130x8
(e.g. GD32F130F8, GD32F130G8, …)gd32f150x4
(e.g. GD32F150G4, GD32F150K4, …)gd32f150x6
(e.g. GD32F150G6, GD32F150K6, …)gd32f150x8
(e.g. GD32F150G8, GD32F150K8, …)gd32f170x4
(e.g. GD32F170T4, GD32F170C4, …)gd32f170x6
(e.g. GD32F170T6, GD32F170C6, …)gd32f170x8
(e.g. GD32F170T8, GD32F170C8, …)gd32f190x4
(e.g. GD32F190T4, GD32F190C4, …)gd32f190x6
(e.g. GD32F190T6, GD32F190C6, …)gd32f190x8
(e.g. GD32F190T8, GD32F190C8, …)
§Commonly used setup
Almost all peripherals require references to some registers in RCU
. The following
code shows how to set up those registers
// Get access to the device specific peripherals from the peripheral access crate
let dp = pac::Peripherals::take().unwrap();
// Take ownership over the raw RCU and FMC devices and convert tem into the corresponding HAL
// structs.
let mut rcu = dp.rcu.constrain();
let mut flash = p.fmc.constrain();
// Freeze the configuration of all the clocks in the system and store the frozen frequencies in
// `clocks`
let clocks = rcu.cfgr.freeze(&mut flash.ws);
§Usage examples
See the examples folder.
Most of the examples require the following additional dependencies
[dependencies]
embedded-hal = "1.0.0"
nb = "1.1.0"
cortex-m = { version = "0.7.7", features = ["critical-section-single-core"] }
cortex-m-rt = "0.7.3"
# Panic behaviour, see https://crates.io/keywords/panic-impl for alternatives
panic-halt = "0.2.0"
Modules§
- API for the Analog to Digital converter
- CRC
- Delays
- Direct Memory Access
- Flash memory
- Inter-Integrated Circuit (I2C) bus
- Peripheral access API for GD32F130 microcontrollers (generated using svd2rust v0.32.0 ( ))
- Reset & Clock Unit
- Serial Communication (USART)
- Time units
- Watchdog peripherals