Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 14 additions & 0 deletions .github/workflows/buil_parallel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,20 @@ jobs:
family: "ESP32-S3",
partitions: { bootloader_addr: "0x0" },
}
- {
vendor: "Lilygo",
name: "Lilygo T-Display-S3 (SD_MMC)",
env: "lilygo-t-display-s3-mmc",
family: "ESP32-S3",
partitions: { bootloader_addr: "0x0" },
}
- {
vendor: "Lilygo",
name: "Lilygo T-Display-S3 Touch (SD_MMC)",
env: "lilygo-t-display-s3-touch-mmc",
family: "ESP32-S3",
partitions: { bootloader_addr: "0x0" },
}
- {
vendor: "Smoochiee",
name: "Smoochiee-Board",
Expand Down
27 changes: 8 additions & 19 deletions boards/_boards_json/lilygo-t-display-s3.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,16 @@
"-DBOARD_HAS_PSRAM",
"-DARDUINO_RUNNING_CORE=1",
"-DARDUINO_EVENT_RUNNING_CORE=1",
"-DARDUINO_USB_CDC_ON_BOOT",
"-DARDUINO_USB_MODE=1"
],
"f_cpu": "240000000L",
"f_flash": "80000000L",
"flash_mode": "qio",
"hwids": [
[
"0x239A",
"0x811B"
],
[
"0x239A",
"0x011B"
],
[
"0x239A",
"0x811C"
"0X303A",
"0x1001"
]
],
"mcu": "esp32s3",
Expand All @@ -38,11 +31,7 @@
"wifi"
],
"debug": {
"default_tool": "esp-builtin",
"onboard_tools": [
"esp-builtin"
],
"openocd_target": "esp32s3.cfg"
"openocd_target": "esp32s3-builtin.cfg"
},
"frameworks": [
"arduino",
Expand All @@ -54,8 +43,8 @@
"maximum_ram_size": 327680,
"maximum_size": 16777216,
"require_upload_port": true,
"speed": 460800
"speed": 921600
},
"url": "https://www.lilygo.cc",
"vendor": "LilyGo"
}
"url": "https://www.lilygo.cc/products/t-display-s3",
"vendor": "LILYGO"
}
33 changes: 18 additions & 15 deletions boards/lilygo-t-display-s3/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
#include <globals.h>
#include <interface.h>

