esp-hal/hil-test/tests/lcd_cam_i8080_async.rs
liebman 67bb6c54bb
Implement async for lcd_cam i8080 (#1834)
* implement async for lcd_cam i8080

* lcd_cam: implement InterruptConfigurable for blocking and improve async

* lcd_cam: use new async interrupt semantics from #1835

* lcd_cam: move interrupt handler binding into `new_async()`

* lcd_cam: Instance::is_listening_lcd_done not used

* i8080: no need for seperate `new_async()`

* i8080: don't use DmaTxFuture, just test for dma error after complete

* add HIL tests for LCD_CAM i8080 in blocking and async.

* lcd_cam_i8080: test channels configured for async as well since teh compiler can't prevent it for now

* fmt :-/

* lcd_cam fix comment

* changelog

* lcd_cam async: no need to enable interrupts until polled

* lcd_cam: i8080 update for ReadBuffer changes
2024-07-29 13:59:52 +00:00

129 lines
3.0 KiB
Rust

//! lcd_cam i8080 tests
//% CHIPS: esp32s3
#![no_std]
#![no_main]
use defmt_rtt as _;
use esp_backtrace as _;
use esp_hal::{
clock::{ClockControl, Clocks},
dma::{Dma, DmaDescriptor, DmaPriority},
dma_buffers,
gpio::dummy_pin::DummyPin,
lcd_cam::{
lcd::{
i8080,
i8080::{Command, TxEightBits, I8080},
},
LcdCam,
},
peripherals::Peripherals,
prelude::*,
system::SystemControl,
};
const DATA_SIZE: usize = 1024 * 10;
struct Context<'d> {
lcd_cam: LcdCam<'d, esp_hal::Async>,
clocks: Clocks<'d>,
dma: Dma<'d>,
tx_buffer: &'static [u8],
tx_descriptors: &'static mut [DmaDescriptor],
}
impl<'d> Context<'d> {
pub fn init() -> Self {
let peripherals = Peripherals::take();
let system = SystemControl::new(peripherals.SYSTEM);
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();
let dma = Dma::new(peripherals.DMA);
let lcd_cam = LcdCam::new_async(peripherals.LCD_CAM);
let (tx_buffer, tx_descriptors, _, _) = dma_buffers!(DATA_SIZE, 0);
Self {
lcd_cam,
clocks,
dma,
tx_buffer,
tx_descriptors,
}
}
}
#[cfg(test)]
#[embedded_test::tests(executor = esp_hal_embassy::Executor::new())]
mod tests {
use super::*;
#[init]
async fn init() -> Context<'static> {
Context::init()
}
#[test]
async fn test_i8080_8bit(ctx: Context<'static>) {
let channel = ctx.dma.channel0.configure(false, DmaPriority::Priority0);
let pins = TxEightBits::new(
DummyPin::new(),
DummyPin::new(),
DummyPin::new(),
DummyPin::new(),
DummyPin::new(),
DummyPin::new(),
DummyPin::new(),
DummyPin::new(),
);
let mut i8080 = I8080::new(
ctx.lcd_cam.lcd,
channel.tx,
ctx.tx_descriptors,
pins,
20.MHz(),
i8080::Config::default(),
&ctx.clocks,
);
i8080
.send_dma_async(Command::<u8>::None, 0, &ctx.tx_buffer)
.await
.unwrap();
}
#[test]
async fn test_i8080_8bit_async_channel(ctx: Context<'static>) {
let channel = ctx
.dma
.channel0
.configure_for_async(false, DmaPriority::Priority0);
let pins = TxEightBits::new(
DummyPin::new(),
DummyPin::new(),
DummyPin::new(),
DummyPin::new(),
DummyPin::new(),
DummyPin::new(),
DummyPin::new(),
DummyPin::new(),
);
let mut i8080 = I8080::new(
ctx.lcd_cam.lcd,
channel.tx,
ctx.tx_descriptors,
pins,
20.MHz(),
i8080::Config::default(),
&ctx.clocks,
);
i8080
.send_dma_async(Command::<u8>::None, 0, &ctx.tx_buffer)
.await
.unwrap();
}
}