# ESP32-WROVER-KIT-LCD-DRIVER: main/Driver.h Source File

Driver.h
Go to the documentation of this file.
#ifndef __DRIVER_H
#define __DRIVER_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "driver/spi_master.h"
#include "esp_system.h"
#include "driver/gpio.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#define LCD_HOST HSPI_HOST
#define DMA_CHAN 2
#define PIN_NUM_MISO 25
#define PIN_NUM_MOSI 23
#define PIN_NUM_CLK 19
#define PIN_NUM_CS 22
#define PIN_NUM_DC 21
#define PIN_NUM_RST 18
#define PIN_NUM_BCKL 5
#define LCD_WIDTH 320
#define LCD_HIGH 240
//To speed up transfers, every SPI transfer sends a bunch of lines. This define specifies how many. More means more memory use,
//but less overhead for setting up / finishing transfers. Make sure 240 is dividable by this.
#define PARALLEL_LINES 16
/*
The LCD needs a bunch of command/argument values to be initialized. They are stored in this struct.
*/
typedef struct {
uint8_t cmd;
uint8_t data[16];
uint8_t databytes; //No of data in data; bit 7 = delay after set; 0xFF = end of cmds.
} lcd_init_cmd_t;
typedef enum {
LCD_TYPE_ILI = 1,
LCD_TYPE_ST,
LCD_TYPE_MAX,
} type_lcd_t;
esp_err_t vDriver_init(void);
esp_err_t iDriver_writeFramebuffer(uint16_t ***pu16Framebuffer);
#endif /* __DRIVER_H */
LCD_TYPE_ST
@ LCD_TYPE_ST
Definition: Driver.h:51
LCD_TYPE_MAX
@ LCD_TYPE_MAX
Definition: Driver.h:52
iDriver_sendLineFinish
static esp_err_t iDriver_sendLineFinish(void)
send finish after line
Definition: Driver.c:457
PIN_NUM_CLK
#define PIN_NUM_CLK
Definition: Driver.h:26
iDriver_writeFramebuffer
esp_err_t iDriver_writeFramebuffer(uint16_t ***pu16Framebuffer)
write framebuffer to LCD via SPI
Definition: Driver.c:341
LCD_TYPE_ILI
@ LCD_TYPE_ILI
Definition: Driver.h:50
set
set(srcs "LCD.c" "Driver.c" "Example_Main.c") idf_component_register(SRCS $
Definition: CMakeLists.txt:1
LCD_HOST
#define LCD_HOST
Definition: Driver.h:21
vDriver_getFramenufferPerLine
void vDriver_getFramenufferPerLine(uint16_t *pu16Dest, uint16_t u16Line, uint16_t u16Linect, uint16_t ***pu16Framebuffer)
Get the pixel data for a set of lines (with implied line size of 320)
Definition: Driver.c:374
PIN_NUM_DC
#define PIN_NUM_DC
Definition: Driver.h:29
vDriver_init
esp_err_t vDriver_init(void)
Initialize the driver.
Definition: Driver.c:130
iDriver_SendData
esp_err_t iDriver_SendData(const uint8_t *pu8Data, uint16_t u16Len)
Send data to the LCD.
Definition: Driver.c:276
vDriver_init
esp_err_t vDriver_init(void)
Initialize the driver.
Definition: Driver.c:130
vDriver_spiPreTransferCallback
void vDriver_spiPreTransferCallback(spi_transaction_t *t)
Pre Transfer Callback.
Definition: Driver.c:300
vDriver_GetId
uint32_t vDriver_GetId(void)
get LCD driver chip id
Definition: Driver.c:314
PIN_NUM_BCKL
#define PIN_NUM_BCKL
Definition: Driver.h:31
ili_init_cmds
static DRAM_ATTR const lcd_init_cmd_t ili_init_cmds[]
Definition: Driver.c:62
iDriver_writeFramebuffer
esp_err_t iDriver_writeFramebuffer(uint16_t ***pu16Framebuffer)
write framebuffer to LCD via SPI
Definition: Driver.c:341
PIN_NUM_CS
#define PIN_NUM_CS
Definition: Driver.h:27
sending_line
int16_t sending_line
Definition: Driver.c:16
iDriver_sendLines
static esp_err_t iDriver_sendLines(uint16_t u16Ypos, uint16_t *pu16Linedata)
send line to lcd chip
Definition: Driver.c:399
st_init_cmds
static DRAM_ATTR const lcd_init_cmd_t st_init_cmds[]
Definition: Driver.c:28
type_lcd_t
type_lcd_t
Definition: Driver.h:49
lines
uint16_t * lines[2]
Definition: Driver.c:15
PARALLEL_LINES
#define PARALLEL_LINES
Definition: Driver.h:38
pu16Framebuffer
uint16_t ** pu16Framebuffer
Definition: LCD.c:23
PIN_NUM_MISO
#define PIN_NUM_MISO
Definition: Driver.h:24
DMA_CHAN
#define DMA_CHAN
Definition: Driver.h:22
lcd_init_cmd_t::databytes
uint8_t databytes
Definition: Driver.h:46
PIN_NUM_RST
#define PIN_NUM_RST
Definition: Driver.h:30
iDriver_sendCmd
esp_err_t iDriver_sendCmd(const uint8_t u8Cmd)
Send a command to the LCD.
Definition: Driver.c:247
calc_line
int16_t calc_line
Definition: Driver.c:17
PIN_NUM_MOSI
#define PIN_NUM_MOSI
Definition: Driver.h:25
lcd_init_cmd_t::cmd
uint8_t cmd
Definition: Driver.h:44
lcd_init_cmd_t
Definition: Driver.h:43
Driver.h
spi
spi_device_handle_t spi
Definition: Driver.c:13