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

AP_HAL_ChibiOS: add hwdef for LongBowF405WING #27009

Merged
merged 2 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
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
Binary file added Tools/bootloaders/LongBowF405WING_bl.bin
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
117 changes: 117 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/LongBowF405WING/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# LongBowF405WING Flight Controller

The LongBowF405WING is a flight controller produced by [lefei rc](http://www.lefeirc.com/).

Hwurzburg marked this conversation as resolved.
Show resolved Hide resolved
## Features
Processor
STM32F405 168Mhz, 1MB 32-bit processor
AT7456E OSD
Sensors
ICM42688P Acc/Gyro
SPL006 barometer
Power
2S - 6S Lipo input voltage with voltage monitoring
120A Cont., 215A peak current monitor
9V/12/5V, 1.8A BEC for powering Video Transmitter controlled by GPIO
4.9V/6V/7.2V, 6A BEC for servos
5V, 2.4A BEC for internal and peripherals
Interfaces
12x PWM outputs DShot capable (Serail LED output is PWM12)
1x RC input
5x UARTs/serial for GPS and other peripherals, 6th UART internally tied to Wireless board)
I2C port for external compass, airspeed, etc.
microSDCard for logging, etc.
USB-C port

## Pinout
![LongBowF405WING](LongBowF405WING_pinout.png)

## Wiring Diagram
![LongBowF405WING](LongBowF405WING.jpg)

## PDB
![LongBowF405WING](PMU.png)

## UART Mapping

The UARTs are marked Rn and Tn in the above pinouts. The Rn pin is the
receive pin for UARTn. The Tn pin is the transmit pin for UARTn.

- SERIAL0 -> USB
- SERIAL1 -> USART1 (User) (DMA capable)
- SERIAL2 -> USART2 (RX tied to inverted SBUS RC input, but can be used as normal UART if :ref:`BRD_ALT_CONFIG<>` =1)
- SERIAL3 -> UART3 (GPS) (TX DMA capable)
- SERIAL4 -> UART4 (User) (TX DMA capable)
- SERIAL5 -> UART5 (DisplayPort, available on DJI air unit connector) (TX DMA capable)
- SERIAL6 -> UART6 (tied to internal wireless module, MAVLink2 telem)


## RC Input

