Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce RGB/DPI driver #2415

Merged
merged 8 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
non_exhaustive
  • Loading branch information
Dominic Fischer committed Nov 18, 2024
commit f54530664213170d80a7bfb1cdf834b9fe12bfd8
53 changes: 26 additions & 27 deletions esp-hal/src/lcd_cam/lcd/dpi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,35 +38,33 @@
//!
//! let lcd_cam = LcdCam::new(peripherals.LCD_CAM);
//!
//! let config = dpi::Config {
//! clock_mode: ClockMode {
//! polarity: Polarity::IdleHigh,
//! phase: Phase::ShiftLow,
//! },
//! format: Format {
//! enable_2byte_mode: false,
//! ..Default::default()
//! },
//! // Send a 50x50 video
//! timing: FrameTiming {
//! horizontal_total_width: 65,
//! hsync_width: 5,
//! horizontal_blank_front_porch: 10,
//! horizontal_active_width: 50,
//! let mut config = dpi::Config::default();
//! config.clock_mode = ClockMode {
//! polarity: Polarity::IdleLow,
//! phase: Phase::ShiftLow,
//! };
//! config.format = Format {
//! enable_2byte_mode: true,
//! ..Default::default()
//! };
//! config.timing = FrameTiming {
//! horizontal_active_width: 480,
//! horizontal_total_width: 520,
//! horizontal_blank_front_porch: 10,
//!
//! vertical_total_height: 65,
//! vsync_width: 5,
//! vertical_blank_front_porch: 10,
//! vertical_active_height: 50,
//! vertical_active_height: 480,
//! vertical_total_height: 510,
//! vertical_blank_front_porch: 10,
//!
//! hsync_position: 0,
//! },
//! vsync_idle_level: Level::High,
//! hsync_idle_level: Level::High,
//! de_idle_level: Level::Low,
//! disable_black_region: false,
//! ..Default::default()
//! hsync_width: 10,
//! vsync_width: 10,
//!
//! hsync_position: 0,
//! };
//! config.vsync_idle_level = Level::High;
//! config.hsync_idle_level = Level::High;
//! config.de_idle_level = Level::Low;
//! config.disable_black_region = false;
//!
//! let mut dpi = Dpi::new(lcd_cam.lcd, channel.tx, 1.MHz(), config)
//! .with_vsync(peripherals.GPIO3)
Expand Down Expand Up @@ -670,9 +668,10 @@ impl<'d, BUF: DmaTxBuffer> Drop for DpiTransfer<'d, BUF> {
}
}

/// Configuration settings for the RGB/DPI interface.
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
/// Configuration settings for the RGB/DPI interface.
pub struct Config {
Dominaezzz marked this conversation as resolved.
Show resolved Hide resolved
/// Specifies the clock mode, including polarity and phase settings.
pub clock_mode: ClockMode,
Expand Down
48 changes: 23 additions & 25 deletions examples/src/bin/lcd_dpi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,35 +138,33 @@ fn main() -> ! {

let mut dma_buf = dma_loop_buffer!(2 * 16);

let config = Config {
clock_mode: ClockMode {
polarity: Polarity::IdleLow,
phase: Phase::ShiftLow,
},
format: Format {
enable_2byte_mode: true,
..Default::default()
},
timing: FrameTiming {
horizontal_active_width: 480,
horizontal_total_width: 520,
horizontal_blank_front_porch: 10,
let mut config = Config::default();
config.clock_mode = ClockMode {
polarity: Polarity::IdleLow,
phase: Phase::ShiftLow,
};
config.format = Format {
enable_2byte_mode: true,
..Default::default()
};
config.timing = FrameTiming {
horizontal_active_width: 480,
horizontal_total_width: 520,
horizontal_blank_front_porch: 10,

vertical_active_height: 480,
vertical_total_height: 510,
vertical_blank_front_porch: 10,
vertical_active_height: 480,
vertical_total_height: 510,
vertical_blank_front_porch: 10,

hsync_width: 10,
vsync_width: 10,
hsync_width: 10,
vsync_width: 10,

hsync_position: 0,
},
vsync_idle_level: Level::High,
hsync_idle_level: Level::High,
de_idle_level: Level::Low,
disable_black_region: false,
..Default::default()
hsync_position: 0,
};
config.vsync_idle_level = Level::High;
config.hsync_idle_level = Level::High;
config.de_idle_level = Level::Low;
config.disable_black_region = false;

let mut dpi = Dpi::new(lcd_cam.lcd, channel.tx, 16.MHz(), config)
.with_vsync(vsync_pin)
Expand Down
53 changes: 26 additions & 27 deletions hil-test/tests/lcd_cam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,35 +74,34 @@ mod tests {
let (d6_in, d6_out) = peripherals.GPIO17.split();
let (d7_in, d7_out) = peripherals.GPIO16.split();

let config = dpi::Config {
clock_mode: ClockMode {
polarity: Polarity::IdleHigh,
phase: Phase::ShiftLow,
},
format: Format {
enable_2byte_mode: false,
..Default::default()
},
// Send a 50x50 video
timing: FrameTiming {
horizontal_total_width: 65,
hsync_width: 5,
horizontal_blank_front_porch: 10,
horizontal_active_width: 50,

vertical_total_height: 65,
vsync_width: 5,
vertical_blank_front_porch: 10,
vertical_active_height: 50,

hsync_position: 0,
},
vsync_idle_level: Level::High,
hsync_idle_level: Level::High,
de_idle_level: Level::Low,
disable_black_region: false,
let mut config = dpi::Config::default();
config.clock_mode = ClockMode {
polarity: Polarity::IdleHigh,
phase: Phase::ShiftLow,
};
config.format = Format {
enable_2byte_mode: false,
..Default::default()
};
// Send a 50x50 video
config.timing = FrameTiming {
horizontal_total_width: 65,
hsync_width: 5,
horizontal_blank_front_porch: 10,
horizontal_active_width: 50,

vertical_total_height: 65,
vsync_width: 5,
vertical_blank_front_porch: 10,
vertical_active_height: 50,

hsync_position: 0,
};
config.vsync_idle_level = Level::High;
config.hsync_idle_level = Level::High;
config.de_idle_level = Level::Low;
config.disable_black_region = false;

let dpi = Dpi::new(lcd_cam.lcd, channel.tx, 500u32.kHz(), config)
.with_vsync(vsync_out)
.with_hsync(hsync_out)
Expand Down