Merge pull request #15547 from akshaim/Kconfig_driver_ili9341
drivers/ili9341 : Expose configurations to Kconfig
This commit is contained in:
commit
f74cb053b2
@ -19,17 +19,20 @@ rsource "motor_driver/Kconfig"
|
||||
rsource "my9221/Kconfig"
|
||||
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"
|
||||
rsource "at/Kconfig"
|
||||
rsource "at24mac/Kconfig"
|
||||
rsource "disp_dev/Kconfig"
|
||||
rsource "ds1307/Kconfig"
|
||||
rsource "ds3231/Kconfig"
|
||||
rsource "ds3234/Kconfig"
|
||||
rsource "dsp0401/Kconfig"
|
||||
rsource "edbg_eui/Kconfig"
|
||||
rsource "hd44780/Kconfig"
|
||||
rsource "ili9341/Kconfig"
|
||||
rsource "io1_xplained/Kconfig"
|
||||
rsource "uart_half_duplex/Kconfig"
|
||||
endmenu # Miscellaneous Device Drivers
|
||||
|
||||
@ -13,3 +13,47 @@ config MODULE_ILI9341
|
||||
select MODULE_PERIPH_SPI
|
||||
select MODULE_PERIPH_GPIO
|
||||
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
|
||||
|
||||
@ -23,6 +23,8 @@
|
||||
#include "byteorder.h"
|
||||
#include "periph/spi.h"
|
||||
#include "xtimer.h"
|
||||
#include "kernel_defines.h"
|
||||
|
||||
#include "ili9341.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);
|
||||
|
||||
/* 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);
|
||||
|
||||
command_params[0] = 0x10; /* PWRCTL 0 0 0 */
|
||||
_write_cmd(dev, ILI9341_CMD_PWCTRL2, command_params, 1);
|
||||
|
||||
/* VCOMCTL */
|
||||
command_params[0] = _ili9341_calc_vmh(ILI9341_VCOMH);
|
||||
command_params[1] = _ili9341_calc_vml(ILI9341_VCOML);
|
||||
command_params[0] = _ili9341_calc_vmh(CONFIG_ILI9341_VCOMH);
|
||||
command_params[1] = _ili9341_calc_vml(CONFIG_ILI9341_VCOML);
|
||||
_write_cmd(dev, ILI9341_CMD_VMCTRL1, command_params, 2);
|
||||
|
||||
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);
|
||||
/* Memory access command */
|
||||
_ili9341_cmd_start(dev, ILI9341_CMD_RAMWR, true);
|
||||
#if ILI9341_LE_MODE
|
||||
|
||||
if (IS_ACTIVE(CONFIG_ILI9341_LE_MODE)) {
|
||||
color = htons(color);
|
||||
#endif
|
||||
}
|
||||
|
||||
for (int i = 0; i < (num_pix - 1); i++) {
|
||||
spi_transfer_bytes(dev->params->spi, dev->params->cs_pin, true,
|
||||
(uint8_t *)&color, NULL, sizeof(color));
|
||||
@ -277,7 +281,7 @@ void ili9341_pixmap(const ili9341_t *dev, uint16_t x1, uint16_t x2,
|
||||
/* Memory access command */
|
||||
_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++) {
|
||||
uint16_t ncolor = htons(*(color + i));
|
||||
spi_transfer_bytes(dev->params->spi, dev->params->cs_pin, true,
|
||||
@ -286,11 +290,11 @@ void ili9341_pixmap(const ili9341_t *dev, uint16_t x1, uint16_t x2,
|
||||
uint16_t ncolor = htons(*(color + num_pix - 1));
|
||||
spi_transfer_bytes(dev->params->spi, dev->params->cs_pin, false,
|
||||
&ncolor, NULL, sizeof(uint16_t));
|
||||
#else
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
* implemented here operates over SPI to communicate with the device.
|
||||
*
|
||||
* 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
|
||||
* certainly can't use DMA anymore, every short has to be converted before
|
||||
* transfer.
|
||||
@ -52,28 +52,35 @@ extern "C" {
|
||||
/**
|
||||
* @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
|
||||
#define ILI9341_GVDD 4800
|
||||
#ifndef CONFIG_ILI9341_GVDD
|
||||
#define CONFIG_ILI9341_GVDD 4800
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @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
|
||||
#define ILI9341_VCOMH 4250
|
||||
#ifndef CONFIG_ILI9341_VCOMH
|
||||
#define CONFIG_ILI9341_VCOMH 4250
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @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
|
||||
#define ILI9341_VCOML -2000
|
||||
#ifndef CONFIG_ILI9341_VCOML
|
||||
#define CONFIG_ILI9341_VCOML -2000
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -82,8 +89,8 @@ extern "C" {
|
||||
* Compile time switch to change the driver to convert little endian
|
||||
* colors to big endian.
|
||||
*/
|
||||
#ifndef ILI9341_LE_MODE
|
||||
#define ILI9341_LE_MODE (0)
|
||||
#ifdef DOXYGEN
|
||||
#define CONFIG_ILI9341_LE_MODE
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
|
||||
@ -4,10 +4,13 @@ include ../Makefile.tests_common
|
||||
USEMODULE += ili9341
|
||||
USEMODULE += xtimer
|
||||
|
||||
CFLAGS += -DILI9341_LE_MODE
|
||||
|
||||
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.
|
||||
# This flag excludes the image from the test
|
||||
ifneq (,$(filter arch_avr8,$(FEATURES_USED)))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user