#![no_main] #![cfg_attr(target_os = "none", no_std)] use core::sync::atomic::{AtomicI32, Ordering}; const STACK_SIZE: usize = rt::stack::FP_MIN.next_power_of_two(); rt::timer_queue!(QUEUE, 4); rt::timer_task!(&QUEUE, STACK_SIZE, 0); static X: AtomicI32 = AtomicI32::new(0); rt::timer_periodic!(TIMER, &QUEUE, X.fetch_add(1, Ordering::Relaxed), 5); rt::timer_autostart!(TIMER); fn task0() { rt::task::sleep(18); TIMER.stop(); assert_eq!(X.load(Ordering::Relaxed), 3, "x has an unexpected value"); TIMER.change_period(3); TIMER.start(); rt::task::sleep(25); TIMER.stop(); assert_eq!(X.load(Ordering::Relaxed), 11, "x has an unexpected value"); rt::trap(); } rt::task!(task0, STACK_SIZE, 0);