//! examples/late.rs #![deny(unsafe_code)] // something something about: // // error: use of deprecated item // 'cortex_m::peripheral::nvic::::enable': // Use `NVIC::unmask` // // #![deny(warnings)] #![no_main] #![no_std] use cortex_m_semihosting::hprintln; use hal::raw::Interrupt; use heapless::{ consts::*, i, spsc::{Consumer, Producer, Queue}, }; use lpc55s6x_hal as hal; use panic_semihosting as _; #[rtfm::app(device = hal::raw)] const APP: () = { // Late resources struct Resources { p: Producer<'static, u32, U4>, c: Consumer<'static, u32, U4>, } #[init] fn init(_: init::Context) -> init::LateResources { static mut Q: Queue = Queue(i::Queue::new()); let (p, c) = Q.split(); // Initialization of late resources init::LateResources { p, c } } #[idle(resources = [c])] fn idle(c: idle::Context) -> ! { loop { if let Some(byte) = c.resources.c.dequeue() { hprintln!("received message: {}", byte).unwrap(); // cortex_m::asm::wfi(); } else { rtfm::pend(Interrupt::ADC0); } } } #[task(binds = ADC0, resources = [p])] fn adc0(c: adc0::Context) { c.resources.p.enqueue(42).unwrap(); } };