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 new mode 100755 index a4195a61fa..8b5bffa00e Binary files a/boards/zeroone/x6/extras/zeroone_x6_bootloader.bin and b/boards/zeroone/x6/extras/zeroone_x6_bootloader.bin differ 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}) }),