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:
parent
aa59bc302d
commit
643e5f1af4
1 changed files with 23 additions and 1 deletions
|
@ -1,8 +1,13 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
use atmega_hal::{pins, Peripherals};
|
use atmega_hal::{
|
||||||
|
pins,
|
||||||
|
spi::{DataOrder, SerialClockRate, Settings, Spi},
|
||||||
|
Peripherals,
|
||||||
|
};
|
||||||
use avr_device::interrupt;
|
use avr_device::interrupt;
|
||||||
|
use embedded_hal::spi::{Mode, Phase, Polarity};
|
||||||
use panic_halt as _;
|
use panic_halt as _;
|
||||||
|
|
||||||
#[atmega_hal::entry]
|
#[atmega_hal::entry]
|
||||||
|
@ -31,6 +36,23 @@ fn main() -> ! {
|
||||||
tc0.ocr0b.write(|w| unsafe { w.bits(0) });
|
tc0.ocr0b.write(|w| unsafe { w.bits(0) });
|
||||||
pins.pd5.into_output();
|
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
|
// Enable interrupts
|
||||||
unsafe { interrupt::enable() };
|
unsafe { interrupt::enable() };
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue