After having a hard time getting the ILI9341 touchscreen working with the NanoPi Neo (Allwinner H3) it seems to work now.
To have more GPIOs available for other stuff the touch and display share one SPI bus.
There is basically nothing available out of the box and I'm a total noob with NanoPi, Armbian and overlays so there may be errors.
But it works.
root@nanopineo:~# uname -a
Linux nanopineo 5.15.93-sunxi #23.02.2 SMP Fri Feb 17 00:00:00 UTC 2023 armv7l armv7l armv7l GNU/Linux
This is the wiring between ILI9341 and NanoPi Neo:
/*
3.3v <--> VCC & LED
GND <--> GND
PC2 <--> SCK & T_CLK
PC1 <--> SDO<MISO> & T_DO
PC0 <--> SDI<MOSI> & T_DIN
PA1 <--> DC
PG8 <--> RESET
PC3 <--> CS
PA3 <--> T_CS
PG9 <--> T_IRG
*/
This is the overlay ( ili9341-touch-double-spi-cs.dts ):
/dts-v1/;
/plugin/;
/ {
compatible = "allwinner,sun8i-h3";
fragment@0 {
target = <&pio>;
__overlay__ {
spi0_cs1: spi0_cs1 {
pins = "PC3";
function = "gpio_out";
output-high;
};
spi1_cs1: spi1_cs1 {
pins = "PA3";
function = "gpio_out";
output-high;
};
opiz_display_pins: opiz_display_pins {
pins = "PA1", "PG8", "PA6";
function = "gpio_out";
};
ads7846_pins: ads7846_pins {
pins = "PG9";
function = "irq";
};
};
};
fragment@1 {
target = <&spi1>;
__overlay__ {
pinctrl-names = "default", "default";
pinctrl-1 = <&spi1_cs1>;
cs-gpios = <0>, <&pio 0 3 0>; /* PA3 */
};
};
fragment@2 {
target = <&spi0>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
pinctrl-names = "default", "default";
cs-gpios= <&pio 2 3 0>, <&pio 0 3 1>;
opizdisplay: opiz-display@0 {
pinctrl-1 = <&spi0_cs1>;
reg = <0>; /* Chip Select 0 */
compatible = "ilitek,ili9341";
spi-max-frequency = <1000000>;
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&opiz_display_pins>;
rotate = <90>;
bgr = <0>;
fps = <33>;
buswidth = <8>;
dc-gpios = <&pio 0 1 0>; /* PIN_22 GPIOA1 > */
reset-gpios = <&pio 6 8 1 >; /* GPIOG8> */
/*led-gpios=<&pio 0 6 0>; PIN_12 GPIOA6 > */
debug=<4>;
};
ads7846: ads7846@1 {
reg = <1>; /* Chip Select 1 */
compatible = "ti,ads7846";
spi-max-frequency = <1000000>;
status = "okay";
pinctrl-2=<&spi1_cs1 &spi1_cs1>;
pinctrl-names = "default";
pinctrl-3 = <&ads7846_pins>;
interrupt-parent = <&pio>;
interrupts = <6 9 2>; /* PG9 IRQ_TYPE_EDGE_FALLING */
pendown-gpio = <&pio 6 9 0>; /* PG9 */
/* driver defaults, optional */
ti,x-min = /bits/ 16 <0>;
ti,y-min = /bits/ 16 <0>;
ti,x-max = /bits/ 16 <0x0FFF>;
ti,y-max = /bits/ 16 <0x0FFF>;
ti,pressure-min = /bits/ 16 <0>;
ti,pressure-max = /bits/ 16 <0xFFFF>;
ti,x-plate-ohms = /bits/ 16 <400>;
};
};
};
This is the /boot/armbianEnv.txt
verbosity=1 bootlogo=false console=serial disp_mode=1920x1080p60 overlay_prefix=sun8i-h3 overlays=usbhost1 usbhost2 spi0 param_spidev_spi_bus=0 param_spidev_spi_cs=1 param_spidev_spi_cs=0 rootdev=UUID=XYZ-LONG-UUID-IS-LONG rootfstype=ext4 user_overlays=ili9341-touch-double-spi-cs usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u
After connecting via ssh and starting evtest it shows this when touched ( not sure if it shows the correct coordinates yet )
Event: time 1682020476.763295, -------------- SYN_REPORT ------------
Event: time 1682020476.775286, type 3 (EV_ABS), code 0 (ABS_X), value 535
Event: time 1682020476.775286, type 3 (EV_ABS), code 1 (ABS_Y), value 3553
Event: time 1682020476.775286, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 65169
To add the overlay:
armbian-add-overlay /path/to/ili9341-touch-double-spi-cs.dts
I'm still not sure if it works like it should. But at least it does something that looks promising.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
Hi, I'm very interested in your project, I'm trying to compile your DTS file, but it keeps giving me syntax error..
Error: ili9341-touch-double-spi-cs.dts:96.6-7 syntax error
FATAL ERROR: Unable to parse input tree
Do you have any suggestions?
Thanks in advance
Are you sure? yes | no