Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(devboard): Add support for ESP32 #39

Merged
merged 35 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a4d62c1
feat(devboard): Add preliminary support for Adafruit QtPy ESP32 Pico
ZZ-Cat Oct 9, 2023
00ea169
fix(build/compile/verify): Force integer conversion in `min()` function.
ZZ-Cat Oct 9, 2023
4b6955f
fix(build/compile/verify): Resolve incorrect formatting
ZZ-Cat Oct 9, 2023
600264c
docs(readme): Fix typo
ZZ-Cat Oct 10, 2023
99c87f5
docs(readme): Add links to additional boards URLs for supported devel…
ZZ-Cat Oct 10, 2023
f8677b0
feat(devboard): Add preliminary support for Adafruit Feather ESP32
ZZ-Cat Oct 10, 2023
31bc252
feat(devboard): Add preliminary support for Adafruit Feather ESP32-S2
ZZ-Cat Oct 10, 2023
a6a2e1e
build(platformio): Move core directory to the working project directory
ZZ-Cat Oct 11, 2023
94af03b
build(platformio): Add missing default environment in `platformio.ini`
ZZ-Cat Oct 11, 2023
265fd6a
chore(compatibility table): Add missing board ID for Adafruit Feather…
ZZ-Cat Oct 11, 2023
f28d953
feat(devboard): Add preliminary support for Adafruit Metro ESP32-S2
ZZ-Cat Oct 11, 2023
0141487
feat(devboard): Add preliminary support for Adafruit QtPy ESP32-S3
ZZ-Cat Oct 12, 2023
8dd7db0
feat(devboard): Add preliminary support for Adafruit QtPy ESP32-C3
ZZ-Cat Oct 12, 2023
19f35a2
feat(devboard): Add preliminary support for Adafruit Feather ESP32-S3…
ZZ-Cat Oct 16, 2023
11d25c1
feat(devboard): Add preliminary support for Adafruit Feather ESP32-S3…
ZZ-Cat Oct 16, 2023
077f4e0
build(build/compile/verify): Add missing environment configuration fo…
ZZ-Cat Oct 16, 2023
a26b366
build(build/compile/verify): Add missing build flags for both Adafrui…
ZZ-Cat Oct 16, 2023
d331c71
feat(devboard): Add preliminary support for Adafruit ItsyBitsy ESP32
ZZ-Cat Oct 16, 2023
b7e7418
feat(devboard): Add preliminary support for Adafruit QtPy ESP32-S2
ZZ-Cat Oct 16, 2023
feb1ebe
feat(devboard): Add preliminary support for Arduino Nano ESP32
ZZ-Cat Oct 16, 2023
ae6b32e
feat(devboard): Add preliminary support for Espressif ESP32-C3-DevKit…
ZZ-Cat Oct 16, 2023
3acfddf
feat(devboard): Add preliminary support for Espressif ESP32-C3-DevKitM-1
ZZ-Cat Oct 17, 2023
734a14b
fix(compatibility table): Fix typo for DevKit variants of Espressif E…
ZZ-Cat Oct 17, 2023
736f214
feat(devboard): Add preliminary support for Espressif ESP32-S3-DevKitC-1
ZZ-Cat Oct 17, 2023
6500126
feat(devboard): Add preliminary support for Seeed Studio Xiao ESP32-C3
ZZ-Cat Oct 17, 2023
09e560e
feat(devboard): Add preliminary support for Seeed Studio Xiao ESP32-S3
ZZ-Cat Oct 17, 2023
423a6f6
feat(devboard): Add preliminary support for SparkFun ESP32 IoT RedBoard
ZZ-Cat Oct 18, 2023
8be5351
feat(devboard): Add preliminary support for SparkFun ESP32 Thing
ZZ-Cat Oct 18, 2023
0b4c287
feat(devboard): Add preliminary support for SparkFun ESP32 Thing Plus
ZZ-Cat Oct 18, 2023
c0313f4
feat(devboard): Add preliminary support for SparkFun ESP32-S2 WROOM T…
ZZ-Cat Oct 18, 2023
f9bc28f
build(build/compile/verify): Revert default environment back to Adafr…
ZZ-Cat Oct 18, 2023
2b15847
Merge branch 'Main-Trunk' into ZZ-Cat/issue38
ZZ-Cat Oct 18, 2023
9dfac0b
docs(readme): Populate list of ESP32 based development boards
ZZ-Cat Oct 18, 2023
3f1380a
docs(issue templates): Populate development board dropdown menu with …
ZZ-Cat Oct 18, 2023
7c19e15
docs(issue templates): Populate development boards dropdown menu with…
ZZ-Cat Oct 18, 2023
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
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,17 @@ This provides you with up to 16 11-bit full resolution channels & telemetry with
If you want to use CRSF for Arduino in the Arduino IDE, you need these:

