From b508b2619a52f3e2ad3d998dcdaf0952a16eabca Mon Sep 17 00:00:00 2001
From: Seon Rozenblum <seon@unexpectedmaker.com>
Date: Tue, 31 Aug 2021 15:50:48 +1000
Subject: [PATCH] Added UM FeatherS2 Neo to boards.txt and added appropriate
 variants stuff.

---
 boards.txt                              | 137 ++++++++++++++++++++++--
 variants/um_feathers2neo/pins_arduino.h |  70 ++++++++++++
 2 files changed, 200 insertions(+), 7 deletions(-)
 create mode 100644 variants/um_feathers2neo/pins_arduino.h

diff --git a/boards.txt b/boards.txt
index 138cbcdbf2c..5575e216226 100644
--- a/boards.txt
+++ b/boards.txt
@@ -977,7 +977,7 @@ feathers2.build.variant=um_feathers2
 feathers2.build.board=FEATHERS2
 
 feathers2.build.cdc_on_boot=1
-feathers2.build.msc_on_boot=1
+feathers2.build.msc_on_boot=0
 feathers2.build.dfu_on_boot=0
 feathers2.build.f_cpu=240000000L
 feathers2.build.flash_size=16MB
@@ -992,10 +992,10 @@ feathers2.menu.CDCOnBoot.cdc.build.cdc_on_boot=1
 feathers2.menu.CDCOnBoot.default=Disabled
 feathers2.menu.CDCOnBoot.default.build.cdc_on_boot=0
 
-feathers2.menu.MSCOnBoot.msc=Enabled
-feathers2.menu.MSCOnBoot.msc.build.msc_on_boot=1
 feathers2.menu.MSCOnBoot.default=Disabled
 feathers2.menu.MSCOnBoot.default.build.msc_on_boot=0
+feathers2.menu.MSCOnBoot.msc=Enabled
+feathers2.menu.MSCOnBoot.msc.build.msc_on_boot=1
 
 feathers2.menu.DFUOnBoot.default=Disabled
 feathers2.menu.DFUOnBoot.default.build.dfu_on_boot=0
@@ -1092,7 +1092,131 @@ feathers2.menu.DebugLevel.verbose=Verbose
 feathers2.menu.DebugLevel.verbose.build.code_debug=5
 
 ##############################################################
