1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

drivers/ili9341 : Model 'CONFIG_ILI9341_LE_MODE' as BOOL

This commit is contained in:
Akshai M 2020-12-02 11:44:14 +01:00
parent a322c6d4c0
commit 9f81956e41
3 changed files with 23 additions and 19 deletions

View File

@ -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);
}

View File

@ -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
/** @} */

View File

@ -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