Crate gd32f1x0_hal[−][src]
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, …)
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 = "0.2.3"
nb = "0.1.2"
cortex-m = "0.6.2"
cortex-m-rt = "0.6.11"
# Panic behaviour, see https://crates.io/keywords/panic-impl for alternatives
panic-halt = "0.2.0"
Modules
adc | API for the Analog to Digital converter |
crc | CRC |
delay | Delays |
dma | Direct Memory Access |
flash | Flash memory |
gpio | |
pac | |
prelude | |
pwm | |
rcu | Reset & Clock Unit |
serial | Serial Communication (USART) |
time | Time units |
timer | |
watchdog | Watchdog peripherals |