+feathers2neo.name=UM FeatherS2 Neo
+feathers2neo.vid.0=0x303a
+feathers2neo.pid.0=0x80B4
+
+feathers2neo.upload.tool=esptool_py
+feathers2neo.upload.maximum_size=1310720
+feathers2neo.upload.maximum_data_size=327680
+feathers2neo.upload.flags=
+feathers2neo.upload.extra_flags=
+feathers2neo.upload.use_1200bps_touch=true
+feathers2neo.upload.wait_for_upload_port=true
+
+feathers2neo.serial.disableDTR=false
+feathers2neo.serial.disableRTS=false
+
+feathers2neo.build.tarch=xtensa
+feathers2neo.build.bootloader_addr=0x1000
+feathers2neo.build.target=esp32s2
+feathers2neo.build.mcu=esp32s2
+feathers2neo.build.core=esp32
+feathers2neo.build.variant=um_feathers2neo
+feathers2neo.build.board=FEATHERS2NEO
+
+feathers2neo.build.cdc_on_boot=1
+feathers2neo.build.msc_on_boot=0
+feathers2neo.build.dfu_on_boot=0
+feathers2neo.build.f_cpu=240000000L
+feathers2neo.build.flash_size=4MB
+feathers2neo.build.flash_freq=80m
+feathers2neo.build.flash_mode=dio
+feathers2neo.build.boot=qio
+feathers2neo.build.partitions=default
+feathers2neo.build.defines=
+
+feathers2neo.menu.CDCOnBoot.cdc=Enabled
+feathers2neo.menu.CDCOnBoot.cdc.build.cdc_on_boot=1
+feathers2neo.menu.CDCOnBoot.default=Disabled
+feathers2neo.menu.CDCOnBoot.default.build.cdc_on_boot=0
+
+feathers2neo.menu.MSCOnBoot.default=Disabled
+feathers2neo.menu.MSCOnBoot.default.build.msc_on_boot=0
+feathers2neo.menu.MSCOnBoot.msc=Enabled
+feathers2neo.menu.MSCOnBoot.msc.build.msc_on_boot=1
+
+feathers2neo.menu.DFUOnBoot.default=Disabled
+feathers2neo.menu.DFUOnBoot.default.build.dfu_on_boot=0
+feathers2neo.menu.DFUOnBoot.dfu=Enabled
+feathers2neo.menu.DFUOnBoot.dfu.build.dfu_on_boot=1
+
+feathers2neo.menu.PSRAM.enabled=Enabled
+feathers2neo.menu.PSRAM.enabled.build.defines=-DBOARD_HAS_PSRAM
+feathers2neo.menu.PSRAM.disabled=Disabled
+feathers2neo.menu.PSRAM.disabled.build.defines=
+
+feathers2neo.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS)
+feathers2neo.menu.PartitionScheme.default.build.partitions=default
+feathers2neo.menu.PartitionScheme.defaultffat=Default 4MB with ffat (1.2MB APP/1.5MB FATFS)
+feathers2neo.menu.PartitionScheme.defaultffat.build.partitions=default_ffat
+feathers2neo.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS)
+feathers2neo.menu.PartitionScheme.minimal.build.partitions=minimal
+feathers2neo.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
+feathers2neo.menu.PartitionScheme.no_ota.build.partitions=no_ota
+feathers2neo.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
+feathers2neo.menu.PartitionScheme.noota_3g=No OTA (1MB APP/3MB SPIFFS)
+feathers2neo.menu.PartitionScheme.noota_3g.build.partitions=noota_3g
+feathers2neo.menu.PartitionScheme.noota_3g.upload.maximum_size=1048576
+feathers2neo.menu.PartitionScheme.noota_ffat=No OTA (2MB APP/2MB FATFS)
+feathers2neo.menu.PartitionScheme.noota_ffat.build.partitions=noota_ffat
+feathers2neo.menu.PartitionScheme.noota_ffat.upload.maximum_size=2097152
+feathers2neo.menu.PartitionScheme.noota_3gffat=No OTA (1MB APP/3MB FATFS)
+feathers2neo.menu.PartitionScheme.noota_3gffat.build.partitions=noota_3gffat
+feathers2neo.menu.PartitionScheme.noota_3gffat.upload.maximum_size=1048576
+feathers2neo.menu.PartitionScheme.huge_app=Huge APP (3MB No OTA/1MB SPIFFS)
+feathers2neo.menu.PartitionScheme.huge_app.build.partitions=huge_app
+feathers2neo.menu.PartitionScheme.huge_app.upload.maximum_size=3145728
+feathers2neo.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (1.9MB APP with OTA/190KB SPIFFS)
+feathers2neo.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
+feathers2neo.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080
+
+feathers2neo.menu.CPUFreq.240=240MHz (WiFi)
+feathers2neo.menu.CPUFreq.240.build.f_cpu=240000000L
+feathers2neo.menu.CPUFreq.160=160MHz (WiFi)
+feathers2neo.menu.CPUFreq.160.build.f_cpu=160000000L
+feathers2neo.menu.CPUFreq.80=80MHz (WiFi)
+feathers2neo.menu.CPUFreq.80.build.f_cpu=80000000L
+feathers2neo.menu.CPUFreq.40=40MHz
+feathers2neo.menu.CPUFreq.40.build.f_cpu=40000000L
+feathers2neo.menu.CPUFreq.20=20MHz
+feathers2neo.menu.CPUFreq.20.build.f_cpu=20000000L
+feathers2neo.menu.CPUFreq.10=10MHz
+feathers2neo.menu.CPUFreq.10.build.f_cpu=10000000L
+
+feathers2neo.menu.FlashSize.4M=4MB (32Mb)
+feathers2neo.menu.FlashSize.4M.build.flash_size=4MB
+feathers2neo.menu.FlashSize.2M=2MB (16Mb)
+feathers2neo.menu.FlashSize.2M.build.flash_size=2MB
+feathers2neo.menu.FlashSize.2M.build.partitions=minimal
+
+feathers2neo.menu.UploadSpeed.921600=921600
+feathers2neo.menu.UploadSpeed.921600.upload.speed=921600
+feathers2neo.menu.UploadSpeed.115200=115200
+feathers2neo.menu.UploadSpeed.115200.upload.speed=115200
+feathers2neo.menu.UploadSpeed.256000.windows=256000
+feathers2neo.menu.UploadSpeed.256000.upload.speed=256000
+feathers2neo.menu.UploadSpeed.230400.windows.upload.speed=256000
+feathers2neo.menu.UploadSpeed.230400=230400
+feathers2neo.menu.UploadSpeed.230400.upload.speed=230400
+feathers2neo.menu.UploadSpeed.460800.linux=460800
+feathers2neo.menu.UploadSpeed.460800.macosx=460800
+feathers2neo.menu.UploadSpeed.460800.upload.speed=460800
+
+feathers2neo.menu.DebugLevel.none=None
+feathers2neo.menu.DebugLevel.none.build.code_debug=0
+feathers2neo.menu.DebugLevel.error=Error
+feathers2neo.menu.DebugLevel.error.build.code_debug=1
+feathers2neo.menu.DebugLevel.warn=Warn
+feathers2neo.menu.DebugLevel.warn.build.code_debug=2
+feathers2neo.menu.DebugLevel.info=Info
+feathers2neo.menu.DebugLevel.info.build.code_debug=3
+feathers2neo.menu.DebugLevel.debug=Debug
+feathers2neo.menu.DebugLevel.debug.build.code_debug=4
+feathers2neo.menu.DebugLevel.verbose=Verbose
+feathers2neo.menu.DebugLevel.verbose.build.code_debug=5
 
