Skip to content

Commit ed0d308

Browse files
committed
Add SD support
1 parent 6af6213 commit ed0d308

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

hardware/ESP32S3_8048_TOUCH_LCD_7/components/bsp/bsp.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
#include "bsp.h"
2525

2626
#include "esp3d_log.h"
27-
27+
#include "driver/i2c.h"
28+
#include "esp_timer.h"
2829
#if ESP3D_DISPLAY_FEATURE
2930
#include "disp_def.h"
3031
#include "i2c_def.h"
@@ -35,6 +36,8 @@
3536
#include "usb_serial.h"
3637
#endif // ESP3D_USB_SERIAL_FEATURE
3738

39+
#define I2C_MASTER_TIMEOUT_MS 1000
40+
3841
/**********************
3942
* STATIC PROTOTYPES
4043
**********************/
@@ -150,7 +153,7 @@ esp_err_t bsp_init(void) {
150153
esp3d_log_e("Failed to register VSync event callback");
151154
return ESP_FAIL;
152155
}
153-
156+
#endif // ESP3D_DISPLAY_FEATURE
154157
/* i2c controller initialization */
155158
esp3d_log("Initializing i2C controller...");
156159
i2c_bus_handle = i2c_bus_create(I2C_PORT_NUMBER, &i2c_cfg);
@@ -159,8 +162,22 @@ esp_err_t bsp_init(void) {
159162
return ESP_FAIL;
160163
}
161164

165+
162166
//TODO: Enable IO expander
163167
// Which has : Touch Reset pin, Display Reset pin, Display Backlight pin, SD Cs pin
168+
uint8_t write_buf = 0x01;
169+
i2c_master_write_to_device(I2C_PORT_NUMBER, 0x24, &write_buf, 1, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
170+
171+
//Reset the touch screen. It is recommended that you reset the touch screen before using it.
172+
write_buf = 0x2C;
173+
i2c_master_write_to_device(I2C_PORT_NUMBER, 0x38, &write_buf, 1, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
174+
esp_rom_delay_us(100 * 1000);
175+
176+
write_buf = 0x2E;
177+
i2c_master_write_to_device(I2C_PORT_NUMBER, 0x38, &write_buf, 1, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
178+
esp_rom_delay_us(200 * 1000);
179+
180+
#if ESP3D_DISPLAY_FEATURE
164181

165182
/* Touch controller initialization */
166183
esp3d_log("Initializing touch controller...");

hardware/ESP32S3_8048_TOUCH_LCD_7/components/bsp/sd_def.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern "C" {
1414
#define ESP3D_SD_MOSI_PIN (11) // GPIO 11
1515
#define ESP3D_SD_MISO_PIN (13) // GPIO 13
1616
#define ESP3D_SD_CLK_PIN (12) // GPIO 12
17-
#define ESP3D_SD_CS_PIN (34) // GPIO 34 (we use GPIO34 because is not connected, because actually cs pin is connected to IO expander pin EXI03)
17+
#define ESP3D_SD_CS_PIN (-1) // GPIO -1 (we use -1 because actually cs pin is connected to IO expander pin EXI03)
1818

1919
// #define ESP3D_SD_DETECT_PIN (-1) //GPIO -1
2020
// #define ESP3D_SD_DETECT_VALUE (0) //LOW

hardware/common/sdkconfig/ESP32-S3/with_PSRAM/8MB_Flash

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ CONFIG_APP_COMPILE_TIME_DATE=y
384384
# CONFIG_APP_EXCLUDE_PROJECT_VER_VAR is not set
385385
# CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR is not set
386386
# CONFIG_APP_PROJECT_VER_FROM_CONFIG is not set
387-
CONFIG_APP_RETRIEVE_LEN_ELF_SHA=9
387+
CONFIG_APP_RETRIEVE_LEN_ELF_SHA=16
388388
# end of Application manager
389389

390390
CONFIG_ESP_ROM_HAS_CRC_LE=y
@@ -903,13 +903,12 @@ CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ=240
903903
#
904904
# Cache config
905905
#
906-
CONFIG_ESP32S3_INSTRUCTION_CACHE_16KB=y
907-
# CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB is not set
908-
CONFIG_ESP32S3_INSTRUCTION_CACHE_SIZE=0x4000
906+
# CONFIG_ESP32S3_INSTRUCTION_CACHE_16KB is not set
907+
CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y
908+
CONFIG_ESP32S3_INSTRUCTION_CACHE_SIZE=0x8000
909909
# CONFIG_ESP32S3_INSTRUCTION_CACHE_4WAYS is not set
910910
CONFIG_ESP32S3_INSTRUCTION_CACHE_8WAYS=y
911911
CONFIG_ESP32S3_ICACHE_ASSOCIATED_WAYS=8
912-
# CONFIG_ESP32S3_INSTRUCTION_CACHE_LINE_16B is not set
913912
CONFIG_ESP32S3_INSTRUCTION_CACHE_LINE_32B=y
914913
CONFIG_ESP32S3_INSTRUCTION_CACHE_LINE_SIZE=32
915914
# CONFIG_ESP32S3_DATA_CACHE_16KB is not set
@@ -1410,8 +1409,8 @@ CONFIG_LWIP_HOOK_IP6_INPUT_NONE=y
14101409
#
14111410
# mbedTLS
14121411
#
1413-
CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y
1414-
# CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC is not set
1412+
# CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC is not set
1413+
CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y
14151414
# CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC is not set
14161415
# CONFIG_MBEDTLS_CUSTOM_MEM_ALLOC is not set
14171416
CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y

0 commit comments

Comments
 (0)