diff --git a/drivers/ili9341/ili9341.c b/drivers/ili9341/ili9341.c index 243744d5f1..455c3faffb 100644 --- a/drivers/ili9341/ili9341.c +++ b/drivers/ili9341/ili9341.c @@ -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" @@ -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 - color = htons(color); -#endif + + if (IS_ACTIVE(CONFIG_ILI9341_LE_MODE)) { + color = htons(color); + } + 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,20 +281,20 @@ 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 - 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, + 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, + &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)); } - 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 - spi_transfer_bytes(dev->params->spi, dev->params->cs_pin, false, - (const uint8_t *)color, NULL, num_pix * 2); - -#endif + else { + spi_transfer_bytes(dev->params->spi, dev->params->cs_pin, false, + (const uint8_t *)color, NULL, num_pix * 2); + } spi_release(dev->params->spi); } diff --git a/drivers/include/ili9341.h b/drivers/include/ili9341.h index 4fb5d067a6..1951966f3f 100644 --- a/drivers/include/ili9341.h +++ b/drivers/include/ili9341.h @@ -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. @@ -82,8 +82,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 /** @} */ diff --git a/tests/driver_ili9341/Makefile b/tests/driver_ili9341/Makefile index cb1b116be4..a62200a91c 100644 --- a/tests/driver_ili9341/Makefile +++ b/tests/driver_ili9341/Makefile @@ -4,7 +4,7 @@ include ../Makefile.tests_common USEMODULE += ili9341 USEMODULE += xtimer -CFLAGS += -DILI9341_LE_MODE +CFLAGS += -DCONFIG_ILI9341_LE_MODE include $(RIOTBASE)/Makefile.include