RC input is configured on the SBUS pin (inverted and sent to UART2_RX). It supports all RC
protocols except serial protocols such as CRSF, ELRS, etc. Those devices can be connected to USART1 TX and RX, instead.
Fport can be connected to USART1 TX also, but will require an external bi-directional inverter and the ref:`SERIAL1_OPTION<SERIAL1_OPTION>' = 4 (HalfDuplex) set.

## OSD Support

The LongBowF405WING supports using its internal OSD using OSD_TYPE 1 (MAX7456 driver). External OSD support such DisplayPor is setup by default using UART5. Simultaneous use of the internal OSD and Displayport is allowed. See :ref:`common-msp-osd-overview-4.2` for more info.


## PWM Output

The LongBowF405WING supports up to 12 PWM outputs .
All outputs support DShot.

The PWM is in 5 groups:

- PWM 1,2 in group1
- PWM 3,4 in group2
- PWM 5-6 in group3
- PWM 7-9 in group4
- PWM 10-12 in group5

Channels within the same group need to use the same output rate. If
any channel in a group uses DShot then all channels in that group would need
to use DShot.

## Battery Monitoring

The board has a builting voltage and current sensor. The current
sensor can read up to 120A continuosly, 160 Amps peak. The voltage sensor can handle up to 6S
LiPo batteries.

The correct battery setting parameters are set by default and are:

- BATT_MONITOR 4
- BATT_VOLT_PIN 10
- BATT_CURR_PIN 11
- BATT_VOLT_MULT 11.0
- BATT_AMP_PERVLT 50

## Compass

The LongBowF405WING does not have a built-in compass, but you can attach an external compass using I2C on the SDA and SCL pads.

## VTX power control

GPIO 81 controls the VTX BEC output to pins marked "9V" and "Vs1". Setting a RELAY function to this pin and turning it "ON" will remove the supply from these pins.

## Camera Switch

GPIO 82 controls which camera input (CC1 or C2 is applied to the internal OSD. A RELAY function can be enabled to control the switching.

## Buzzer

An active buzzer output is provided and is controlled as GPIO 80

Hwurzburg marked this conversation as resolved.
Show resolved Hide resolved
## Loading Firmware

Firmware for these boards can be found at https://firmware.ardupilot.org in sub-folders labeled LongBowF405WING.

Initial firmware load can be done with DFU by plugging in USB with the
boot button pressed. Then you should load the "LongBowF405WING_bl.hex"
firmware, using your favourite DFU loading tool.

Subsequently, you can update firmware with Mission Planner.


10 changes: 10 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/LongBowF405WING/defaults.parm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#Serial Port defaults
SERIAL4_PROTOCOL -1
SERIAL1_PROTOCOL 23
SERIAL2_PROTOCOL -1
SERIAL5_PROTOCOL 42
SERIAL6_PROTOCOL 2
Hwurzburg marked this conversation as resolved.
Show resolved Hide resolved

#Enable second OSD Type as DisplayPort
OSD_TYPE2 5

38 changes: 38 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/LongBowF405WING/hwdef-bl.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# hw definition file for processing by chibios_pins.py
# for LongBowF4 bootloader

# MCU class and specific type
MCU STM32F4xx STM32F405xx

# board ID for firmware load
APJ_BOARD_ID AP_HW_LongbowF405


# crystal frequency
OSCILLATOR_HZ 8000000

FLASH_SIZE_KB 1024

# bootloader is installed at zero offset
FLASH_RESERVE_START_KB 0

# the location where the bootloader will put the firmware
FLASH_BOOTLOADER_LOAD_KB 64

# LEDs
PA14 LED_BOOTLOADER OUTPUT LOW GPIO(0)
PA13 LED_ACTIVITY OUTPUT LOW GPIO(1)
define HAL_LED_ON 0

# order of UARTs
SERIAL_ORDER OTG1

PA11 OTG_FS_DM OTG1
PA12 OTG_FS_DP OTG1

DEFAULTGPIO OUTPUT LOW PULLDOWN

# Add CS pins to ensure they are high in bootloader
PA4 MPU_CS CS
PB12 OSD_CS CS
PC14 SDCARD_CS CS
192 changes: 192 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/LongBowF405WING/hwdef.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
# hw definition file for LongBow F4 WING hardware
# tested on the LongBow F405 WING board
#

# MCU class and specific type
MCU STM32F4xx STM32F405xx

# board ID for firmware load
APJ_BOARD_ID AP_HW_LongbowF405

# crystal frequency
OSCILLATOR_HZ 8000000

define STM32_ST_USE_TIMER 5
define CH_CFG_ST_RESOLUTION 32

# reserve 16k for bootloader, 16k for OSD and 32k for flash storage
FLASH_RESERVE_START_KB 64
FLASH_SIZE_KB 1024

define HAL_STORAGE_SIZE 15360
STORAGE_FLASH_PAGE 1

# only one I2C bus
I2C_ORDER I2C1

# order of UARTs (and USB)
SERIAL_ORDER OTG1 USART1 USART2 USART3 UART4 UART5 USART6

# LEDs
PA13 LED_GREEN OUTPUT LOW GPIO(0)
PA14 LED_BLUE OUTPUT LOW GPIO(1)

define HAL_GPIO_A_LED_PIN 0
define HAL_GPIO_B_LED_PIN 1

# buzzer
PC15 BUZZER OUTPUT GPIO(80) LOW
define HAL_BUZZER_PIN 80



# spi1 bus for IMU
PA5 SPI1_SCK SPI1
PA6 SPI1_MISO SPI1
PA7 SPI1_MOSI SPI1
PA4 MPU_CS CS

# spi2 for OSD
PB13 SPI2_SCK SPI2
PC2 SPI2_MISO SPI2
PC3 SPI2_MOSI SPI2
PB12 OSD_CS CS

# spi3 for sdcard
PB3 SPI3_SCK SPI3
PB4 SPI3_MISO SPI3
PB5 SPI3_MOSI SPI3
PC14 SDCARD_CS CS

# only one I2C bus in normal config
PB8 I2C1_SCL I2C1
PB9 I2C1_SDA I2C1

# analog pins
PC0 BATT_VOLTAGE_SENS ADC1 SCALE(1)
PC1 BATT_CURRENT_SENS ADC1 SCALE(1)
PC4 RSSI_ADC_PIN ADC1 SCALE(1)

PC5 PRESSURE_SENS ADC1 SCALE(1)
define HAL_DEFAULT_AIRSPEED_PIN 15

# define default battery setup
define HAL_BATT_MONITOR_DEFAULT 4
define HAL_BATT_VOLT_PIN 10
define HAL_BATT_CURR_PIN 11
define HAL_BATT_VOLT_SCALE 11.0 # matched to PDB board
define HAL_BATT_CURR_SCALE 50 # matched to PDB board

# analog rssi pin
Hwurzburg marked this conversation as resolved.
Show resolved Hide resolved
define BOARD_RSSI_ANA_PIN 14

# USART1 (ELRS)
PA9 USART1_TX USART1
PA10 USART1_RX USART1


# USART2 (RCIN with inverter)

PA3 TIM9_CH2 TIM9 RCININT PULLDOWN LOW

# alternative with PA3 as USART2_RX
PA2 USART2_TX USART2 NODMA
PA3 USART2_RX USART2 NODMA ALT(1)

# USART3 (GPS)
PC10 USART3_TX USART3
PC11 USART3_RX USART3 NODMA
define DEFAULT_SERIAL3_BAUD 115

# UART4 serial4
PA0 UART4_TX UART4
PA1 UART4_RX UART4 NODMA

# USART5 (DJI / VTX)
PC12 UART5_TX UART5
PD2 UART5_RX UART5 NODMA

# UART6 (onboard Telemetry)
PC6 USART6_TX USART6
PC7 USART6_RX USART6
define DEFAULT_SERIAL6_BAUD 115

# USB
PA11 OTG_FS_DM OTG1
PA12 OTG_FS_DP OTG1

# PWM out pins. Note that channel order follows the ArduPilot motor
# order conventions
PC9 TIM8_CH4 TIM8 PWM(1) GPIO(50)
PC8 TIM8_CH3 TIM8 PWM(2) GPIO(51)
PB1 TIM3_CH4 TIM3 PWM(3) GPIO(52)
PB0 TIM3_CH3 TIM3 PWM(4) GPIO(53)
PB6 TIM4_CH1 TIM4 PWM(5) GPIO(54)
PB7 TIM4_CH2 TIM4 PWM(6) GPIO(55)
PA8 TIM1_CH1 TIM1 PWM(7) GPIO(56)
PB15 TIM1_CH3N TIM1 PWM(8) GPIO(57)
PB14 TIM1_CH2N TIM1 PWM(9) GPIO(58)
PA15 TIM2_CH1 TIM2 PWM(10) GPIO(59)
PB11 TIM2_CH4 TIM2 PWM(11) GPIO(60)
PB10 TIM2_CH3 TIM2 PWM(12) GPIO(61)


# one IMU
IMU Invensensev3 SPI:icm42688 ROTATION_ROLL_180_YAW_270
define HAL_DEFAULT_INS_FAST_SAMPLE 1

# one baro
BARO SPL06 I2C:0:0x77
define AP_BARO_BACKEND_DEFAULT_ENABLED 0
define AP_BARO_SPL06_ENABLED 1

# no built-in compass, but probe the i2c bus for all possible
# external compass types
define ALLOW_ARM_NO_COMPASS
define HAL_PROBE_EXTERNAL_I2C_COMPASSES
define HAL_I2C_INTERNAL_MASK 0
define HAL_COMPASS_AUTO_ROT_DEFAULT 2

# ICM42688P on SPI1
SPIDEV icm42688 SPI1 DEVID1 MPU_CS MODE3 2*MHZ 8*MHZ

# OSD on SPI2
SPIDEV osd SPI2 DEVID2 OSD_CS MODE0 10*MHZ 10*MHZ

# SD Card on SPI3
SPIDEV sdcard SPI3 DEVID3 SDCARD_CS MODE0 400*KHZ 25*MHZ

# filesystem setup on sdcard
define HAL_OS_FATFS_IO 1

# setup for OSD
define OSD_ENABLED 1
define HAL_OSD_TYPE_DEFAULT 1
ROMFS_WILDCARD libraries/AP_OSD/fonts/font0.bin

#VTX power control
PC13 PINIO1 OUTPUT GPIO(81) LOW

#CAM SW
PB2 PINIO2 OUTPUT GPIO(82) LOW

define STM32_PWM_USE_ADVANCED TRUE

define HAL_WITH_DSP FALSE

include ../include/minimize_fpv_osd.inc

#undef AP_CAMERA_MOUNT_ENABLED
#undef AP_LANDINGGEAR_ENABLED
#undef HAL_MOUNT_ENABLED
#undef HAL_MOUNT_SERVO_ENABLED
#undef QAUTOTUNE_ENABLED

#define AP_CAMERA_MOUNT_ENABLED 1
#define AP_LANDINGGEAR_ENABLED 1
#define HAL_MOUNT_ENABLED 1
#define HAL_MOUNT_SERVO_ENABLED 1
#define QAUTOTUNE_ENABLED 1

#define DEFAULT_NTF_LED_TYPES 257

Loading