AI Reasoning: This document explains the AI's reasoning for the LCD driver implementation.
⚠️ This is AI-generated content - verify against hardware before use
The LCD driver controls the 320×240 TFT display using an 8080-style parallel interface.
AI Reasoning:
- OEM firmware uses GPIO toggles for data bus (PD8-PD15 observed)
- Control pins (WR, CS, RS, RST) all on GPIOD
- No hardware LCD controller peripheral observed
- 8080 interface is common for small TFT displays
Evidence:
- FUN_080271c0 / FUN_08027220: Write command/data functions
- PD8-PD15 used as 8-bit data bus
- WR strobe toggled in software loops
Confidence: HIGH - Confirmed from OEM firmware analysis
AI Reasoning:
- Frame buffer address found in OEM firmware: DAT_08015790 → 0x20000BD0
- Size: 320 × 240 × 2 bytes (RGB565) = 153,600 bytes
- Located in SRAM (0x20000000 base)
- Leaves room for stack above this location
Memory Layout:
0x20000000 - Start of SRAM
0x20000BD0 - Frame buffer (153.6 KB)
0x20018000 - Top of RAM / Stack
Confidence: HIGH - Directly from OEM firmware memory map
Potential Issues:
- Frame buffer may overlap with stack if stack grows too large
- Location must be preserved in linker script
AI Reasoning:
- Data bus: PD8-PD15 (8 pins, 8-bit transfers)
- WR: PD0 (write strobe)
- CS: PD1 (chip select)
- RST: PD2 (reset)
- RS (D/C): PD3 (command/data select)
Implementation:
LCD_WRITE_DATA_BUS(d) - Writes byte to PD8-PD15
LCD_RS_LOW() - Command mode
LCD_RS_HIGH() - Data mode
lcd_strobe_wr() - Toggles WR to clock dataConfidence: HIGH - Pin assignments confirmed from OEM firmware register writes
AI Reasoning:
- Command sequences match ILI9341/ST7789 controllers (common TFT controllers)
- Window commands: 0x2A (column), 0x2B (row), 0x2C (RAM write)
- Typical display controller command set
Commands Used:
- 0x2A: Set column address
- 0x2B: Set row address
- 0x2C: Memory write (start pixel transfer)
Confidence: MEDIUM - Commands inferred from OEM firmware, controller ID not verified
Potential Issues:
- Controller may not be ILI9341/ST7789 - could be different model
- Command sequences may need adjustment
- Initialization sequence is guessed (not fully extracted from OEM)
AI Reasoning:
- FUN_080037b0 in OEM firmware uses DMA2 (base 0x40020430)
- Streaming 153.6 KB frame buffer would be slow via software loops
- DMA allows CPU to do other work while transferring
Current Implementation:
- Placeholder: Uses software loop (LCD_DrawImage)
- TODO: Implement DMA transfer for performance
Confidence: HIGH - DMA usage confirmed, but implementation incomplete
Potential Issues:
- DMA configuration may need tuning
- Transfer completion detection needed
- May need double-buffering to avoid tearing
AI Reasoning:
- 2 bytes per pixel (320×240×2 = 153,600 bytes)
- Matches frame buffer size exactly
- Common embedded display format
- Balanced between color depth and memory usage
Confidence: HIGH - Format confirmed from buffer size calculation
AI Reasoning:
- Observed in OEM firmware: DAT_08015410 → 0x2000A1D0
- Used for command packet building
- Allows building complex command sequences before sending
Confidence: MEDIUM - Address found in OEM firmware, purpose inferred
Potential Issues:
- Buffer size unknown
- May not be necessary for all operations
AI Reasoning:
- Initialization sequence is guessed based on typical ILI9341/ST7789 startup
- Not fully extracted from OEM firmware (too complex to reverse)
- Follows standard TFT display initialization pattern
Typical Sequence:
- Hardware reset (RST pin)
- Software reset command (0x01)
- Exit sleep (0x11)
- Display on (0x29)
- Normal mode (0x13)
- Set pixel format
- Set display orientation
Confidence: LOW - Initialization sequence is guessed, needs hardware verification
Potential Issues:
- Sequence may be completely wrong
- Display may not initialize at all
- Orientation may be incorrect
- Color format may need adjustment
- Frame Buffer Address: Directly from OEM firmware (HIGH confidence)
- Pin Assignments: Confirmed from register writes (HIGH confidence)
- Interface Type: 8080 parallel confirmed (HIGH confidence)
- Controller Type: Guessed ILI9341/ST7789 (LOW confidence)
- Initialization: Guessed from typical patterns (LOW confidence)
- DMA Usage: Confirmed but not implemented (MEDIUM confidence)
- Read display ID register (0x04) to identify actual controller
- Verify frame buffer location doesn't conflict with stack/heap
- Test pixel writes actually appear on display
- Verify color format (RGB565 vs RGB888 vs other)
- Test display orientation (may be rotated)
- Implement and test DMA transfer
- Verify initialization sequence works
- Test backlight control (PC6 PWM)
- OEM Firmware: FUN_080271c0, FUN_08027220, FUN_080037b0, FUN_0801cb52
- Memory Map: Frame buffer address from DAT_08015790
- Register Analysis: GPIO register writes for pin assignments
- Pattern Matching: ILI9341/ST7789 command sets (standard)