Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP-IDF Release v4.0 Support & Open PR Consolidation #79

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
acf567a
Adding CMake support #68
mica-angeli Sep 8, 2019
b5b2f44
Fix compile errors. ESP-WROVER-KIT 4.1 menuconfig
Sep 8, 2019
d2913dd
Make invert and RST pins configurable.
jeremyjh Sep 8, 2019
3dfc5b2
Update demo for current framework.
jeremyjh Sep 14, 2019
84fe000
Add SPIFFS Kconfig; use idf_register_component
jeremyjh Sep 15, 2019
3b62707
Silence warnings. C++ compatibility.
jeremyjh Sep 15, 2019
ab5ef94
Remove unused imports. SPIFFS config has moved.
jeremyjh Sep 15, 2019
1e04a2b
Make height/width configurable and namespace the globals.
jeremyjh Sep 15, 2019
7d13ee8
Move display configuration into the library component.
jeremyjh Sep 15, 2019
abdebcc
Fix default and docs for SPIFFS.
jeremyjh Sep 15, 2019
6167d6e
Update to release/v4.0 and document idf_register_component installation.
jeremyjh Sep 15, 2019
c222304
Make all pins configurable.
jeremyjh Sep 15, 2019
bead8c0
Namespace all global variables.
jeremyjh Sep 15, 2019
e145cba
Remaining fixups from open PRs.
jeremyjh Sep 15, 2019
e098c86
Range needs to be in base 10.
jeremyjh Sep 15, 2019
3b1b357
Fixup touchscreen config notes.
jeremyjh Sep 15, 2019
a98a448
Make X/Y case consistent with other globals.
jeremyjh Sep 16, 2019
2017ad3
README tweaks.
jeremyjh Sep 16, 2019
855a17f
Expose RGB in config. Switch order around a bit.
jeremyjh Sep 17, 2019
c94fd5a
use config to feed default dimensions
jeremyjh Sep 19, 2019
fe621a5
Touch controller should be a choice. Remove config ifdefs.
jeremyjh Sep 20, 2019
c349761
Fix touch config; hide unused menuconfigs
jeremyjh Sep 22, 2019
cf34710
Fix invertDisplay. resolves #1
jeremyjh Oct 2, 2019
dd5ecde
Fix IDF 4.x compatibility
frhun Mar 21, 2020
fd47bd9
Add TTGO T-Display
frhun Mar 21, 2020
0933f83
Merge pull request #3 from frhun/ttgo-t-display
jeremyjh Mar 22, 2020
76208ed
Adding default inversion option
frhun Mar 22, 2020
2ba5509
Adding coordinate offsets
frhun Mar 22, 2020
8d7dc5a
More direct color inversion option naming
frhun Mar 25, 2020
a06a578
Merge pull request #4 from frhun/ttgo-t-display
jeremyjh Mar 26, 2020
17fc226
cmake: Declare nvs_flash as a dependency, instead of pushing absolute…
projectgus Jun 24, 2020
3a841fa
Merge pull request #10 from projectgus/bugfix/cmake_component_depende…
jeremyjh Jun 24, 2020
8016437
Adding support for the TTGO T-WRISTBAND support
gameofyou Jun 30, 2020
35be976
Merge pull request #11 from gameofyou/master
jeremyjh Jun 30, 2020
f4e07be
Fix const correctness in TFT functions
mlepage-google Jul 8, 2020
11d56bb
Fix typos in README
mlepage-google Jul 8, 2020
c12e296
Merge pull request #17 from mlepage-google/fix-const-correctness
jeremyjh Jul 9, 2020
42cadf2
Merge pull request #18 from mlepage-google/fix-typos-in-readme
jeremyjh Jul 9, 2020
3351a89
Add const qualifier to temp pointer to fix warning
mlepage-google Jul 23, 2020
a1ece2c
Merge pull request #21 from mlepage-google/master
jeremyjh Jul 24, 2020
82427a3
Remove tftspi.h from demo
jeremyjh Jun 2, 2021
fac22b3
Update README Regarding Current Status
jeremyjh Jun 2, 2021
9283df8
tftspi.h doesn't need to include itself.
jeremyjh Jun 2, 2021
f401699
Fixes for compiling with esp-idf v5.0
shubhamdp Jan 23, 2023
3344a81
Merge pull request #27 from shubhamdp/esp_idf_v5_0
jeremyjh Jan 23, 2023
a9482e3
Use the newer spi_flash APIs for read/write/erase flash operations
shubhamdp Jul 31, 2023
a6299b6
Merge pull request #28 from shubhamdp/support-idf-v5.1
jeremyjh Aug 1, 2023
edbb14c
Fix warnings when building with esp-idf v5.2.1
shubhamdp Jun 18, 2024
d99f5ef
Merge pull request #29 from shubhamdp/fix_warnings
jeremyjh Jun 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ sdkconfig.lobo
BUILD
PBUILD
build/
cmake-build-debug/
.idea/
temp/
local/
*.dis
*.elf
*.map
**/.DS_Store
mkspiffs/
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# The following lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)

