Skip to content
Open
Changes from all commits
Commits
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
160 changes: 160 additions & 0 deletions configs/GD32H757VSTART_V02/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
/*
* This file is part of Betaflight.
*
* Betaflight is free software. You can redistribute this software
* and/or modify this software under the terms of the GNU General
* Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later
* version.
*
* Betaflight is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this software.
*
* If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#define FC_TARGET_MCU GD32H757VI

#define BOARD_NAME GD32H757V1START
#define MANUFACTURER_ID GD32MCU

#define USE_GYRO
#define USE_GYRO_SPI_MPU6000
#define USE_GYRO_SPI_ICM42688P
#define USE_ACC
#define USE_ACC_SPI_MPU6000
#define USE_ACC_SPI_ICM42688P
#define USE_BARO
#define USE_BARO_DPS310
#define USE_BARO_BMP280
#define USE_BARO_MS5611
#define USE_BARO_GDY112X

#define USE_FLASH
#define USE_FLASH_W25Q128FV
#define USE_MAX7456

// #define USE_MAG
// #define USE_MAG_QMC5883

#define BEEPER_PIN PD3

#define MOTOR1_PIN PE9
#define MOTOR2_PIN PE11
#define MOTOR3_PIN PE13
#define MOTOR4_PIN PE14
#define MOTOR5_PIN PC6
#define MOTOR6_PIN PC7
#define MOTOR7_PIN PC8
#define MOTOR8_PIN PC9

// #define SERVO1_PIN PE5
// #define SERVO2_PIN PE6

#define RX_PPM_PIN PA10
#define LED_STRIP_PIN PB1


#define UART0_TX_PIN PA9
#define UART1_TX_PIN PD5
#define UART2_TX_PIN PD8
#define UART3_TX_PIN PB8
#define UART4_TX_PIN PC12
#define UART6_TX_PIN PE8
#define UART7_TX_PIN PE1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Critical pin conflict: PE1 assigned to both UART7_TX and LED1.

Line 72 defines UART7_TX_PIN as PE1, and line 87 defines LED1_PIN as PE1. The same GPIO pin cannot serve two simultaneous functions. This will cause hardware configuration errors and unpredictable behavior.

🔧 Verify hardware schematic and correct the conflict

Please check the board schematic to determine:

  1. Which function should actually use PE1
  2. What the correct pin assignment should be for the other function

Then update one of these definitions accordingly.

Also applies to: 87-87

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@configs/GD32H757VSTART_V02/config.h` at line 72, UART7_TX_PIN and LED1_PIN
are both defined as PE1 causing a hardware pin conflict; check the board
schematic to determine which function should keep PE1 and update the other macro
(either UART7_TX_PIN or LED1_PIN) to the correct GPIO pin per the schematic so
they are not the same pin; ensure the updated definition uses the correct symbol
name (UART7_TX_PIN or LED1_PIN) and matches existing pin naming convention
(e.g., PXn) used elsewhere in the file.

#define UART0_RX_PIN PA10
#define UART1_RX_PIN PD6
#define UART2_RX_PIN PD9
#define UART3_RX_PIN PB9
#define UART4_RX_PIN PD2
#define UART6_RX_PIN PE7
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for similar PE7 dual-assignment patterns in other board configs
rg -n 'UART6_RX_PIN.*PE7' --type=c -A2 -B2
rg -n 'ESCSERIAL_PIN.*PE7' --type=c -A2 -B2

Repository: betaflight/config

Length of output: 659


🏁 Script executed:

# Search for ESCSERIAL_PIN definitions in all board configs to see if pin sharing is common
rg -n 'ESCSERIAL_PIN' --type=c | head -20

# Check for configuration guards around UART6_RX_PIN and ESCSERIAL_PIN
rg -B5 -A5 'UART6_RX_PIN|ESCSERIAL_PIN' configs/GD32H757VSTART_V02/config.h

Repository: betaflight/config

Length of output: 1838


🏁 Script executed:

# Search across all board configs for UART6_RX_PIN to see if this pattern appears elsewhere
find configs -name "config.h" -exec grep -l "UART6_RX_PIN" {} \;
find configs -name "config.h" -exec grep -l "ESCSERIAL_PIN" {} \;

Repository: betaflight/config

Length of output: 14257


🏁 Script executed:

# Check if there are any conditional definitions or comments indicating mutual exclusivity
rg -B10 'UART6_RX_PIN.*PE7|ESCSERIAL_PIN.*PE7' configs/GD32H757VSTART_V02/config.h

Repository: betaflight/config

Length of output: 595


🏁 Script executed:

# Search for any configuration guards or conditional definitions around PE7
rg -B20 'UART6_RX_PIN.*PE7' configs/GD32H757VSTART_V02/config.h | head -40

# Check if there are any comments explaining ESCSERIAL usage
rg -B5 'ESCSERIAL_PIN' configs/GD32H757VSTART_V02/config.h

# Search for any `#ifdef` or feature guards related to ESCSERIAL or UART6
rg '`#ifdef`.*ESCSERIAL|`#ifdef`.*UART6' --type=c

Repository: betaflight/config

Length of output: 669


🏁 Script executed:

# Check if there's any other board with the same pin sharing pattern
rg 'UART6_RX_PIN' --type=c -A50 | rg -B50 'ESCSERIAL_PIN.*PE' | grep -E 'configs/|UART6_RX_PIN|ESCSERIAL_PIN'

Repository: betaflight/config

Length of output: 6142


Fix PE7 pin conflict: UART6_RX_PIN and ESCSERIAL_PIN both defined as PE7.

This board is the only one in the codebase where UART6_RX_PIN and ESCSERIAL_PIN share the same pin (PE7). All other boards use distinct pins for these functions. Without conditional guards or runtime configuration to disable one, this creates a hardware conflict. Reassign one of these pins to an available GPIO.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@configs/GD32H757VSTART_V02/config.h` at line 78, UART6_RX_PIN is defined as
PE7 but ESCSERIAL_PIN also uses PE7, causing a hardware conflict; change one to
a free GPIO (e.g., pick an unused port/pin like PE8 or another verified free pin
on this board) and update the define for either UART6_RX_PIN or ESCSERIAL_PIN in
config.h accordingly, ensuring the chosen pin does not collide with other
peripherals; alternatively add a conditional guard (e.g., USE_ESCSERIAL or
ENABLE_UART6) around the ESCSERIAL_PIN or UART6_RX_PIN define so only one is
active at build time and document the choice in the config comment.

#define UART7_RX_PIN PE0

#define I2C0_SCL_PIN PB6
#define I2C0_SDA_PIN PB7
#define I2C1_SCL_PIN PB10
#define I2C1_SDA_PIN PB11

#define LED0_PIN PE3
#define LED1_PIN PE1

#define SPI0_SCK_PIN PA5
#define SPI1_SCK_PIN PB13
#define SPI2_SCK_PIN PB3
#define SPI3_SCK_PIN PE2
#define SPI0_SDI_PIN PA6
#define SPI1_SDI_PIN PB14
#define SPI2_SDI_PIN PB4
#define SPI3_SDI_PIN PE5
#define SPI0_SDO_PIN PA7
#define SPI1_SDO_PIN PB15
#define SPI2_SDO_PIN PB5
#define SPI3_SDO_PIN PE6

#define ESCSERIAL_PIN PE7
#define ADC_VBAT_PIN PC0
#define ADC_CURR_PIN PC1
#define ADC_RSSI_PIN PC2

#define FLASH_CS_PIN PA15
#define MAX7456_SPI_CS_PIN PB12
#define GYRO_1_EXTI_PIN PE15
#define GYRO_1_CS_PIN PA4
#define GYRO_2_EXTI_PIN PC13
#define GYRO_2_CS_PIN PE4

#define USB_DETECT_PIN PC15

// #define PINIO1_PIN PD10
// #define PINIO2_PIN PD11

#define TIMER_PIN_MAPPING \
TIMER_PIN_MAP( 0, PB1, 2, 8) \
TIMER_PIN_MAP( 1, PE9, 1, 0) \
TIMER_PIN_MAP( 2, PE11, 1, 0) \
TIMER_PIN_MAP( 3, PE13, 1, 0) \
TIMER_PIN_MAP( 4, PE14, 1, 0) \
TIMER_PIN_MAP( 5, PC6, 2, 0) \
TIMER_PIN_MAP( 6, PC7, 3, 0) \
TIMER_PIN_MAP( 7, PC8, 2, 0) \
TIMER_PIN_MAP( 8, PC9, 2, 0) \


#define ADC0_DMA_OPT 0
#define ADC2_DMA_OPT 1

#define GPS_UART SERIAL_PORT_USART1
#define SERIALRX_UART SERIAL_PORT_USART2
#define MSP_UART SERIAL_PORT_UART4

#define MAG_I2C_INSTANCE I2CDEV_1
#define BARO_I2C_INSTANCE I2CDEV_0
#define DEFAULT_BLACKBOX_DEVICE BLACKBOX_DEVICE_FLASH

// #define DEFAULT_DSHOT_BURST DSHOT_DMAR_OFF
// #define DEFAULT_DSHOT_BITBANG DSHOT_BITBANG_OFF

#define DEFAULT_CURRENT_METER_SOURCE CURRENT_METER_ADC
#define DEFAULT_VOLTAGE_METER_SOURCE VOLTAGE_METER_ADC
#define DEFAULT_CURRENT_METER_SCALE 206
#define BEEPER_INVERTED
#define MAX7456_SPI_INSTANCE SPI1
#define PINIO1_BOX 40
#define PINIO2_BOX 41
#define PINIO3_BOX 42
#define PINIO1_CONFIG 129
#define PINIO2_CONFIG 129
Comment on lines +150 to +154
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Inconsistent PINIO configuration: boxes and configs defined but pins are commented out.

Lines 150-154 define PINIO1_BOX, PINIO2_BOX, PINIO3_BOX, PINIO1_CONFIG, and PINIO2_CONFIG, but the actual PINIO pins (PINIO1_PIN and PINIO2_PIN) are commented out on lines 116-117. Additionally, PINIO3_BOX is defined without a corresponding PINIO3_CONFIG or PINIO3_PIN.

Based on learnings, config.h should only define settings that differ from defaults. If PINIO functionality is not being used (pins commented), the box and config macros should also be removed or commented out.

🔧 Recommended fix

Either uncomment the PINIO pins if the functionality is intended:

-// `#define` PINIO1_PIN PD10
-// `#define` PINIO2_PIN PD11
+#define PINIO1_PIN PD10
+#define PINIO2_PIN PD11
+#define PINIO3_PIN <appropriate_pin>  // Add if PINIO3 is needed
+#define PINIO3_CONFIG 129  // Add if PINIO3 is needed

Or remove/comment out the unused PINIO configuration:

-#define PINIO1_BOX 40
-#define PINIO2_BOX 41
-#define PINIO3_BOX 42
-#define PINIO1_CONFIG 129
-#define PINIO2_CONFIG 129
+// `#define` PINIO1_BOX 40
+// `#define` PINIO2_BOX 41
+// `#define` PINIO3_BOX 42
+// `#define` PINIO1_CONFIG 129
+// `#define` PINIO2_CONFIG 129
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#define PINIO1_BOX 40
#define PINIO2_BOX 41
#define PINIO3_BOX 42
#define PINIO1_CONFIG 129
#define PINIO2_CONFIG 129
// `#define` PINIO1_BOX 40
// `#define` PINIO2_BOX 41
// `#define` PINIO3_BOX 42
// `#define` PINIO1_CONFIG 129
// `#define` PINIO2_CONFIG 129
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@configs/GD32H757VSTART_V02/config.h` around lines 150 - 154, The file defines
PINIO1_BOX, PINIO2_BOX, PINIO3_BOX and PINIO1_CONFIG, PINIO2_CONFIG while
PINIO1_PIN and PINIO2_PIN are commented out and PINIO3 has no PIN or CONFIG, so
either re-enable the PINIO pins and fully define PINIO3 (uncomment PINIO1_PIN
and PINIO2_PIN, add PINIO3_PIN and PINIO3_CONFIG consistent with
PINIO1_CONFIG/PINIO2_CONFIG) if PINIO is intended, or remove/comment out
PINIO1_BOX, PINIO2_BOX, PINIO3_BOX, PINIO1_CONFIG, and PINIO2_CONFIG to match
the default/no-PINIO usage (ensure PINIO1_PIN, PINIO2_PIN remain commented if
removing).

#define FLASH_SPI_INSTANCE SPI2
#define SERIALRX_PROVIDER SERIALRX_CRSF
#define GYRO_1_SPI_INSTANCE SPI0
#define GYRO_1_ALIGN CW90_DEG
#define GYRO_2_SPI_INSTANCE SPI3
#define GYRO_2_ALIGN CW90_DEG