2024-06-11 13:48:42 +02:00
|
|
|
//! Simple blinky example
|
|
|
|
#![no_main]
|
|
|
|
#![no_std]
|
|
|
|
|
2024-06-11 20:24:24 +02:00
|
|
|
use cortex_m_rt::entry;
|
2024-06-11 13:48:42 +02:00
|
|
|
use panic_halt as _;
|
|
|
|
use va416xx_hal::pac;
|
|
|
|
|
|
|
|
// Mask for the LED
|
|
|
|
const LED_PG5: u32 = 1 << 5;
|
|
|
|
|
|
|
|
#[entry]
|
|
|
|
fn main() -> ! {
|
2024-06-11 20:24:24 +02:00
|
|
|
// SAFETY: Peripherals are only stolen once here.
|
|
|
|
let dp = unsafe { pac::Peripherals::steal() };
|
2024-06-11 13:48:42 +02:00
|
|
|
// Enable all peripheral clocks
|
2024-06-11 20:24:24 +02:00
|
|
|
dp.sysconfig
|
|
|
|
.peripheral_clk_enable()
|
2024-06-11 13:48:42 +02:00
|
|
|
.modify(|_, w| unsafe { w.bits(0xffffffff) });
|
2024-06-11 20:24:24 +02:00
|
|
|
dp.portg.dir().modify(|_, w| unsafe { w.bits(LED_PG5) });
|
|
|
|
dp.portg
|
|
|
|
.datamask()
|
|
|
|
.modify(|_, w| unsafe { w.bits(LED_PG5) });
|
2024-06-11 13:48:42 +02:00
|
|
|
for _ in 0..10 {
|
2024-06-11 20:24:24 +02:00
|
|
|
dp.portg.clrout().write(|w| unsafe { w.bits(LED_PG5) });
|
|
|
|
cortex_m::asm::delay(2_000_000);
|
|
|
|
dp.portg.setout().write(|w| unsafe { w.bits(LED_PG5) });
|
|
|
|
cortex_m::asm::delay(2_000_000);
|
2024-06-11 13:48:42 +02:00
|
|
|
}
|
|
|
|
loop {
|
2024-06-11 20:24:24 +02:00
|
|
|
dp.portg.togout().write(|w| unsafe { w.bits(LED_PG5) });
|
|
|
|
cortex_m::asm::delay(2_000_000);
|
2024-06-11 13:48:42 +02:00
|
|
|
}
|
|
|
|
}
|