fw-rust: Create a SPI interface for the display

In order to, later on, send data to the display create a SPI
interface.
This commit is contained in:
finga 2022-03-04 13:11:45 +01:00
parent aa59bc302d
commit 643e5f1af4

View file

@ -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() };