From ad7bb089316aa04c4d877d9dbc3b22b7f115ebec Mon Sep 17 00:00:00 2001 From: qqqlab <46283638+qqqlab@users.noreply.github.com> Date: Thu, 22 Feb 2024 22:47:57 +0100 Subject: [PATCH] add ESP32-S3 --- .../Quadcopter.ino} | 0 library.properties | 6 +-- readme.md | 45 ++++++++++++++++--- src/madflight.h | 2 +- src/madflight_board_default_ESP32-S3.h | 34 +++++++++++--- 5 files changed, 72 insertions(+), 15 deletions(-) rename examples/{madflight_Quadcopter/madflight_Quadcopter.ino => Quadcopter/Quadcopter.ino} (100%) diff --git a/examples/madflight_Quadcopter/madflight_Quadcopter.ino b/examples/Quadcopter/Quadcopter.ino similarity index 100% rename from examples/madflight_Quadcopter/madflight_Quadcopter.ino rename to examples/Quadcopter/Quadcopter.ino diff --git a/library.properties b/library.properties index c1eac28..12440f1 100644 --- a/library.properties +++ b/library.properties @@ -1,12 +1,12 @@ name=madflight -version=1.0.2 +version=1.0.3 author=qqqlab maintainer=qqqlab license=GNU sentence=Flight Controller for RP2040 / ESP32 / STM32 -paragraph=This is a 1000 line Arduino ESP32 / RP2040 / STM32 flight controller, forked from dRehmFlight. A functional DIY flight controller can be build for under $10 from readily available development boards and sensor breakout boards. Ideal if you want to try out new flight control concepts, without first having to setup a build environment and without having to read through thousands lines of code to find the spot where you want to change something. +paragraph=Flight tested with readily available development boards and sensor breakout boards. Build a quadcopter, helicoper, airplane or VTOL craft. Includes modules for PID control, CRSF/ELRS/DSMX/SBUS receiver and telemetry, AHRS, GPS, barometer, magnetometer, calibration, command line interface, black box data logging. category=Other -url=https://github.com/qqqlab/madflight +url=https://madflight.com/arduino architectures=* depends= includes=madflight.h diff --git a/readme.md b/readme.md index 798561e..a042b27 100644 --- a/readme.md +++ b/readme.md @@ -32,11 +32,11 @@ Flight tested on ESP32, RP2040, and STM32F405 microcontrollers with the Arduino ## Getting Started 1. Install the Arduino madflight library -2. Open example madflight_Quadcopter.ino in the Arduino IDE. +2. Open example Quadcopter.ino in the Arduino IDE. 3. Setup the USER-SPECIFIED DEFINES section 4. If you're not using a default pinout (see below) then setup your board pinout in the BOARD section. 5. Connect your IMU (gyro/acceleration) sensor as shown below. -6. Compile and upload madflight_Quadcopter.ino to your board. Connect the Serial Monitor at 115200 baud and check the messages. Type 'help' to see the available CLI commands. +6. Compile and upload Quadcopter.ino to your board. Connect the Serial Monitor at 115200 baud and check the messages. Type 'help' to see the available CLI commands. 7. Check that IMU sensor and AHRS are working correctly: use CLI print commands to show gyro, accelerometer, magnetometer and roll/pitch/yaw. 8. Use CLI to calibate the sensor. 9. Connect radio receiver to your development board according to the configured pins. @@ -110,7 +110,7 @@ I2C sensor: ## Default Pinout for ESP32 DevKitC (38 pin) -This pinout can be configured as needed in hw_ESP32.h +This pinout can be configured as needed in madflight_board_default_ESP32.h | Function | GPIO | Board | GPIO | Function | | --: | :-- | -- |--: | :-- | @@ -142,7 +142,7 @@ Note: During boot the input voltage levels (pull up/pull down) on strap pins hav ## Default Pinout for Raspberry Pi Pico (40 pin) -This pinout can be configured as needed in hw_RP2040.h +This pinout can be configured as needed in madflight_board_default_RP2040.h | Function | GPIO | Board | GPIO | Function | | --: | :-- | -- |--: | :-- | @@ -173,7 +173,7 @@ This pinout can be configured as needed in hw_RP2040.h ## Default Pinout for WeActStudio STM32F411 Black Pill (40 pin) -This pinout can be configured as needed in hw_STM32.h +This pinout can be configured as needed in madflight_board_default_STM32.h | Function | GPIO | Board | GPIO | Function | | --: | :-- | -- |--: | :-- | @@ -206,6 +206,41 @@ PWM1-6 are connected to timer1, PWM7-8 to timer3 and PWM9-10 to timer4. PWM pins + +## Default Pinout for ESP32-S3 DevKitC-1 (44 pin) + +This pinout can be configured as needed in madflight_board_default_ESP32-S3.h + +| Function | GPIO | Board | GPIO | Function | +| --: | :-- | -- |--: | :-- | +3V3 out | 3V3 | Antenna side | G | GND +3V3 out | 3V3 | | 43 | TX serial debug UART port +reset button | RST | | 44 | RX serial debug UART port +PWM1 | 4 | | 1 | - +PWM2 | 5 | | 2 | - +PWM3 | 6 | | 42 | - +PWM4 | 7 | | 41 | - +PWM5 | 15 | | 40 | - +PWM6 | 16 | | 39 | - +RCIN_TX | 17 | | 38 | LED +RCIN_RX | 18 | | 37 | - +I2C_SDA | 8 | | 36 | - +GPS_RX | 3 | | 35 | - +GPS_TX | 46 | | 0 | boot button +I2C_SCL | 9 | | 45| - +IMU_CS | 10 | | 48 | RGB_LED +SPI_MOSI | 11 | | 47 | - +MISO | 12 | | 21 | - +SCLK | 13 | | 20 | USB_D+ (serial debug alternate) +IMU_EXTI | 14 | | 19 | USB_D- (serial debug alternate) +5V in (*) | 5V | | G | GND +GND | G | USB connector | G | GND + +(*) 5V input via diode from BEC. Without a diode take care not connect USB and the battery at the same time! + + + + ## Changes from dRehmFlight - Add support for RP2040, ESP32, and STM32 diff --git a/src/madflight.h b/src/madflight.h index b861add..14564ac 100644 --- a/src/madflight.h +++ b/src/madflight.h @@ -1,4 +1,4 @@ -#define MADFLIGHT_VERSION "madflight v1.0.2" +#define MADFLIGHT_VERSION "madflight v1.0.3" /*========================================================================================== madflight - Flight Controller for ESP32 / RP2040 / STM32 diff --git a/src/madflight_board_default_ESP32-S3.h b/src/madflight_board_default_ESP32-S3.h index 20d46d6..f41315e 100644 --- a/src/madflight_board_default_ESP32-S3.h +++ b/src/madflight_board_default_ESP32-S3.h @@ -1,16 +1,38 @@ -//This pin layout is optimized for Espressif ESP32 DevKitC 38 pin board, use "ESP32 Dev Module" as board in Arduino IDE +/*This pin layout is optimized for Espressif ESP32-S3-DevKitC-1 - 44 pin pin board + +Arduino IDE setup for Espressif ESP32-S3-DevKitC-1 with ESP32-S3-WROOM-2-N32R8V module: +board: ESP32S3 Dev Module + Flash Mode: OPI 80MHz + Flash Size: 32MB (256Mb) + +Regular setup with 3 Serial ports (Serial, Serial1 and Serial2) + USB CDC On Boot: Disabled + --> Serial connected to "UART", error 'Serial0' was not declared + +Add USB as 4th serial port (Serial, Serial0, Serial1 and Serial2) + USB CDC On Boot: Enabled + USB DFU On Boot: Disabled + USB Mode: USB-OTG (TinyUSB) + --> Serial connected to "USB", Serial0 connected to "UART" + +Settings for programming via "UART" micro usb port (programming works without pressing boot/reset buttons) + Upload Mode: UART0 / Hardware CDC + +Settings for programming via "USB" micro usb port (need to press boot/reset buttons for programming) + Upload Mode: USB-OTG CDC (TinyUSB) +Programming/debugging: + press boot, press+release reset, release boot, then upload + press+release reset, then open serial monitor + +*/ #define HW_BOARD_NAME "DEFAULT ESP32-S3 BOARD - Espressif ESP32-S3-DevKitC-1 - 44 pin" #define HW_MCU "ESP32-S3" //ESP32-S3 - Most pins can be assigned freely //NOTE: DON'T USE SAME PIN TWICE. All pins here get configured, even if they are not used. Set pin to -1 to disable. -//Serial Debug -//19,20=USB, 43,44=CP2102 -//USB CDC On Boot "Enabled": Serial->USB, Serial0->UART, "Disabled": Serial->UART, Serial1->undefined - //LED: -const int HW_PIN_LED = 38; //Note: ESP32S3 DevKitC has RGB LED on this pin +const int HW_PIN_LED = 38; //Note: plus RGB_LED on pin 48, some versions have RGB_LED on pin 38 and no LED const int HW_LED_ON = 1; //0:low is on, 1:high is on //IMU SPI: