Merge pull request #15547 from akshaim/Kconfig_driver_ili9341

drivers/ili9341 : Expose configurations to Kconfig
This commit is contained in:
Leandro Lanzieri 2020-12-07 09:49:33 +01:00 committed by GitHub
commit f74cb053b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 97 additions and 36 deletions

View File

@ -19,17 +19,20 @@ rsource "motor_driver/Kconfig"
rsource "my9221/Kconfig" rsource "my9221/Kconfig"
endmenu # Actuator Device Drivers endmenu # Actuator Device Drivers
menu "Display Device Drivers"
rsource "disp_dev/Kconfig"
rsource "dsp0401/Kconfig"
rsource "hd44780/Kconfig"
rsource "ili9341/Kconfig"
endmenu # Display Device Drivers
menu "Miscellaneous Device Drivers" menu "Miscellaneous Device Drivers"
rsource "at/Kconfig" rsource "at/Kconfig"
rsource "at24mac/Kconfig" rsource "at24mac/Kconfig"
rsource "disp_dev/Kconfig"
rsource "ds1307/Kconfig" rsource "ds1307/Kconfig"
rsource "ds3231/Kconfig" rsource "ds3231/Kconfig"
rsource "ds3234/Kconfig" rsource "ds3234/Kconfig"
rsource "dsp0401/Kconfig"
rsource "edbg_eui/Kconfig" rsource "edbg_eui/Kconfig"
rsource "hd44780/Kconfig"
rsource "ili9341/Kconfig"
rsource "io1_xplained/Kconfig" rsource "io1_xplained/Kconfig"
rsource "uart_half_duplex/Kconfig" rsource "uart_half_duplex/Kconfig"
endmenu # Miscellaneous Device Drivers endmenu # Miscellaneous Device Drivers

View File

@ -13,3 +13,47 @@ config MODULE_ILI9341
select MODULE_PERIPH_SPI select MODULE_PERIPH_SPI
select MODULE_PERIPH_GPIO select MODULE_PERIPH_GPIO
select MODULE_XTIMER select MODULE_XTIMER
menuconfig KCONFIG_USEMODULE_ILI9341
bool "Configure ILI9341 driver"
depends on USEMODULE_ILI9341
help
Configure the ILI9341 display driver using Kconfig.
if KCONFIG_USEMODULE_ILI9341
config ILI9341_GVDD
int "GVDD voltage level (in millivolts)"
default 4800
range 3000 6000
help
Configure GVDD level, which is a reference level for the VCOM level and
the grayscale voltage level. GVDD should be ≦ (AVDD - 0.5) V .
config ILI9341_VCOMH
int "VCOMH voltage level (in millivolts)"
default 4250
range 2700 5875
help
Configure the high level of VCOM AC voltage. VCOM needs to be adjusted
to match the capacitance and performance specifications of the TFT panel
to maximize contrast and minimize flickering
config ILI9341_VCOML
int "VCOML voltage level (in millivolts)"
default -2000
range -2500 0
help
Configure the low level of VCOM AC voltage. VCOM needs to be adjusted to
match the capacitance and performance specifications of the TFT panel to
maximize contrast and minimize flickering
config ILI9341_LE_MODE
bool "Enable little endian to big endian conversion"
help
Enable this configuration to convert little endian colors to big endian.
ILI9341 device requires colors to be send in big endian RGB-565 format.
Enabling this option allows for little endian colors. Enabling this
however will slow down the driver as it cannot use DMA anymore.
endif # KCONFIG_USEMODULE_ILI9341

View File

