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

drivers/ili9341: add number of lines parameter

This commit is contained in:
Kaspar Schleiser 2020-01-15 15:33:32 +01:00
parent 74b463ab94
commit cab8729e32
3 changed files with 10 additions and 2 deletions

View File

@ -18,6 +18,7 @@
* @}
*/
#include <assert.h>
#include <string.h>
#include "byteorder.h"
#include "periph/spi.h"
@ -85,6 +86,7 @@ static void _ili9341_set_area(ili9341_t *dev, uint16_t x1, uint16_t x2,
int ili9341_init(ili9341_t *dev, const ili9341_params_t *params)
{
assert(params->lines >= 16 && params->lines <= 320 && !(params->lines & 0x7));
dev->params = params;
uint8_t command_params[4] = { 0 };
gpio_init(dev->params->dcx_pin, GPIO_OUT);
@ -139,10 +141,10 @@ int ili9341_init(ili9341_t *dev, const ili9341_params_t *params)
/* Display function control */
command_params[0] = 0x08;
command_params[1] = 0x82;
command_params[2] = 0x27; /* 320 lines */
/* number of lines, see datasheet p. 166 (DISCTRL::NL) */
command_params[2] = (params->lines >> 3) - 1;
_write_cmd(dev, ILI9341_CMD_DFUNC, command_params, 3);
/* Pixel format */
command_params[0] = 0x55; /* 16 bit mode */
_write_cmd(dev, ILI9341_CMD_PIXSET, command_params, 1);

View File

@ -55,6 +55,10 @@ extern "C" {
#define ILI9341_PARAM_INVERTED 0
#endif
#ifndef ILI9341_PARAM_NUM_LINES
#define ILI9341_PARAM_NUM_LINES 320U
#endif
#ifndef ILI9341_PARAMS
#define ILI9341_PARAMS { .spi = ILI9341_PARAM_SPI, \
.spi_clk = ILI9341_PARAM_SPI_CLK, \
@ -64,6 +68,7 @@ extern "C" {
.rst_pin = ILI9341_PARAM_RST, \
.rgb = ILI9341_PARAM_RGB, \
.inverted = ILI9341_PARAM_INVERTED, \
.lines = ILI9341_PARAM_NUM_LINES, \
}
#endif
/**@}*/

View File

@ -91,6 +91,7 @@ typedef struct {
bool rgb; /**< True when display is connected in RGB mode
* False when display is connected in BGR mode */
bool inverted; /**< Display works in inverted color mode */
uint16_t lines; /**< Number of lines, from 16 to 320 in 8 line steps */
} ili9341_params_t;
/**