fast blinky

This commit is contained in:
2024-06-11 20:24:24 +02:00
parent f41ebc64c3
commit b41f902a14
14 changed files with 135 additions and 53 deletions

View File

@ -2,7 +2,7 @@
#![no_main]
#![no_std]
use cortex_m_rt::{entry};
use cortex_m_rt::entry;
use panic_halt as _;
use va416xx_hal::pac;
@ -11,27 +11,24 @@ const LED_PG5: u32 = 1 << 5;
#[entry]
fn main() -> ! {
let dp = pac::Peripherals::take().unwrap();
// SAFETY: Peripherals are only stolen once here.
let dp = unsafe { pac::Peripherals::steal() };
// Enable all peripheral clocks
dp.SYSCONFIG
.peripheral_clk_enable
dp.sysconfig
.peripheral_clk_enable()
.modify(|_, w| unsafe { w.bits(0xffffffff) });
dp.PORTG.dir().modify(|_, w| unsafe { w.bits(LED_PG5) });
dp.PORTG.datamask().modify(|_, w| unsafe { w.bits(LED_PG5)});
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);
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);
}
loop {
dp.PORTG
.togout()
.write(|w| unsafe { w.bits(LED_PG5) });
cortex_m::asm::delay(25_000_000);
dp.portg.togout().write(|w| unsafe { w.bits(LED_PG5) });
cortex_m::asm::delay(2_000_000);
}
}