Skip to content
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
24 changes: 7 additions & 17 deletions docs/development/Converting Betaflight Targets.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,37 +40,27 @@ Using the BETAFPVF405 target mentioned above, to create the target now we need t
3. Create a target folder that will be used as the output folder for the `bf2inav.py` script, eg: `inav/src/main/targets/BETAFPVF405`
4. Navigate to the script folder in `inav/src/utils/`
5. `python3 ./bf2inav.py -i config.h -o ../main/target/BETAFPVF405/`
6. Edit generated `target.c` and chose the correct timer definitions to match Betaflight's timer definitions.
6. Edit generated `target.c` and chose the correct timer definitions to match Betaflight's timer definitions for motor, servo, and LED timers (not gyro).
```
timerHardware_t timerHardware[] = {
DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0),
//DEF_TIM(TIM8, CH2N, PB0, TIM_USE_OUTPUT_AUTO, 0, 0),
//DEF_TIM(TIM1, CH2N, PB0, TIM_USE_OUTPUT_AUTO, 0, 0),

DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0),
//DEF_TIM(TIM8, CH3N, PB1, TIM_USE_OUTPUT_AUTO, 0, 0),
//DEF_TIM(TIM1, CH3N, PB1, TIM_USE_OUTPUT_AUTO, 0, 0),

//DEF_TIM(TIM5, CH4, PA3, TIM_USE_OUTPUT_AUTO, 0, 0),
//DEF_TIM(TIM9, CH2, PA3, TIM_USE_OUTPUT_AUTO, 0, 0),
DEF_TIM(TIM2, CH4, PA3, TIM_USE_OUTPUT_AUTO, 0, 0),

//DEF_TIM(TIM5, CH3, PA2, TIM_USE_OUTPUT_AUTO, 0, 0),
//DEF_TIM(TIM9, CH1, PA2, TIM_USE_OUTPUT_AUTO, 0, 0),
DEF_TIM(TIM2, CH3, PA2, TIM_USE_OUTPUT_AUTO, 0, 0),

DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0),
//DEF_TIM(TIM3, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0),

DEF_TIM(TIM1, CH1, PA8, TIM_USE_OUTPUT_AUTO, 0, 0),

//DEF_TIM(TIM3, CH1, PB4, TIM_USE_BEEPER, 0, 0),

DEF_TIM(TIM4, CH1, PB6, TIM_USE_LED, 0, 0),

};
```
In this particular example, PA3, PA2 were changed to match Betaflight's mapping, and the timer PB4 was disabled, due to a timer conflict. Normal channels are prefered over N channels (CH1, over CH1N) or C channels in AT32 architectures.
7. Now update yout build scripts by running `cmake` and build the target you just created. The target name can be checked in the generated `CMakeLists.txt`, but should match the Betaflight target name.
Normal channels are prefered over N channels (CH1, over CH1N) or C channels in AT32 architectures.

The typical value to be set in target.h for DEFAULT_FEATURES is:
#define DEFAULT_FEATURES (FEATURE_OSD | FEATURE_TELEMETRY | FEATURE_CURRENT_METER | FEATURE_VBAT | FEATURE_TX_PROF_SEL | FEATURE_BLACKBOX)

7. Now update your build scripts by running `cmake` and build the target you just created. The target name can be checked in the generated `CMakeLists.txt`, but should match the Betaflight target name.

For information on how to build INAV, check the documents in the [docs/development](https://github.com/iNavFlight/inav/tree/master/docs/development) folder.
1 change: 1 addition & 0 deletions src/main/target/AXISFLYINGH743PRO/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target_stm32h743xi(AXISFLYINGH743PRO)
34 changes: 34 additions & 0 deletions src/main/target/AXISFLYINGH743PRO/config.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* This file is part of INAV.
*
* INAV is free software: you can redistribute it and/or modify
* it 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.
*
* INAV 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 INAV. If not, see <http://www.gnu.org/licenses/>.
*/

#include <stdint.h>

#include "platform.h"

#include "fc/fc_msp_box.h"

#include "io/piniobox.h"
#include "io/serial.h"

void targetConfiguration(void)
{
pinioBoxConfigMutable()->permanentId[0] = BOX_PERMANENT_ID_USER1;
pinioBoxConfigMutable()->permanentId[1] = BOX_PERMANENT_ID_USER2;

// UART5 is RX-only and hard-wired to ESC telemetry
serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART5)].functionMask = FUNCTION_ESCSERIAL;
}
59 changes: 59 additions & 0 deletions src/main/target/AXISFLYINGH743PRO/target.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* This file is part of INAV.
*
* INAV is free software: you can redistribute it and/or modify
* it 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.
*
* INAV 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 INAV. If not, see <http://www.gnu.org/licenses/>.
*/

#include <stdint.h>

