[−][src]Crate gd32vf103_hal
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] extern crate panic_halt; use riscv_rt::entry; use gd32vf103_hal as hal; use hal::prelude::*; use hal::pac as pac; #[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
afio | (TODO) Alternate Function I/O |
backup | (TODO) Backup register domain |
crc | (TODO) CRC calculation unit |
ctimer | (TODO) Core Timer |
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 |
time | Time units |
timer | Timers |
wdog | (TODO) Watchdog Timer (WDGT) |