+##############################################################
 tinys2.name=UM TinyS2
 tinys2.vid.0=0x303a
 tinys2.pid.0=0x8001
@@ -1117,7 +1241,7 @@ tinys2.build.variant=um_tinys2
 tinys2.build.board=TINYS2
 
 tinys2.build.cdc_on_boot=1
-tinys2.build.msc_on_boot=1
+tinys2.build.msc_on_boot=0
 tinys2.build.dfu_on_boot=0
 tinys2.build.f_cpu=240000000L
 tinys2.build.flash_size=4MB
@@ -1132,10 +1256,10 @@ tinys2.menu.CDCOnBoot.cdc.build.cdc_on_boot=1
 tinys2.menu.CDCOnBoot.default=Disabled
 tinys2.menu.CDCOnBoot.default.build.cdc_on_boot=0
 
-tinys2.menu.MSCOnBoot.msc=Enabled
-tinys2.menu.MSCOnBoot.msc.build.msc_on_boot=1
 tinys2.menu.MSCOnBoot.default=Disabled
 tinys2.menu.MSCOnBoot.default.build.msc_on_boot=0
+tinys2.menu.MSCOnBoot.msc=Enabled
+tinys2.menu.MSCOnBoot.msc.build.msc_on_boot=1
 
 tinys2.menu.DFUOnBoot.default=Disabled
 tinys2.menu.DFUOnBoot.default.build.dfu_on_boot=0
@@ -1204,7 +1328,6 @@ tinys2.menu.UploadSpeed.460800.linux=460800
 tinys2.menu.UploadSpeed.460800.macosx=460800
 tinys2.menu.UploadSpeed.460800.upload.speed=460800
 
-
 tinys2.menu.DebugLevel.none=None
 tinys2.menu.DebugLevel.none.build.code_debug=0
 tinys2.menu.DebugLevel.error=Error
diff --git a/variants/um_feathers2neo/pins_arduino.h b/variants/um_feathers2neo/pins_arduino.h
new file mode 100644
index 00000000000..993aac1aa88
--- /dev/null
+++ b/variants/um_feathers2neo/pins_arduino.h
@@ -0,0 +1,70 @@
+#ifndef Pins_Arduino_h
+#define Pins_Arduino_h
+
+#include <stdint.h>
+
+#define USB_VID 0x239A
+#define USB_PID 0x80B4
+#define USB_MANUFACTURER "Unexpected Maker"
+#define USB_PRODUCT "FeatherS2 Neo"
+#define USB_SERIAL ""
+
+#define EXTERNAL_NUM_INTERRUPTS 46
+#define NUM_DIGITAL_PINS        22
+#define NUM_ANALOG_INPUTS       11
+
+#define analogInputToDigitalPin(p)  (((p)<20)?(esp32_adc2gpio[(p)]):-1)
+#define digitalPinToInterrupt(p)    (((p)<48)?(p):-1)
+#define digitalPinHasPWM(p)         (p < 46)
+
+static const uint8_t TX = 43;
+static const uint8_t RX = 44;
+
+static const uint8_t SDA = 8;
+static const uint8_t SCL = 9;
+
+static const uint8_t SS    = 34;
+static const uint8_t MOSI  = 35;
+static const uint8_t MISO  = 37;
+static const uint8_t SDO  = 35;
+static const uint8_t SDI  = 37;
+static const uint8_t SCK   = 36;
+
+static const uint8_t A0 = 17;
+static const uint8_t A1 = 18;
+static const uint8_t A2 = 14;
+static const uint8_t A3 = 12;
+static const uint8_t A4 = 6;
+static const uint8_t A5 = 5;
+static const uint8_t A6 = 1;
+static const uint8_t A7 = 3;
+static const uint8_t A8 = 7;
+static const uint8_t A9 = 10;
+static const uint8_t A10 = 11;
+
+
+static const uint8_t T1 = 1;
+static const uint8_t T3 = 3;
+static const uint8_t T5 = 5;
+static const uint8_t T6 = 6;
+static const uint8_t T7 = 7;
+static const uint8_t T8 = 8;
+static const uint8_t T9 = 9;
+static const uint8_t T10 = 10;
+static const uint8_t T11 = 11;
+static const uint8_t T12 = 12;
+static const uint8_t T14 = 14;
+
+static const uint8_t DAC1 = 17;
+static const uint8_t DAC2 = 18;
+
+static const uint8_t NEOPIXEL_MATRIX_DATA = 21;
+static const uint8_t NEOPIXEL_MATRIX_PWR = 4;
+
+static const uint8_t NEOPIXEL_DATA = 40;
+static const uint8_t NEOPIXEL_PWR = 39;
+
+static const uint8_t VBAT_SENSE = 2;
+static const uint8_t VBUS_SENSE = 34;
+
+#endif /* Pins_Arduino_h */