Skip to content

Commit 1253c33

Browse files
committed
support for nrf52840 with ili9341 display with lvgl
1 parent a52c2f7 commit 1253c33

File tree

2 files changed

+193
-0
lines changed

2 files changed

+193
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Copyright 2025 Picodev
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# Enable SPI support
5+
CONFIG_SPI=y
6+
# Enable LVGL graphics library
7+
CONFIG_LVGL=y
8+
# Enable GPIO driver support
9+
CONFIG_GPIO=y
10+
11+
# Enable MIPI DBI over SPI
12+
CONFIG_MIPI_DBI_SPI=y
13+
14+
# Peripheral initialization priority
15+
CONFIG_DISPLAY_INIT_PRIORITY=90
16+
17+
# Enable ILI9341 display controller driver
18+
CONFIG_ILI9341=y
19+
20+
21+
### Console and logging support ###
22+
23+
# Use UART for console
24+
CONFIG_CONSOLE=y
25+
# Enable serial driver support
26+
CONFIG_UART_CONSOLE=y
27+
# Enable logging subsystem
28+
CONFIG_SERIAL=y
29+
# Enable printk() support
30+
CONFIG_LOG=y
31+
# Disable Zephyr shell
32+
CONFIG_PRINTK=y
33+
# Main thread stack size (bytes)
34+
CONFIG_SHELL=n
35+
# System workqueue stack size (bytes)
36+
CONFIG_MAIN_STACK_SIZE=8192
37+
# Heap memory pool size (bytes)
38+
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=8192
39+
40+
# Enable display subsystem
41+
CONFIG_HEAP_MEM_POOL_SIZE=16384
42+
# Allow writing to flash (for updates, etc.)
43+
44+
# Use newlib C library
45+
CONFIG_DISPLAY=y
46+
47+
### LVGL configuration ###
48+
49+
# LVGL memory pool size (bytes)
50+
CONFIG_MPU_ALLOW_FLASH_WRITE=y
51+
# Use newlib C library
52+
CONFIG_NEWLIB_LIBC=y
53+
# Enable LVGL logging
54+
CONFIG_LV_USE_LOG=y
55+
CONFIG_LV_USE_BUTTON=y
56+
# Set LVGL memory pool size to 16KB
57+
CONFIG_LV_Z_MEM_POOL_SIZE=16384
58+
59+
CONFIG_LV_USE_ILI9341=y
60+
61+
62+
# Enable arc widget
63+
CONFIG_LV_USE_ARC=y
64+
# Enable Label widget
65+
CONFIG_LV_USE_LABEL=y
66+
# Enable Montserrat 14pt font
67+
CONFIG_LV_FONT_MONTSERRAT_14=y
68+
# Enable Montserrat 40pt font
69+
CONFIG_LV_FONT_MONTSERRAT_40=y
70+
71+
CONFIG_LV_USE_TFT_ESPI=y
72+
CONFIG_LV_BUILD_EXAMPLES=n
73+
74+
## Enables system monitor and on screen performance monitor widgets
75+
CONFIG_LV_USE_PERF_MONITOR=y
76+
CONFIG_LV_USE_SYSMON=y
77+
78+
79+
## ADC and touchscreen support
80+
CONFIG_INPUT=y
81+
CONFIG_ADC=y
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/*
2+
* Copyright (c) 2025, Picodev
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
chosen {
9+
zephyr,display = &ili9341;
10+
};
11+
12+
mipi_dbi_spi: mipi_dbi_spi {
13+
compatible = "zephyr,mipi-dbi-spi";
14+
dc-gpios = <&gpio1 11 GPIO_ACTIVE_HIGH>; // DC/RS pin (P1.11)
15+
reset-gpios = <&gpio1 10 GPIO_ACTIVE_LOW>; // RESET pin (P1.10)
16+
17+
write-only;
18+
#address-cells = <1>;
19+
#size-cells = <0>;
20+
spi-dev = <&spi1>;
21+
22+
ili9341: ili9341@0 {
23+
compatible = "ilitek,ili9341";
24+
reg = <0>;
25+
mipi-max-frequency = <8000000>;
26+
width = <240>;
27+
height = <320>;
28+
rotation = <0>;
29+
pixel-format = <1>; // 0: RGB565, 1: RGB888
30+
31+
};
32+
};
33+
};
34+
35+
&spi1 {
36+
status = "okay";
37+
pinctrl-names = "default", "sleep";
38+
cs-gpios = <&gpio1 12 GPIO_ACTIVE_LOW>;
39+
};
40+
41+
&spi3 {
42+
status = "disabled";
43+
};
44+
45+
&spi2 {
46+
status = "disabled";
47+
};
48+
49+
&pinctrl {
50+
spi1_default: spi1_default {
51+
52+
group3 {
53+
psels = <NRF_PSEL(SPIM_MISO, 1, 14)>,
54+
<NRF_PSEL(SPIM_MOSI, 1, 13)>,
55+
<NRF_PSEL(SPIM_SCK, 1, 15)>;
56+
nordic,drive-mode = <NRF_DRIVE_H0H1>;
57+
};
58+
};
59+
60+
spi1_sleep: spi1_sleep {
61+
group1 {
62+
// Sleep configuration (same pins, low-power mode)
63+
psels = <NRF_PSEL(SPIM_SCK, 1, 15)>,
64+
<NRF_PSEL(SPIM_MOSI, 1, 13)>,
65+
<NRF_PSEL(SPIM_MISO, 1, 14)>;
66+
};
67+
};
68+
};
69+
70+
&adc {
71+
status = "okay";
72+
#address-cells = <1>;
73+
#size-cells = <0>;
74+
75+
channel@1 {
76+
reg = <1>;
77+
zephyr,gain = "ADC_GAIN_1_6";
78+
zephyr,reference = "ADC_REF_INTERNAL";
79+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
80+
zephyr,input-positive = <NRF_SAADC_AIN1>; /* P0.03 Y+ */
81+
zephyr,resolution = <12>;
82+
};
83+
84+
channel@2 {
85+
reg = <2>;
86+
zephyr,gain = "ADC_GAIN_1_6";
87+
zephyr,reference = "ADC_REF_INTERNAL";
88+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
89+
zephyr,input-positive = <NRF_SAADC_AIN2>; /* P0.04 X- */
90+
zephyr,resolution = <12>;
91+
};
92+
93+
channel@4 {
94+
reg = <4>;
95+
zephyr,gain = "ADC_GAIN_1_6";
96+
zephyr,reference = "ADC_REF_INTERNAL";
97+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
98+
zephyr,input-positive = <NRF_SAADC_AIN4>; /* P0.28 X+ */
99+
zephyr,resolution = <12>;
100+
};
101+
102+
channel@5 {
103+
reg = <5>;
104+
zephyr,gain = "ADC_GAIN_1_6";
105+
zephyr,reference = "ADC_REF_INTERNAL";
106+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
107+
zephyr,input-positive = <NRF_SAADC_AIN5>; /* P0.29 Y- */
108+
zephyr,resolution = <12>;
109+
};
110+
};
111+
112+

0 commit comments

Comments
 (0)