-
Notifications
You must be signed in to change notification settings - Fork 8.2k
drivers: display: ili9xxx: Add support for ili9342c display controller #51988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
carlescufi
merged 2 commits into
zephyrproject-rtos:main
from
ExtremeGTX:ili9342_driver
May 19, 2023
+492
−10
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| /* | ||
| * Copyright (c) 2020 Teslabs Engineering S.L. | ||
| * Copyright (c) 2021 Krivorot Oleg <[email protected]> | ||
| * Copyright (c) 2022 Konstantinos Papadopoulos <[email protected]> | ||
| * Copyright (c) 2022 Mohamed ElShahawi <[email protected]> | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #include "display_ili9342c.h" | ||
| #include "display_ili9xxx.h" | ||
|
|
||
| #include <zephyr/logging/log.h> | ||
| LOG_MODULE_REGISTER(display_ili9342c, CONFIG_DISPLAY_LOG_LEVEL); | ||
|
|
||
| int ili9342c_regs_init(const struct device *dev) | ||
| { | ||
| const struct ili9xxx_config *config = dev->config; | ||
| const struct ili9342c_regs *regs = config->regs; | ||
| int r; | ||
|
|
||
ExtremeGTX marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| /* some commands require that SETEXTC be set first before it becomes enabled. */ | ||
| LOG_HEXDUMP_DBG(regs->setextc, ILI9342C_SETEXTC_LEN, "SETEXTC"); | ||
| r = ili9xxx_transmit(dev, ILI9342C_SETEXTC, regs->setextc, | ||
| ILI9342C_SETEXTC_LEN); | ||
| if (r < 0) { | ||
| return r; | ||
| } | ||
|
|
||
| LOG_HEXDUMP_DBG(regs->gamset, ILI9342C_GAMSET_LEN, "GAMSET"); | ||
| r = ili9xxx_transmit(dev, ILI9342C_GAMSET, regs->gamset, | ||
| ILI9342C_GAMSET_LEN); | ||
| if (r < 0) { | ||
| return r; | ||
| } | ||
|
|
||
| LOG_HEXDUMP_DBG(regs->ifmode, ILI9342C_IFMODE_LEN, "IFMODE"); | ||
| r = ili9xxx_transmit(dev, ILI9342C_IFMODE, regs->ifmode, | ||
| ILI9342C_IFMODE_LEN); | ||
| if (r < 0) { | ||
| return r; | ||
| } | ||
|
|
||
| LOG_HEXDUMP_DBG(regs->frmctr1, ILI9342C_FRMCTR1_LEN, "FRMCTR1"); | ||
| r = ili9xxx_transmit(dev, ILI9342C_FRMCTR1, regs->frmctr1, | ||
| ILI9342C_FRMCTR1_LEN); | ||
| if (r < 0) { | ||
| return r; | ||
| } | ||
|
|
||
| LOG_HEXDUMP_DBG(regs->invtr, ILI9342C_INVTR_LEN, "INVTR"); | ||
| r = ili9xxx_transmit(dev, ILI9342C_INVTR, regs->invtr, | ||
| ILI9342C_INVTR_LEN); | ||
| if (r < 0) { | ||
| return r; | ||
| } | ||
|
|
||
| LOG_HEXDUMP_DBG(regs->disctrl, ILI9342C_DISCTRL_LEN, "DISCTRL"); | ||
| r = ili9xxx_transmit(dev, ILI9342C_DISCTRL, regs->disctrl, | ||
| ILI9342C_DISCTRL_LEN); | ||
| if (r < 0) { | ||
| return r; | ||
| } | ||
|
|
||
| LOG_HEXDUMP_DBG(regs->etmod, ILI9342C_ETMOD_LEN, "ETMOD"); | ||
| r = ili9xxx_transmit(dev, ILI9342C_ETMOD, regs->etmod, | ||
| ILI9342C_ETMOD_LEN); | ||
| if (r < 0) { | ||
| return r; | ||
| } | ||
|
|
||
ExtremeGTX marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| LOG_HEXDUMP_DBG(regs->pwctrl1, ILI9342C_PWCTRL1_LEN, "PWCTRL1"); | ||
| r = ili9xxx_transmit(dev, ILI9342C_PWCTRL1, regs->pwctrl1, | ||
| ILI9342C_PWCTRL1_LEN); | ||
| if (r < 0) { | ||
| return r; | ||
| } | ||
|
|
||
| LOG_HEXDUMP_DBG(regs->pwctrl2, ILI9342C_PWCTRL2_LEN, "PWCTRL2"); | ||
| r = ili9xxx_transmit(dev, ILI9342C_PWCTRL2, regs->pwctrl2, | ||
| ILI9342C_PWCTRL2_LEN); | ||
| if (r < 0) { | ||
| return r; | ||
| } | ||
|
|
||
| LOG_HEXDUMP_DBG(regs->pwctrl3, ILI9342C_PWCTRL3_LEN, "PWCTRL3"); | ||
ExtremeGTX marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| r = ili9xxx_transmit(dev, ILI9342C_PWCTRL3, regs->pwctrl3, | ||
| ILI9342C_PWCTRL3_LEN); | ||
| if (r < 0) { | ||
| return r; | ||
| } | ||
|
|
||
| LOG_HEXDUMP_DBG(regs->vmctrl1, ILI9342C_VMCTRL1_LEN, "VMCTRL1"); | ||
| r = ili9xxx_transmit(dev, ILI9342C_VMCTRL1, regs->vmctrl1, | ||
| ILI9342C_VMCTRL1_LEN); | ||
| if (r < 0) { | ||
| return r; | ||
| } | ||
|
|
||
| LOG_HEXDUMP_DBG(regs->pgamctrl, ILI9342C_PGAMCTRL_LEN, "PGAMCTRL"); | ||
| r = ili9xxx_transmit(dev, ILI9342C_PGAMCTRL, regs->pgamctrl, | ||
| ILI9342C_PGAMCTRL_LEN); | ||
| if (r < 0) { | ||
| return r; | ||
| } | ||
|
|
||
| LOG_HEXDUMP_DBG(regs->ngamctrl, ILI9342C_NGAMCTRL_LEN, "NGAMCTRL"); | ||
| r = ili9xxx_transmit(dev, ILI9342C_NGAMCTRL, regs->ngamctrl, | ||
| ILI9342C_NGAMCTRL_LEN); | ||
| if (r < 0) { | ||
| return r; | ||
| } | ||
|
|
||
| LOG_HEXDUMP_DBG(regs->ifctl, ILI9342C_IFCTL_LEN, "IFCTL"); | ||
| r = ili9xxx_transmit(dev, ILI9342C_IFCTL, regs->ifctl, | ||
| ILI9342C_IFCTL_LEN); | ||
| if (r < 0) { | ||
| return r; | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| /* | ||
| * Copyright (c) 2020 Teslabs Engineering S.L. | ||
| * Copyright (c) 2021 Krivorot Oleg <[email protected]> | ||
| * Copyright (c) 2022 Konstantinos Papadopoulos <[email protected]> | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| #ifndef ZEPHYR_DRIVERS_DISPLAY_DISPLAY_ILI9342C_H_ | ||
| #define ZEPHYR_DRIVERS_DISPLAY_DISPLAY_ILI9342C_H_ | ||
|
|
||
| #include <zephyr/device.h> | ||
|
|
||
| /* Commands/registers. */ | ||
| #define ILI9342C_GAMSET 0x26 | ||
| #define ILI9342C_IFMODE 0xB0 | ||
| #define ILI9342C_FRMCTR1 0xB1 | ||
| #define ILI9342C_INVTR 0xB4 | ||
| #define ILI9342C_DISCTRL 0xB6 | ||
| #define ILI9342C_ETMOD 0xB7 | ||
| #define ILI9342C_PWCTRL1 0xC0 | ||
| #define ILI9342C_PWCTRL2 0xC1 | ||
| #define ILI9342C_PWCTRL3 0xC2 | ||
| #define ILI9342C_VMCTRL1 0xC5 | ||
| #define ILI9342C_SETEXTC 0xC8 | ||
| #define ILI9342C_PGAMCTRL 0xE0 | ||
| #define ILI9342C_NGAMCTRL 0xE1 | ||
| #define ILI9342C_IFCTL 0xF6 | ||
|
|
||
| /* Commands/registers length. */ | ||
| #define ILI9342C_GAMSET_LEN 1U | ||
| #define ILI9342C_IFMODE_LEN 1U | ||
| #define ILI9342C_FRMCTR1_LEN 2U | ||
| #define ILI9342C_INVTR_LEN 1U | ||
| #define ILI9342C_DISCTRL_LEN 4U | ||
| #define ILI9342C_ETMOD_LEN 1U | ||
| #define ILI9342C_PWCTRL1_LEN 2U | ||
| #define ILI9342C_PWCTRL2_LEN 1U | ||
| #define ILI9342C_PWCTRL3_LEN 1U | ||
| #define ILI9342C_VMCTRL1_LEN 1U | ||
| #define ILI9342C_SETEXTC_LEN 3U | ||
| #define ILI9342C_PGAMCTRL_LEN 15U | ||
| #define ILI9342C_NGAMCTRL_LEN 15U | ||
| #define ILI9342C_IFCTL_LEN 3U | ||
|
|
||
| /** X resolution (pixels). */ | ||
| #define ILI9342c_X_RES 320U | ||
| /** Y resolution (pixels). */ | ||
| #define ILI9342c_Y_RES 240U | ||
|
|
||
| /** ILI9342C registers to be initialized. */ | ||
| struct ili9342c_regs { | ||
| uint8_t gamset[ILI9342C_GAMSET_LEN]; | ||
| uint8_t ifmode[ILI9342C_IFMODE_LEN]; | ||
| uint8_t frmctr1[ILI9342C_FRMCTR1_LEN]; | ||
| uint8_t invtr[ILI9342C_INVTR_LEN]; | ||
| uint8_t disctrl[ILI9342C_DISCTRL_LEN]; | ||
| uint8_t etmod[ILI9342C_ETMOD_LEN]; | ||
| uint8_t pwctrl1[ILI9342C_PWCTRL1_LEN]; | ||
| uint8_t pwctrl2[ILI9342C_PWCTRL2_LEN]; | ||
| uint8_t pwctrl3[ILI9342C_PWCTRL3_LEN]; | ||
| uint8_t vmctrl1[ILI9342C_VMCTRL1_LEN]; | ||
| uint8_t setextc[ILI9342C_SETEXTC_LEN]; | ||
| uint8_t pgamctrl[ILI9342C_PGAMCTRL_LEN]; | ||
| uint8_t ngamctrl[ILI9342C_NGAMCTRL_LEN]; | ||
| uint8_t ifctl[ILI9342C_IFCTL_LEN]; | ||
| }; | ||
|
|
||
| /* Initializer macro for ILI9342C registers. */ | ||
| #define ILI9342c_REGS_INIT(n) \ | ||
| static const struct ili9342c_regs ili9xxx_regs_##n = { \ | ||
| .gamset = DT_PROP(DT_INST(n, ilitek_ili9342c), gamset), \ | ||
| .ifmode = DT_PROP(DT_INST(n, ilitek_ili9342c), ifmode), \ | ||
| .frmctr1 = DT_PROP(DT_INST(n, ilitek_ili9342c), frmctr1), \ | ||
| .invtr = DT_PROP(DT_INST(n, ilitek_ili9342c), invtr), \ | ||
| .disctrl = DT_PROP(DT_INST(n, ilitek_ili9342c), disctrl), \ | ||
| .etmod = DT_PROP(DT_INST(n, ilitek_ili9342c), etmod), \ | ||
| .pwctrl1 = DT_PROP(DT_INST(n, ilitek_ili9342c), pwctrl1), \ | ||
| .pwctrl2 = DT_PROP(DT_INST(n, ilitek_ili9342c), pwctrl2), \ | ||
| .pwctrl3 = DT_PROP(DT_INST(n, ilitek_ili9342c), pwctrl3), \ | ||
| .vmctrl1 = DT_PROP(DT_INST(n, ilitek_ili9342c), vmctrl1), \ | ||
| .setextc = {0xFF, 0x93, 0x42}, \ | ||
| .pgamctrl = DT_PROP(DT_INST(n, ilitek_ili9342c), pgamctrl), \ | ||
| .ngamctrl = DT_PROP(DT_INST(n, ilitek_ili9342c), ngamctrl), \ | ||
| .ifctl = DT_PROP(DT_INST(n, ilitek_ili9342c), ifctl), \ | ||
|
||
| }; | ||
|
|
||
| /** | ||
| * @brief Initialize ILI9342C registers with DT values. | ||
| * | ||
| * @param dev ILI9342C device instance | ||
| * @return 0 on success, errno otherwise. | ||
| */ | ||
| int ili9342c_regs_init(const struct device *dev); | ||
|
|
||
| #endif /* ZEPHYR_DRIVERS_DISPLAY_DISPLAY_ILI9342C_H_ */ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.