//! Simple blinky example #![no_main] #![no_std] use cortex_m_rt::entry; use panic_halt as _; use va416xx_hal::{ pac, gpio::PinsG }; use embedded_hal::digital::v2::{ToggleableOutputPin, OutputPin}; // Mask for the LED const LED_PG5: u32 = 1 << 5; #[allow(dead_code)] enum LibType { Pac, Hal, Bsp, } #[entry] fn main() -> ! { let mut dp = pac::Peripherals::take().unwrap(); let lib_type = LibType::Hal; match lib_type { LibType::Pac => { // Enable all peripheral clocks dp.SYSCONFIG .peripheral_clk_enable .modify(|_, w| w.portg().set_bit()); dp.PORTG.dir().modify(|_, w| unsafe { w.bits(LED_PG5) }); dp.PORTG .datamask() .modify(|_, w| unsafe { w.bits(LED_PG5) }); for _ in 0..10 { dp.PORTG.clrout().write(|w| unsafe { w.bits(LED_PG5) }); cortex_m::asm::delay(5_000_000); dp.PORTG.setout().write(|w| unsafe { w.bits(LED_PG5) }); cortex_m::asm::delay(5_000_000); } loop { dp.PORTG.togout().write(|w| unsafe { w.bits(LED_PG5) }); cortex_m::asm::delay(25_000_000); } } LibType::Hal => { let portg = PinsG::new(&mut dp.SYSCONFIG, Some(dp.IOCONFIG), dp.PORTG); // Enable all peripheral clocks let mut led = portg.pg5.into_push_pull_output(); for _ in 0..10 { led.set_low().ok(); cortex_m::asm::delay(5_000_000); led.set_high().ok(); }; loop { led.toggle().ok(); cortex_m::asm::delay(25_000_000); } } LibType::Bsp => loop {}, } }