// #include <SD_MMC.h>
// #define PIN_SD_CMD 13
// #define PIN_SD_CLK 11
// #define PIN_SD_D0 12
#ifdef USE_SD_MMC
#define PIN_SD_CMD 13
#define PIN_SD_CLK 11
#define PIN_SD_D0 12
#endif
#ifdef HAS_TOUCH
#define TOUCH_MODULES_CST_SELF
#include <TouchLib.h>
Expand Down Expand Up @@ -41,7 +42,9 @@ Button *btn2;
void _setup_gpio() {

#ifdef HAS_TOUCH
// SD_MMC.setPins(PIN_SD_CLK, PIN_SD_CMD, PIN_SD_D0);
#ifdef USE_SD_MMC
SD.setPins(PIN_SD_CLK, PIN_SD_CMD, PIN_SD_D0);
#endif

gpio_hold_dis((gpio_num_t)21); // PIN_TOUCH_RES
pinMode(15, OUTPUT);
Expand All @@ -60,21 +63,19 @@ void _setup_gpio() {
.type = BUTTON_TYPE_GPIO,
.long_press_time = 600,
.short_press_time = 120,
.gpio_button_config =
{
.gpio_num = DW_BTN,
.active_level = 0,
},
.gpio_button_config = {
.gpio_num = DW_BTN,
.active_level = 0,
},
};
button_config_t bt2 = {
.type = BUTTON_TYPE_GPIO,
.long_press_time = 600,
.short_press_time = 120,
.gpio_button_config =
{
.gpio_num = UP_BTN,
.active_level = 0,
},
.gpio_button_config = {
.gpio_num = UP_BTN,
.active_level = 0,
},
};
pinMode(SEL_BTN, INPUT_PULLUP);

Expand Down Expand Up @@ -105,6 +106,8 @@ void _setup_gpio() {

bruceConfig.irRx = RXLED;
bruceConfig.irTx = LED;

Serial.begin(115200);
}

/***************************************************************************************
Expand Down
46 changes: 22 additions & 24 deletions boards/lilygo-t-display-s3/lilygo-t-display-s3.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,11 @@ build_flags =
-DREDRAW_DELAY=1 # Used to improve navigation on menus for this device
-DMIC_SPM1423

-UARDUINO_USB_CDC_ON_BOOT #Turn off CDC on boot https://github.com/Xinyuan-LilyGO/T-Display-S3
-DALLOW_ALL_GPIO_FOR_IR_RF=1 ; Set this option to make use of all GPIOs, from 1 to 44 to be chosen, except TFT and SD pins

;-UARDUINO_USB_CDC_ON_BOOT #Turn off CDC on boot https://github.com/Xinyuan-LilyGO/T-Display-S3
-DDISABLE_ALL_LIBRARY_WARNINGS

;Infrared Led default pin and state
-DIR_TX_PINS='{{"Pin 43", 43}, {"Pin 44", 44}}'
-DIR_RX_PINS='{{"Pin 43", 43}, {"Pin 44", 44}}'

;Radio Frequency (one pin modules) pin setting
-DRF_TX_PINS='{{"Pin 43", 43}, {"Pin 44", 44}}'
-DRF_RX_PINS='{{"Pin 43", 43}, {"Pin 44", 44}}'

;CC1101 support SPI
-DUSE_CC1101_VIA_SPI
-DCC1101_GDO0_PIN=44
-DCC1101_SS_PIN=43
-DCC1101_MOSI_PIN=SPI_MOSI_PIN
-DCC1101_SCK_PIN=SPI_SCK_PIN
-DCC1101_MISO_PIN=SPI_MISO_PIN

;NRF24 support SPI
-DUSE_NRF24_VIA_SPI
-DNRF24_CE_PIN=3
-DNRF24_SS_PIN=SPI_SS_PIN
-DNRF24_MOSI_PIN=SPI_MOSI_PIN
-DNRF24_SCK_PIN=SPI_SCK_PIN
-DNRF24_MISO_PIN=SPI_MISO_PIN
lib_deps =
${env.lib_deps}
fastled/FastLED @3.9.4
Expand All @@ -48,3 +27,22 @@ extends = env:lilygo-t-display-s3
build_flags =
${env:lilygo-t-display-s3.build_flags}
-DHAS_TOUCH=1

[env:lilygo-t-display-s3-mmc]
extends = env:lilygo-t-display-s3
build_flags =
${env:lilygo-t-display-s3.build_flags}
-DUSE_SD_MMC=1
lib_ignore =
SD


[env:lilygo-t-display-s3-touch-mmc]
extends = env:lilygo-t-display-s3
build_flags =
${env:lilygo-t-display-s3.build_flags}
-DHAS_TOUCH=1
-DUSE_SD_MMC=1
lib_ignore =
SD

66 changes: 60 additions & 6 deletions boards/lilygo-t-display-s3/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,69 @@
// Lite Version
// #define LITE_VERSION 1

// Main I2C Bus
// Main SPI Bus
#ifdef USE_SD_MMC

// Willy board definitions
#define SPI_SS_PIN 1
#define SPI_MOSI_PIN 3
#define SPI_MISO_PIN 2
#define SPI_SCK_PIN 43

#define SDCARD_CS -1
#define SDCARD_SCK -1
#define SDCARD_MISO -1
#define SDCARD_MOSI -1

#define USE_CC1101_VIA_SPI
#define CC1101_GDO0_PIN 44
#define CC1101_SS_PIN 1
#define CC1101_MOSI_PIN 3
#define CC1101_SCK_PIN 43
#define CC1101_MISO_PIN 2

#define USE_NRF24_VIA_SPI
#define NRF24_CE_PIN 44
#define NRF24_SS_PIN 1
#define NRF24_MOSI_PIN 3
#define NRF24_SCK_PIN 43
#define NRF24_MISO_PIN 2

#else

#define SPI_SS_PIN 10
#define SPI_MOSI_PIN 11
#define SPI_MISO_PIN 13
#define SPI_SCK_PIN 12

#define SDCARD_CS SPI_SS_PIN
#define SDCARD_SCK SPI_SCK_PIN
#define SDCARD_MISO SPI_MISO_PIN
#define SDCARD_MOSI SPI_MOSI_PIN

#define USE_CC1101_VIA_SPI
#define CC1101_GDO0_PIN 44
#define CC1101_SS_PIN 43
#define CC1101_MOSI_PIN SPI_MOSI_PIN
#define CC1101_SCK_PIN SPI_SCK_PIN
#define CC1101_MISO_PIN SPI_MISO_PIN

#define USE_NRF24_VIA_SPI
#define NRF24_CE_PIN 3
#define NRF24_SS_PIN SPI_SS_PIN
#define NRF24_MOSI_PIN SPI_MOSI_PIN
#define NRF24_SCK_PIN SPI_SCK_PIN
#define NRF24_MISO_PIN SPI_MISO_PIN
#endif

static const uint8_t SS = SPI_SS_PIN;
static const uint8_t MOSI = SPI_MOSI_PIN;
static const uint8_t SCK = SPI_MISO_PIN;
static const uint8_t MISO = SPI_SCK_PIN;

// Set Main I2C Bus
#define GROVE_SDA 44
#define GROVE_SCL 43
#define GROVE_SDA 17
#define GROVE_SCL 16
static const uint8_t SDA = GROVE_SDA;
static const uint8_t SCL = GROVE_SCL;

Expand Down Expand Up @@ -64,8 +114,8 @@ static const uint8_t SCL = GROVE_SCL;
#define FG 3

// Serial
#define SERIAL_TX 43
#define SERIAL_RX 44
#define SERIAL_TX 16
#define SERIAL_RX 17

// Battery PIN
#define PIN_POWER_ON 15
Expand All @@ -81,12 +131,16 @@ static const uint8_t SCL = GROVE_SCL;
#define SEL_BTN 16
#define UP_BTN 0
#define DW_BTN 14
#define BK_BTN 3
#define BTN_ACT LOW

// IR pins
#ifdef USE_SD_MMC
#define LED 10
#define RXLED 44
#else
#define LED 44
#define RXLED 43
#endif
#define LED_ON HIGH
#define LED_OFF LOW

Expand Down
93 changes: 93 additions & 0 deletions lib/HAL/SD.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#ifndef __SDM__H
#define __SDM__H
#include <FS.h>

// #define USE_SD_MMC // test, delete later

#ifdef USE_SD_MMC
#include "sdkconfig.h"
#include "soc/soc_caps.h"
#ifndef SOC_SDMMC_HOST_SUPPORTED

#ifdef ARDUINO
#warning The SDMMC library requires a device with an SDIO Host
#endif

#else
#include "driver/sdmmc_types.h"
#include "sd_defines.h"
#ifndef BOARD_MAX_SDMMC_FREQ
#define BOARD_MAX_SDMMC_FREQ SDMMC_FREQ_HIGHSPEED
#endif
#endif

#else
#include <SPI.h>
#include <sd_diskio.h>
#endif

namespace fs {

class SDFS : public FS {
#ifdef USE_SD_MMC
protected:
sdmmc_card_t *_card;
int8_t _pin_clk = -1;
int8_t _pin_cmd = -1;
int8_t _pin_d0 = -1;
int8_t _pin_d1 = -1;
int8_t _pin_d2 = -1;
int8_t _pin_d3 = -1;
#ifdef SOC_SDMMC_IO_POWER_EXTERNAL
int8_t _power_channel = -1;
#endif
uint8_t _pdrv = 0xFF;
bool _mode1bit = false;

private:
static bool sdmmcDetachBus(void *bus_pointer);

public:
bool setPins(int clk, int cmd, int d0);
bool setPins(int clk, int cmd, int d0, int d1, int d2, int d3);
#ifdef SOC_SDMMC_IO_POWER_EXTERNAL
bool setPowerChannel(int power_channel);
#endif
bool begin(
const char *mountpoint = "/sdcard", bool mode1bit = false, bool format_if_mount_failed = false,
int sdmmc_frequency = BOARD_MAX_SDMMC_FREQ, uint8_t maxOpenFiles = 5
);

#else
protected:
uint8_t _pdrv;

public:
bool begin(
uint8_t ssPin = SS, SPIClass &spi = SPI, uint32_t frequency = 4000000, const char *mountpoint = "/sd",
uint8_t max_files = 5, bool format_if_empty = false
);
#endif

SDFS(FSImplPtr impl);

void end();
sdcard_type_t cardType();
uint64_t cardSize();
size_t numSectors();
size_t sectorSize();
uint64_t totalBytes();
uint64_t usedBytes();
bool readRAW(uint8_t *buffer, uint32_t sector);
bool writeRAW(uint8_t *buffer, uint32_t sector);
};

} // namespace fs

extern fs::SDFS SD;

using namespace fs;
typedef fs::File SDFile;
typedef fs::SDFS SDFileSystemClass;
#define SDFileSystem SD
#endif
Loading