diff --git a/docs/assets/images/flyingrcf435wingmini_front_back.jpg b/docs/assets/images/flyingrcf435wingmini_front_back.jpg new file mode 100644 index 00000000000..7dccb422996 Binary files /dev/null and b/docs/assets/images/flyingrcf435wingmini_front_back.jpg differ diff --git a/docs/assets/images/flyingrcf435wingmini_hardware_overview.jpg b/docs/assets/images/flyingrcf435wingmini_hardware_overview.jpg new file mode 100644 index 00000000000..46756824872 Binary files /dev/null and b/docs/assets/images/flyingrcf435wingmini_hardware_overview.jpg differ diff --git a/docs/assets/images/flyingrcf435wingmini_wiring.jpeg b/docs/assets/images/flyingrcf435wingmini_wiring.jpeg new file mode 100644 index 00000000000..df423b7371e Binary files /dev/null and b/docs/assets/images/flyingrcf435wingmini_wiring.jpeg differ diff --git a/docs/boards/FLYINGRCF435WINGMINI.md b/docs/boards/FLYINGRCF435WINGMINI.md new file mode 100644 index 00000000000..97cc277b286 --- /dev/null +++ b/docs/boards/FLYINGRCF435WINGMINI.md @@ -0,0 +1,120 @@ +# Board - FlyingRC F435 Wing Mini + +The FlyingRC F435 Wing Mini is a compact fixed-wing flight controller based on +the AT32F435 in a QFN48 package. Both the AT32F435CGU7 and AT32F435CMU7 hardware +variants use the same peripheral and connector layout. + +## Firmware targets + +| MCU | INAV target | Flash | +|---|---|---:| +| AT32F435CGU7 | `FLYINGRCF435WINGMINI` | 1 MiB | +| AT32F435CMU7 | `FLYINGRCF435WINGMINI_CMU7` | 4 MiB | + +Board identifier: `FAM1` + +## Board views + +![FlyingRC F435 Wing Mini front and back](../assets/images/flyingrcf435wingmini_front_back.jpg) + +## Specifications + +- BMI270 IMU +- SPA06 barometer +- MAX7456/AT7456E analog OSD +- Four full-duplex UARTs +- One external I2C bus +- Six motor/servo outputs +- USB virtual serial port +- Analog battery-voltage and current inputs +- External INA226 support on I2C1 +- Two status LEDs, an addressable LED output, and a buzzer output +- No onboard SD card or flash storage + +## Hardware overview + +![FlyingRC F435 Wing Mini hardware overview](../assets/images/flyingrcf435wingmini_hardware_overview.jpg) + +## Wiring example + +The following manufacturer-provided diagram shows typical connections for an +analog video system, serial receivers, GPS, I2C airspeed sensor, DJI O4 Air Unit +and an external power module. + +![FlyingRC F435 Wing Mini wiring diagram](../assets/images/flyingrcf435wingmini_wiring.jpeg) + +## Pinout + +### Serial ports + +| Port | TX | RX | Default use | +|---|---|---|---| +| UART1 | PA9 | PA10 | GPS | +| UART2 | PA2 | PA3 | Serial receiver (CRSF) | +| UART3 | PB10 | PB11 | Telemetry, VTX, or MSP | +| UART4 | PA0 | PA1 | General purpose | + +### I2C1 + +| Signal | Pin | +|---|---| +| SCL | PB8 | +| SDA | PB9 | + +The onboard SPA06 barometer uses I2C1. The same bus is available on the external +pads for magnetometers, airspeed sensors, rangefinders, additional barometers, +and INA226 battery monitors. The default INA226 address is `0x40`. + +### Motor and servo outputs + +| Output | Pin | Timer | +|---|---|---| +| OUT1 | PB12 | TMR5 CH1 | +| OUT2 | PH3 | TMR5 CH2 | +| OUT3 | PA15 | TMR2 CH1 | +| OUT4 | PB2 | TMR2 CH4 | +| OUT5 | PB6 | TMR4 CH1 | +| OUT6 | PB7 | TMR4 CH2 | + +OUT4 shares PB2 with the MCU boot configuration function. The hardware keeps +the pin low during startup so that the normal firmware boot mode is selected. + +### Battery monitoring + +| Function | Pin | Notes | +|---|---|---| +| Battery voltage | PB1 | 200 kOhm / 10 kOhm divider (21:1) | +| Analog current | PB0 | Current-sensor analog output | + +The default voltage scale is configured for the 200 kOhm / 10 kOhm divider. +Current can be measured using either the analog input or an external INA226 on +I2C1. Configure the INA226 address and shunt resistance in the INAV CLI. + +### Indicators and other interfaces + +| Function | Pin | Active level | +|---|---|---| +| Blue status LED | PB4 | Low | +| Green status LED | PB5 | Low | +| WS2812 LED output | PA8 | High | +| Buzzer | PH2 | Low | +| SWDIO | PA13 | - | +| SWCLK | PA14 | - | +| USB D- | PA11 | - | +| USB D+ | PA12 | - | + +## IMU and OSD bus + +The BMI270 and MAX7456/AT7456E share SPI1 and use independent chip-select pins. + +| Signal | Pin | +|---|---| +| SPI1 SCK | PA5 | +| SPI1 MISO | PA6 | +| SPI1 MOSI | PA7 | +| BMI270 CS | PA4 | +| BMI270 interrupt | PC13 | +| MAX7456/AT7456E CS | PC14 | + +The BMI270 alignment is defined by the target and does not require a board +alignment override in the configurator. diff --git a/src/main/config/config_streamer_at32f43x.c b/src/main/config/config_streamer_at32f43x.c index dce84dbd275..4d0e29b0c66 100644 --- a/src/main/config/config_streamer_at32f43x.c +++ b/src/main/config/config_streamer_at32f43x.c @@ -23,9 +23,11 @@ #if defined(AT32F43x) && !defined(CONFIG_IN_RAM) && !defined(CONFIG_IN_EXTERNAL_FLASH) -#if defined(AT32F437ZMT7) || defined(AT32F437VMT7) || defined(AT32F435RMT7) +#if defined(AT32F437ZMT7) || defined(AT32F437VMT7) || defined(AT32F435RMT7) || \ + defined(AT32F435CMU7) #define FLASH_PAGE_SIZE ((uint32_t)0x1000) -#elif defined(AT32F437ZGT7) || defined(AT32F437VGT7) || defined(AT32F435RGT7) +#elif defined(AT32F437ZGT7) || defined(AT32F437VGT7) || defined(AT32F435RGT7) || \ + defined(AT32F435CGU7) #define FLASH_PAGE_SIZE ((uint32_t)0x800) #endif diff --git a/src/main/target/FLYINGRCF435WINGMINI/CMakeLists.txt b/src/main/target/FLYINGRCF435WINGMINI/CMakeLists.txt new file mode 100644 index 00000000000..3f1323093ac --- /dev/null +++ b/src/main/target/FLYINGRCF435WINGMINI/CMakeLists.txt @@ -0,0 +1,28 @@ +# INAV's generic xGT7 helper selects the correct 1 MiB linker script but +# identifies the package as AT32F435RGT7. Select the actual QFN48 part here. +function(target_at32f435xgu7 name) + target_at32f43x( + NAME ${name} + STARTUP startup_at32f435_437.s + SOURCES ${AT32F4_STDPERIPH_SRC} + COMPILE_DEFINITIONS AT32F435CGU7 MCU_RAM_SIZE=192 MCU_FLASH_SIZE=1024 + LINKER_SCRIPT at32_flash_f43xG + SVD at32f43x_xGT7 + ${ARGN} + ) +endfunction() + +function(target_at32f435xmu7 name) + target_at32f43x( + NAME ${name} + STARTUP startup_at32f435_437.s + SOURCES ${AT32F4_STDPERIPH_SRC} + COMPILE_DEFINITIONS AT32F435CMU7 MCU_RAM_SIZE=192 MCU_FLASH_SIZE=4032 + LINKER_SCRIPT at32_flash_f43xM + SVD at32f43x_xMT7 + ${ARGN} + ) +endfunction() + +target_at32f435xgu7(FLYINGRCF435WINGMINI) +target_at32f435xmu7(FLYINGRCF435WINGMINI_CMU7) diff --git a/src/main/target/FLYINGRCF435WINGMINI/target.c b/src/main/target/FLYINGRCF435WINGMINI/target.c new file mode 100644 index 00000000000..861f3dbfe3d --- /dev/null +++ b/src/main/target/FLYINGRCF435WINGMINI/target.c @@ -0,0 +1,24 @@ +/* + * FlyingRC F435 Wing Mini timer map. + */ + +#include + +#include "platform.h" + +#include "drivers/bus.h" +#include "drivers/io.h" +#include "drivers/pwm_mapping.h" +#include "drivers/timer.h" + +timerHardware_t timerHardware[] = { + DEF_TIM(TMR5, CH1, PB12, TIM_USE_OUTPUT_AUTO, 0, 8), // OUT1, DMA2 CH2 + DEF_TIM(TMR5, CH2, PH3, TIM_USE_OUTPUT_AUTO, 0, 9), // OUT2, DMA2 CH3 + DEF_TIM(TMR2, CH1, PA15, TIM_USE_OUTPUT_AUTO, 0, 0), // OUT3, DMA1 CH1 + DEF_TIM(TMR2, CH4, PB2, TIM_USE_OUTPUT_AUTO, 0, 6), // OUT4 / BOOT1, DMA1 CH7 + DEF_TIM(TMR4, CH1, PB6, TIM_USE_OUTPUT_AUTO, 0, 11), // OUT5, DMA2 CH5 + DEF_TIM(TMR4, CH2, PB7, TIM_USE_OUTPUT_AUTO, 0, 10), // OUT6, DMA2 CH4 + DEF_TIM(TMR1, CH1, PA8, TIM_USE_LED, 0, 5), // WS2812, DMA1 CH6 +}; + +const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); diff --git a/src/main/target/FLYINGRCF435WINGMINI/target.h b/src/main/target/FLYINGRCF435WINGMINI/target.h new file mode 100644 index 00000000000..b6b93dc1308 --- /dev/null +++ b/src/main/target/FLYINGRCF435WINGMINI/target.h @@ -0,0 +1,115 @@ +/* + * FlyingRC AT32F435 Mini fixed-wing target. + * MCU: AT32F435CGU7 / AT32F435CMU7, QFN48, 8 MHz HEXT. + */ + +#pragma once + +#define TARGET_BOARD_IDENTIFIER "FAM1" + +#if defined(AT32F435CMU7) +#define USBD_PRODUCT_STRING "FlyingRC ATF435 Mini CMU7" +#else +#define USBD_PRODUCT_STRING "FlyingRC ATF435 Mini CGU7" +#endif + +/* Indicators */ +#define LED0 PB4 // Blue +#define LED1 PB5 // Green +#define LED0_INVERTED +#define LED1_INVERTED + +#define BEEPER PH2 +#define BEEPER_INVERTED + +#define USE_LED_STRIP +#define WS2811_PIN PA8 + +/* SPI1: IMU and MAX7456 share the bus, with independent chip selects. */ +#define USE_SPI +#define USE_SPI_DEVICE_1 +#define SPI1_SCK_PIN PA5 +#define SPI1_MISO_PIN PA6 +#define SPI1_MOSI_PIN PA7 + +#define USE_IMU_BMI270 +#define IMU_BMI270_ALIGN CW0_DEG_FLIP +#define BMI270_SPI_BUS BUS_SPI1 +#define BMI270_CS_PIN PA4 +#define BMI270_EXTI_PIN PC13 + +#define USE_MAX7456 +#define MAX7456_SPI_BUS BUS_SPI1 +#define MAX7456_CS_PIN PC14 + +/* I2C1: external barometer, compass, pitot and rangefinder bus. */ +#define USE_I2C +#define USE_I2C_DEVICE_1 +#define I2C1_SCL PB8 +#define I2C1_SDA PB9 +/* The AT32 I2C driver instantiates all three descriptors. Mark the unused + * controllers explicitly instead of assigning duplicate pins. */ +#define I2C2_SCL NONE +#define I2C2_SDA NONE +#define I2C3_SCL NONE +#define I2C3_SDA NONE +#define DEFAULT_I2C_BUS BUS_I2C1 + +#define USE_BARO +#define BARO_I2C_BUS BUS_I2C1 +#define USE_BARO_ALL + +#define USE_MAG +#define MAG_I2C_BUS BUS_I2C1 +#define USE_MAG_ALL + +#define PITOT_I2C_BUS BUS_I2C1 +#define RANGEFINDER_I2C_BUS BUS_I2C1 + +/* USB and four UARTs. */ +#define USE_VCP + +#define USE_UART1 +#define UART1_TX_PIN PA9 +#define UART1_RX_PIN PA10 + +#define USE_UART2 +#define UART2_TX_PIN PA2 +#define UART2_RX_PIN PA3 + +#define USE_UART3 +#define UART3_TX_PIN PB10 +#define UART3_RX_PIN PB11 + +#define USE_UART4 +#define UART4_TX_PIN PA0 +#define UART4_RX_PIN PA1 + +#define SERIAL_PORT_COUNT 5 + +#define DEFAULT_RX_TYPE RX_TYPE_SERIAL +#define SERIALRX_PROVIDER SERIALRX_CRSF +#define SERIALRX_UART SERIAL_PORT_USART2 + +/* Analog battery monitoring. */ +#define USE_ADC +#define ADC_INSTANCE ADC1 +#define ADC1_DMA_STREAM DMA2_CHANNEL1 +#define ADC_CHANNEL_1_PIN PB1 +#define ADC_CHANNEL_2_PIN PB0 +#define VBAT_ADC_CHANNEL ADC_CHN_1 +#define CURRENT_METER_ADC_CHANNEL ADC_CHN_2 +#define VBAT_SCALE_DEFAULT 2100 // 200k:10k divider, 21:1 + +#define DEFAULT_FEATURES (FEATURE_TX_PROF_SEL | FEATURE_CURRENT_METER | FEATURE_TELEMETRY | FEATURE_VBAT | FEATURE_OSD | FEATURE_LED_STRIP) + +#define USE_SERIAL_4WAY_BLHELI_INTERFACE +#define USE_DSHOT +#define USE_ESC_SENSOR + +#define TARGET_IO_PORTA 0xffff +#define TARGET_IO_PORTB 0xffff +#define TARGET_IO_PORTC (BIT(13) | BIT(14) | BIT(15)) +#define TARGET_IO_PORTH (BIT(2) | BIT(3)) + +#define MAX_PWM_OUTPUT_PORTS 6