From 4e50f214f196b98d2315aa7101efad6ffd043711 Mon Sep 17 00:00:00 2001 From: Jacob Dahl Date: Tue, 14 Jan 2025 15:54:28 -0900 Subject: [PATCH 1/9] ARK FPV board support --- configs/ARK_FPV/config.h | 203 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 203 insertions(+) create mode 100644 configs/ARK_FPV/config.h diff --git a/configs/ARK_FPV/config.h b/configs/ARK_FPV/config.h new file mode 100644 index 00000000..6c9d520c --- /dev/null +++ b/configs/ARK_FPV/config.h @@ -0,0 +1,203 @@ +/* + * 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 . + */ + +#pragma once + +#define FC_TARGET_MCU STM32H743 +#define SYSTEM_HSE_MHZ 16 +#define BOARD_NAME ARK_FPV +#define MANUFACTURER_ID ARK + +#define TARGET_IO_PORTH 0xffff +#define TARGET_IO_PORTI 0xffff + +#define LED0_PIN PE5 +#define LED1_PIN PE4 +#define LED2_PIN PE3 + +#define USE_BEEPER +#define BEEPER_PIN PF9 +#define USE_USB_DETECT +#define USB_DETECT_PIN PA9 + +// PINIO Box Config -- VTX Pit Mode +#define PERIPH_12V_EN PG4 +#define PINIO1_PIN PERIPH_12V_EN +#define PINIO1_CONFIG 1 +#define PINIO1_BOX 39 + +// TODO: useful for...? Suggestions? +// PINIO Box Config -- USER1 +// #define MOTOR9_PIN PD12 // TIM4_CH1 +// #define PINIO2_PIN MOTOR9_PIN +// #define PINIO2_CONFIG 1 +// #define PINIO2_BOX 40 + +// GPS1 UART +#define USE_GPS +#define UART1_TX_PIN PB6 +#define UART1_RX_PIN PB7 +#define GPS_UART SERIAL_PORT_UART1 +// GPS1 I2C +#define I2C1_SCL_PIN PB8 +#define I2C1_SDA_PIN PB9 + +// DJI HDL (RX only) +#define UART2_TX_PIN PD5 +#define UART2_RX_PIN PA3 + +// Debug +#define UART3_TX_PIN PD8 +#define UART3_RX_PIN PD9 +#define MSP_UART SERIAL_PORT_UART3 + +// TODO: this doesn't work, fw hangs. +// Is it really needed since we have DSHOT and analog battery current/voltage measurements? +// ESC Telemetry (RX only) +// #define USE_ESCSERIAL +// #define UART4_RX_PIN PH14 +// #define ESC_SENSOR_UART SERIAL_PORT_UART4 +// #define ESCSERIAL_PIN PH14 + +// VTX +#define UART5_TX_PIN PC12 +#define UART5_RX_PIN PD2 +#define MSP_DISPLAYPORT_UART SERIAL_PORT_UART5 + +// RC Input +#define USE_SERIALRX +#define UART6_TX_PIN PC6 +#define UART6_RX_PIN PC7 +#define SERIALRX_UART SERIAL_PORT_UART6 + +// Telem +#define UART7_TX_PIN PE8 +#define UART7_RX_PIN PF6 +#define UART7_RTS_PIN PF8 +#define UART7_CTS_PIN PE10 + +// Baro I2C bus +#define USE_BARO +#define USE_BARO_BMP388 +#define I2C2_SCL_PIN PF1 +#define I2C2_SDA_PIN PF0 +#define BARO_I2C_INSTANCE I2CDEV_2 + +// Compass I2C bus +#define USE_MAG +#define USE_MAG_LIS2MDL +#define I2C4_SCL_PIN PF14 +#define I2C4_SDA_PIN PF15 +#define MAG_I2C_INSTANCE I2CDEV_4 +#define MAG_LIS2MDL_ALIGN CW90_DEG + +// IIM42653 on SPI1 +#define USE_ACC +#define USE_GYRO +#define USE_ACCGYRO_IIM42653 +#define USE_SPI +#define USE_SPI_DEVICE_1 +#define SPI1_SCK_PIN PA5 +#define SPI1_SDI_PIN PG9 +#define SPI1_SDO_PIN PB5 +#define USE_EXTI +#define GYRO_1_SPI_INSTANCE SPI1 +#define GYRO_1_EXTI_PIN PF2 +#define GYRO_1_CS_PIN PI9 +#define GYRO_1_ALIGN CW90_DEG_FLIP + +// External SPI port (OSD or IMU) +#define SPI6_SCK_PIN PB3 +#define SPI6_SDI_PIN PA6 +#define SPI6_SDO_PIN PG14 + +// SD card +#define USE_SDCARD +#define USE_SDCARD_SDIO +#define USE_SDIO_PULLUP +#define SDIO_DEVICE SDIODEV_2 +#define SDIO_USE_4BIT true +#define SDIO_CK_PIN PD6 +#define SDIO_CMD_PIN PD7 +#define SDIO_D0_PIN PB14 +#define SDIO_D1_PIN PB15 +#define SDIO_D2_PIN PG11 +#define SDIO_D3_PIN PB4 +#define DEFAULT_BLACKBOX_DEVICE BLACKBOX_DEVICE_SDCARD + +// BAT voltage ADC +#define ADC_VBAT_PIN PB0 +#define DEFAULT_VOLTAGE_METER_SOURCE VOLTAGE_METER_ADC +#define DEFAULT_VOLTAGE_METER_SCALE 210 +// BAT current ADC +#define ADC_CURR_PIN PC2 +#define DEFAULT_CURRENT_METER_SOURCE CURRENT_METER_ADC +#define DEFAULT_CURRENT_METER_SCALE 120 +// 3V3 ADC +#define ADC_EXTERNAL1_PIN PA0 +// 5V ADC +#define ADC_EXTERNAL2_PIN PB1 +// 12V ADC +#define ADC_EXTERNAL3_PIN PA4 + +// Default GPIOs +#define VDD_3V3_SENSORS1_EN PI11 +#define VDD_3V3_SD_CARD_EN PC13 +#define DEFAULT_GPIO_ARRAY \ + GPIO_CONFIG_OUTPUT(VDD_3V3_SENSORS1_EN, IOCFG_OUT_PP, GPIO_STATE_HIGH), \ + GPIO_CONFIG_OUTPUT(VDD_3V3_SD_CARD_EN, IOCFG_OUT_PP, GPIO_STATE_HIGH), + +// Motor configuration +#define USE_TIMER_MAP_PRINT +#define MOTOR1_PIN PI0 // PI0 : TIM5_CH4 +#define MOTOR2_PIN PH12 // PH12 : TIM5_CH3 +#define MOTOR3_PIN PH11 // PH11 : TIM5_CH2 +#define MOTOR4_PIN PH10 // PH10 : TIM5_CH1 +#define MOTOR5_PIN PI5 // PI5 : TIM8_CH1 +#define MOTOR6_PIN PI6 // PI6 : TIM8_CH2 +#define MOTOR7_PIN PI7 // PI7 : TIM8_CH3 +#define MOTOR8_PIN PI2 // PI2 : TIM8_CH4 + +// TIMER_PIN_MAP(mot_idx, pin, occurance, dma_opt) +// NOTE: dma_opt unnecessary since H7 has dmamux +#define TIMER_PIN_MAPPING \ + TIMER_PIN_MAP(0, MOTOR1_PIN, 1, 0) \ + TIMER_PIN_MAP(1, MOTOR2_PIN, 1, 0) \ + TIMER_PIN_MAP(2, MOTOR3_PIN, 1, 0) \ + TIMER_PIN_MAP(3, MOTOR4_PIN, 1, 0) \ + TIMER_PIN_MAP(4, MOTOR5_PIN, 1, 0) \ + TIMER_PIN_MAP(5, MOTOR6_PIN, 1, 0) \ + TIMER_PIN_MAP(6, MOTOR7_PIN, 1, 0) \ + TIMER_PIN_MAP(7, MOTOR8_PIN, 1, 0) + +// DMA stream assignment +#define TIMUP8_DMA_OPT 10 +#define TIMUP5_DMA_OPT 11 +#define ADC1_DMA_OPT 12 +#define ADC3_DMA_OPT 13 +#define SPI1_TX_DMA_OPT 14 +#define SPI1_RX_DMA_OPT 15 + +// Remaining unmapped signals (no use in betaflight?) +// TODO: 12v pgood : PE15 --> 12V regulator PGOOD +// TODO: 5v pgood : PF13 --> 5V regulator PGOOD +// TODO: 5V_ON_BATn : PG1 --> Diode status signal (5V from USB or 5V from regulator) +// TODO: IMU heater : PB10 --> TIM2_CH3 for PWM resistor IMU temperature control From 5785b0433342ce4e23c7815395430ade32a16c21 Mon Sep 17 00:00:00 2001 From: Jacob Dahl Date: Tue, 14 Jan 2025 16:10:55 -0900 Subject: [PATCH 2/9] Manufacturers: add ARK Electronics --- Manufacturers.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Manufacturers.md b/Manufacturers.md index 1e39f837..f1ceab36 100644 --- a/Manufacturers.md +++ b/Manufacturers.md @@ -15,6 +15,7 @@ This is the official list of manufacturer ids (`manufacturer_id` in the target c |ALWH|Alienwhoop|https://shop.alienwhoop.us/| |ANYL|AnyLeaf|https://www.anyleaf.org/| |APEX|Apexfpv|https://apexfpv.eu/| +|ARK|ARK Electronics|https://arkelectron.com/| |AXFL|Axisflying|https://www.axisflying.com/| |BKRC|BAYCK RC|| |BLDY|BotLab Dynamics|https://www.botlabdynamics.store| From 8baa1eb91a0d2fb1979c7cf61c083046283c16df Mon Sep 17 00:00:00 2001 From: Jacob Dahl Date: Tue, 14 Jan 2025 16:57:47 -0900 Subject: [PATCH 3/9] fix mag orientation --- configs/ARK_FPV/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/ARK_FPV/config.h b/configs/ARK_FPV/config.h index 6c9d520c..bf0e2b98 100644 --- a/configs/ARK_FPV/config.h +++ b/configs/ARK_FPV/config.h @@ -107,7 +107,7 @@ #define I2C4_SCL_PIN PF14 #define I2C4_SDA_PIN PF15 #define MAG_I2C_INSTANCE I2CDEV_4 -#define MAG_LIS2MDL_ALIGN CW90_DEG +#define MAG_LIS2MDL_ALIGN CW180_DEG // IIM42653 on SPI1 #define USE_ACC From bb9061e7e48affe3e7371ca81984dd6f322e1c5d Mon Sep 17 00:00:00 2001 From: Jacob Dahl Date: Tue, 21 Jan 2025 13:23:33 -0900 Subject: [PATCH 4/9] clock divider 2 --- configs/ARK_FPV/config.h | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/ARK_FPV/config.h b/configs/ARK_FPV/config.h index bf0e2b98..48ac8cac 100644 --- a/configs/ARK_FPV/config.h +++ b/configs/ARK_FPV/config.h @@ -133,6 +133,7 @@ #define USE_SDCARD #define USE_SDCARD_SDIO #define USE_SDIO_PULLUP +#define SDIO_CLOCK_DIV 2 #define SDIO_DEVICE SDIODEV_2 #define SDIO_USE_4BIT true #define SDIO_CK_PIN PD6 From b005cf6c4c60e51ff90af765b79106a375649caa Mon Sep 17 00:00:00 2001 From: Jacob Dahl Date: Tue, 21 Jan 2025 13:26:23 -0900 Subject: [PATCH 5/9] manufacturer ID ARKE, update comment on esc telem --- Manufacturers.md | 2 +- configs/ARK_FPV/config.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Manufacturers.md b/Manufacturers.md index f1ceab36..65d0ba47 100644 --- a/Manufacturers.md +++ b/Manufacturers.md @@ -15,7 +15,7 @@ This is the official list of manufacturer ids (`manufacturer_id` in the target c |ALWH|Alienwhoop|https://shop.alienwhoop.us/| |ANYL|AnyLeaf|https://www.anyleaf.org/| |APEX|Apexfpv|https://apexfpv.eu/| -|ARK|ARK Electronics|https://arkelectron.com/| +|ARKE|ARK Electronics|https://arkelectron.com/| |AXFL|Axisflying|https://www.axisflying.com/| |BKRC|BAYCK RC|| |BLDY|BotLab Dynamics|https://www.botlabdynamics.store| diff --git a/configs/ARK_FPV/config.h b/configs/ARK_FPV/config.h index 48ac8cac..9ffa9a51 100644 --- a/configs/ARK_FPV/config.h +++ b/configs/ARK_FPV/config.h @@ -24,7 +24,7 @@ #define FC_TARGET_MCU STM32H743 #define SYSTEM_HSE_MHZ 16 #define BOARD_NAME ARK_FPV -#define MANUFACTURER_ID ARK +#define MANUFACTURER_ID ARKE #define TARGET_IO_PORTH 0xffff #define TARGET_IO_PORTI 0xffff @@ -69,8 +69,8 @@ #define UART3_RX_PIN PD9 #define MSP_UART SERIAL_PORT_UART3 -// TODO: this doesn't work, fw hangs. -// Is it really needed since we have DSHOT and analog battery current/voltage measurements? +// NOTE: enabling this doesn't work, fw hangs +// Bidirectional DShot telemetry is used instead // ESC Telemetry (RX only) // #define USE_ESCSERIAL // #define UART4_RX_PIN PH14 From 5c22f5abbaff4f5553de9ea46ea7fb7746c93617 Mon Sep 17 00:00:00 2001 From: Jacob Dahl Date: Fri, 24 Jan 2025 12:11:47 -0900 Subject: [PATCH 6/9] added IO preinit through config.c --- configs/ARK_FPV/config.c | 7 +++++++ configs/ARK_FPV/config.h | 1 + 2 files changed, 8 insertions(+) create mode 100644 configs/ARK_FPV/config.c diff --git a/configs/ARK_FPV/config.c b/configs/ARK_FPV/config.c new file mode 100644 index 00000000..cbeb685d --- /dev/null +++ b/configs/ARK_FPV/config.c @@ -0,0 +1,7 @@ +#include "drivers/io.h" + +void configTargetPreInit(void) +{ + ioPreinitByIO(IOGetByTag(IO_TAG(VDD_3V3_SENSORS1_EN)), IOCFG_OUT_PP, PREINIT_PIN_STATE_HIGH); + ioPreinitByIO(IOGetByTag(IO_TAG(VDD_3V3_SD_CARD_EN)), IOCFG_OUT_PP, PREINIT_PIN_STATE_HIGH); +} diff --git a/configs/ARK_FPV/config.h b/configs/ARK_FPV/config.h index 9ffa9a51..18e3ea29 100644 --- a/configs/ARK_FPV/config.h +++ b/configs/ARK_FPV/config.h @@ -25,6 +25,7 @@ #define SYSTEM_HSE_MHZ 16 #define BOARD_NAME ARK_FPV #define MANUFACTURER_ID ARKE +#define USE_CONFIG_TARGET_PREINIT #define TARGET_IO_PORTH 0xffff #define TARGET_IO_PORTI 0xffff From 6e6cb9096fd3ed9fbe7798d98c35f95c7af1154d Mon Sep 17 00:00:00 2001 From: Jacob Dahl Date: Fri, 24 Jan 2025 12:15:25 -0900 Subject: [PATCH 7/9] remove DEFAULT_GPIO_ARRAY, add config.c for IO preinit, change to MAG_ALIGN --- configs/ARK_FPV/config.h | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/configs/ARK_FPV/config.h b/configs/ARK_FPV/config.h index 18e3ea29..f468c499 100644 --- a/configs/ARK_FPV/config.h +++ b/configs/ARK_FPV/config.h @@ -25,11 +25,14 @@ #define SYSTEM_HSE_MHZ 16 #define BOARD_NAME ARK_FPV #define MANUFACTURER_ID ARKE -#define USE_CONFIG_TARGET_PREINIT #define TARGET_IO_PORTH 0xffff #define TARGET_IO_PORTI 0xffff +#define USE_CONFIG_TARGET_PREINIT +#define VDD_3V3_SENSORS1_EN PI11 +#define VDD_3V3_SD_CARD_EN PC13 + #define LED0_PIN PE5 #define LED1_PIN PE4 #define LED2_PIN PE3 @@ -108,7 +111,7 @@ #define I2C4_SCL_PIN PF14 #define I2C4_SDA_PIN PF15 #define MAG_I2C_INSTANCE I2CDEV_4 -#define MAG_LIS2MDL_ALIGN CW180_DEG +#define MAG_ALIGN CW180_DEG // IIM42653 on SPI1 #define USE_ACC @@ -160,13 +163,6 @@ // 12V ADC #define ADC_EXTERNAL3_PIN PA4 -// Default GPIOs -#define VDD_3V3_SENSORS1_EN PI11 -#define VDD_3V3_SD_CARD_EN PC13 -#define DEFAULT_GPIO_ARRAY \ - GPIO_CONFIG_OUTPUT(VDD_3V3_SENSORS1_EN, IOCFG_OUT_PP, GPIO_STATE_HIGH), \ - GPIO_CONFIG_OUTPUT(VDD_3V3_SD_CARD_EN, IOCFG_OUT_PP, GPIO_STATE_HIGH), - // Motor configuration #define USE_TIMER_MAP_PRINT #define MOTOR1_PIN PI0 // PI0 : TIM5_CH4 From c9faba2a5fcd8c8bc3c795ae22b62c14af785577 Mon Sep 17 00:00:00 2001 From: Jacob Dahl Date: Fri, 24 Jan 2025 13:32:57 -0900 Subject: [PATCH 8/9] remove port H and I masks --- configs/ARK_FPV/config.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/configs/ARK_FPV/config.h b/configs/ARK_FPV/config.h index f468c499..7d68541a 100644 --- a/configs/ARK_FPV/config.h +++ b/configs/ARK_FPV/config.h @@ -26,9 +26,6 @@ #define BOARD_NAME ARK_FPV #define MANUFACTURER_ID ARKE -#define TARGET_IO_PORTH 0xffff -#define TARGET_IO_PORTI 0xffff - #define USE_CONFIG_TARGET_PREINIT #define VDD_3V3_SENSORS1_EN PI11 #define VDD_3V3_SD_CARD_EN PC13 From c03ec51a50a2c5fa8382fae76f5eff9fa34a97ab Mon Sep 17 00:00:00 2001 From: Mark Haslinghuis Date: Tue, 28 Jan 2025 23:13:41 +0100 Subject: [PATCH 9/9] Update configs/ARK_FPV/config.c --- configs/ARK_FPV/config.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configs/ARK_FPV/config.c b/configs/ARK_FPV/config.c index cbeb685d..c8777e87 100644 --- a/configs/ARK_FPV/config.c +++ b/configs/ARK_FPV/config.c @@ -2,6 +2,6 @@ void configTargetPreInit(void) { - ioPreinitByIO(IOGetByTag(IO_TAG(VDD_3V3_SENSORS1_EN)), IOCFG_OUT_PP, PREINIT_PIN_STATE_HIGH); - ioPreinitByIO(IOGetByTag(IO_TAG(VDD_3V3_SD_CARD_EN)), IOCFG_OUT_PP, PREINIT_PIN_STATE_HIGH); + ioPreinitByIO(IOGetByTag(IO_TAG(VDD_3V3_SENSORS1_EN)), IOCFG_OUT_PP, PREINIT_PIN_STATE_HIGH); + ioPreinitByIO(IOGetByTag(IO_TAG(VDD_3V3_SD_CARD_EN)), IOCFG_OUT_PP, PREINIT_PIN_STATE_HIGH); }