#include <platform.h>
#include "drivers/io.h"
#include "drivers/pwm_mapping.h"
#include "drivers/timer.h"
#include "drivers/bus.h"
#include "drivers/sensor.h"

#include "drivers/pwm_output.h"
#include "common/maths.h"
#include "fc/config.h"

// Gyro 1 - ICM42688P on SPI1, tag 0
BUSDEV_REGISTER_SPI_TAG(busdev_gyro1_icm42605, DEVHW_ICM42605, GYRO_1_SPI_BUS, GYRO_1_CS_PIN, GYRO_1_EXTI_PIN, 0, DEVFLAGS_NONE, GYRO_1_ALIGN);

// Gyro 2 - ICM42688P on SPI4, tag 1
BUSDEV_REGISTER_SPI_TAG(busdev_gyro2_icm42605, DEVHW_ICM42605, GYRO_2_SPI_BUS, GYRO_2_CS_PIN, GYRO_2_EXTI_PIN, 1, DEVFLAGS_NONE, GYRO_2_ALIGN);

timerHardware_t timerHardware[] = {
// Motors - DMA1 Stream0-7 (dmaopt 0-7), kept unique per channel so a
// fallback to per-channel DMA (USE_DSHOT_DMAR disabled) still works.
DEF_TIM(TIM8, CH1, PC6, TIM_USE_OUTPUT_AUTO, 0, 0), // M1
DEF_TIM(TIM8, CH2, PC7, TIM_USE_OUTPUT_AUTO, 0, 1), // M2
DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 2), // M3
DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 3), // M4
DEF_TIM(TIM2, CH1, PA0, TIM_USE_OUTPUT_AUTO, 0, 4), // M5
DEF_TIM(TIM2, CH2, PA1, TIM_USE_OUTPUT_AUTO, 0, 5), // M6
DEF_TIM(TIM2, CH3, PA2, TIM_USE_OUTPUT_AUTO, 0, 6), // M7
DEF_TIM(TIM2, CH4, PA3, TIM_USE_OUTPUT_AUTO, 0, 7), // M8

// dmaopt 8 (DMA2 Stream0) is reserved for ADC
DEF_TIM(TIM4, CH1, PD12, TIM_USE_OUTPUT_AUTO, 0, 9), // S1
DEF_TIM(TIM4, CH2, PD13, TIM_USE_OUTPUT_AUTO, 0, 10), // S2
DEF_TIM(TIM4, CH3, PD14, TIM_USE_OUTPUT_AUTO, 0, 11), // S3
DEF_TIM(TIM4, CH4, PD15, TIM_USE_OUTPUT_AUTO, 0, 12), // S4 - needs USE_DSHOT_DMAR, see target.h

// LED strip - DMA2 Stream5 (dmaopt 13)
DEF_TIM(TIM15, CH1, PE5, TIM_USE_LED, 0, 13), // LED_STRIP_PIN
};

