1 /* 2 * Copyright (c) 2020 Teslabs Engineering S.L. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 #ifndef ZEPHYR_DRIVERS_DISPLAY_DISPLAY_ILI9340_H_ 7 #define ZEPHYR_DRIVERS_DISPLAY_DISPLAY_ILI9340_H_ 8 9 #include <zephyr/device.h> 10 11 /* Commands/registers. */ 12 #define ILI9340_GAMSET 0x26 13 #define ILI9340_FRMCTR1 0xB1 14 #define ILI9340_DISCTRL 0xB6 15 #define ILI9340_PWCTRL1 0xC0 16 #define ILI9340_PWCTRL2 0xC1 17 #define ILI9340_VMCTRL1 0xC5 18 #define ILI9340_VMCTRL2 0xC7 19 #define ILI9340_PGAMCTRL 0xE0 20 #define ILI9340_NGAMCTRL 0xE1 21 22 /* Commands/registers length. */ 23 #define ILI9340_GAMSET_LEN 1U 24 #define ILI9340_FRMCTR1_LEN 2U 25 #define ILI9340_DISCTRL_LEN 3U 26 #define ILI9340_PWCTRL1_LEN 2U 27 #define ILI9340_PWCTRL2_LEN 1U 28 #define ILI9340_VMCTRL1_LEN 2U 29 #define ILI9340_VMCTRL2_LEN 1U 30 #define ILI9340_PGAMCTRL_LEN 15U 31 #define ILI9340_NGAMCTRL_LEN 15U 32 33 /** X resolution (pixels). */ 34 #define ILI9340_X_RES 240U 35 /** Y resolution (pixels). */ 36 #define ILI9340_Y_RES 320U 37 38 /** ILI9340 registers to be initialized. */ 39 struct ili9340_regs { 40 uint8_t gamset[ILI9340_GAMSET_LEN]; 41 uint8_t frmctr1[ILI9340_FRMCTR1_LEN]; 42 uint8_t disctrl[ILI9340_DISCTRL_LEN]; 43 uint8_t pwctrl1[ILI9340_PWCTRL1_LEN]; 44 uint8_t pwctrl2[ILI9340_PWCTRL2_LEN]; 45 uint8_t vmctrl1[ILI9340_VMCTRL1_LEN]; 46 uint8_t vmctrl2[ILI9340_VMCTRL2_LEN]; 47 uint8_t pgamctrl[ILI9340_PGAMCTRL_LEN]; 48 uint8_t ngamctrl[ILI9340_NGAMCTRL_LEN]; 49 }; 50 51 /* Initializer macro for ILI9340 registers. */ 52 #define ILI9340_REGS_INIT(n) \ 53 static const struct ili9340_regs ili9xxx_regs_##n = { \ 54 .gamset = DT_PROP(DT_INST(n, ilitek_ili9340), gamset), \ 55 .frmctr1 = DT_PROP(DT_INST(n, ilitek_ili9340), frmctr1), \ 56 .disctrl = DT_PROP(DT_INST(n, ilitek_ili9340), disctrl), \ 57 .pwctrl1 = DT_PROP(DT_INST(n, ilitek_ili9340), pwctrl1), \ 58 .pwctrl2 = DT_PROP(DT_INST(n, ilitek_ili9340), pwctrl2), \ 59 .vmctrl1 = DT_PROP(DT_INST(n, ilitek_ili9340), vmctrl1), \ 60 .vmctrl2 = DT_PROP(DT_INST(n, ilitek_ili9340), vmctrl2), \ 61 .pgamctrl = DT_PROP(DT_INST(n, ilitek_ili9340), pgamctrl), \ 62 .ngamctrl = DT_PROP(DT_INST(n, ilitek_ili9340), ngamctrl), \ 63 } 64 65 /** 66 * @brief Initialize ILI9340 registers with DT values. 67 * 68 * @param dev ILI9340 device instance 69 * @return 0 on success, errno otherwise. 70 */ 71 int ili9340_regs_init(const struct device *dev); 72 73 #endif /* ZEPHYR_DRIVERS_DISPLAY_DISPLAY_ILI9340_H_ */ 74