@ -23,6 +23,8 @@
#include "byteorder.h" #include "byteorder.h"
#include "periph/spi.h" #include "periph/spi.h"
#include "xtimer.h" #include "xtimer.h"
#include "kernel_defines.h"
#include "ili9341.h" #include "ili9341.h"
#include "ili9341_internal.h" #include "ili9341_internal.h"
@ -114,15 +116,15 @@ int ili9341_init(ili9341_t *dev, const ili9341_params_t *params)
_write_cmd(dev, ILI9341_CMD_DISPOFF, NULL, 0); _write_cmd(dev, ILI9341_CMD_DISPOFF, NULL, 0);
/* PWRCTL1/2 */ /* PWRCTL1/2 */
command_params[0] = _ili9341_calc_pwrctl1(ILI9341_GVDD); command_params[0] = _ili9341_calc_pwrctl1(CONFIG_ILI9341_GVDD);
_write_cmd(dev, ILI9341_CMD_PWCTRL1, command_params, 1); _write_cmd(dev, ILI9341_CMD_PWCTRL1, command_params, 1);
command_params[0] = 0x10; /* PWRCTL 0 0 0 */ command_params[0] = 0x10; /* PWRCTL 0 0 0 */
_write_cmd(dev, ILI9341_CMD_PWCTRL2, command_params, 1); _write_cmd(dev, ILI9341_CMD_PWCTRL2, command_params, 1);
/* VCOMCTL */ /* VCOMCTL */
command_params[0] = _ili9341_calc_vmh(ILI9341_VCOMH); command_params[0] = _ili9341_calc_vmh(CONFIG_ILI9341_VCOMH);
command_params[1] = _ili9341_calc_vml(ILI9341_VCOML); command_params[1] = _ili9341_calc_vml(CONFIG_ILI9341_VCOML);
_write_cmd(dev, ILI9341_CMD_VMCTRL1, command_params, 2); _write_cmd(dev, ILI9341_CMD_VMCTRL1, command_params, 2);
command_params[0] = 0x86; command_params[0] = 0x86;
@ -248,9 +250,11 @@ void ili9341_fill(const ili9341_t *dev, uint16_t x1, uint16_t x2, uint16_t y1,
_ili9341_set_area(dev, x1, x2, y1, y2); _ili9341_set_area(dev, x1, x2, y1, y2);
/* Memory access command */ /* Memory access command */
_ili9341_cmd_start(dev, ILI9341_CMD_RAMWR, true); _ili9341_cmd_start(dev, ILI9341_CMD_RAMWR, true);
#if ILI9341_LE_MODE
color = htons(color); if (IS_ACTIVE(CONFIG_ILI9341_LE_MODE)) {
#endif color = htons(color);
}
for (int i = 0; i < (num_pix - 1); i++) { for (int i = 0; i < (num_pix - 1); i++) {
spi_transfer_bytes(dev->params->spi, dev->params->cs_pin, true, spi_transfer_bytes(dev->params->spi, dev->params->cs_pin, true,
(uint8_t *)&color, NULL, sizeof(color)); (uint8_t *)&color, NULL, sizeof(color));
@ -277,20 +281,20 @@ void ili9341_pixmap(const ili9341_t *dev, uint16_t x1, uint16_t x2,
/* Memory access command */ /* Memory access command */
_ili9341_cmd_start(dev, ILI9341_CMD_RAMWR, true); _ili9341_cmd_start(dev, ILI9341_CMD_RAMWR, true);
#if ILI9341_LE_MODE if (IS_ACTIVE(CONFIG_ILI9341_LE_MODE)) {
for (size_t i = 0; i < num_pix - 1; i++) { for (size_t i = 0; i < num_pix - 1; i++) {
uint16_t ncolor = htons(*(color + i)); uint16_t ncolor = htons(*(color + i));
spi_transfer_bytes(dev->params->spi, dev->params->cs_pin, true, spi_transfer_bytes(dev->params->spi, dev->params->cs_pin, true,
&ncolor, NULL, sizeof(uint16_t));
}
uint16_t ncolor = htons(*(color + num_pix - 1));
spi_transfer_bytes(dev->params->spi, dev->params->cs_pin, false,
&ncolor, NULL, sizeof(uint16_t)); &ncolor, NULL, sizeof(uint16_t));
} }
uint16_t ncolor = htons(*(color + num_pix - 1)); else {
spi_transfer_bytes(dev->params->spi, dev->params->cs_pin, false, spi_transfer_bytes(dev->params->spi, dev->params->cs_pin, false,
&ncolor, NULL, sizeof(uint16_t)); (const uint8_t *)color, NULL, num_pix * 2);
#else }
spi_transfer_bytes(dev->params->spi, dev->params->cs_pin, false,
(const uint8_t *)color, NULL, num_pix * 2);
#endif
spi_release(dev->params->spi); spi_release(dev->params->spi);
} }

View File

@ -23,7 +23,7 @@
* implemented here operates over SPI to communicate with the device. * implemented here operates over SPI to communicate with the device.
* *
* The device requires colors to be send in big endian RGB-565 format. The * The device requires colors to be send in big endian RGB-565 format. The
* @ref ILI9341_LE_MODE compile time option can switch this, but only use this * @ref CONFIG_ILI9341_LE_MODE compile time option can switch this, but only use this
* when strictly necessary. This option will slow down the driver as it * when strictly necessary. This option will slow down the driver as it
* certainly can't use DMA anymore, every short has to be converted before * certainly can't use DMA anymore, every short has to be converted before
* transfer. * transfer.
@ -52,28 +52,35 @@ extern "C" {
/** /**
* @brief ILI9341 gvdd level. * @brief ILI9341 gvdd level.
* *
* Default GVDD voltage of 4.8V * Default GVDD voltage of 4.8V. GVDD is reference level for the VCOM level and
* the grayscale voltage level. GVDD should be (AVDD - 0.5) V .
*/ */
#ifndef ILI9341_GVDD #ifndef CONFIG_ILI9341_GVDD
#define ILI9341_GVDD 4800 #define CONFIG_ILI9341_GVDD 4800
#endif #endif
/** /**
* @brief ILI9341 VCOMH voltage level. * @brief ILI9341 VCOMH voltage level.
* *
* Default VCOMH voltage of 4.25V * Default VCOMH voltage of 4.25V. VCOMH represents the high level of VCOM AC
* voltage. VCOM levels needs to be adjusted to match the capacitance and
* performance specifications of the TFT panel to maximize contrast and minimize
* flickering.
*/ */
#ifndef ILI9341_VCOMH #ifndef CONFIG_ILI9341_VCOMH
#define ILI9341_VCOMH 4250 #define CONFIG_ILI9341_VCOMH 4250
#endif #endif
/** /**
* @brief ILI9341 VCOML voltage level. * @brief ILI9341 VCOML voltage level.
* *
* Default VCOMH voltage of -2V * Default VCOML voltage of -2V. VCOML represents the low level of VCOM AC
* voltage. VCOM levels needs to be adjusted to match the capacitance and
* performance specifications of the TFT panel to maximize contrast and minimize
* flickering
*/ */
#ifndef ILI9341_VCOML #ifndef CONFIG_ILI9341_VCOML
#define ILI9341_VCOML -2000 #define CONFIG_ILI9341_VCOML -2000
#endif #endif
/** /**
@ -82,8 +89,8 @@ extern "C" {
* Compile time switch to change the driver to convert little endian * Compile time switch to change the driver to convert little endian
* colors to big endian. * colors to big endian.
*/ */
#ifndef ILI9341_LE_MODE #ifdef DOXYGEN
#define ILI9341_LE_MODE (0) #define CONFIG_ILI9341_LE_MODE
#endif #endif
/** @} */ /** @} */

View File

@ -4,10 +4,13 @@ include ../Makefile.tests_common
USEMODULE += ili9341 USEMODULE += ili9341
USEMODULE += xtimer USEMODULE += xtimer
CFLAGS += -DILI9341_LE_MODE
include $(RIOTBASE)/Makefile.include include $(RIOTBASE)/Makefile.include
# Check if being configured via Kconfig
ifndef CONFIG_KCONFIG_USEMODULE_ILI9341
CFLAGS += -DCONFIG_ILI9341_LE_MODE
endif
# The AVR architecture stores the image in the RAM, this usually doesn't fit. # The AVR architecture stores the image in the RAM, this usually doesn't fit.
# This flag excludes the image from the test # This flag excludes the image from the test
ifneq (,$(filter arch_avr8,$(FEATURES_USED))) ifneq (,$(filter arch_avr8,$(FEATURES_USED)))