const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]);
186 changes: 186 additions & 0 deletions src/main/target/AXISFLYINGH743PRO/target.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
/*
* This file is part of INAV.
*
* INAV is free software: you can redistribute it and/or modify
* it 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.
*
* INAV 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 INAV. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#define TARGET_BOARD_IDENTIFIER "AXHP"
#define USBD_PRODUCT_STRING "AXISFLYINGH743PRO"

#define USE_TARGET_CONFIG

// *************** LED, BEEPER ***************
#define LED0 PD3
#define BEEPER PC13
#define BEEPER_INVERTED

// *************** Gyro / Acc - dual ICM42688P (registered as DEVHW_ICM42605,
// whose WHO_AM_I switch also matches ICM42688P) ***************
#define USE_DUAL_GYRO
#define USE_TARGET_IMU_HARDWARE_DESCRIPTORS // Don't use common busdev descriptors for IMU
#define USE_IMU_ICM42605

// SPI1: Gyro 1
#define USE_SPI
#define USE_SPI_DEVICE_1
#define SPI1_SCK_PIN PA5
#define SPI1_MISO_PIN PA6
#define SPI1_MOSI_PIN PA7

#define GYRO_1_SPI_BUS BUS_SPI1
#define GYRO_1_CS_PIN PC4
#define GYRO_1_EXTI_PIN PA4
#define GYRO_1_ALIGN CW0_DEG

// SPI4: Gyro 2
#define USE_SPI_DEVICE_4
#define SPI4_SCK_PIN PE12
#define SPI4_MISO_PIN PE13
#define SPI4_MOSI_PIN PE14

#define GYRO_2_SPI_BUS BUS_SPI4
#define GYRO_2_CS_PIN PE15
#define GYRO_2_EXTI_PIN PE11
#define GYRO_2_ALIGN CW90_DEG

// Motor/servo DMA note: SERVO4_PIN (PD15/TIM4_CH4) has no per-channel DMAMUX
// request on this MCU; USE_DSHOT_DMAR repoints TIM4_CH4 at the TIM4_UP burst
// request so the channel keeps a valid DMA path. This makes all DSHOT-capable
// outputs use one shared burst DMA stream per timer
#define USE_DSHOT_DMAR

// *************** SPI2: OSD *****************
#define USE_SPI_DEVICE_2
#define SPI2_SCK_PIN PB13
#define SPI2_MISO_PIN PB14
#define SPI2_MOSI_PIN PB15

#define USE_MAX7456
#define MAX7456_SPI_BUS BUS_SPI2
#define MAX7456_CS_PIN PB12

// *************** SPI3: Flash ***************
#define USE_SPI_DEVICE_3
#define SPI3_SCK_PIN PB3
#define SPI3_MISO_PIN PB4
#define SPI3_MOSI_PIN PB5

#define USE_FLASHFS
#define USE_FLASH_M25P16
#define M25P16_SPI_BUS BUS_SPI3
#define M25P16_CS_PIN PD7
#define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT

// *************** I2C1: Mag (external) *********************
#define USE_I2C
#define USE_I2C_DEVICE_1
#define I2C1_SCL PB8
#define I2C1_SDA PB9

#define USE_MAG
#define MAG_I2C_BUS BUS_I2C1
#define USE_MAG_ALL

// *************** I2C2: Baro *********************
#define USE_I2C_DEVICE_2
#define I2C2_SCL PB10
#define I2C2_SDA PB11

#define USE_BARO
#define BARO_I2C_BUS BUS_I2C2
#define USE_BARO_DPS310

// *************** Serial ports *****************************
#define USE_VCP

#define USE_UART1
#define UART1_TX_PIN PB6
#define UART1_RX_PIN PB7

#define USE_UART2
#define UART2_TX_PIN PD5
#define UART2_RX_PIN PD6

#define USE_UART3
#define UART3_TX_PIN PD8
#define UART3_RX_PIN PD9

#define USE_UART4
#define UART4_TX_PIN PC10
#define UART4_RX_PIN PC11

// RX only - hard-wired to ESC telemetry, see config.c
#define USE_UART5
#define UART5_TX_PIN PC12 // Unconnected placeholder: H7 UART5 driver's .af_tx lacks an #ifdef UART5_TX_PIN guard
#define UART5_RX_PIN PD2

#define USE_UART7
#define UART7_TX_PIN PE8
#define UART7_RX_PIN PE7

#define USE_UART8
#define UART8_TX_PIN PE1
#define UART8_RX_PIN PE0

#define SERIAL_PORT_COUNT 8

#define DEFAULT_FEATURES (FEATURE_OSD | FEATURE_TELEMETRY | FEATURE_CURRENT_METER | FEATURE_VBAT | FEATURE_TX_PROF_SEL | FEATURE_BLACKBOX)
#define DEFAULT_RX_TYPE RX_TYPE_SERIAL
#define SERIALRX_PROVIDER SERIALRX_CRSF
#define SERIALRX_UART SERIAL_PORT_USART2

#define GPS_UART SERIAL_PORT_USART8

// Default MSP DisplayPort (HD OSD) port
#define MSP_UART SERIAL_PORT_USART1

#define USE_ESC_SENSOR

// *************** ADC *****************************
#define USE_ADC
#define ADC_INSTANCE ADC1
#define ADC_CHANNEL_1_PIN PC0
#define ADC_CHANNEL_2_PIN PC1
#define VBAT_ADC_CHANNEL ADC_CHN_1
#define CURRENT_METER_ADC_CHANNEL ADC_CHN_2

#define DEFAULT_VOLTAGE_METER_SOURCE VOLTAGE_METER_ADC
#define DEFAULT_CURRENT_METER_SOURCE CURRENT_METER_ADC

// *************** LED2812 ************************
#define USE_LED_STRIP
#define WS2811_PIN PE5

// *************** PINIO ***************************
#define USE_PINIO
#define USE_PINIOBOX
#define PINIO1_PIN PE2 // VTX PWR box
#define PINIO2_PIN PA8 // CAM 1,2 box

// *************** Blackbox ************************
#define DEFAULT_BLACKBOX_DEVICE BLACKBOX_DEVICE_FLASH

// *************** OTHERS *************************
#define USE_SERIAL_4WAY_BLHELI_INTERFACE

#define TARGET_IO_PORTA 0xffff
#define TARGET_IO_PORTB 0xffff
#define TARGET_IO_PORTC 0xffff
#define TARGET_IO_PORTD 0xffff
#define TARGET_IO_PORTE 0xffff

#define USE_DSHOT
#define MAX_PWM_OUTPUT_PORTS 12
Loading