From cb71aea7fa804f2edb1fa4e982aa361fabe2ce40 Mon Sep 17 00:00:00 2001 From: xue Date: Mon, 23 Jun 2025 09:54:28 +0800 Subject: [PATCH] boards: Updated ZeroOne X6 * Starts pwm_voltage_apply * Enable Septentrio modules * Enable IIM42653 IMU * Enable SCH16T IMU Signed-off-by: Ramon Roche --- boards/zeroone/x6/CMakeLists.txt | 34 +++++ boards/zeroone/x6/default.px4board | 3 + .../x6/extras/zeroone_x6_bootloader.bin | Bin 46752 -> 46856 bytes boards/zeroone/x6/init/rc.board_defaults | 3 + boards/zeroone/x6/init/rc.board_sensors | 117 ++++-------------- boards/zeroone/x6/pwm_voltage/CMakeLists.txt | 42 +++++++ boards/zeroone/x6/pwm_voltage/parameters.c | 43 +++++++ boards/zeroone/x6/pwm_voltage/pwm_voltage.cpp | 56 +++++++++ boards/zeroone/x6/src/board_config.h | 14 ++- boards/zeroone/x6/src/spi.cpp | 35 ++++-- 10 files changed, 235 insertions(+), 112 deletions(-) create mode 100644 boards/zeroone/x6/CMakeLists.txt mode change 100644 => 100755 boards/zeroone/x6/extras/zeroone_x6_bootloader.bin create mode 100644 boards/zeroone/x6/pwm_voltage/CMakeLists.txt create mode 100644 boards/zeroone/x6/pwm_voltage/parameters.c create mode 100644 boards/zeroone/x6/pwm_voltage/pwm_voltage.cpp diff --git a/boards/zeroone/x6/CMakeLists.txt b/boards/zeroone/x6/CMakeLists.txt new file mode 100644 index 0000000000..8756f63e64 --- /dev/null +++ b/boards/zeroone/x6/CMakeLists.txt @@ -0,0 +1,34 @@ +############################################################################ +# +# Copyright (c) 2025 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +add_subdirectory(pwm_voltage) diff --git a/boards/zeroone/x6/default.px4board b/boards/zeroone/x6/default.px4board index 20677f9d1f..f739136c3b 100644 --- a/boards/zeroone/x6/default.px4board +++ b/boards/zeroone/x6/default.px4board @@ -20,6 +20,9 @@ CONFIG_DRIVERS_GPS=y CONFIG_DRIVERS_HEATER=y CONFIG_DRIVERS_IMU_BOSCH_BMI088=y CONFIG_DRIVERS_IMU_INVENSENSE_ICM45686=y +CONFIG_DRIVERS_IMU_INVENSENSE_IIM42653=y +CONFIG_DRIVERS_IMU_MURATA_SCH16T=y +CONFIG_DRIVERS_GNSS_SEPTENTRIO=y CONFIG_COMMON_INS=y CONFIG_COMMON_LIGHT=y CONFIG_COMMON_MAGNETOMETER=y diff --git a/boards/zeroone/x6/extras/zeroone_x6_bootloader.bin b/boards/zeroone/x6/extras/zeroone_x6_bootloader.bin old mode 100644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|8LmyVyr%g-w3^6gQZfJ%{2_zR8Y zEE2}flEU{>lV5}3a>&s89=P8O0`MN3tU^!wmLQeq=jU*~?)~FflRK*75(|-#MQjJ^ zR0m;AXULrc2aBV+Lm#!>La}%Ng)iRdbWhzlq448@kEtRl0TsH7r4VFtFD;94pKCD> zJ9YMgC=SvcderG`LF_R2VT|L^3Gc?b`>+)U4#uTLN=TR0p={t$?^Pue%xE!&t;Duc z9;BDWZ{hU0FE)%K;R?w(loZQaDXy-}WzlrwduWo&qWV@<=qlT7se}zqHXTa950gJ1 zN^+!2IQO2XTnIy19Z}qv*KA#YvRY;FBU!~2x$ldg`j~hIGDsE=$)fnmsE*6(C>JI( zBVGk{0#J(qbqY{Qp2^|`*~p3FQ@_A9-*e_cCEzApLie1=jG@fS^eSiBf2N{=d6ZU5 z<{!>*gc(8kBE#8kaojWACUCSGT;CVhLg{`q;J8u_;*hbxqfGLc%ou*fg}|!U$OC1z zVf*qB{q?CvE{39quRbq}%VlRkuV9}BLbA9@W;jzj%`pifdgZxTHo!5U*aiF*1VF_B z?l(t5+7$w+a-Um$56xBpiSilu2}_6vO`p5fnoj)0E$B^-b9;N6^mYqP|EF5v_I9(>3#(t9_NthNKqMypOfqux(&$DpN9Aya6 zEBITavvCRjfFPnbP#9Dh!O6PQZ+lMV^1nfRCm3< z#Mh8@P33qox!#n6)5)|WGpL|3{_!KcI&}8Krj;+w$$Vk?ob0S@GSQuoJGcX}(IA># za38Ef?0=zv_JUM_)PppDEZPgY>cEX0VJNO}Ge1(M`*#~3?CTmZnlEZv9I}Cpj0F?+n tBX}S0pzvSF8>bCWfZsbEuAi-V_~CaIj}I=ucF2Qa5rfbra`|+|{{W8zlZ*fW diff --git a/boards/zeroone/x6/init/rc.board_defaults b/boards/zeroone/x6/init/rc.board_defaults index cb1eb580a4..0300654d6a 100644 --- a/boards/zeroone/x6/init/rc.board_defaults +++ b/boards/zeroone/x6/init/rc.board_defaults @@ -27,3 +27,6 @@ else fi safety_button start + +# pwm voltage 3.3V/5V switch +pwm_voltage_apply start diff --git a/boards/zeroone/x6/init/rc.board_sensors b/boards/zeroone/x6/init/rc.board_sensors index 19038ecd13..ae42aa8ad2 100644 --- a/boards/zeroone/x6/init/rc.board_sensors +++ b/boards/zeroone/x6/init/rc.board_sensors @@ -43,6 +43,7 @@ then set INA_CONFIGURED yes fi + if param compare SENS_EN_INA238 1 then # Start Digital power monitors @@ -55,96 +56,35 @@ then set INA_CONFIGURED yes fi -#Start Auterion Power Module selector for zeroone boards -if ver hwbasecmp 009 010 011 + +if ver hwtypecmp ZeroOneX6000 then - pm_selector_auterion start -else - if [ $INA_CONFIGURED = no ] - then - # INA226, INA228, INA238 auto-start - i2c_launcher start -b 1 - if [ $HAVE_PM2 = yes ] - then - i2c_launcher start -b 2 - fi - fi + # Internal SPI bus icm45686 with SPIX + icm45686 -b 2 -s -R 6 start //X6 & X6 air + + bmi088 -A -R 4 -s start //X6 + bmi088 -G -R 4 -s start //X6 + + # Internal SPI bus icm45686 with SPIX + icm45686 -b 1 -s -R 8 start //X6 & X6 air fi -# Keep nesting shallow -if ver hwtypecmp V6X006 V6X008 + +if ver hwtypecmp ZeroOneX6001 //X6 PRO then - if ver hwtypecmp V6X006 - then - # Internal SPI bus ICM45686 - adis16470 -s -R 0 start - iim42652 -s -R 6 start - icm45686 -s -R 10 start - else - # Internal SPI bus 3x ICM45686 - icm45686 -b 3 -s -R 0 start - icm45686 -b 2 -s -R 0 start - icm45686 -b 1 -s -R 10 start - fi -else - if ver hwtypecmp V6X004 - then - # Internal SPI bus ICM20649 - icm20649 -s -R 6 start - else - # Internal SPI BMI088 - if ver hwbasecmp 009 010 011 - then - bmi088 -A -R 6 -s start - bmi088 -G -R 6 -s start - else - if ver hwtypecmp V6X010 - then - bmi088 -A -R 0 -s start - bmi088 -G -R 0 -s start - else - bmi088 -A -R 4 -s start - bmi088 -G -R 4 -s start - fi - fi - fi + # Internal SPI bus IIM42653 with SPIX + iim42653 -b 2 -s -R 6 start - # Internal SPI bus ICM42688p - if ver hwbasecmp 009 010 011 - then - icm42688p -R 12 -s start - else - if ver hwtypecmp V6X010 - then - icm42688p -R 14 -s start - else - icm45686 -b 1 -s -R 8 start //ZeroOne - fi - fi + bmi088 -A -R 4 -s start + bmi088 -G -R 4 -s start - if ver hwtypecmp V6X003 V6X004 - then - # Internal SPI bus ICM-42670-P (hard-mounted) - icm42670p -R 10 -s start - else - if ver hwbasecmp 009 010 011 - then - icm20602 -R 6 -s start - else - # Internal SPI bus ICM-20649 (hard-mounted) - icm45686 -b 2 -s -R 6 start //ZeroOne - fi - fi + # Internal SPI bus IIM42653 with SPIX + iim42653 -b 1 -s -R 8 start fi + + rm3100 -I -b 4 start # Internal magnetometer on I2c -# if ver hwtypecmp V6X001 -# then -# rm3100 -I -b 4 start -# else -# # Internal magnetometer on I2C -# bmm150 -I -R 0 start -# fi # External compass on GPS1/I2C1 (the 3rd external bus): standard Holybro Pixhawk 4 or CUAV V5 GPS/compass puck (with lights, safety button, and buzzer) ist8310 -X -b 1 -R 10 start @@ -156,24 +96,9 @@ ist8310 start -I -a 0x0E -R 12 if param compare SENS_INT_BARO_EN 1 then icp201xx -I -a 0x64 start - # if ver hwtypecmp V6X001 V6X006 V6X008 - # then - # icp201xx -I -a 0x64 start - # else - # bmp388 -I -a 0x77 start - # fi fi icp201xx -X start #external baro -# if ver hwtypecmp V6X001 -# then -# icp201xx -X start -# else -# bmp388 -X start -# fi - -# Baro on I2C3 -ms5611 -X start unset INA_CONFIGURED unset HAVE_PM2 diff --git a/boards/zeroone/x6/pwm_voltage/CMakeLists.txt b/boards/zeroone/x6/pwm_voltage/CMakeLists.txt new file mode 100644 index 0000000000..6db1696208 --- /dev/null +++ b/boards/zeroone/x6/pwm_voltage/CMakeLists.txt @@ -0,0 +1,42 @@ +############################################################################ +# +# Copyright (c) 2025 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +px4_add_module( + MODULE modules__pwm_voltage_apply + MAIN pwm_voltage_apply + + SRCS + pwm_voltage.cpp + DEPENDS + px4_work_queue + ) diff --git a/boards/zeroone/x6/pwm_voltage/parameters.c b/boards/zeroone/x6/pwm_voltage/parameters.c new file mode 100644 index 0000000000..728bcc7a55 --- /dev/null +++ b/boards/zeroone/x6/pwm_voltage/parameters.c @@ -0,0 +1,43 @@ +/**************************************************************************** + * + * Copyright (c) 2025 PX4 Development Team. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name PX4 nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/** + * Control PWM output voltage + * + * @value 0 3.3V + * @value 1 5.0V + * + * @reboot_required true + * @group PWM Outputs + */ +PARAM_DEFINE_INT32(PWM_VOLT_SEL, 0); diff --git a/boards/zeroone/x6/pwm_voltage/pwm_voltage.cpp b/boards/zeroone/x6/pwm_voltage/pwm_voltage.cpp new file mode 100644 index 0000000000..2bef9ae0f6 --- /dev/null +++ b/boards/zeroone/x6/pwm_voltage/pwm_voltage.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** + * + * Copyright (c) 2025 PX4 Development Team. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name PX4 nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#include +#include + +#include +#include + +#include "board_config.h" + +extern "C" int pwm_voltage_apply_main(int argc, char *argv[]) +{ + int32_t pwm_volt_sel = 0; + + param_get(param_find("PWM_VOLT_SEL"), &pwm_volt_sel); + + if (pwm_volt_sel != 0) { + PWM_5V_VOLT_SEL(true); + + } else { + PWM_5V_VOLT_SEL(false); + } + + return 0; +} diff --git a/boards/zeroone/x6/src/board_config.h b/boards/zeroone/x6/src/board_config.h index f1a00d642b..114c3ce101 100644 --- a/boards/zeroone/x6/src/board_config.h +++ b/boards/zeroone/x6/src/board_config.h @@ -215,10 +215,11 @@ #define GPIO_HW_VER_SENSE /* PH3 */ GPIO_ADC3_INP14 #define HW_INFO_INIT_PREFIX "ZeroOneX6" -#define BOARD_NUM_SPI_CFG_HW_VERSIONS 2 +#define BOARD_NUM_SPI_CFG_HW_VERSIONS 3 // Base/FMUM -#define ZeroOneX6_0 HW_FMUM_ID(0x0) // ZeroOneX6, Sensor Set Rev 0 -#define ZeroOneX6_1 HW_FMUM_ID(0x1) // ZeroOneX6, Sensor Set Rev 1 +#define ZeroOneX6_0 HW_FMUM_ID(0x0) // ZeroOneX6, +#define ZeroOneX6_1 HW_FMUM_ID(0x1) // ZeroOneX6 Pro, +#define ZeroOneX6_2 HW_FMUM_ID(0x2) // reserved #define UAVCAN_NUM_IFACES_RUNTIME 1 @@ -244,6 +245,10 @@ */ #define DIRECT_PWM_OUTPUT_CHANNELS 9 +/* PWM Power */ +#define GPIO_PWM_VOLT_SEL /* PD15 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTG|GPIO_PIN6) +#define PWM_5V_VOLT_SEL(on_true) px4_arch_gpiowrite(GPIO_PWM_VOLT_SEL, (on_true)) + /* Power supply control and monitoring GPIOs */ #define GPIO_nPOWER_IN_A /* PG1 */ (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTG|GPIO_PIN1) @@ -457,7 +462,8 @@ GPIO_nSAFETY_SWITCH_LED_OUT_INIT, \ GPIO_SAFETY_SWITCH_IN, \ GPIO_PG6, \ - GPIO_nARMED_INIT \ + GPIO_nARMED_INIT, \ + GPIO_PWM_VOLT_SEL \ } #define BOARD_ENABLE_CONSOLE_BUFFER diff --git a/boards/zeroone/x6/src/spi.cpp b/boards/zeroone/x6/src/spi.cpp index ae655b1d6e..d9318233dd 100644 --- a/boards/zeroone/x6/src/spi.cpp +++ b/boards/zeroone/x6/src/spi.cpp @@ -47,10 +47,6 @@ constexpr px4_spi_bus_all_hw_t px4_spi_buses_all_hw[BOARD_NUM_SPI_CFG_HW_VERSION initSPIDevice(DRV_GYR_DEVTYPE_BMI088, SPI::CS{GPIO::PortI, GPIO::Pin8}, SPI::DRDY{GPIO::PortI, GPIO::Pin7}), initSPIDevice(DRV_ACC_DEVTYPE_BMI088, SPI::CS{GPIO::PortI, GPIO::Pin4}, SPI::DRDY{GPIO::PortI, GPIO::Pin6}), }, {GPIO::PortE, GPIO::Pin7}), - // initSPIBus(SPI::Bus::SPI4, { - // // no devices - // TODO: if enabled, remove GPIO_VDD_3V3_SENSORS4_EN from board_config.h - // }, {GPIO::PortG, GPIO::Pin8}), initSPIBus(SPI::Bus::SPI5, { initSPIDevice(SPIDEV_FLASH(0), SPI::CS{GPIO::PortG, GPIO::Pin7}) }), @@ -60,21 +56,36 @@ constexpr px4_spi_bus_all_hw_t px4_spi_buses_all_hw[BOARD_NUM_SPI_CFG_HW_VERSION }), }), - initSPIFmumID(ZeroOneX6_1, { // Placeholder + initSPIFmumID(ZeroOneX6_1, { // X6 Pro initSPIBus(SPI::Bus::SPI1, { - initSPIDevice(DRV_IMU_DEVTYPE_ICM45686, SPI::CS{GPIO::PortI, GPIO::Pin9}, SPI::DRDY{GPIO::PortF, GPIO::Pin2}), + initSPIDevice(DRV_IMU_DEVTYPE_IIM42653, SPI::CS{GPIO::PortI, GPIO::Pin9}, SPI::DRDY{GPIO::PortF, GPIO::Pin2}), }, {GPIO::PortI, GPIO::Pin11}), initSPIBus(SPI::Bus::SPI2, { - initSPIDevice(DRV_IMU_DEVTYPE_ICM45686, SPI::CS{GPIO::PortH, GPIO::Pin5}, SPI::DRDY{GPIO::PortA, GPIO::Pin10}), + initSPIDevice(DRV_IMU_DEVTYPE_IIM42653, SPI::CS{GPIO::PortH, GPIO::Pin5}, SPI::DRDY{GPIO::PortA, GPIO::Pin10}), }, {GPIO::PortF, GPIO::Pin4}), initSPIBus(SPI::Bus::SPI3, { initSPIDevice(DRV_GYR_DEVTYPE_BMI088, SPI::CS{GPIO::PortI, GPIO::Pin8}, SPI::DRDY{GPIO::PortI, GPIO::Pin7}), - initSPIDevice(DRV_ACC_DEVTYPE_BMI088, SPI::CS{GPIO::PortI, GPIO::Pin4}), + initSPIDevice(DRV_ACC_DEVTYPE_BMI088, SPI::CS{GPIO::PortI, GPIO::Pin4}, SPI::DRDY{GPIO::PortI, GPIO::Pin6}), + }, {GPIO::PortE, GPIO::Pin7}), + initSPIBus(SPI::Bus::SPI5, { + initSPIDevice(SPIDEV_FLASH(0), SPI::CS{GPIO::PortG, GPIO::Pin7}) + }), + initSPIBusExternal(SPI::Bus::SPI6, { + initSPIConfigExternal(SPI::CS{GPIO::PortI, GPIO::Pin10}, SPI::DRDY{GPIO::PortD, GPIO::Pin11}), + initSPIConfigExternal(SPI::CS{GPIO::PortA, GPIO::Pin15}, SPI::DRDY{GPIO::PortD, GPIO::Pin12}), + }), + }), + + initSPIFmumID(ZeroOneX6_2, { // reserved + initSPIBus(SPI::Bus::SPI1, { + initSPIDevice(DRV_IMU_DEVTYPE_IIM42653, SPI::CS{GPIO::PortI, GPIO::Pin9}, SPI::DRDY{GPIO::PortF, GPIO::Pin2}), + }, {GPIO::PortI, GPIO::Pin11}), + initSPIBus(SPI::Bus::SPI2, { + initSPIDevice(DRV_IMU_DEVTYPE_SCH16T, SPI::CS{GPIO::PortH, GPIO::Pin5}, SPI::DRDY{GPIO::PortA, GPIO::Pin10}), + }, {GPIO::PortF, GPIO::Pin4}), + initSPIBus(SPI::Bus::SPI3, { + initSPIDevice(DRV_IMU_DEVTYPE_SCH16T, SPI::CS{GPIO::PortI, GPIO::Pin4}, SPI::DRDY{GPIO::PortI, GPIO::Pin6}), }, {GPIO::PortE, GPIO::Pin7}), - // initSPIBus(SPI::Bus::SPI4, { - // // no devices - // TODO: if enabled, remove GPIO_VDD_3V3_SENSORS4_EN from board_config.h - // }, {GPIO::PortG, GPIO::Pin8}), initSPIBus(SPI::Bus::SPI5, { initSPIDevice(SPIDEV_FLASH(0), SPI::CS{GPIO::PortG, GPIO::Pin7}) }),