Crate gd32vf103_hal[−][src]
Hardware abstract layer (HAL) for the GD32VF103 microcontroller chip.
This is an implementation of embedded-hal
traits for the GD32VF103, MCU with
one RISC-V’s RV32IMAC core as well as up to 128 KiB of Flash and 32 KiB of SRAM,
produced by GigaDevice Semiconductor Inc.
Usage
Add this crate to your dependencies:
[dependencies] gd32vf103-hal = "0.0"
Example
#![no_std] #![no_main] // choose a panic handler crate extern crate panic_halt; // include this library use gd32vf103_hal::{pac, prelude::*}; // use the `riscv_rt` runtime to define entry #[riscv_rt::entry] fn main() -> ! { // Get ownership of device peripherals let dp = pac::Peripherals::take().unwrap(); // Constrain RCU register for further use let mut rcu = dp.RCU.constrain(); // Split GPIOA into separate pins. // You need a mutable reference of APB2 struct to initialize GPIOA, // so we offer `&mut rcu.apb2` as a parameter here. let mut gpioa = dp.GPIOA.split(&mut rcu.apb2); // Change the state of `pa1` into push-pull output with default speed. let mut pa1 = gpioa.pa1.into_push_pull_output(&mut gpioa.ctl0); // Use API offered by `embedded-hal` to set `pa1` low, // An LED light with cathode connected to PA1 should be lit now. pa1.set_low().unwrap(); // We just end this program with infinite loop. // A `wfi` instruction should be also acceptable here. loop {} }
Re-exports
pub use gd32vf103_pac as pac; |
Modules
adc | (TODO) Analog-to-Digital Converter |
afio | (TODO) Alternate Function I/O |
backup | (TODO) Backup register domain |
crc | CRC calculation unit |
ctimer | (TODO) Core Timer |
debug | Debug features |
delay | Delays |
esig | Device electronic signature |
fmc | (TODO) Flash Memory Controller (FMC) |
gpio | General Purpose Input / Output |
prelude | Prelude |
rcu | Reset and Control Unit |
serial | (TODO) Serial Communication (USART) |
spi | Serial Peripheral Interface (SPI) bus |
timer | Timers |
unit | Measurement units |
wdog | (TODO) Watchdog Timer (WDGT) |