From 94d9807b47975e370ab4d1ce7aa582fb610665b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20BOU=C3=89?= Date: Sun, 13 Oct 2024 20:01:21 +0000 Subject: [PATCH] [Board]: Support for M5Stack CoreS3 (Part 1: radio) --- src/platform/esp32/architecture.h | 2 + variants/m5stack_cores3/pins_arduino.h | 63 ++++++++++++++++++++++++++ variants/m5stack_cores3/platformio.ini | 14 ++++++ variants/m5stack_cores3/variant.h | 22 +++++++++ 4 files changed, 101 insertions(+) create mode 100644 variants/m5stack_cores3/pins_arduino.h create mode 100644 variants/m5stack_cores3/platformio.ini create mode 100644 variants/m5stack_cores3/variant.h diff --git a/src/platform/esp32/architecture.h b/src/platform/esp32/architecture.h index 01f4166296..ba3050e9ab 100644 --- a/src/platform/esp32/architecture.h +++ b/src/platform/esp32/architecture.h @@ -104,6 +104,8 @@ #define HW_VENDOR meshtastic_HardwareModel_NANO_G1 #elif defined(M5STACK) #define HW_VENDOR meshtastic_HardwareModel_M5STACK +#elif defined(M5STACK_CORES3) +#define HW_VENDOR meshtastic_HardwareModel_M5STACK_CORES3 #elif defined(STATION_G1) #define HW_VENDOR meshtastic_HardwareModel_STATION_G1 #elif defined(DR_DEV) diff --git a/variants/m5stack_cores3/pins_arduino.h b/variants/m5stack_cores3/pins_arduino.h new file mode 100644 index 0000000000..78e9369907 --- /dev/null +++ b/variants/m5stack_cores3/pins_arduino.h @@ -0,0 +1,63 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include "soc/soc_caps.h" +#include + +#define USB_VID 0x303a +#define USB_PID 0x1001 + +// Some boards have too low voltage on this pin (board design bug) +// Use different pin with 3V and connect with 48 +// and change this setup for the chosen pin (for example 38) +static const uint8_t LED_BUILTIN = SOC_GPIO_PIN_COUNT + 48; +#define BUILTIN_LED LED_BUILTIN // backward compatibility +#define LED_BUILTIN LED_BUILTIN +#define RGB_BUILTIN LED_BUILTIN +#define RGB_BRIGHTNESS 64 + +static const uint8_t TX = 43; +static const uint8_t RX = 44; + +static const uint8_t TXD2 = 17; +static const uint8_t RXD2 = 18; + +static const uint8_t SDA = 12; +static const uint8_t SCL = 11; + +static const uint8_t SS = 15; +static const uint8_t MOSI = 37; +static const uint8_t MISO = 35; +static const uint8_t SCK = 36; + +static const uint8_t G0 = 0; +static const uint8_t G1 = 1; +static const uint8_t G2 = 2; +static const uint8_t G3 = 3; +static const uint8_t G4 = 4; +static const uint8_t G5 = 5; +static const uint8_t G6 = 6; +static const uint8_t G7 = 7; +static const uint8_t G8 = 8; +static const uint8_t G9 = 9; +static const uint8_t G11 = 11; +static const uint8_t G12 = 12; +static const uint8_t G13 = 13; +static const uint8_t G14 = 14; +static const uint8_t G17 = 17; +static const uint8_t G18 = 18; +static const uint8_t G19 = 19; +static const uint8_t G20 = 20; +static const uint8_t G21 = 21; +static const uint8_t G33 = 33; +static const uint8_t G34 = 34; +static const uint8_t G35 = 35; +static const uint8_t G36 = 36; +static const uint8_t G37 = 37; +static const uint8_t G38 = 38; +static const uint8_t G45 = 45; +static const uint8_t G46 = 46; + +static const uint8_t ADC = 10; + +#endif /* Pins_Arduino_h */ diff --git a/variants/m5stack_cores3/platformio.ini b/variants/m5stack_cores3/platformio.ini new file mode 100644 index 0000000000..fc73fabaea --- /dev/null +++ b/variants/m5stack_cores3/platformio.ini @@ -0,0 +1,14 @@ +; M5stack CoreS3 +[env:m5stack-cores3] +extends = esp32s3_base +board = m5stack-cores3 +board_check = true +upload_protocol = esptool + +build_flags = ${esp32_base.build_flags} + -DPRIVATE_HW + -DM5STACK_CORES3 + -Ivariants/m5stack_cores3 + +lib_deps = + ${esp32_base.lib_deps} diff --git a/variants/m5stack_cores3/variant.h b/variants/m5stack_cores3/variant.h new file mode 100644 index 0000000000..2ad4fcbddd --- /dev/null +++ b/variants/m5stack_cores3/variant.h @@ -0,0 +1,22 @@ +#define I2C_SDA 12 +#define I2C_SCL 11 + +#undef LORA_SCK +#undef LORA_MISO +#undef LORA_MOSI +#undef LORA_CS + +#define LORA_SCK 36 +#define LORA_MISO 35 +#define LORA_MOSI 37 +#define LORA_CS 6 // NSS + +#define USE_RF95 +#define LORA_DIO0 14 // IRQ +#define LORA_RESET 5 // RESET +#define LORA_RST 5 // RESET +#define LORA_IRQ 14 // DIO0 +#define LORA_DIO1 RADIOLIB_NC // Not really used +#define LORA_DIO2 RADIOLIB_NC // Not really used + +#define HAS_AXP2101