made spi interface async
This commit is contained in:
@@ -2,7 +2,7 @@ use embassy_rp::{
|
|||||||
Peri,
|
Peri,
|
||||||
gpio::{Level, Output},
|
gpio::{Level, Output},
|
||||||
peripherals::SPI0,
|
peripherals::SPI0,
|
||||||
spi::{self, Blocking, Spi},
|
spi::{self, Async, Spi},
|
||||||
};
|
};
|
||||||
use embassy_time::Timer;
|
use embassy_time::Timer;
|
||||||
use embedded_hal_bus::spi::{ExclusiveDevice, NoDelay};
|
use embedded_hal_bus::spi::{ExclusiveDevice, NoDelay};
|
||||||
@@ -17,7 +17,7 @@ use static_cell::StaticCell;
|
|||||||
pub type SPIDisplay = Display<
|
pub type SPIDisplay = Display<
|
||||||
SpiInterface<
|
SpiInterface<
|
||||||
'static,
|
'static,
|
||||||
ExclusiveDevice<Spi<'static, SPI0, Blocking>, Output<'static>, NoDelay>,
|
ExclusiveDevice<Spi<'static, SPI0, Async>, Output<'static>, NoDelay>,
|
||||||
Output<'static>,
|
Output<'static>,
|
||||||
>,
|
>,
|
||||||
ST7789,
|
ST7789,
|
||||||
@@ -26,6 +26,7 @@ pub type SPIDisplay = Display<
|
|||||||
|
|
||||||
pub async fn init_display(
|
pub async fn init_display(
|
||||||
inner: Peri<'static, embassy_rp::peripherals::SPI0>,
|
inner: Peri<'static, embassy_rp::peripherals::SPI0>,
|
||||||
|
dma: Peri<'static, embassy_rp::peripherals::DMA_CH0>,
|
||||||
clk: Peri<'static, embassy_rp::peripherals::PIN_6>,
|
clk: Peri<'static, embassy_rp::peripherals::PIN_6>,
|
||||||
mosi: Peri<'static, embassy_rp::peripherals::PIN_7>,
|
mosi: Peri<'static, embassy_rp::peripherals::PIN_7>,
|
||||||
cs: Peri<'static, embassy_rp::peripherals::PIN_5>,
|
cs: Peri<'static, embassy_rp::peripherals::PIN_5>,
|
||||||
@@ -35,7 +36,7 @@ pub async fn init_display(
|
|||||||
let mut spi_cfg = spi::Config::default();
|
let mut spi_cfg = spi::Config::default();
|
||||||
spi_cfg.frequency = 62_500_000;
|
spi_cfg.frequency = 62_500_000;
|
||||||
|
|
||||||
let spi = Spi::new_blocking_txonly(inner, clk, mosi, spi_cfg);
|
let spi = Spi::new_txonly(inner, clk, mosi, dma, spi_cfg);
|
||||||
|
|
||||||
let cs_display = Output::new(cs, Level::Low);
|
let cs_display = Output::new(cs, Level::Low);
|
||||||
let dc_display = Output::new(dc, Level::Low);
|
let dc_display = Output::new(dc, Level::Low);
|
||||||
|
|||||||
@@ -32,8 +32,10 @@ async fn main(spawner: Spawner) {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let Ok(display) =
|
let Ok(display) = init::spi_display::init_display(
|
||||||
init::spi_display::init_display(p.SPI0, p.PIN_6, p.PIN_7, p.PIN_5, p.PIN_9, p.PIN_10).await
|
p.SPI0, p.DMA_CH0, p.PIN_6, p.PIN_7, p.PIN_5, p.PIN_9, p.PIN_10,
|
||||||
|
)
|
||||||
|
.await
|
||||||
else {
|
else {
|
||||||
error!("Failed to init display");
|
error!("Failed to init display");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user