- [Arduino IDE](https://www.arduino.cc/en/software)
- [Arduino SAMD Board Support Pack](https://github.com/arduino/ArduinoCore-samd)
- [Adafruit SAMD Board Support Pack](https://github.com/adafruit/ArduinoCore-samd)
- [Adafruit_ZeroDMA](https://github.com/adafruit/Adafruit_ZeroDMA)
- ESP32 targets:
- Additional Boards URL: `https://espressif.github.io/arduino-esp32/package_esp32_index.json`
- [Arduino ESP32 Board Support Pack](https://github.com/espressif/arduino-esp32)
- SAMD21 & SAMD51 targets:
- Additional Boards URL: `https://adafruit.github.io/arduino-board-index/package_adafruit_index.json`
- [Arduino SAMD Board Support Pack](https://github.com/arduino/ArduinoCore-samd)
- [Adafruit SAMD Board Support Pack](https://github.com/adafruit/ArduinoCore-samd)
- [Adafruit_ZeroDMA](https://github.com/adafruit/Adafruit_ZeroDMA)
- Teensy 3.x & Teensy 4.x targets:
- Additional Boards URL: `https://www.pjrc.com/teensy/package_teensy_index.json`
- [Teensy Board Support Pack](https://github.com/PaulStoffregen/cores)

## Prerequisites - Visual Studio Code & PlatformIO

Expand Down Expand Up @@ -336,6 +344,8 @@ For example, if you are using an Adafruit Metro M4 Express, you would use `pio r
CRSF for Arduino is designed to be compatible with modern hardware.
While CRSF for Arduino is primarily developed on the Adafruit Metro M4 Express, here is a list of target development boards CRSF for Arduino is compatible with (Keep in mind that this list is not exhaustive, & actual compatibility with everything listed here may be untested):

- ESP32 based boards:
- Adafruit QtPy ESP32
ZZ-Cat marked this conversation as resolved.
Show resolved Hide resolved
- SAMD21 based boards:
- Adafruit Feather M0 & all of its variants, including the Adafruit Feather M0 Express
- Adafruit ItsyBitsy M0 Express
Expand All @@ -362,7 +372,7 @@ While CRSF for Arduino is primarily developed on the Adafruit Metro M4 Express,
- Adafruit Metro M4 Express AirLift Lite
- SAME51 based boards:
- Adafruit Feather M4 CAN Express
- Teensy 3.x
- Teensy 3.x
**NB:** The entire Teensy 3.x line is discontinued by the manufacturer, and is _not_ recommended for new projects.
- Teensy 4.x

Expand Down
144 changes: 143 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,147 @@ debug_tool = ${common_samd51.debugger}
lib_deps = ${common_samd51.lib_deps}
upload_protocol = ${common_samd51.sketch_upload_protocol}

; ESP32 Boards
[env:adafruit_qtpy_esp32]
platform = espressif32
board = adafruit_qtpy_esp32
build_flags =
-DUSE_ABSTRACTION_LAYER
-DCRC_OPTIMISATION_LEVEL=0

[env:adafruit_qtpy_esp32c3]
platform = espressif32
board = adafruit_qtpy_esp32c3
build_flags =
-DUSE_ABSTRACTION_LAYER
-DCRC_OPTIMISATION_LEVEL=0

[env:adafruit_qtpy_esp32s2]
platform = espressif32
board = adafruit_qtpy_esp32s2
build_flags =
-DUSE_ABSTRACTION_LAYER
-DCRC_OPTIMISATION_LEVEL=0

[env:adafruit_qtpy_esp32s3_nopsram]
platform = espressif32
board = adafruit_qtpy_esp32s3_nopsram
build_flags =
-DUSE_ABSTRACTION_LAYER
-DCRC_OPTIMISATION_LEVEL=0

[env:featheresp32-s2]
platform = espressif32
board = featheresp32-s2
build_flags =
-DUSE_ABSTRACTION_LAYER
-DCRC_OPTIMISATION_LEVEL=0

[env:adafruit_feather_esp32s3]
platform = espressif32
board = adafruit_feather_esp32s3
build_flags =
-DUSE_ABSTRACTION_LAYER
-DCRC_OPTIMISATION_LEVEL=0

[env:adafruit_feather_esp32s3_nopsram]
platform = espressif32
board = adafruit_feather_esp32s3_nopsram
build_flags =
-DUSE_ABSTRACTION_LAYER
-DCRC_OPTIMISATION_LEVEL=0

[env:featheresp32]
platform = espressif32
board = featheresp32
build_flags =
-DUSE_ABSTRACTION_LAYER
-DCRC_OPTIMISATION_LEVEL=0

[env:adafruit_itsybitsy_esp32]
platform = espressif32
board = adafruit_itsybitsy_esp32
build_flags =
-DUSE_ABSTRACTION_LAYER
-DCRC_OPTIMISATION_LEVEL=0

[env:adafruit_metro_esp32s2]
platform = espressif32
board = adafruit_metro_esp32s2
build_flags =
-DUSE_ABSTRACTION_LAYER
-DCRC_OPTIMISATION_LEVEL=0

[env:arduino_nano_esp32]
platform = espressif32
board = arduino_nano_esp32
build_flags =
-DUSE_ABSTRACTION_LAYER
-DCRC_OPTIMISATION_LEVEL=0

[env:esp32-c3-devkitc-02]
platform = espressif32
board = esp32-c3-devkitc-02
build_flags =
-DUSE_ABSTRACTION_LAYER
-DCRC_OPTIMISATION_LEVEL=0

[env:esp32-c3-devkitm-1]
platform = espressif32
board = esp32-c3-devkitm-1
build_flags =
-DUSE_ABSTRACTION_LAYER
-DCRC_OPTIMISATION_LEVEL=0

[env:esp32-s3-devkitc-1]
platform = espressif32
board = esp32-s3-devkitc-1
build_flags =
-DUSE_ABSTRACTION_LAYER
-DCRC_OPTIMISATION_LEVEL=0

[env:seeed_xiao_esp32c3]
platform = espressif32
board = seeed_xiao_esp32c3
build_flags =
-DUSE_ABSTRACTION_LAYER
-DCRC_OPTIMISATION_LEVEL=0

[env:seeed_xiao_esp32s3]
platform = espressif32
board = seeed_xiao_esp32s3
build_flags =
-DUSE_ABSTRACTION_LAYER
-DCRC_OPTIMISATION_LEVEL=0

[env:sparkfun_esp32_iot_redboard]
platform = espressif32
board = sparkfun_esp32_iot_redboard
build_flags =
-DUSE_ABSTRACTION_LAYER
-DCRC_OPTIMISATION_LEVEL=0

[env:esp32thing]
platform = espressif32
board = esp32thing
build_flags =
-DUSE_ABSTRACTION_LAYER
-DCRC_OPTIMISATION_LEVEL=0

[env:esp32thing_plus]
platform = espressif32
board = esp32thing_plus
build_flags =
-DUSE_ABSTRACTION_LAYER
-DCRC_OPTIMISATION_LEVEL=0

[env:sparkfun_esp32s2_thing_plus]
platform = espressif32
board = sparkfun_esp32s2_thing_plus
build_flags =
-DUSE_ABSTRACTION_LAYER
-DCRC_OPTIMISATION_LEVEL=0

; Teensy Boards
[env:teensy_30]
platform = teensy
Expand Down Expand Up @@ -306,7 +447,8 @@ build_flags =
-DCRC_OPTIMISATION_LEVEL=0

[platformio]
default_envs = adafruit_metro_m0
default_envs = adafruit_metro_m4
core_dir = $PROJECT_DIR/.pio/core
include_dir = src/include
lib_dir = src/lib
src_dir = src/src
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,63 @@ namespace hal
// TEMPORARILY DISABLED: Arduino IDE must be 1.7.0 or greater
// #if ARDUINO >= 10700

// Arduino ESP32 Architecture
#if defined(ARDUINO_ARCH_ESP32)

// Adafruit devboards
#if defined(ARDUINO_FEATHER_ESP32)
device.type.devboard = DEVBOARD_ADAFRUIT_FEATHER_ESP32;
#elif defined(ARDUINO_METRO_ESP32S2)
device.type.devboard = DEVBOARD_ADAFRUIT_METRO_ESP32S2;
#elif defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2_NOPSRAM)
device.type.devboard = DEVBOARD_ADAFRUIT_FEATHER_ESP32S2;
#elif defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S3)
device.type.devboard = DEVBOARD_ADAFRUIT_FEATHER_ESP32S3;
#elif defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S3_NOPSRAM)
device.type.devboard = DEVBOARD_ADAFRUIT_FEATHER_ESP32S3_NOPSRAM;
#elif defined(ARDUINO_ADAFRUIT_ITSYBITSY_ESP32)
device.type.devboard = DEVBOARD_ADAFRUIT_ITSYBITSY_ESP32;
#elif defined(ARDUINO_ADAFRUIT_QTPY_ESP32C3)
device.type.devboard = DEVBOARD_ADAFRUIT_QTPY_ESP32C3;
#elif defined(ARDUINO_ADAFRUIT_QTPY_ESP32S2)
device.type.devboard = DEVBOARD_ADAFRUIT_QTPY_ESP32S2;
#elif defined(ARDUINO_ADAFRUIT_QTPY_ESP32S3_NOPSRAM)
device.type.devboard = DEVBOARD_ADAFRUIT_QTPY_ESP32S3;
#elif defined(ARDUINO_ADAFRUIT_QTPY_ESP32_PICO)
device.type.devboard = DEVBOARD_ADAFRUIT_QTPY_ESP32_PICO;

// Espressif devboards.
#elif defined(ARDUINO_ESP32C3_DEV)
device.type.devboard = DEVBOARD_ESPRESSIF_ESP32C3_DEVKIT;
#elif defined(ARDUINO_ESP32S3_DEV)
device.type.devboard = DEVBOARD_ESPRESSIF_ESP32S3_DEVKIT;

// Seeed Studio ESP32 devboards.
#elif defined(ARDUINO_XIAO_ESP32C3)
device.type.devboard = DEVBOARD_SEEEDSTUDIO_XIAO_ESP32C3;
#elif defined(ARDUINO_XIAO_ESP32S3)
device.type.devboard = DEVBOARD_SEEEDSTUDIO_XIAO_ESP32S3;

// SparkFun ESP32 devboards.
#elif defined(ARDUINO_ESP32_IOT_REDBOARD)
device.type.devboard = DEVBOARD_SPARKFUN_REDBOARD_ESP32_IOT;
#elif defined(ARDUINO_ESP32_THING)
device.type.devboard = DEVBOARD_SPARKFUN_THING_ESP32;
#elif defined(ARDUINO_ESP32_THING_PLUS)
device.type.devboard = DEVBOARD_SPARKFUN_THING_PLUS_ESP32;
#elif defined(ARDUINO_ESP32S2_THING_PLUS)
device.type.devboard = DEVBOARD_SPARKFUN_THING_PLUS_ESP32S2;

// Arduino devboards
#elif defined(ARDUINO_NANO_ESP32)
device.type.devboard = DEVBOARD_ARDUINO_NANO_ESP32;
#else
#warning "Devboard not supported. Please check the compatibility table."
device.type.devboard = DEVBOARD_IS_INCOMPATIBLE;
#endif

// Arduino SAMD Architecture
#if defined(ARDUINO_ARCH_SAMD)
#elif defined(ARDUINO_ARCH_SAMD)

// Adafruit devboards
#if USB_VID == 0x239A
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ namespace hal
// Unknown device.
DEVBOARD_IS_INCOMPATIBLE = 0,

// Adafruit ESP32 boards.
DEVBOARD_ADAFRUIT_FEATHER_ESP32,
DEVBOARD_ADAFRUIT_FEATHER_ESP32S2,
DEVBOARD_ADAFRUIT_FEATHER_ESP32S3,
DEVBOARD_ADAFRUIT_FEATHER_ESP32S3_NOPSRAM,
DEVBOARD_ADAFRUIT_ITSYBITSY_ESP32,
DEVBOARD_ADAFRUIT_METRO_ESP32S2,
DEVBOARD_ADAFRUIT_QTPY_ESP32C3,
DEVBOARD_ADAFRUIT_QTPY_ESP32_PICO,
DEVBOARD_ADAFRUIT_QTPY_ESP32S2,
DEVBOARD_ADAFRUIT_QTPY_ESP32S3,

// Adafruit SAMD21 boards.
DEVBOARD_ADAFRUIT_FEATHER_M0,
DEVBOARD_ADAFRUIT_FEATHER_M0_EXPRESS,
Expand All @@ -63,6 +75,9 @@ namespace hal
// Adafruit SAME51 boards.
DEVBOARD_ADAFRUIT_FEATHER_M4_CAN,

// Arduino ESP32 boards.
DEVBOARD_ARDUINO_NANO_ESP32,

// Arduino SAMD21 boards.
DEVBOARD_ARDUINO_MKR1000,
DEVBOARD_ARDUINO_MKRFOX1200,
Expand All @@ -76,9 +91,21 @@ namespace hal
DEVBOARD_ARDUINO_NANO_33_IOT,
DEVBOARD_ARDUINO_ZERO,

// Espresif ESP32 boards.
DEVBOARD_ESPRESSIF_ESP32C3_DEVKIT,
DEVBOARD_ESPRESSIF_ESP32S3_DEVKIT,

// Seeed Studio boards.
DEVBOARD_SEEEDSTUDIO_XIAO_ESP32C3,
DEVBOARD_SEEEDSTUDIO_XIAO_ESP32S3,
DEVBOARD_SEEEDSTUDIO_XIAO_M0,

// SparkFun Boards
DEVBOARD_SPARKFUN_REDBOARD_ESP32_IOT,
DEVBOARD_SPARKFUN_THING_ESP32,
DEVBOARD_SPARKFUN_THING_PLUS_ESP32,
DEVBOARD_SPARKFUN_THING_PLUS_ESP32S2,

// Teensy boards.
DEVBOARD_TEENSY_30,
DEVBOARD_TEENSY_31_32,
Expand All @@ -104,6 +131,16 @@ namespace hal

const char *deviceNames[DEVBOARD_COUNT] = {
"Incompatible device",
"Adafruit Feather ESP32",
"Adafruit Feather ESP32-S2",
"Adafruit Feather ESP32-S3",
"Adafruit Feather ESP32-S3 (no PSRAM)",
"Adafruit ItsyBitsy ESP32",
"Adafruit Metro ESP32-S2",
"Adafruit QT Py ESP32 C3",
"Adafruit QT Py ESP32 Pico",
"Adafruit QT Py ESP32-S2",
"Adafruit QT Py ESP32-S3",
"Adafruit Feather M0",
"Adafruit Feather M0 Express",
"Adafruit ItsyBitsy M0 Express",
Expand All @@ -116,6 +153,7 @@ namespace hal
"Adafruit Metro M4 AirLift Lite",
"Adafruit Metro M4 Express",
"Adafruit Feather M4 CAN",
"Arduino Nano ESP32",
"Arduino MKR1000",
"Arduino MKRFOX1200",
"Arduino MKRGSM1400",
Expand All @@ -127,7 +165,15 @@ namespace hal
"Arduino MKRZERO",
"Arduino Nano 33 IoT",
"Arduino Zero",
"Espressif ESP32-C3 DevKit",
"Espressif ESP32-S3 DevKit",
"Seeed Studio Xiao ESP32-C3",
"Seeed Studio Xiao ESP32-S3",
"Seeed Studio Xiao SAMD21",
"SparkFun RedBoard ESP32 IoT",
"SparkFun Thing ESP32",
"SparkFun Thing Plus ESP32",
"SparkFun Thing Plus ESP32-S2",
"Teensy 3.0",
"Teensy 3.1/3.2",
"Teensy 3.5",
Expand Down
12 changes: 9 additions & 3 deletions src/lib/CRSFforArduino/src/Hardware/DevBoards/DevBoards.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ namespace hal
// Default to Serial1 if Teensyduino is being used. May expand this in the future, if requested.
uart_port = &Serial1;

// Debug.
Serial.println("[Development Board | DEBUG]: Using Serial1.");
#elif defined(ARDUINO_ARCH_ESP32)
// Default to Serial1 if ESP32 is being used. May expand this in the future, if requested.
uart_port = &Serial1;

// Debug.
Serial.println("[Development Board | DEBUG]: Using Serial1.");
#else
Expand All @@ -132,13 +138,13 @@ namespace hal
// If UART port was defined beforehand, delete it.
if (uart_port != nullptr)
{
#ifndef TEENSYDUINO
#if not(defined(TEENSYDUINO) || defined(ARDUINO_ARCH_ESP32))
uart_port->~Uart();
#endif
}
}

void DevBoards::begin(unsigned long baudrate, uint16_t config)
void DevBoards::begin(unsigned long baudrate, int config)
{
// Begin the UART port.
uart_port->begin(baudrate, config);
Expand Down Expand Up @@ -180,7 +186,7 @@ namespace hal
return uart_port->write(c);
}

#if defined(TEENSYDUINO)
#if defined(TEENSYDUINO) || defined(ARDUINO_ARCH_ESP32)
size_t DevBoards::write(const uint8_t *buffer, size_t size)
{
// Write a buffer to the UART port.
Expand Down
Loading