#![no_std] #![no_main] #![feature(abi_avr_interrupt)] #![feature(macro_metavar_expr)] use atmega_hal::{entry, Peripherals}; use avr_device::{asm::sleep, interrupt}; use avr_hal_generic::avr_device; use core::sync::atomic::{compiler_fence, Ordering}; mod animator; mod canvas; mod devices; mod hilton; mod lcd; mod panic; mod rng; use self::canvas::Draw; #[entry] fn main() -> ! { let dp = Peripherals::take().unwrap(); devices::init(dp); // SAFETY: Not inside a critical section. The fence ensures the compiler won't // reorder any setup code after this operation, which means any non-atomic // operations have been completed at this point. unsafe { compiler_fence(Ordering::SeqCst); interrupt::enable(); } loop { sleep(); } } #[interrupt(atmega328p)] fn TIMER1_COMPA() { interrupt::free(|token| { let mut devices = devices::get(token); let mut state = hilton::state::borrow_mut(token); state.update(); let state = &*state; devices.lcd.clear(); hilton::animation::next_frame(state, token).draw(&mut devices.lcd); devices.lcd.display_frame(); }); }