diff --git a/firmware/rust/src/main.rs b/firmware/rust/src/main.rs index 88c8d5f..bf1f68b 100644 --- a/firmware/rust/src/main.rs +++ b/firmware/rust/src/main.rs @@ -1,8 +1,13 @@ #![no_std] #![no_main] -use atmega_hal::{pins, Peripherals}; +use atmega_hal::{ + pins, + spi::{DataOrder, SerialClockRate, Settings, Spi}, + Peripherals, +}; use avr_device::interrupt; +use embedded_hal::spi::{Mode, Phase, Polarity}; use panic_halt as _; #[atmega_hal::entry] @@ -31,6 +36,23 @@ fn main() -> ! { tc0.ocr0b.write(|w| unsafe { w.bits(0) }); pins.pd5.into_output(); + // Init SPI + let (_, _) = Spi::new( + dp.SPI, + pins.pb5.into_output(), + pins.pb3.into_output(), + pins.pb4.into_pull_up_input(), + pins.pb2.into_output(), + Settings { + data_order: DataOrder::MostSignificantFirst, + clock: SerialClockRate::OscfOver2, + mode: Mode { + polarity: Polarity::IdleLow, + phase: Phase::CaptureOnFirstTransition, + }, + }, + ); + // Enable interrupts unsafe { interrupt::enable() };