How to port LVGL to MAX78000?
Here’s a practical, battle-tested path to get LVGL running on MAX78000 / MAX78000FTHR (Cortex-M4F @ 100 MHz).
0) What you need
-
MSDK (Maxim/ADI SDK) installed + board support for MAX78000 (projects build with makefile/VS Code or Eclipse).
-
MAX78000 User Guide / datasheet handy (clocks, SPI, DMA, cache).
-
A SPI TFT (e.g., ILI9341 240×320 or ST7789 240×240) and—if it’s a touch panel—an I²C/SPI touch controller. Examples/projects using MAX78000 with SPI TFTs exist and are a good reference.
-
LVGL docs (use v9 porting guide if you’re on LVGL 9.x).
1) Create a minimal LVGL “port” layer
LVGL needs 3 things from your MCU side:
-
Ticks – call
lv_tick_inc(ms)
periodically -
Handler – call
lv_timer_handler()
in your main loop (or a 1–5 ms task) -
Drivers – display
flush_cb
(+ optional input device)
1.1 Ticks
Use a hardware timer or SysTick at 1 kHz:
Configure the timer using MSDK HAL (clock tree per UG).
1.2 Main loop
2) Implement the display driver (SPI + DMA)
Most MAX78000 designs will talk to the TFT via SPI (modes 0/3 supported). Use DMA for throughput; LVGL’s flush callback is where you start your SPI transfer.
Hook this up in your lv_port_disp_init()
with a draw buffer:
-
MAX78000 SPI supports the needed modes; use DMA for the pixel stream and keep CPU free.
-
The MSDK repo/eval examples include TFT demos; mine them for init sequences, DC/CS pins, and SPI/DMA setup.
-
A community project shows ILI9341 over SPI with MAX78000FTHR—use as reference for wiring and init sequence.
3) (Optional) Touch input driver
Register an input device (indev) that reads your touch controller each poll:
4) LVGL config (lv_conf.h) tips for MAX78000
-
Color format:
#define LV_COLOR_DEPTH 16
(RGB565) -
If colors look swapped, set
LV_COLOR_16_SWAP 1
(panel-specific). -
Buffers: Use 1–2 stripe buffers (e.g., 40–80 lines) to fit SRAM.
-
Tick:
LV_TICK_CUSTOM 1
if you provide your own tick source. -
Start with software rendering; add optimizations later. LVGL’s v9 porting page explains all required hooks.
5) Performance checklist (MAX78000 specifics)
-
Enable a higher SPI baud (tens of MHz if the TFT allows; check panel datasheet). MAX78000 SPI and DMA can handle it; keep CPU out of the hot path.
-
Use partial refresh (LVGL invalidation) and double buffering for smooth scrolling.
-
If using caches or tightly coupled SRAM regions, follow the MSDK/User Guide notes (align DMA buffers; avoid cache lines if applicable).
-
Place the TFT init + command macros in a thin HAL (e.g.,
tft_ll.c
) so LVGL code stays portable. -
For larger UIs, turn on LV_IMG_CACHE and keep fonts small.
6) Bring-up order that works
-
Blink + SPI loopback ⇒ verify clocks/pins.
-
Initialize TFT and draw a solid color rectangle (no LVGL yet).
-
Drop in LVGL, set
disp_flush
to call the same SPI-DMA write. -
Show
lv_label
orlv_demo_widgets
. -
Add touch driver.
7) Known good references
-
MSDK User Guide + MAX78000 UG (peripheral setup, SPI/DMA usage, examples).
-
MSDK examples/TFT demo for MAX78000 (panel init and pins).
-
ILI9341 on MAX78000FTHR community project (wiring + code ideas).
-
LVGL porting guide (v9) for required callbacks and configuration.
Quick wiring (ILI9341 over SPI, typical)
-
SPI SCK/MOSI/MISO → TFT SCK/MOSI/MISO
-
CS → TFT CS
-
DC (D/C) → TFT D/C
-
RST → TFT RESET
-
BL → GPIO (PWM dimming optional)
-
Touch (if XPT2046): separate SPI or share bus with a different CS; if FT6206: I²C + INT
(Use the board’s pinout and MSDK BSP for the exact pins—evaluate kit/Feather pin names and examples cover this.)
评论
发表评论