Arduino-Pedal-Effects/rust/arduino/src/main.rs

54 lines
1.2 KiB
Rust
Raw Normal View History

2022-07-18 16:23:07 +00:00
#![no_std]
#![no_main]
2022-07-19 21:05:19 +00:00
#![feature(abi_avr_interrupt)]
mod setup;
2022-07-18 16:23:07 +00:00
use arduino_hal::{delay_ms, pins, Peripherals};
use core::panic::PanicInfo;
2022-07-19 21:05:19 +00:00
use setup::Setup;
2022-07-18 16:23:07 +00:00
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
// disable interrupts - firmware has panicked so no ISRs should continue running
avr_device::interrupt::disable();
// get the peripherals so we can access serial and the LED.
//
// SAFETY: Because main() already has references to the peripherals this is an unsafe
// operation - but because no other code can run after the panic handler was called,
// we know it is okay.
let dp = unsafe { Peripherals::steal() };
let pins = pins!(dp);
let mut led = pins.d13.into_output();
loop {
led.toggle();
delay_ms(500);
}
}
#[arduino_hal::entry]
fn main() -> ! {
2022-07-21 11:13:19 +00:00
let mut setup = Setup::default();
2022-07-19 21:05:19 +00:00
loop {
fuzz(&setup);
2022-07-21 11:13:19 +00:00
if setup.led.is_set_high() {
setup.led.set_low();
} else {
setup.led.set_high();
}
delay_ms(250);
2022-07-19 21:05:19 +00:00
}
2022-07-18 16:23:07 +00:00
}
2022-07-19 21:05:19 +00:00
fn fuzz(setup: &Setup<'_>) {}
#[avr_device::interrupt(atmega328p)]
#[allow(non_snake_case)]
fn TIMER1_COMPA() {}