#![no_main] #![no_std] extern crate panic_semihosting; // use cortex_m::iprintln; use cortex_m_rt::entry; // use cortex_m_semihosting::{dbg, hprintln}; use hal::prelude::*; use lpc55s6x_hal as hal; #[entry] fn main() -> ! { let hal = hal::new(); let anactrl = hal.anactrl; let pmc = hal.pmc; let mut syscon = hal.syscon; // dbg!(syscon.get_num_wait_states()); let mut gpio = hal.gpio.enabled(&mut syscon); let mut iocon = hal.iocon.enabled(&mut syscon); // let mut cp = hal::raw::CorePeripherals::take().unwrap(); // let stim = &mut cp.ITM.stim[0]; // dbg!(unsafe { &(*hal::raw::TPIU::ptr()) }.sppr.read() ); // unsafe { &(*hal::raw::TPIU::ptr()) .sppr.write(2) }; // dbg!(unsafe { &(*hal::raw::TPIU::ptr()) }.sppr.read() ); // UM kind of says it's not enabled, but it actually is // let iocon = iocon.enabled(&mut syscon); // R = pio1_6 // G = pio1_7 // B = pio1_4 // // on = low, off = high let pins = hal::Pins::take().unwrap(); let mut red = pins .pio1_6 .into_gpio_pin(&mut iocon, &mut gpio) .into_output(hal::drivers::pins::Level::High); // start turned off let clocks = hal::ClockRequirements::default() .configure(&mut anactrl, &mut pmc, &mut syscon) .unwrap(); let token = clocks.support_utick_token().unwrap(); let mut utick = hal.utick.enabled(&mut syscon, &token); let delay = hal::time::Ticks { value: 500_000, // clock: &clock, }; // 500 ms = 0.5 s let mut sleep = hal::time::Busy::wrap(&mut utick); loop { sleep.sleep(delay); red.set_low().unwrap(); // iprintln!(stim, "led on"); sleep.sleep(delay); red.set_high().unwrap(); // iprintln!(stim, "led off"); } }