1 /*
2 * Copyright (c) 2020 Teslabs Engineering S.L.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include "display_ili9340.h"
8 #include "display_ili9xxx.h"
9
10 #include <zephyr/logging/log.h>
11 LOG_MODULE_REGISTER(display_ili9340, CONFIG_DISPLAY_LOG_LEVEL);
12
ili9340_regs_init(const struct device * dev)13 int ili9340_regs_init(const struct device *dev)
14 {
15 const struct ili9xxx_config *config = dev->config;
16 const struct ili9340_regs *regs = config->regs;
17
18 int r;
19
20 LOG_HEXDUMP_DBG(regs->gamset, ILI9340_GAMSET_LEN, "GAMSET");
21 r = ili9xxx_transmit(dev, ILI9340_GAMSET, regs->gamset,
22 ILI9340_GAMSET_LEN);
23 if (r < 0) {
24 return r;
25 }
26
27 LOG_HEXDUMP_DBG(regs->frmctr1, ILI9340_FRMCTR1_LEN, "FRMCTR1");
28 r = ili9xxx_transmit(dev, ILI9340_FRMCTR1, regs->frmctr1,
29 ILI9340_FRMCTR1_LEN);
30 if (r < 0) {
31 return r;
32 }
33
34 LOG_HEXDUMP_DBG(regs->disctrl, ILI9340_DISCTRL_LEN, "DISCTRL");
35 r = ili9xxx_transmit(dev, ILI9340_DISCTRL, regs->disctrl,
36 ILI9340_DISCTRL_LEN);
37 if (r < 0) {
38 return r;
39 }
40
41 LOG_HEXDUMP_DBG(regs->pwctrl1, ILI9340_PWCTRL1_LEN, "PWCTRL1");
42 r = ili9xxx_transmit(dev, ILI9340_PWCTRL1, regs->pwctrl1,
43 ILI9340_PWCTRL1_LEN);
44 if (r < 0) {
45 return r;
46 }
47
48 LOG_HEXDUMP_DBG(regs->pwctrl2, ILI9340_PWCTRL2_LEN, "PWCTRL2");
49 r = ili9xxx_transmit(dev, ILI9340_PWCTRL2, regs->pwctrl2,
50 ILI9340_PWCTRL2_LEN);
51 if (r < 0) {
52 return r;
53 }
54
55 LOG_HEXDUMP_DBG(regs->vmctrl1, ILI9340_VMCTRL1_LEN, "VMCTRL1");
56 r = ili9xxx_transmit(dev, ILI9340_VMCTRL1, regs->vmctrl1,
57 ILI9340_VMCTRL1_LEN);
58 if (r < 0) {
59 return r;
60 }
61
62 LOG_HEXDUMP_DBG(regs->vmctrl2, ILI9340_VMCTRL2_LEN, "VMCTRL2");
63 r = ili9xxx_transmit(dev, ILI9340_VMCTRL2, regs->vmctrl2,
64 ILI9340_VMCTRL2_LEN);
65 if (r < 0) {
66 return r;
67 }
68
69 LOG_HEXDUMP_DBG(regs->pgamctrl, ILI9340_PGAMCTRL_LEN, "PGAMCTRL");
70 r = ili9xxx_transmit(dev, ILI9340_PGAMCTRL, regs->pgamctrl,
71 ILI9340_PGAMCTRL_LEN);
72 if (r < 0) {
73 return r;
74 }
75
76 LOG_HEXDUMP_DBG(regs->ngamctrl, ILI9340_NGAMCTRL_LEN, "NGAMCTRL");
77 r = ili9xxx_transmit(dev, ILI9340_NGAMCTRL, regs->ngamctrl,
78 ILI9340_NGAMCTRL_LEN);
79 if (r < 0) {
80 return r;
81 }
82
83 return 0;
84 }
85