esp-hal/hil-test/tests/lcd_cam_i8080_async.rs
Dániel Buga 38dde2ebbd
[DMA 1/N] Add mode to DMA channel drivers (#2519)
* Add mode to DMA channel drivers

* Swap dma Channel CH and DM

* Fix copy-paste mistake
2024-11-14 08:03:05 +00:00

74 lines
1.7 KiB
Rust

//! lcd_cam i8080 tests
//% CHIPS: esp32s3
//% FEATURES: generic-queue
#![no_std]
#![no_main]
use esp_hal::{
dma::{Dma, DmaPriority, DmaTxBuf},
dma_buffers,
gpio::NoPin,
lcd_cam::{
lcd::i8080::{Command, Config, TxEightBits, I8080},
LcdCam,
},
prelude::*,
Async,
};
use hil_test as _;
const DATA_SIZE: usize = 1024 * 10;
struct Context<'d> {
lcd_cam: LcdCam<'d, Async>,
dma: Dma<'d>,
dma_buf: DmaTxBuf,
}
#[cfg(test)]
#[embedded_test::tests(executor = esp_hal_embassy::Executor::new())]
mod tests {
use super::*;
#[init]
async fn init() -> Context<'static> {
let peripherals = esp_hal::init(esp_hal::Config::default());
let dma = Dma::new(peripherals.DMA);
let lcd_cam = LcdCam::new(peripherals.LCD_CAM).into_async();
let (_, _, tx_buffer, tx_descriptors) = dma_buffers!(0, DATA_SIZE);
let dma_buf = DmaTxBuf::new(tx_descriptors, tx_buffer).unwrap();
Context {
lcd_cam,
dma,
dma_buf,
}
}
#[test]
async fn test_i8080_8bit(ctx: Context<'static>) {
let channel = ctx.dma.channel0.configure(false, DmaPriority::Priority0);
let pins = TxEightBits::new(NoPin, NoPin, NoPin, NoPin, NoPin, NoPin, NoPin, NoPin);
let i8080 = I8080::new(
ctx.lcd_cam.lcd,
channel.tx,
pins,
20.MHz(),
Config::default(),
);
let mut transfer = i8080.send(Command::<u8>::None, 0, ctx.dma_buf).unwrap();
transfer.wait_for_done().await;
// This should not block forever and should immediately return.
transfer.wait_for_done().await;
transfer.wait().0.unwrap();
}
}