ngl this do be ai, I remove a few things it works

This commit is contained in:
benstrb 2026-04-12 20:20:41 +02:00
parent 2854adeb13
commit a60dcf5fd9
4 changed files with 136 additions and 51 deletions

11
Cargo.lock generated
View file

@ -259,6 +259,16 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6673768db2d862beb9b39a78fdcb1a69439615d5794a1be50caa9bc92c81967" checksum = "c6673768db2d862beb9b39a78fdcb1a69439615d5794a1be50caa9bc92c81967"
[[package]]
name = "otm8009a"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e56059a2e83de4409e5fa0854d3ae891b0f949af86c74ccf76a8bffe4ce6dc6d"
dependencies = [
"embedded-display-controller",
"embedded-hal 0.2.7",
]
[[package]] [[package]]
name = "panic-halt" name = "panic-halt"
version = "1.0.0" version = "1.0.0"
@ -391,6 +401,7 @@ dependencies = [
"defmt", "defmt",
"defmt-rtt", "defmt-rtt",
"embedded-hal 1.0.0", "embedded-hal 1.0.0",
"otm8009a",
"panic-halt", "panic-halt",
"panic-probe", "panic-probe",
"stm32f4xx-hal", "stm32f4xx-hal",

View file

@ -11,6 +11,7 @@ defmt-rtt = "1.1.0"
defmt = "1.0.1" defmt = "1.0.1"
panic-probe = {version = "1.0.0", features = ["print-defmt"]} panic-probe = {version = "1.0.0", features = ["print-defmt"]}
panic-halt = "1.0.0" panic-halt = "1.0.0"
otm8009a = "0.1.0"
[dependencies.stm32f4xx-hal] [dependencies.stm32f4xx-hal]
version = "0.23.0" version = "0.23.0"

View file

@ -1,12 +1,18 @@
/* Memory layout of the STM32F469NI */ /* Memory layout of the STM32F469NI */
MEMORY MEMORY
{ {
FLASH : ORIGIN = 0x08000000, LENGTH = 2048K FLASH : ORIGIN = 0x08000000, LENGTH = 2M
RAM : ORIGIN = 0x20000000, LENGTH = 256K RAM : ORIGIN = 0x20000000, LENGTH = 384K
/* Core Coupled Memory (CCM) SRAM: 128KB at 0x10000000 */ CCMRAM : ORIGIN = 0x10000000, LENGTH = 64K
CCMRAM : ORIGIN = 0x10000000, LENGTH = 128K SDRAM : ORIGIN = 0xC0000000, LENGTH = 16M
}
SECTIONS
{
.sdram (NOLOAD) :
{
*(.sdram .sdram.*);
} > SDRAM
} }
/* This is where the call stack will be allocated. */
/* The stack is of the full size of the RAM, minus the size of the .data section */
_stack_start = ORIGIN(RAM) + LENGTH(RAM); _stack_start = ORIGIN(RAM) + LENGTH(RAM);

View file

@ -1,65 +1,132 @@
#![no_std]
#![no_main] #![no_main]
#![no_std]
use crate::hal::{
dsi::{
ColorCoding, DsiChannel, DsiCmdModeTransmissionKind, DsiConfig, DsiHost, DsiInterrupts,
DsiMode, DsiPhyTimers, DsiPllConfig, DsiVideoMode, LaneCount,
},
ltdc::{DisplayConfig, DisplayController, PixelFormat},
pac::{CorePeripherals, Peripherals},
prelude::*,
};
use cortex_m_rt::entry; use cortex_m_rt::entry;
use defmt_rtt as _; use defmt_rtt as _;
use hal::prelude::*; use otm8009a::{Otm8009A, Otm8009AConfig};
use panic_probe as _; use panic_probe as _;
use stm32f4xx_hal::{self as hal, ltdc::DisplayController}; use stm32f4xx_hal::{self as hal, ltdc, rcc::Config};
defmt::timestamp!("{=u32}", 0u32); defmt::timestamp!("{=u32}", 0u32);
#[entry] const WIDTH: usize = 480;
fn main() -> ! { const HEIGHT: usize = 800;
let peripherals = hal::pac::Peripherals::take().unwrap();
let mut rcc = peripherals.RCC.constrain();
let ltdc = peripherals.LTDC;
let dma2d = peripherals.DMA2D;
let display_config = hal::ltdc::DisplayConfig { const DISPLAY_CONFIGURATION: DisplayConfig = DisplayConfig {
active_width: 480, active_width: WIDTH as _,
active_height: 800, active_height: HEIGHT as _,
h_back_porch: 8, h_back_porch: 34,
h_front_porch: 8, h_front_porch: 34,
v_back_porch: 1, v_back_porch: 15,
v_front_porch: 1, v_front_porch: 16,
h_sync: 15, h_sync: 2,
v_sync: 60, v_sync: 1,
frame_rate: 5, frame_rate: 60,
h_sync_pol: false, h_sync_pol: true,
v_sync_pol: false, v_sync_pol: true,
no_data_enable_pol: false, no_data_enable_pol: false,
pixel_clock_pol: false, pixel_clock_pol: true,
}; };
let mut display: DisplayController<u8> = hal::ltdc::DisplayController::new( #[entry]
ltdc, fn main() -> ! {
dma2d, let peripherals = Peripherals::take().unwrap();
None, let core_peripherals = CorePeripherals::take().unwrap();
hal::ltdc::PixelFormat::AL88,
display_config, let hse_freq = 8.MHz();
let mut rcc = peripherals
.RCC
.freeze(Config::hse(hse_freq).pclk2(32.MHz()).sysclk(180.MHz()));
let mut delay = core_peripherals.SYST.delay(&rcc.clocks);
let gpioh = peripherals.GPIOH.split(&mut rcc);
let mut lcd_reset = gpioh.ph7.into_push_pull_output();
lcd_reset.set_low();
delay.delay_ms(20u32);
lcd_reset.set_high();
delay.delay_ms(10u32);
#[unsafe(link_section = ".sdram")]
static mut BUFF: [u32; 480 * 800] = [0; 480 * 800];
let mut display = DisplayController::<u32>::new(
peripherals.LTDC,
peripherals.DMA2D,
None, None,
PixelFormat::ARGB8888,
DISPLAY_CONFIGURATION,
Some(hse_freq),
); );
display.draw_pixel(hal::ltdc::Layer::L1, 50, 50, 1); display.enable_layer(ltdc::Layer::L1);
display.config_layer(
ltdc::Layer::L1,
unsafe { &mut BUFF[..] },
PixelFormat::ARGB8888,
);
let gpiog = peripherals.GPIOG.split(&mut rcc); let dsi_pll_config = unsafe { DsiPllConfig::manual(125, 2, 0, 4) };
let gpiod = peripherals.GPIOD.split(&mut rcc); let dsi_config = DsiConfig {
mode: DsiMode::Video {
mode: DsiVideoMode::Burst,
},
lane_count: LaneCount::DoubleLane,
channel: DsiChannel::Ch0,
hse_freq,
ltdc_freq: 27_429.kHz(),
interrupts: DsiInterrupts::None,
color_coding_host: ColorCoding::TwentyFourBits,
color_coding_wrapper: ColorCoding::TwentyFourBits,
lp_size: 4,
vlp_size: 4,
};
let mut led1 = gpiog.pg6.into_push_pull_output(); let mut dsi_host = DsiHost::init(
let mut led2 = gpiod.pd4.into_push_pull_output(); dsi_pll_config,
DISPLAY_CONFIGURATION,
dsi_config,
peripherals.DSI,
&mut rcc,
)
.unwrap();
led1.set_low(); dsi_host.configure_phy_timers(DsiPhyTimers {
led2.set_low(); dataline_hs2lp: 35,
dataline_lp2hs: 35,
clock_hs2lp: 35,
clock_lp2hs: 35,
dataline_max_read_time: 0,
stop_wait_time: 10,
});
loop { dsi_host.set_command_mode_transmission_kind(DsiCmdModeTransmissionKind::AllInLowPower);
for _ in 0..100000 { dsi_host.start();
led1.set_low(); dsi_host.enable_bus_turn_around();
led2.set_high(); dsi_host.set_command_mode_transmission_kind(DsiCmdModeTransmissionKind::AllInHighSpeed);
} dsi_host.force_rx_low_power(true);
dsi_host.enable_color_test();
for _ in 0..100000 {
led1.set_high(); let mut otm = Otm8009A::new();
led2.set_low(); otm.init(
} &mut dsi_host,
} Otm8009AConfig {
frame_rate: otm8009a::FrameRate::_60Hz,
mode: otm8009a::Mode::Portrait,
color_map: otm8009a::ColorMap::Rgb,
cols: WIDTH as u16,
rows: HEIGHT as u16,
},
&mut delay,
)
.unwrap();
loop {}
} }