mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-09-28 04:40:52 +00:00

* Rework hal initialization * Turn sw interrupt control into a virtual peripheral * Return a tuple instead of a named struct * Fix docs * Remove SystemClockControl * Move software interrupts under interrupt * Re-document what's left in system * Update time docs * Update sw int docs * Introduce Config * Fix tests * Remove redundant inits * Doc * Clean up examples&tests * Update tests * Add changelog entry * Start migration guide * Restore some convenience-imports * Remove Config from prelude
117 lines
2.7 KiB
Rust
117 lines
2.7 KiB
Rust
//! lcd_cam i8080 tests
|
|
|
|
//% CHIPS: esp32s3
|
|
//% FEATURES: generic-queue
|
|
|
|
#![no_std]
|
|
#![no_main]
|
|
|
|
use esp_hal::{
|
|
clock::Clocks,
|
|
dma::{Dma, DmaDescriptor, DmaPriority},
|
|
dma_buffers,
|
|
gpio::DummyPin,
|
|
lcd_cam::{
|
|
lcd::i8080::{Command, Config, TxEightBits, I8080},
|
|
LcdCam,
|
|
},
|
|
prelude::*,
|
|
};
|
|
use hil_test as _;
|
|
|
|
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],
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[embedded_test::tests(executor = esp_hal_embassy::Executor::new())]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[init]
|
|
async fn init() -> Context<'static> {
|
|
let (peripherals, clocks) = esp_hal::init(esp_hal::Config::default());
|
|
|
|
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);
|
|
|
|
Context {
|
|
lcd_cam,
|
|
clocks,
|
|
dma,
|
|
tx_buffer,
|
|
tx_descriptors,
|
|
}
|
|
}
|
|
|
|
#[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(),
|
|
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(),
|
|
Config::default(),
|
|
&ctx.clocks,
|
|
);
|
|
|
|
i8080
|
|
.send_dma_async(Command::<u8>::None, 0, &ctx.tx_buffer)
|
|
.await
|
|
.unwrap();
|
|
}
|
|
}
|