From 353c7e07d16a73a63fde4bfeb8cce8f8875291e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Mon, 6 May 2024 13:48:57 +0200 Subject: [PATCH] Wiphone (#3793) * add wiphone, still WIP * (very preliminary) wiphone support * undo config changes * revert extensions.json * eh? --- boards/wiphone.json | 34 ++++++++++++++++++ src/graphics/TFTDisplay.cpp | 6 ++++ src/platform/esp32/architecture.h | 2 ++ variants/wiphone/pins_arduino.h | 52 +++++++++++++++++++++++++++ variants/wiphone/platformio.ini | 13 +++++++ variants/wiphone/variant.h | 58 +++++++++++++++++++++++++++++++ 6 files changed, 165 insertions(+) create mode 100644 boards/wiphone.json create mode 100644 variants/wiphone/pins_arduino.h create mode 100644 variants/wiphone/platformio.ini create mode 100644 variants/wiphone/variant.h diff --git a/boards/wiphone.json b/boards/wiphone.json new file mode 100644 index 000000000..bb01f425f --- /dev/null +++ b/boards/wiphone.json @@ -0,0 +1,34 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32_out.ld", + "partitions": "default_16MB.csv" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_WIPHONE14", + "-DBOARD_HAS_PSRAM", + "-mfix-esp32-psram-cache-issue", + "-mfix-esp32-psram-cache-strategy=memw" + ], + "f_cpu": "240000000L", + "f_flash": "40000000L", + "flash_mode": "dio", + "mcu": "esp32", + "variant": "wiphone", + "board": "WiPhone" + }, + "connectivity": ["wifi", "bluetooth"], + "frameworks": ["arduino", "espidf"], + "name": "WIPhone Integrated 1.4", + "upload": { + "flash_size": "16MB", + "maximum_ram_size": 532480, + "maximum_size": 6553600, + "maximum_data_size": 4521984, + "require_upload_port": true, + "speed": 921600 + }, + "url": "https://www.wiphone.io/", + "vendor": "HackEDA" +} diff --git a/src/graphics/TFTDisplay.cpp b/src/graphics/TFTDisplay.cpp index fac9a5796..36397a826 100644 --- a/src/graphics/TFTDisplay.cpp +++ b/src/graphics/TFTDisplay.cpp @@ -8,6 +8,12 @@ #define TFT_BACKLIGHT_ON HIGH #endif +#ifdef GPIO_EXTENDER +#include +#include +extern SX1509 gpioExtender; +#endif + #ifndef TFT_MESH #define TFT_MESH COLOR565(0x67, 0xEA, 0x94) #endif diff --git a/src/platform/esp32/architecture.h b/src/platform/esp32/architecture.h index 27088f86f..45d533a76 100644 --- a/src/platform/esp32/architecture.h +++ b/src/platform/esp32/architecture.h @@ -143,6 +143,8 @@ #define HW_VENDOR meshtastic_HardwareModel_STATION_G2 #elif defined(UNPHONE) #define HW_VENDOR meshtastic_HardwareModel_UNPHONE +#elif defined(WIPHONE) +#define HW_VENDOR meshtastic_HardwareModel_WIPHONE #endif // ----------------------------------------------------------------------------- diff --git a/variants/wiphone/pins_arduino.h b/variants/wiphone/pins_arduino.h new file mode 100644 index 000000000..bca9c1173 --- /dev/null +++ b/variants/wiphone/pins_arduino.h @@ -0,0 +1,52 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#define EXTERNAL_NUM_INTERRUPTS 16 +#define NUM_DIGITAL_PINS 20 +#define NUM_ANALOG_INPUTS 16 + +#define analogInputToDigitalPin(p) (((p) < 20) ? (esp32_adc2gpio[(p)]) : -1) +#define digitalPinToInterrupt(p) (((p) < 40) ? (p) : -1) +#define digitalPinHasPWM(p) (p < 34) + +static const uint8_t TX = 1; +static const uint8_t RX = 3; + +static const uint8_t SDA = 21; +static const uint8_t SCL = 22; + +static const uint8_t SS = 5; +static const uint8_t MOSI = 23; +static const uint8_t MISO = 19; +static const uint8_t SCK = 18; + +static const uint8_t G23 = 23; +static const uint8_t G19 = 19; +static const uint8_t G18 = 18; +static const uint8_t G3 = 3; +static const uint8_t G16 = 16; +static const uint8_t G21 = 21; +static const uint8_t G2 = 2; +static const uint8_t G12 = 12; +static const uint8_t G15 = 15; +static const uint8_t G35 = 35; +static const uint8_t G36 = 36; +static const uint8_t G25 = 25; +static const uint8_t G26 = 26; +static const uint8_t G1 = 1; +static const uint8_t G17 = 17; +static const uint8_t G22 = 22; +static const uint8_t G5 = 5; +static const uint8_t G13 = 13; +static const uint8_t G0 = 0; +static const uint8_t G34 = 34; + +static const uint8_t DAC1 = 25; +static const uint8_t DAC2 = 26; + +static const uint8_t ADC1 = 35; +static const uint8_t ADC2 = 36; + +#endif /* Pins_Arduino_h */ diff --git a/variants/wiphone/platformio.ini b/variants/wiphone/platformio.ini new file mode 100644 index 000000000..10c0de55e --- /dev/null +++ b/variants/wiphone/platformio.ini @@ -0,0 +1,13 @@ +[env:wiphone] +extends = esp32_base +board = wiphone +monitor_filters = esp32_exception_decoder +board_build.partitions = default_16MB.csv +build_flags = + ${esp32_base.build_flags} -D WIPHONE -I variants/wiphone +lib_deps = + ${esp32_base.lib_deps} + lovyan03/LovyanGFX@^1.1.8 + sparkfun/SX1509 IO Expander@^3.0.5 + pololu/APA102@^3.0.0 + \ No newline at end of file diff --git a/variants/wiphone/variant.h b/variants/wiphone/variant.h new file mode 100644 index 000000000..b2b3ade78 --- /dev/null +++ b/variants/wiphone/variant.h @@ -0,0 +1,58 @@ +#define I2C_SDA 15 +#define I2C_SCL 25 + +#define GPIO_EXTENDER 1509 +#define EXTENDER_FLAG 0x40 +#define EXTENDER_PIN(x) (x + EXTENDER_FLAG) + +#undef RF95_SCK +#undef RF95_MISO +#undef RF95_MOSI +#undef RF95_NSS + +#define RF95_SCK 14 +#define RF95_MISO 12 +#define RF95_MOSI 13 +#define RF95_NSS 27 + +#define USE_RF95 +#define LORA_DIO0 38 +#define LORA_RESET RADIOLIB_NC +#define LORA_DIO1 RADIOLIB_NC +#define LORA_DIO2 RADIOLIB_NC + +// This board has no GPS or Screen for now +#undef GPS_RX_PIN +#undef GPS_TX_PIN +#define NO_GPS +#define HAS_GPS 0 +#define NO_SCREEN +#define HAS_SCREEN 0 + +// Default SPI1 will be mapped to the display +#define ST7789_SDA 23 +#define ST7789_SCK 18 +#define ST7789_CS 5 +#define ST7789_RS 26 +#define ST7789_BL -1 // EXTENDER_PIN(9) + +#define ST7789_RESET -1 +#define ST7789_MISO 19 +#define ST7789_BUSY -1 +#define ST7789_SPI_HOST SPI3_HOST +#define ST7789_BACKLIGHT_EN -1 // EXTENDER_PIN(9) +#define SPI_FREQUENCY 40000000 +#define SPI_READ_FREQUENCY 16000000 +#define TFT_HEIGHT 240 +#define TFT_WIDTH 320 +#define TFT_OFFSET_X 0 +#define TFT_OFFSET_Y 0 +#define TFT_OFFSET_ROTATION 0 +#define SCREEN_ROTATE +#define SCREEN_TRANSITION_FRAMERATE 5 + +#define I2S_MCLK_GPIO0 +#define I2S_BCK_PIN 4 // rev1.3 - 4 (wp05) +#define I2S_WS_PIN 33 +#define I2S_MOSI_PIN 21 +#define I2S_MISO_PIN 34 \ No newline at end of file