#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --save-temps")
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(tft_demo)
201 changes: 128 additions & 73 deletions README.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions components/mkspiffs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set(COMPONENT_SRCDIRS "")
set(COMPONENT_ADD_INCLUDEDIRS "")
register_component()
Binary file added components/mkspiffs/src/mkspiffs
Binary file not shown.
31 changes: 30 additions & 1 deletion components/mkspiffs/src/spiffs/esp_spiffs.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@

#include "spiffs.h"

#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
#include <esp_flash.h>
#include <spi_flash_mmap.h>
#else
#include <esp_spi_flash.h>
#endif

s32_t esp32_spi_flash_read(u32_t addr, u32_t size, u8_t *dst) {
u32_t aaddr;
Expand Down Expand Up @@ -63,7 +68,11 @@ s32_t esp32_spi_flash_read(u32_t addr, u32_t size, u8_t *dst) {

abuff = (u8_t *)(((ptrdiff_t)buff + (4 - 1)) & (u32_t)-4);

#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
if (esp_flash_read(NULL, (void *)abuff, aaddr, asize) != ESP_OK) {
#else
if (spi_flash_read(aaddr, (void *)abuff, asize) != 0) {
#endif
free(buff);
return SPIFFS_ERR_INTERNAL;
}
Expand All @@ -72,7 +81,11 @@ s32_t esp32_spi_flash_read(u32_t addr, u32_t size, u8_t *dst) {

free(buff);
} else {
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
if (esp_flash_read(NULL, (void *)dst, addr, size) != ESP_OK) {
#else
if (spi_flash_read(addr, (void *)dst, size) != 0) {
#endif
return SPIFFS_ERR_INTERNAL;
}
}
Expand All @@ -87,7 +100,7 @@ s32_t esp32_spi_flash_write(u32_t addr, u32_t size, const u8_t *src) {
u32_t asize;

asize = size;

// Align address to 4 byte
aaddr = (addr + (4 - 1)) & -4;
if (aaddr != addr) {
Expand All @@ -107,21 +120,33 @@ s32_t esp32_spi_flash_write(u32_t addr, u32_t size, const u8_t *src) {

abuff = (u8_t *)(((ptrdiff_t)buff + (4 - 1)) & -4);

#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
if (esp_flash_read(NULL, (void *)abuff, aaddr, asize) != ESP_OK) {
#else
if (spi_flash_read(aaddr, (void *)abuff, asize) != 0) {
#endif
free(buff);
return SPIFFS_ERR_INTERNAL;
}

memcpy(abuff + (addr - aaddr), src, size);

#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
if (esp_flash_write(NULL, (uint32_t *)abuff, aaddr, asize) != ESP_OK) {
#else
if (spi_flash_write(aaddr, (uint32_t *)abuff, asize) != 0) {
#endif
free(buff);
return SPIFFS_ERR_INTERNAL;
}

free(buff);
} else {
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
if (esp_flash_write(NULL, (uint32_t *)src, addr, size) != ESP_OK) {
#else
if (spi_flash_write(addr, (uint32_t *)src, size) != 0) {
#endif
return SPIFFS_ERR_INTERNAL;
}
}
Expand All @@ -130,7 +155,11 @@ s32_t esp32_spi_flash_write(u32_t addr, u32_t size, const u8_t *src) {
}

s32_t IRAM_ATTR esp32_spi_flash_erase(u32_t addr, u32_t size) {
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
if (esp_flash_erase_region(NULL, addr, size) != ESP_OK) {
#else
if (spi_flash_erase_sector(addr >> 12) != 0) {
#endif
return SPIFFS_ERR_INTERNAL;
}

Expand Down
3 changes: 3 additions & 0 deletions components/spidriver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FILE(GLOB SOURCES *.c)
idf_component_register(SRCS ${SOURCES} INCLUDE_DIRS "."
PRIV_REQUIRES driver)
22 changes: 4 additions & 18 deletions components/spidriver/spi_master_lobo.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,30 +60,16 @@ Main driver's function is 'spi_lobo_transfer_data()'
*/
#include "freertos/FreeRTOS.h"
#include <string.h>
#include <stdio.h>
#include "soc/gpio_sig_map.h"
#include "soc/spi_reg.h"
#include "soc/dport_reg.h"
#include "soc/rtc_cntl_reg.h"
#include "rom/ets_sys.h"
#include "esp_types.h"
#include "esp_attr.h"
#include "esp_log.h"
#include "esp_err.h"
#include "freertos/semphr.h"
#include "freertos/xtensa_api.h"
#include "freertos/task.h"
#include "freertos/ringbuf.h"
#include "soc/soc.h"
#include "soc/dport_reg.h"
#include "soc/uart_struct.h"
#include "driver/uart.h"
#include "driver/gpio.h"
#include "driver/periph_ctrl.h"
#include "esp_heap_caps.h"
#include "driver/periph_ctrl.h"
#include "spi_master_lobo.h"

#include "driver/periph_ctrl.h"
#include "soc/gpio_periph.h"
#include "rom/gpio.h"

static spi_lobo_host_t *spihost[3] = {NULL};

Expand Down Expand Up @@ -635,8 +621,8 @@ esp_err_t spi_lobo_bus_remove_device(spi_lobo_device_handle_t handle)
if (spihost[handle->host_dev]->device[x] !=NULL) break;
}
if (x == NO_DEV) {
free(handle);
spi_lobo_bus_free(handle->host_dev, 1);
free(handle);
}
else free(handle);

Expand Down
3 changes: 1 addition & 2 deletions components/spidriver/spi_master_lobo.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
#include "freertos/semphr.h"
#include "soc/spi_struct.h"

#include "esp_intr.h"
#include "esp_intr_alloc.h"
#include "rom/lldesc.h"
#include "esp32/rom/lldesc.h"


#ifdef __cplusplus
Expand Down
3 changes: 3 additions & 0 deletions components/spiffs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FILE(GLOB SOURCES *.c)
idf_component_register(SRCS ${SOURCES} INCLUDE_DIRS "."
REQUIRES vfs spi_flash)
27 changes: 27 additions & 0 deletions components/spiffs/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
menu "TFT SPIFFS"

config SPIFFS_BASE_ADDR
int "SPIFFS Base address"
range 1048576 33546240
default 0x180000
help
Starting address of the SPIFFS area in ESP32 Flash

config SPIFFS_SIZE
int "SPIFFS Size in bytes"
range 262144 2097152
default 1048576

config SPIFFS_LOG_BLOCK_SIZE
int "SPIFFS Logical block size"
range 4096 65536
default 8192

config SPIFFS_LOG_PAGE_SIZE
int "SPIFFS Logical page size"
range 256 2048
default 256
help
Set it to the physical page size og the used SPI Flash chip.

endmenu
29 changes: 29 additions & 0 deletions components/spiffs/esp_spiffs.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@

#include "spiffs.h"

#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
#include <esp_flash.h>
#include <spi_flash_mmap.h>
#else
#include <esp_spi_flash.h>
#endif

s32_t IRAM_ATTR esp32_spi_flash_read(u32_t addr, u32_t size, u8_t *dst) {
u32_t aaddr;
Expand Down Expand Up @@ -63,7 +68,11 @@ s32_t IRAM_ATTR esp32_spi_flash_read(u32_t addr, u32_t size, u8_t *dst) {

abuff = (u8_t *)(((ptrdiff_t)buff + (4 - 1)) & (u32_t)-4);

#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
if (esp_flash_read(NULL, (void *)abuff, aaddr, asize) != ESP_OK) {
#else
if (spi_flash_read(aaddr, (void *)abuff, asize) != 0) {
#endif
free(buff);
return SPIFFS_ERR_INTERNAL;
}
Expand All @@ -72,7 +81,11 @@ s32_t IRAM_ATTR esp32_spi_flash_read(u32_t addr, u32_t size, u8_t *dst) {

free(buff);
} else {
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
if (esp_flash_read(NULL, (void *)dst, addr, size) != ESP_OK) {
#else
if (spi_flash_read(addr, (void *)dst, size) != 0) {
#endif
return SPIFFS_ERR_INTERNAL;
}
}
Expand Down Expand Up @@ -107,21 +120,33 @@ s32_t IRAM_ATTR esp32_spi_flash_write(u32_t addr, u32_t size, const u8_t *src) {

abuff = (u8_t *)(((ptrdiff_t)buff + (4 - 1)) & -4);

#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
if (esp_flash_read(NULL, (void *)abuff, aaddr, asize) != ESP_OK) {
#else
if (spi_flash_read(aaddr, (void *)abuff, asize) != 0) {
#endif
free(buff);
return SPIFFS_ERR_INTERNAL;
}

memcpy(abuff + (addr - aaddr), src, size);

#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
if (esp_flash_write(NULL, (uint32_t *)abuff, aaddr, asize) != ESP_OK) {
#else
if (spi_flash_write(aaddr, (uint32_t *)abuff, asize) != 0) {
#endif
free(buff);
return SPIFFS_ERR_INTERNAL;
}

free(buff);
} else {
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
if (esp_flash_write(NULL, (uint32_t *)src, addr, size) != ESP_OK) {
#else
if (spi_flash_write(addr, (uint32_t *)src, size) != 0) {
#endif
return SPIFFS_ERR_INTERNAL;
}
}
Expand All @@ -130,7 +155,11 @@ s32_t IRAM_ATTR esp32_spi_flash_write(u32_t addr, u32_t size, const u8_t *src) {
}

s32_t IRAM_ATTR esp32_spi_flash_erase(u32_t addr, u32_t size) {
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
if (esp_flash_erase_region(NULL, addr, size) != ESP_OK) {
#else
if (spi_flash_erase_sector(addr >> 12) != 0) {
#endif
return SPIFFS_ERR_INTERNAL;
}

Expand Down
2 changes: 1 addition & 1 deletion components/spiffs/spiffs_nucleus.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ static s32_t spiffs_populate_ix_map_v(
res = _spiffs_rd(fs, SPIFFS_OP_T_OBJ_LU2 | SPIFFS_OP_C_READ,
0, SPIFFS_PAGE_TO_PADDR(fs, pix), sizeof(spiffs_page_object_ix), (u8_t *)objix);
SPIFFS_CHECK_RES(res);
SPIFFS_VALIDATE_OBJIX(objix->p_hdr, obj_id, objix->p_hdr.span_ix);
//SPIFFS_VALIDATE_OBJIX(objix->p_hdr, obj_id, objix->p_hdr.span_ix);

// check if hdr is ok, and if objix range overlap with ix map range
if ((objix->p_hdr.flags & (SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_FINAL | SPIFFS_PH_FLAG_IXDELE)) ==
Expand Down
14 changes: 7 additions & 7 deletions components/spiffs/spiffs_vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ int spiffs_is_mounted = 0;

QueueHandle_t spiffs_mutex = NULL;

static int IRAM_ATTR vfs_spiffs_open(const char *path, int flags, int mode);
static ssize_t IRAM_ATTR vfs_spiffs_write(int fd, const void *data, size_t size);
static ssize_t IRAM_ATTR vfs_spiffs_read(int fd, void * dst, size_t size);
static int IRAM_ATTR vfs_spiffs_fstat(int fd, struct stat * st);
static int IRAM_ATTR vfs_spiffs_close(int fd);
static off_t IRAM_ATTR vfs_spiffs_lseek(int fd, off_t size, int mode);
static int vfs_spiffs_open(const char *path, int flags, int mode);
static ssize_t vfs_spiffs_write(int fd, const void *data, size_t size);
static ssize_t vfs_spiffs_read(int fd, void * dst, size_t size);
static int vfs_spiffs_fstat(int fd, struct stat * st);
static int vfs_spiffs_close(int fd);
static off_t vfs_spiffs_lseek(int fd, off_t size, int mode);

typedef struct {
DIR dir;
Expand Down Expand Up @@ -92,7 +92,7 @@ static u8_t *my_spiffs_cache;

//----------------------------------------------------
void spiffs_fs_stat(uint32_t *total, uint32_t *used) {
if (SPIFFS_info(&fs, total, used) != SPIFFS_OK) {
if (SPIFFS_info(&fs, (u32_t *)total, (u32_t *)used) != SPIFFS_OK) {
*total = 0;
*used = 0;
}
Expand Down
3 changes: 3 additions & 0 deletions components/spiffs_image/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set(COMPONENT_SRCDIRS "")
set(COMPONENT_ADD_INCLUDEDIRS "")
register_component()
5 changes: 5 additions & 0 deletions components/tft/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FILE(GLOB SOURCES *.c)
idf_component_register(SRCS ${SOURCES}
INCLUDE_DIRS "."
REQUIRES spidriver
PRIV_REQUIRES driver)
Loading