-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
7,475 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +0,0 @@ | ||
[submodule "components/drivers"] | ||
path = components/drivers | ||
url = https://github.com/pebri86/esplay-drivers | ||
Submodule drivers
deleted from
9888dd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
menu "LittleV Graphics Library" | ||
|
||
config USE_LVGL_LIBRARY | ||
bool "Use LVGL library" | ||
|
||
config USE_LVGL | ||
int | ||
default 1 if USE_LVGL_LIBRARY | ||
|
||
endmenu | ||
|
||
menu "SDCard Configuration" | ||
|
||
config SDIO_DAT2_DISABLED | ||
bool "Disable the DAT2 in SDIO slave" | ||
default y | ||
help | ||
SDIO slave DAT pin is unfortunately the same pin as MTDI, which | ||
controls the flash power voltage. For 3.3v flash devkits / modules / | ||
kits, it conflicts with the DAT2 pullups required by the | ||
specification. | ||
|
||
This disables the peripheral input from the DAT2 so that we can work | ||
in 1-bit mode when DAT2 is floating (pulled down). 4-bit mode is | ||
therefore unavailable. | ||
|
||
endmenu | ||
|
||
menu "Hardware configuration" | ||
|
||
choice EMULATOR_HARDWARE | ||
prompt "Hardware to run on" | ||
default ESPLAY20_HW | ||
help | ||
This emulator can run on various types of hardware. Select what you have here. | ||
|
||
config ESPLAY20_HW | ||
bool "ESPlay 2.0 Hardware" | ||
|
||
config ESPLAY_MICRO_HW | ||
bool "ESPlay Micro Hardware" | ||
|
||
config HW_CUSTOM | ||
bool "Custom hardware" | ||
|
||
endchoice | ||
|
||
choice HW_LCD_TYPE_SEL | ||
prompt "LCD type" | ||
default HW_LCD_TYPE_ILI9341 | ||
depends on HW_CUSTOM | ||
|
||
config HW_LCD_TYPE_ILI9341 | ||
bool "ILI9341 LCD" | ||
|
||
config HW_LCD_TYPE_ILI9342 | ||
bool "ILI9342 LCD" | ||
|
||
endchoice | ||
|
||
config HW_LCD_TYPE | ||
int | ||
default 0 if ESPLAY20_HW | ||
default 0 if ESPLAY_MICRO_HW | ||
default 0 if HW_LCD_TYPE_ILI9341 | ||
default 1 if HW_LCD_TYPE_ILI9342 | ||
|
||
endmenu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# esplay-drivers | ||
|
||
HAL drivers for ESPlay - portable game console based on ESP32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# | ||
# Component Makefile | ||
# | ||
# This Makefile can be left empty. By default, it will take the sources in the | ||
# src/ directory, compile them and link them into lib(subdirectory_name).a | ||
# in the build directory. This behaviour is entirely configurable, | ||
# please read the ESP-IDF documents if you need to do this. | ||
# | ||
|
||
#CFLAGS += -Dmfp16-format=ieee -Dmfpu=neon-fp16 | ||
#COMPONENT_DEPENDS := | ||
COMPONENT_SRCDIRS := . audio display input system storage | ||
COMPONENT_ADD_INCLUDEDIRS := $(COMPONENT_SRCDIRS) .. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
/** | ||
* @file disp_spi.c | ||
* | ||
*/ | ||
|
||
/********************* | ||
* INCLUDES | ||
*********************/ | ||
#include "disp_spi.h" | ||
#include "esp_system.h" | ||
#include "driver/gpio.h" | ||
#include "driver/spi_master.h" | ||
#include <string.h> | ||
|
||
/********************* | ||
* DEFINES | ||
*********************/ | ||
/*Clock out at 40 MHz*/ | ||
#define SPI_CLOCK_SPEED 60000000 | ||
|
||
/********************** | ||
* TYPEDEFS | ||
**********************/ | ||
|
||
/********************** | ||
* STATIC PROTOTYPES | ||
**********************/ | ||
static spi_device_handle_t spi; | ||
static void disp_spi_pre_transfer_callback(spi_transaction_t *t); | ||
|
||
/********************** | ||
* STATIC VARIABLES | ||
**********************/ | ||
|
||
/********************** | ||
* MACROS | ||
**********************/ | ||
|
||
/********************** | ||
* GLOBAL FUNCTIONS | ||
**********************/ | ||
void disp_spi_init(void) | ||
{ | ||
PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[DISP_SPI_DC], PIN_FUNC_GPIO); | ||
gpio_set_direction(DISP_SPI_DC, GPIO_MODE_OUTPUT); | ||
esp_err_t ret; | ||
|
||
spi_bus_config_t buscfg = { | ||
.miso_io_num = -1, | ||
.mosi_io_num = DISP_SPI_MOSI, | ||
.sclk_io_num = DISP_SPI_CLK, | ||
.quadwp_io_num = -1, | ||
.quadhd_io_num = -1, | ||
.max_transfer_sz = 8 * 320 * 2 + 8}; | ||
|
||
spi_device_interface_config_t devcfg = { | ||
.clock_speed_hz = SPI_CLOCK_SPEED, | ||
.mode = 0, //SPI mode 0 | ||
.spics_io_num = DISP_SPI_CS, //CS pin | ||
.queue_size = 7, | ||
.pre_cb = disp_spi_pre_transfer_callback, | ||
.post_cb = NULL, | ||
//.flags=SPI_DEVICE_NO_DUMMY | ||
}; | ||
|
||
//Initialize the SPI bus | ||
ret = spi_bus_initialize(VSPI_HOST, &buscfg, 1); | ||
assert(ret == ESP_OK); | ||
|
||
//Attach the LCD to the SPI bus | ||
ret = spi_bus_add_device(VSPI_HOST, &devcfg, &spi); | ||
assert(ret == ESP_OK); | ||
} | ||
|
||
void send_lines(int ypos, int width, uint16_t *linedata, int lineCount) | ||
{ | ||
esp_err_t ret; | ||
int x; | ||
static spi_transaction_t trans[6]; | ||
|
||
for (x = 0; x < 6; x++) | ||
{ | ||
memset(&trans[x], 0, sizeof(spi_transaction_t)); | ||
if ((x & 1) == 0) | ||
{ | ||
//Even transfers are commands | ||
trans[x].length = 8; | ||
trans[x].user = (void *)0; | ||
} | ||
else | ||
{ | ||
//Odd transfers are data | ||
trans[x].length = 8 * 4; | ||
trans[x].user = (void *)1; | ||
} | ||
trans[x].flags = SPI_TRANS_USE_TXDATA; | ||
} | ||
trans[0].tx_data[0] = 0x2A; //Column Address Set | ||
trans[1].tx_data[0] = 0; //Start Col High | ||
trans[1].tx_data[1] = 0; //Start Col Low | ||
trans[1].tx_data[2] = (width - 1) >> 8; //End Col High | ||
trans[1].tx_data[3] = (width - 1) & 0xff; //End Col Low | ||
trans[2].tx_data[0] = 0x2B; //Page address set | ||
trans[3].tx_data[0] = ypos >> 8; //Start page high | ||
trans[3].tx_data[1] = ypos & 0xff; //start page low | ||
trans[3].tx_data[2] = (ypos + lineCount) >> 8; //end page high | ||
trans[3].tx_data[3] = (ypos + lineCount) & 0xff; //end page low | ||
trans[4].tx_data[0] = 0x2C; //memory write | ||
trans[5].tx_buffer = linedata; //finally send the line data | ||
trans[5].length = width * 2 * 8 * lineCount; //Data length, in bits | ||
trans[5].flags = 0; //undo SPI_TRANS_USE_TXDATA flag | ||
|
||
//Queue all transactions. | ||
for (x = 0; x < 6; x++) | ||
{ | ||
ret = spi_device_queue_trans(spi, &trans[x], portMAX_DELAY); | ||
assert(ret == ESP_OK); | ||
} | ||
} | ||
|
||
void send_lines_ext(int ypos, int xpos, int width, uint16_t *linedata, int lineCount) | ||
{ | ||
esp_err_t ret; | ||
int x; | ||
static spi_transaction_t trans[6]; | ||
|
||
for (x = 0; x < 6; x++) | ||
{ | ||
memset(&trans[x], 0, sizeof(spi_transaction_t)); | ||
if ((x & 1) == 0) | ||
{ | ||
//Even transfers are commands | ||
trans[x].length = 8; | ||
trans[x].user = (void *)0; | ||
} | ||
else | ||
{ | ||
//Odd transfers are data | ||
trans[x].length = 8 * 4; | ||
trans[x].user = (void *)1; | ||
} | ||
trans[x].flags = SPI_TRANS_USE_TXDATA; | ||
} | ||
trans[0].tx_data[0] = 0x2A; //Column Address Set | ||
trans[1].tx_data[0] = xpos >> 8; //Start Col High | ||
trans[1].tx_data[1] = xpos & 0xff; //Start Col Low | ||
trans[1].tx_data[2] = (width + xpos - 1) >> 8; //End Col High | ||
trans[1].tx_data[3] = (width + xpos - 1) & 0xff; //End Col Low | ||
trans[2].tx_data[0] = 0x2B; //Page address set | ||
trans[3].tx_data[0] = ypos >> 8; //Start page high | ||
trans[3].tx_data[1] = ypos & 0xff; //start page low | ||
trans[3].tx_data[2] = (ypos + lineCount) >> 8; //end page high | ||
trans[3].tx_data[3] = (ypos + lineCount) & 0xff; //end page low | ||
trans[4].tx_data[0] = 0x2C; //memory write | ||
trans[5].tx_buffer = linedata; //finally send the line data | ||
trans[5].length = width * 2 * 8 * lineCount; //Data length, in bits | ||
trans[5].flags = 0; //undo SPI_TRANS_USE_TXDATA flag | ||
|
||
//Queue all transactions. | ||
for (x = 0; x < 6; x++) | ||
{ | ||
ret = spi_device_queue_trans(spi, &trans[x], portMAX_DELAY); | ||
assert(ret == ESP_OK); | ||
} | ||
} | ||
|
||
void send_line_finish(void) | ||
{ | ||
spi_transaction_t *rtrans; | ||
esp_err_t ret; | ||
//Wait for all 6 transactions to be done and get back the results. | ||
for (int x = 0; x < 6; x++) | ||
{ | ||
ret = spi_device_get_trans_result(spi, &rtrans, portMAX_DELAY); | ||
assert(ret == ESP_OK); | ||
} | ||
} | ||
|
||
void disp_spi_send(uint8_t *data, uint16_t length, int dc) | ||
{ | ||
if (length == 0) | ||
return; //no need to send anything | ||
|
||
spi_transaction_t t; | ||
memset(&t, 0, sizeof(t)); //Zero out the transaction | ||
t.length = length * 8; //Length is in bytes, transaction length is in bits. | ||
t.tx_buffer = data; //Data | ||
t.user = (void *)dc; | ||
|
||
spi_device_queue_trans(spi, &t, portMAX_DELAY); | ||
|
||
spi_transaction_t *rt; | ||
spi_device_get_trans_result(spi, &rt, portMAX_DELAY); | ||
} | ||
|
||
/********************** | ||
* STATIC FUNCTIONS | ||
**********************/ | ||
static void disp_spi_pre_transfer_callback(spi_transaction_t *t) | ||
{ | ||
int dc = (int)t->user; | ||
gpio_set_level(DISP_SPI_DC, dc); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* @file disp_spi.h | ||
* | ||
*/ | ||
|
||
#ifndef DISP_SPI_H | ||
#define DISP_SPI_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
|
||
/********************* | ||
* INCLUDES | ||
*********************/ | ||
#include <stdint.h> | ||
|
||
/********************* | ||
* DEFINES | ||
*********************/ | ||
|
||
#define DISP_SPI_MOSI 23 | ||
#define DISP_SPI_CLK 18 | ||
#define DISP_SPI_CS 5 | ||
#define DISP_SPI_DC 12 | ||
#define CMD_ON 0 | ||
#define DATA_ON 1 | ||
|
||
/********************** | ||
* TYPEDEFS | ||
**********************/ | ||
|
||
/********************** | ||
* GLOBAL PROTOTYPES | ||
**********************/ | ||
void disp_spi_init(void); | ||
void disp_spi_send(uint8_t *data, uint16_t length, int dc); | ||
void send_lines(int ypos, int width, uint16_t *linedata, int lineCount); | ||
void send_lines_ext(int ypos, int xpos, int width, uint16_t *linedata, int lineCount); | ||
void send_line_finish(void); | ||
|
||
/********************** | ||
* MACROS | ||
**********************/ | ||
|
||
#ifdef __cplusplus | ||
} /* extern "C" */ | ||
#endif | ||
|
||
#endif /*DISP_SPI_H*/ |
Oops, something went wrong.