From 805476abf6c74eaff18f3eca0ae180c9c86f40ff Mon Sep 17 00:00:00 2001 From: Luis Miguel Collado Llera Date: Wed, 14 May 2025 23:34:27 +0200 Subject: [PATCH 1/3] kode dot board added --- boards.txt | 64 +++++++++++++++- platform.txt | 27 +++++++ tools/partitions/kodedot_partitions.csv | 7 ++ variants/kodedot/custom_ota_override.cpp | 10 +++ variants/kodedot/pins_arduino.h | 96 ++++++++++++++++++++++++ variants/kodedot/variant.cpp | 52 +++++++++++++ 6 files changed, 255 insertions(+), 1 deletion(-) create mode 100644 tools/partitions/kodedot_partitions.csv create mode 100644 variants/kodedot/custom_ota_override.cpp create mode 100644 variants/kodedot/pins_arduino.h create mode 100644 variants/kodedot/variant.cpp diff --git a/boards.txt b/boards.txt index 9158327f5f2..2b99eec33aa 100644 --- a/boards.txt +++ b/boards.txt @@ -2794,7 +2794,69 @@ esp32wroverkit.menu.EraseFlash.none.upload.erase_cmd= esp32wroverkit.menu.EraseFlash.all=Enabled esp32wroverkit.menu.EraseFlash.all.upload.erase_cmd=-e -############################################################## +########################################################### + +kodedot.name=kode dot + +kodedot.bootloader.tool=esptool_py +kodedot.bootloader.tool.default=esptool_py + +kodedot.upload.tool=esptool_py_nomerge +kodedot.upload.tool.default=esptool_py_nomerge +kodedot.upload.tool.network=esp_ota + +kodedot.upload.maximum_size=8388608 +kodedot.upload.maximum_data_size=327680 +kodedot.upload.flags= +kodedot.upload.extra_flags= +kodedot.upload.use_1200bps_touch=false +kodedot.upload.wait_for_upload_port=false +kodedot.upload.speed=921600 + +kodedot.upload.erase_cmd= + +kodedot.serial.disableDTR=false +kodedot.serial.disableRTS=false + +kodedot.build.tarch=xtensa +kodedot.build.bootloader_addr=0x0 +kodedot.build.target=esp32s3 +kodedot.build.mcu=esp32s3 +kodedot.build.core=esp32 +kodedot.build.variant=kodedot +kodedot.build.board=ESP32S3_DEV + +kodedot.build.usb_mode=1 +kodedot.build.cdc_on_boot=1 +kodedot.build.msc_on_boot=0 +kodedot.build.dfu_on_boot=0 + +kodedot.build.f_cpu=240000000L + +kodedot.build.flash_offset=0x400000 +kodedot.build.flash_size=16MB +kodedot.build.flash_freq=80m +kodedot.build.flash_mode=dio + +# Menú de particiones Custom kodeOS +kodedot.menu.PartitionScheme.kodeos=Custom kodeOS +kodedot.menu.PartitionScheme.kodeos.build.partitions=kodedot_partitions + +# Particiones por defecto +kodedot.build.partitions=kodedot_partitions + +kodedot.build.psram_type=qspi +kodedot.build.defines= + +kodedot.build.loop_core=-DARDUINO_RUNNING_CORE=1 +kodedot.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=1 + +kodedot.recipe.hooks.objcopy.postobjcopy.3.pattern= +kodedot.recipe.hooks.objcopy.postobjcopy.3.pattern_args= + +kodedot.recipe.output.save_file={build.project_name}.ino.bin + +########################################################### aventen_s3_sync.name=Aventen S3 Sync ## Based upon ESP32-S3 Dev Board diff --git a/platform.txt b/platform.txt index 65be05b3bf4..f659424cb82 100644 --- a/platform.txt +++ b/platform.txt @@ -288,6 +288,19 @@ tools.esptool_py.upload.params.quiet= tools.esptool_py.upload.pattern_args=--chip {build.mcu} --port "{serial.port}" --baud {upload.speed} {upload.flags} --before default_reset --after hard_reset write_flash {upload.erase_cmd} -z --flash_mode keep --flash_freq keep --flash_size keep {build.bootloader_addr} "{build.path}/{build.project_name}.bootloader.bin" 0x8000 "{build.path}/{build.project_name}.partitions.bin" 0xe000 "{runtime.platform.path}/tools/partitions/boot_app0.bin" 0x10000 "{build.path}/{build.project_name}.bin" {upload.extra_flags} tools.esptool_py.upload.pattern="{path}/{cmd}" {upload.pattern_args} +## Custom tool for kodeOS: esptool_py_nomerge +## ------------------------------------------------------------- +tools.esptool_py_nomerge.path={runtime.tools.esptool_py.path} +tools.esptool_py_nomerge.cmd=esptool +tools.esptool_py_nomerge.cmd.windows=esptool.exe + +tools.esptool_py_nomerge.upload.protocol=serial +tools.esptool_py_nomerge.upload.params.verbose= +tools.esptool_py_nomerge.upload.params.quiet= + +tools.esptool_py_nomerge.upload.pattern_args=--chip {build.mcu} --port "{serial.port}" --baud {upload.speed} {upload.flags} --before default_reset --after hard_reset write_flash {upload.erase_cmd} --flash_mode keep --flash_freq keep --flash_size keep {build.flash_offset} "{build.path}/{build.project_name}.bin" +tools.esptool_py_nomerge.upload.pattern="{path}/{cmd}" {tools.esptool_py_nomerge.upload.pattern_args} + ## Program Application ## ------------------- tools.esptool_py.program.params.verbose= @@ -330,3 +343,17 @@ tools.dfu-util.cmd=dfu-util tools.dfu-util.upload.params.verbose=-d tools.dfu-util.upload.params.quiet= tools.dfu-util.upload.pattern="{path}/{cmd}" --device {vid.0}:{pid.0} -D "{build.path}/{build.project_name}.bin" -Q + +## -------------------------------------------------------------------------- +## Custom tool for Kode Dot: esptool_py_nomerge +## -------------------------------------------------------------------------- +tools.esptool_py_nomerge.path={runtime.tools.esptool_py.path} +tools.esptool_py_nomerge.cmd=esptool +tools.esptool_py_nomerge.cmd.windows=esptool.exe + +tools.esptool_py_nomerge.upload.protocol=serial +tools.esptool_py_nomerge.upload.params.verbose= +tools.esptool_py_nomerge.upload.params.quiet= + +tools.esptool_py_nomerge.upload.pattern_args=--chip {build.mcu} --port "{serial.port}" --baud {upload.speed} {upload.flags} --before default_reset --after hard_reset write_flash --flash_mode {build.flash_mode} --flash_freq {build.flash_freq} --flash_size {build.flash_size} {build.flash_offset} "{build.path}/{build.project_name}.bin" {upload.extra_flags} +tools.esptool_py_nomerge.upload.pattern="{path}/{cmd}" {tools.esptool_py_nomerge.upload.pattern_args} diff --git a/tools/partitions/kodedot_partitions.csv b/tools/partitions/kodedot_partitions.csv new file mode 100644 index 00000000000..fd5c5ce4f06 --- /dev/null +++ b/tools/partitions/kodedot_partitions.csv @@ -0,0 +1,7 @@ +# Name, Type, SubType, Offset, Size, Flags +nvs, data, nvs, 0x9000, 0x6000, +phy_init, data, phy, 0xf000, 0x1000, +otadata, data, ota, 0x10000, 0x2000, +ota_0, app, ota_0, 0x20000, 0x3E0000, +ota_1, app, ota_1, 0x400000, 0x800000, +storage, data, spiffs, 0xC00000, 0x400000, \ No newline at end of file diff --git a/variants/kodedot/custom_ota_override.cpp b/variants/kodedot/custom_ota_override.cpp new file mode 100644 index 00000000000..9f2b4c3813b --- /dev/null +++ b/variants/kodedot/custom_ota_override.cpp @@ -0,0 +1,10 @@ +// custom_ota_override.cpp +// Esta función sobrescribe la definición débil en el core de Arduino-ESP32. +extern "C" { + bool verifyRollbackLater() __attribute__((weak)); +} + +bool verifyRollbackLater() { + // Retorna true para evitar que se marque la imagen OTA como válida automáticamente. + return true; +} diff --git a/variants/kodedot/pins_arduino.h b/variants/kodedot/pins_arduino.h new file mode 100644 index 00000000000..5b873e2d2f1 --- /dev/null +++ b/variants/kodedot/pins_arduino.h @@ -0,0 +1,96 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include +#include + +#define USB_VID 0x303a +#define USB_PID 0x1001 + +static const uint8_t TX = 43; +static const uint8_t RX = 44; + +static const uint8_t SDA = 45; +static const uint8_t SCL = 46; + +static const uint8_t SS = 34; +static const uint8_t MOSI = 35; +static const uint8_t MISO = 37; +static const uint8_t SCK = 36; + +static const uint8_t A0 = 1; +static const uint8_t A1 = 2; +static const uint8_t A2 = 3; + +static const uint8_t T3 = 3; + +// SDCARD Slot +#define BOARD_HAS_SDMMC +#define SDMMC_D2 33 // SDMMC Data2 +#define SDMMC_D3 34 // SDMMC Data3 / SPI CS +#define SDMMC_CMD 35 // SDMMC CMD / SPI MOSI +#define SDMMC_CLK 36 // SDMMC CLK / SPI SCK +#define SDMMC_D0 37 // SDMMC Data0 / SPI MISO +#define SDMMC_D1 38 // SDMMC Data1 +#define BOARD_MAX_SDMMC_FREQ SDMMC_FREQ_DEFAULT + +// 240x240 LCD +#define BOARD_HAS_SPI_LCD +#define LCD_MODEL ST7789 +#define LCD_WIDTH 240 +#define LCD_HEIGHT 240 // *RAM height is actually 320! +#define LCD_MISO -1 // LCD Does not use MISO. +#define LCD_DC 4 // Used to switch data and command status. +#define LCD_CS 5 // used to enable LCD, low level to enable. +#define LCD_CLK 6 // LCD SPI Clock. +#define LCD_MOSI 7 // LCD SPI MOSI. +#define LCD_RST 8 // used to reset LCD, low level to reset. +#define LCD_BL 9 // LCD backlight control. + +// Buttons +#define BUTTON_OK 0 // OK button, low level when pressed. +#define BUTTON_UP 10 // UP button, low level when pressed. +#define BUTTON_DOWN 11 // Down button, low level when pressed. +#define BUTTON_MENU 14 // Menu button, low level when pressed. + +// LEDs +#define LED_GREEN 15 // the light is lit when set high level. +#define LED_YELLOW 16 // the light is lit when set high level. + +// Board Controls +#define DEV_VBUS_EN 12 // High level to enable DEV_VBUS power supply. +#define BOOST_EN 13 // High level to enable Battery Boost circuit. +#define LIMIT_EN 17 // Enable USB_HOST current limiting IC, high level enable. +#define USB_HOST_EN \ + 18 // Used to switch the USB interface. When high level, the USB_HOST interface is enabled. When low level, the USB_DEV interface is enabled. + +// Board Sensors +#define OVER_CURRENT 21 // Current overrun signal, high level means overrun. +#define HOST_VOLTS 1 // USB_DEV voltage monitoring, ADC1 channel 0. actual_v = value_v * 3.7 +#define BAT_VOLTS 2 // Battery voltage monitoring, ADC1 channel 1. actual_v = value_v * 2 + +// USB Port +#define USB_DN 19 // USB D- +#define USB_DP 20 // USB D+ + +// Bottom header +#define MTCK 39 +#define MTDO 40 +#define MTDI 41 +#define MTMS 42 +// #define FREE_6 3 // Idle, can be customized. +// #define FREE_4 26 // Idle, can be customized. +// #define FREE_1 45 // Idle, can be customized. +// #define FREE_2 46 // Idle, can be customized. +// #define FREE_5 47 // Idle, can be customized. +// #define FREE_3 48 // Idle, can be customized. + +typedef enum { + USB_HOST_POWER_OFF, + USB_HOST_POWER_VBUS, + USB_HOST_POWER_BAT +} UsbHostPower_t; +void usbHostPower(UsbHostPower_t mode); +void usbHostEnable(bool enable); + +#endif /* Pins_Arduino_h */ diff --git a/variants/kodedot/variant.cpp b/variants/kodedot/variant.cpp new file mode 100644 index 00000000000..a8de800f90a --- /dev/null +++ b/variants/kodedot/variant.cpp @@ -0,0 +1,52 @@ +#include "Arduino.h" + +void usbHostPower(UsbHostPower_t mode) { + static UsbHostPower_t m = USB_HOST_POWER_OFF; + if (m == mode) { + return; + } + if (mode == USB_HOST_POWER_OFF) { + digitalWrite(LIMIT_EN, LOW); + if (m == USB_HOST_POWER_VBUS) { + digitalWrite(DEV_VBUS_EN, LOW); + } else if (m == USB_HOST_POWER_BAT) { + digitalWrite(BOOST_EN, LOW); + } + } else if (mode == USB_HOST_POWER_VBUS) { + if (m == USB_HOST_POWER_BAT) { + digitalWrite(BOOST_EN, LOW); + } + digitalWrite(DEV_VBUS_EN, HIGH); + } else if (mode == USB_HOST_POWER_BAT) { + if (m == USB_HOST_POWER_VBUS) { + digitalWrite(DEV_VBUS_EN, LOW); + } + digitalWrite(BOOST_EN, HIGH); + } + if (mode != USB_HOST_POWER_OFF) { + digitalWrite(LIMIT_EN, HIGH); + } + m = mode; +} + +void usbHostEnable(bool enable) { + digitalWrite(USB_HOST_EN, enable); +} + +extern "C" void initVariant(void) { + // Route USB to Device Side + pinMode(BOOST_EN, OUTPUT); + digitalWrite(BOOST_EN, LOW); + pinMode(LIMIT_EN, OUTPUT); + digitalWrite(LIMIT_EN, LOW); + pinMode(DEV_VBUS_EN, OUTPUT); + digitalWrite(DEV_VBUS_EN, LOW); + pinMode(USB_HOST_EN, OUTPUT); + digitalWrite(USB_HOST_EN, LOW); + + // Turn Off LCD + pinMode(LCD_RST, OUTPUT); + digitalWrite(LCD_RST, LOW); + pinMode(LCD_BL, OUTPUT); + digitalWrite(LCD_BL, LOW); +} From e85442cf2793b59f8f7b26b2530c57944707d2ee Mon Sep 17 00:00:00 2001 From: Luis Miguel Collado Llera Date: Wed, 14 May 2025 23:41:22 +0200 Subject: [PATCH 2/3] kode dot board added --- platform.txt | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/platform.txt b/platform.txt index f659424cb82..f2287c390ab 100644 --- a/platform.txt +++ b/platform.txt @@ -288,19 +288,6 @@ tools.esptool_py.upload.params.quiet= tools.esptool_py.upload.pattern_args=--chip {build.mcu} --port "{serial.port}" --baud {upload.speed} {upload.flags} --before default_reset --after hard_reset write_flash {upload.erase_cmd} -z --flash_mode keep --flash_freq keep --flash_size keep {build.bootloader_addr} "{build.path}/{build.project_name}.bootloader.bin" 0x8000 "{build.path}/{build.project_name}.partitions.bin" 0xe000 "{runtime.platform.path}/tools/partitions/boot_app0.bin" 0x10000 "{build.path}/{build.project_name}.bin" {upload.extra_flags} tools.esptool_py.upload.pattern="{path}/{cmd}" {upload.pattern_args} -## Custom tool for kodeOS: esptool_py_nomerge -## ------------------------------------------------------------- -tools.esptool_py_nomerge.path={runtime.tools.esptool_py.path} -tools.esptool_py_nomerge.cmd=esptool -tools.esptool_py_nomerge.cmd.windows=esptool.exe - -tools.esptool_py_nomerge.upload.protocol=serial -tools.esptool_py_nomerge.upload.params.verbose= -tools.esptool_py_nomerge.upload.params.quiet= - -tools.esptool_py_nomerge.upload.pattern_args=--chip {build.mcu} --port "{serial.port}" --baud {upload.speed} {upload.flags} --before default_reset --after hard_reset write_flash {upload.erase_cmd} --flash_mode keep --flash_freq keep --flash_size keep {build.flash_offset} "{build.path}/{build.project_name}.bin" -tools.esptool_py_nomerge.upload.pattern="{path}/{cmd}" {tools.esptool_py_nomerge.upload.pattern_args} - ## Program Application ## ------------------- tools.esptool_py.program.params.verbose= From a501b4d85dc3d53aae17714dc71491e3f9b2a09d Mon Sep 17 00:00:00 2001 From: Luis Miguel Collado Llera Date: Fri, 16 May 2025 21:19:05 +0200 Subject: [PATCH 3/3] kode dot board with pins defined --- variants/kodedot/custom_ota_override.cpp | 8 +- variants/kodedot/pins_arduino.h | 185 ++++++++++++----------- variants/kodedot/variant.cpp | 52 ------- 3 files changed, 104 insertions(+), 141 deletions(-) delete mode 100644 variants/kodedot/variant.cpp diff --git a/variants/kodedot/custom_ota_override.cpp b/variants/kodedot/custom_ota_override.cpp index 9f2b4c3813b..81c62a172e0 100644 --- a/variants/kodedot/custom_ota_override.cpp +++ b/variants/kodedot/custom_ota_override.cpp @@ -1,10 +1,14 @@ // custom_ota_override.cpp -// Esta función sobrescribe la definición débil en el core de Arduino-ESP32. +// This function overrides the weak definition of `verifyRollbackLater()` in the kode dot board. + extern "C" { + // Declare the weak function symbol to override it bool verifyRollbackLater() __attribute__((weak)); } +// Custom implementation of verifyRollbackLater() +// Returning `true` prevents the OTA image from being automatically marked as valid. +// This ensures that the system will roll back to the previous image unless it is explicitly validated later. bool verifyRollbackLater() { - // Retorna true para evitar que se marque la imagen OTA como válida automáticamente. return true; } diff --git a/variants/kodedot/pins_arduino.h b/variants/kodedot/pins_arduino.h index 5b873e2d2f1..63847a538d9 100644 --- a/variants/kodedot/pins_arduino.h +++ b/variants/kodedot/pins_arduino.h @@ -1,96 +1,107 @@ +/* + ──────────────────────────────────────────────────────────────────────── + KodeDot – ESP32-S3R8 Variant + Pin definition file for the Arduino-ESP32 core + ──────────────────────────────────────────────────────────────────────── + * External 2 × 10 connector → simple aliases PIN1 … PIN20 + * On-board QSPI LCD 410×502 @40 MHz (SPI3_HOST) + * micro-SD on SPI2_HOST + * Dual-I²C: external (GPIO37/36) + internal-sensors (GPIO48/47) + * USB VID/PID 0x303A:0x1001 +*/ + #ifndef Pins_Arduino_h #define Pins_Arduino_h #include #include -#define USB_VID 0x303a -#define USB_PID 0x1001 - -static const uint8_t TX = 43; -static const uint8_t RX = 44; - -static const uint8_t SDA = 45; -static const uint8_t SCL = 46; - -static const uint8_t SS = 34; -static const uint8_t MOSI = 35; -static const uint8_t MISO = 37; -static const uint8_t SCK = 36; - -static const uint8_t A0 = 1; -static const uint8_t A1 = 2; -static const uint8_t A2 = 3; - -static const uint8_t T3 = 3; - -// SDCARD Slot -#define BOARD_HAS_SDMMC -#define SDMMC_D2 33 // SDMMC Data2 -#define SDMMC_D3 34 // SDMMC Data3 / SPI CS -#define SDMMC_CMD 35 // SDMMC CMD / SPI MOSI -#define SDMMC_CLK 36 // SDMMC CLK / SPI SCK -#define SDMMC_D0 37 // SDMMC Data0 / SPI MISO -#define SDMMC_D1 38 // SDMMC Data1 -#define BOARD_MAX_SDMMC_FREQ SDMMC_FREQ_DEFAULT - -// 240x240 LCD +/*──────────────── USB device descriptor ────────────────*/ +#define USB_VID 0x303A // Espressif Systems VID +#define USB_PID 0x1001 // Product ID: KodeDot-S3 + +/*──────────────── UART0 (Arduino Serial) ────────────────*/ +static const uint8_t TX = 43; // U0TXD – PIN16 on the 2×10 header +static const uint8_t RX = 44; // U0RXD – PIN18 on the 2×10 header + +/*──────────────── I²C buses ─────────────────────────────*/ +/* External expansion bus → header pins 11/13 */ +static const uint8_t SCL = 37; // GPIO37 – PIN12 +static const uint8_t SDA = 36; // GPIO36 – PIN14 + +/* Internal sensor/touch bus (not on header) */ +#define INT_I2C_SCL 47 // GPIO47 +#define INT_I2C_SDA 48 // GPIO48 + +/*──────────────── SPI2 – micro-SD ───────────────────────*/ +static const uint8_t SS = 15; // SD_CS +static const uint8_t MOSI = 16; // SD_MOSI +static const uint8_t MISO = 18; // SD_MISO +static const uint8_t SCK = 17; // SD_CLK +#define BOARD_HAS_SD_SPI +#define SD_CS SS + +/*──────────────── QSPI LCD (SPI3_HOST) ─────────────────– + * Controller: ST7789 / 4-line SPI (no D/C pin) + * Resolution: 410×502 px, 16 bpp, RGB color-space + * Clock: 40 MHz + */ #define BOARD_HAS_SPI_LCD -#define LCD_MODEL ST7789 -#define LCD_WIDTH 240 -#define LCD_HEIGHT 240 // *RAM height is actually 320! -#define LCD_MISO -1 // LCD Does not use MISO. -#define LCD_DC 4 // Used to switch data and command status. -#define LCD_CS 5 // used to enable LCD, low level to enable. -#define LCD_CLK 6 // LCD SPI Clock. -#define LCD_MOSI 7 // LCD SPI MOSI. -#define LCD_RST 8 // used to reset LCD, low level to reset. -#define LCD_BL 9 // LCD backlight control. - -// Buttons -#define BUTTON_OK 0 // OK button, low level when pressed. -#define BUTTON_UP 10 // UP button, low level when pressed. -#define BUTTON_DOWN 11 // Down button, low level when pressed. -#define BUTTON_MENU 14 // Menu button, low level when pressed. - -// LEDs -#define LED_GREEN 15 // the light is lit when set high level. -#define LED_YELLOW 16 // the light is lit when set high level. - -// Board Controls -#define DEV_VBUS_EN 12 // High level to enable DEV_VBUS power supply. -#define BOOST_EN 13 // High level to enable Battery Boost circuit. -#define LIMIT_EN 17 // Enable USB_HOST current limiting IC, high level enable. -#define USB_HOST_EN \ - 18 // Used to switch the USB interface. When high level, the USB_HOST interface is enabled. When low level, the USB_DEV interface is enabled. - -// Board Sensors -#define OVER_CURRENT 21 // Current overrun signal, high level means overrun. -#define HOST_VOLTS 1 // USB_DEV voltage monitoring, ADC1 channel 0. actual_v = value_v * 3.7 -#define BAT_VOLTS 2 // Battery voltage monitoring, ADC1 channel 1. actual_v = value_v * 2 - -// USB Port -#define USB_DN 19 // USB D- -#define USB_DP 20 // USB D+ - -// Bottom header -#define MTCK 39 -#define MTDO 40 -#define MTDI 41 -#define MTMS 42 -// #define FREE_6 3 // Idle, can be customized. -// #define FREE_4 26 // Idle, can be customized. -// #define FREE_1 45 // Idle, can be customized. -// #define FREE_2 46 // Idle, can be customized. -// #define FREE_5 47 // Idle, can be customized. -// #define FREE_3 48 // Idle, can be customized. - -typedef enum { - USB_HOST_POWER_OFF, - USB_HOST_POWER_VBUS, - USB_HOST_POWER_BAT -} UsbHostPower_t; -void usbHostPower(UsbHostPower_t mode); -void usbHostEnable(bool enable); +#define LCD_MODEL ST7789 +#define LCD_WIDTH 410 +#define LCD_HEIGHT 502 + +#define LCD_HOST SPI3_HOST +#define LCD_SCK 35 // GPIO35 • QSPI_CLK +#define LCD_MOSI 33 // GPIO33 • QSPI_IO0 (D0) +#define LCD_IO1 34 // GPIO34 • QSPI_IO1 (D1) +#define LCD_IO2 37 // GPIO37 • QSPI_IO2 (D2) +#define LCD_IO3 36 // GPIO36 • QSPI_IO3 (D3) +#define LCD_CS 10 // GPIO10 +#define LCD_RST 9 // GPIO09 +#define LCD_DC -1 // not used in 4-line SPI +/* Optional: back-light enable shares the NeoPixel pin */ +#define LCD_BL 5 // GPIO05 (same as NEOPIXEL) + +/*──────────────── Analogue / Touch pads ────────────────*/ +static const uint8_t A0 = 11; // PIN4 – GPIO11 / TOUCH11 / ADC2_CH0 +static const uint8_t A1 = 12; // PIN6 – GPIO12 / TOUCH12 / ADC2_CH1 +static const uint8_t A2 = 13; // PIN8 – GPIO13 / TOUCH13 / ADC2_CH2 +static const uint8_t A3 = 14; // PIN10 – GPIO14 / TOUCH14 / ADC2_CH3 +static const uint8_t T0 = A0, T1 = A1, T2 = A2, T3 = A3; + +/*──────────────── On-board controls & indicator ─────────*/ +#define BUTTON_TOP 0 // GPIO00 – BOOT • active-LOW +#define BUTTON_BOTTOM 6 // GPIO06 • active-LOW +#define NEOPIXEL_PIN 5 // GPIO05 – WS2812 +#define LED_BUILTIN NEOPIXEL_PIN + +/*──────────────── JTAG (also on connector) ──────────────*/ +#define MTCK 39 // PIN11 – GPIO39 +#define MTDO 40 // PIN13 – GPIO40 +#define MTDI 41 // PIN15 – GPIO41 +#define MTMS 42 // PIN17 – GPIO42 + +/*──────────────── 2×10 header: simple aliases ─────────── + NOTE: power pins (1 = 5 V, 2 = 3 V3, 19/20 = GND) are **not** + exposed as GPIO numbers – they remain undefined here. */ +#define PIN3 1 // GPIO01 / TOUCH1 / ADC1_CH0 +#define PIN4 11 // GPIO11 / TOUCH11 / ADC2_CH0 +#define PIN5 2 // GPIO02 / TOUCH2 / ADC1_CH1 +#define PIN6 12 // GPIO12 / TOUCH12 / ADC2_CH1 +#define PIN7 3 // GPIO03 / TOUCH3 / ADC1_CH2 +#define PIN8 13 // GPIO13 / TOUCH13 / ADC2_CH2 +#define PIN9 4 // GPIO04 / TOUCH4 / ADC1_CH3 +#define PIN10 14 // GPIO14 / TOUCH14 / ADC2_CH3 +#define PIN11 39 // MTCK +#define PIN12 37 // SCL (external I²C) +#define PIN13 40 // MTDO +#define PIN14 36 // SDA (external I²C) +#define PIN15 41 // MTDI +#define PIN16 43 // TX (U0TXD) +#define PIN17 42 // MTMS +#define PIN18 44 // RX (U0RXD) +/* PIN1, PIN2, PIN19, PIN20 are power/ground and deliberately + left undefined – they are **not** usable as GPIO. */ #endif /* Pins_Arduino_h */ diff --git a/variants/kodedot/variant.cpp b/variants/kodedot/variant.cpp deleted file mode 100644 index a8de800f90a..00000000000 --- a/variants/kodedot/variant.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "Arduino.h" - -void usbHostPower(UsbHostPower_t mode) { - static UsbHostPower_t m = USB_HOST_POWER_OFF; - if (m == mode) { - return; - } - if (mode == USB_HOST_POWER_OFF) { - digitalWrite(LIMIT_EN, LOW); - if (m == USB_HOST_POWER_VBUS) { - digitalWrite(DEV_VBUS_EN, LOW); - } else if (m == USB_HOST_POWER_BAT) { - digitalWrite(BOOST_EN, LOW); - } - } else if (mode == USB_HOST_POWER_VBUS) { - if (m == USB_HOST_POWER_BAT) { - digitalWrite(BOOST_EN, LOW); - } - digitalWrite(DEV_VBUS_EN, HIGH); - } else if (mode == USB_HOST_POWER_BAT) { - if (m == USB_HOST_POWER_VBUS) { - digitalWrite(DEV_VBUS_EN, LOW); - } - digitalWrite(BOOST_EN, HIGH); - } - if (mode != USB_HOST_POWER_OFF) { - digitalWrite(LIMIT_EN, HIGH); - } - m = mode; -} - -void usbHostEnable(bool enable) { - digitalWrite(USB_HOST_EN, enable); -} - -extern "C" void initVariant(void) { - // Route USB to Device Side - pinMode(BOOST_EN, OUTPUT); - digitalWrite(BOOST_EN, LOW); - pinMode(LIMIT_EN, OUTPUT); - digitalWrite(LIMIT_EN, LOW); - pinMode(DEV_VBUS_EN, OUTPUT); - digitalWrite(DEV_VBUS_EN, LOW); - pinMode(USB_HOST_EN, OUTPUT); - digitalWrite(USB_HOST_EN, LOW); - - // Turn Off LCD - pinMode(LCD_RST, OUTPUT); - digitalWrite(LCD_RST, LOW); - pinMode(LCD_BL, OUTPUT); - digitalWrite(LCD_BL, LOW); -}