drivers: imu: Add in ADIS16607 IMU Device (#26301)

* drivers: Add  in ADIS16607 IMU Device

* formatting and style, adjust debug output

* Change variable types of accel_x/y/z and gyro_x/y/z.

* Remove periodic register check

---------

Co-authored-by: Jacob Dahl <dahl.jakejacob@gmail.com>
This commit is contained in:
CUAV Chen
2026-03-05 15:15:39 +08:00
committed by GitHub
parent 40133e0b2c
commit 9228dca9bd
8 changed files with 842 additions and 0 deletions
+1
View File
@@ -135,6 +135,7 @@
#define DRV_IMU_DEVTYPE_ADIS16507 0x5A
#define DRV_IMU_DEVTYPE_SCH16T 0x5B
#define DRV_IMU_DEVTYPE_ADIS16607 0x5C
#define DRV_BARO_DEVTYPE_MPC2520 0x5F
#define DRV_BARO_DEVTYPE_LPS22HB 0x60
+1
View File
@@ -6,6 +6,7 @@ menu "IMU"
select DRIVERS_IMU_ANALOG_DEVICES_ADIS16497
select DRIVERS_IMU_ANALOG_DEVICES_ADIS16448
select DRIVERS_IMU_ANALOG_DEVICES_ADIS16470
select DRIVERS_IMU_ANALOG_DEVICES_ADIS16607
select DRIVERS_IMU_BOSCH_BMI055
select DRIVERS_IMU_BOSCH_BMI088
select DRIVERS_IMU_MURATA_SCH16T
@@ -0,0 +1,430 @@
/****************************************************************************
*
* Copyright (c) 2026 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 "ADIS16607.hpp"
#include <endian.h>
using namespace time_literals;
ADIS16607::ADIS16607(const I2CSPIDriverConfig &config) :
SPI(config),
I2CSPIDriver(config),
_drdy_gpio(config.drdy_gpio),
_px4_accel(get_device_id(), config.rotation),
_px4_gyro(get_device_id(), config.rotation)
{
if (_drdy_gpio != 0) {
_drdy_missed_perf = perf_alloc(PC_COUNT, MODULE_NAME": DRDY missed");
}
}
ADIS16607::~ADIS16607()
{
perf_free(_reset_perf);
perf_free(_bad_transfer_perf);
perf_free(_perf_crc_bad);
perf_free(_drdy_missed_perf);
}
int ADIS16607::init()
{
int ret = SPI::init();
if (ret != PX4_OK) {
DEVICE_DEBUG("SPI::init failed (%i)", ret);
return ret;
}
return Reset() ? 0 : -1;
}
bool ADIS16607::Reset()
{
_state = STATE::RESET;
DataReadyInterruptDisable();
ScheduleClear();
ScheduleNow();
return true;
}
void ADIS16607::exit_and_cleanup()
{
DataReadyInterruptDisable();
I2CSPIDriverBase::exit_and_cleanup();
}
void ADIS16607::print_status()
{
I2CSPIDriverBase::print_status();
perf_print_counter(_reset_perf);
perf_print_counter(_bad_transfer_perf);
perf_print_counter(_perf_crc_bad);
perf_print_counter(_drdy_missed_perf);
}
int ADIS16607::probe()
{
// Power-On Start-Up Time 50 ms
if (hrt_absolute_time() < 50_ms) {
PX4_WARN("required Power-On Start-Up Time 50 ms");
}
// lock the device to half duplex SPI mode
RegisterWrite(Register::SPI_HALFDUPLEX_KEY, SPI_HALFDUPLEX_KEY_VALUE);
const uint16_t device_id = RegisterRead(Register::DEV_ID);
if (device_id != DEVICE_IDENTIFICATION) {
PX4_ERR("unexpected DEV_ID 0x%02x", device_id);
return PX4_ERROR;
}
return PX4_OK;
}
void ADIS16607::RunImpl()
{
const hrt_abstime now = hrt_absolute_time();
switch (_state) {
case STATE::RESET:
perf_count(_reset_perf);
RegisterWrite(Register::SOFT_RESET, SOFT_RESET_BIT::RESET);
_reset_timestamp = now;
_failure_count = 0;
_state = STATE::WAIT_FOR_RESET;
ScheduleDelayed(50_ms); // 50 ms Reset Recovery Time
break;
case STATE::WAIT_FOR_RESET:
// lock the device to half duplex SPI mode
RegisterWrite(Register::SPI_HALFDUPLEX_KEY, SPI_HALFDUPLEX_KEY_VALUE);
// These bits are cleared when read
RegisterRead(Register::DIAG_STAT);
if (_self_test_passed) {
if ((RegisterRead(Register::DEV_ID) == DEVICE_IDENTIFICATION)) {
// if reset succeeded then configure
_state = STATE::CONFIGURE;
ScheduleNow();
} else {
// RESET not complete
if (hrt_elapsed_time(&_reset_timestamp) > 1000_ms) {
PX4_WARN("Reset failed, retrying");
_state = STATE::RESET;
ScheduleDelayed(100_ms);
} else {
PX4_DEBUG("Reset not complete, check again in 100 ms");
ScheduleDelayed(100_ms);
}
}
} else {
RegisterWrite(Register::MSC_CTRL, MSC_CTRL_BIT::Self_test_1);
_state = STATE::SELF_TEST_CHECK;
ScheduleDelayed(50_ms); // Self Test Time
}
break;
case STATE::SELF_TEST_CHECK: {
// read DIAG_STAT to check result
const uint16_t diag_stat = RegisterRead(Register::DIAG_STAT);
if (diag_stat != 0) {
PX4_ERR("self test failed, resetting. DIAG_STAT: %#X", diag_stat);
_state = STATE::RESET;
ScheduleDelayed(3_s);
} else {
PX4_DEBUG("self test passed");
_self_test_passed = true;
_state = STATE::RESET;
ScheduleNow();
}
}
break;
case STATE::CONFIGURE:
if (Configure()) {
// if configure succeeded then start reading
_state = STATE::READ;
if (DataReadyInterruptConfigure()) {
_data_ready_interrupt_enabled = true;
// backup schedule as a watchdog timeout
ScheduleDelayed(100_ms);
} else {
_data_ready_interrupt_enabled = false;
ScheduleOnInterval(SAMPLE_INTERVAL_US, SAMPLE_INTERVAL_US);
}
} else {
// CONFIGURE not complete
if (hrt_elapsed_time(&_reset_timestamp) > 1000_ms) {
PX4_WARN("Configure failed, resetting");
_state = STATE::RESET;
} else {
PX4_WARN("Configure failed, retrying");
}
ScheduleDelayed(100_ms);
}
break;
case STATE::READ: {
hrt_abstime timestamp_sample = now;
if (_data_ready_interrupt_enabled) {
// scheduled from interrupt if _drdy_timestamp_sample was set as expected
const hrt_abstime drdy_timestamp_sample = _drdy_timestamp_sample.fetch_and(0);
if ((now - drdy_timestamp_sample) < SAMPLE_INTERVAL_US) {
timestamp_sample = drdy_timestamp_sample;
} else {
perf_count(_drdy_missed_perf);
}
// push backup schedule back
ScheduleDelayed(SAMPLE_INTERVAL_US * 2);
}
bool success = false;
struct BurstRead {
uint16_t cmd;
uint16_t DIAG_STAT;
int16_t X_ACCL_HIGH_OUT;
int16_t X_ACCL_LOW_OUT;
int16_t Y_ACCL_HIGH_OUT;
int16_t Y_ACCL_LOW_OUT;
int16_t Z_ACCL_HIGH_OUT;
int16_t Z_ACCL_LOW_OUT;
int16_t X_GYRO_HIGH_OUT;
int16_t X_GYRO_LOW_OUT;
int16_t Y_GYRO_HIGH_OUT;
int16_t Y_GYRO_LOW_OUT;
int16_t Z_GYRO_HIGH_OUT;
int16_t Z_GYRO_LOW_OUT;
int16_t TEMP_OUT;
uint16_t COUNT;
uint16_t checksum;
} buffer{};
// ADIS16607 burst report should be 272 bits
static_assert(sizeof(BurstRead) == (272 / 8), "ADIS16607 report not 272 bits");
buffer.cmd = static_cast<uint8_t>(Register::DIAG_STAT) | DIR_READ;
if (transfer((uint8_t *)&buffer, ((uint8_t *)&buffer), sizeof(buffer) / sizeof(uint8_t)) == PX4_OK) {
// Calculate checksum and compare
uint16_t *checksum_helper = &buffer.DIAG_STAT;
uint16_t checksum = 0;
for (int i = 0; i < 15; i++) {
checksum += be16toh(checksum_helper[i]);
}
if (be16toh(buffer.checksum) != checksum) {
perf_count(_bad_transfer_perf);
perf_count(_perf_crc_bad);
}
// Check all Status/Error Flag Indicators (DIAG_STAT)
if (be16toh(buffer.DIAG_STAT) != 0) {
perf_count(_bad_transfer_perf);
}
buffer.TEMP_OUT = (int16_t)be16toh(buffer.TEMP_OUT);
float temperature = (float)(buffer.TEMP_OUT) * 0.005f + 25.0f;
_px4_accel.set_temperature(temperature);
_px4_gyro.set_temperature(temperature);
// sensor's frame is +x forward, +y left, +z up
// flip y & z to publish right handed with z down (x forward, y right, z down)
float accel_x = (be16toh(buffer.X_ACCL_HIGH_OUT) << 16 | be16toh(buffer.X_ACCL_LOW_OUT)) >> 8;
float accel_y = -1 * ((be16toh(buffer.Y_ACCL_HIGH_OUT) << 16 | be16toh(buffer.Y_ACCL_LOW_OUT)) >> 8);
float accel_z = -1 * ((be16toh(buffer.Z_ACCL_HIGH_OUT) << 16 | be16toh(buffer.Z_ACCL_LOW_OUT)) >> 8);
float gyro_x = (be16toh(buffer.X_GYRO_HIGH_OUT) << 16 | be16toh(buffer.X_GYRO_LOW_OUT)) >> 8;
float gyro_y = -1 * ((be16toh(buffer.Y_GYRO_HIGH_OUT) << 16 | be16toh(buffer.Y_GYRO_LOW_OUT)) >> 8);
float gyro_z = -1 * ((be16toh(buffer.Z_GYRO_HIGH_OUT) << 16 | be16toh(buffer.Z_GYRO_LOW_OUT)) >> 8);
_px4_accel.update(timestamp_sample, accel_x, accel_y, accel_z);
_px4_gyro.update(timestamp_sample, gyro_x, gyro_y, gyro_z);
success = true;
if (_failure_count > 0) {
_failure_count--;
}
} else {
perf_count(_bad_transfer_perf);
}
if (!success) {
_failure_count++;
// full reset if things are failing consistently
if (_failure_count > 10) {
Reset();
return;
}
}
}
break;
}
}
bool ADIS16607::Configure()
{
// first set and clear all configured register bits
for (const auto &reg_cfg : _register_cfg) {
RegisterSetAndClearBits(reg_cfg.reg, reg_cfg.set_bits, reg_cfg.clear_bits);
}
// now check that all are configured
bool success = true;
for (const auto &reg_cfg : _register_cfg) {
if (!RegisterCheck(reg_cfg)) {
success = false;
}
}
RegisterWrite(Register::USER_FIFO_CFG, USER_FIFO_CFG_BIT::CLEAR_FIFOB);
// accel: ±40 g, 200000 LSB/g (24-bit format)
_px4_accel.set_range(40.f * CONSTANTS_ONE_G);
_px4_accel.set_scale(CONSTANTS_ONE_G / 200000.f); // scaling 200000 LSB/g -> m/s^2 per LSB
// gyro: ±2000 °/sec, 4000 LSB/°/sec (24-bit format)
_px4_gyro.set_range(math::radians(2000.f));
_px4_gyro.set_scale(math::radians(1.f / 4000.f)); // scaling 4000 LSB/°/sec -> rad/s per LSB
return success;
}
int ADIS16607::DataReadyInterruptCallback(int irq, void *context, void *arg)
{
static_cast<ADIS16607 *>(arg)->DataReady();
return 0;
}
void ADIS16607::DataReady()
{
_drdy_timestamp_sample.store(hrt_absolute_time());
ScheduleNow();
}
bool ADIS16607::DataReadyInterruptConfigure()
{
if (_drdy_gpio == 0) {
return false;
}
// Setup data ready on falling edge
return px4_arch_gpiosetevent(_drdy_gpio, false, true, false, &DataReadyInterruptCallback, this) == 0;
}
bool ADIS16607::DataReadyInterruptDisable()
{
if (_drdy_gpio == 0) {
return false;
}
return px4_arch_gpiosetevent(_drdy_gpio, false, false, false, nullptr, nullptr) == 0;
}
bool ADIS16607::RegisterCheck(const register_config_t &reg_cfg)
{
bool success = true;
const uint16_t reg_value = RegisterRead(reg_cfg.reg);
if (reg_cfg.set_bits && ((reg_value & reg_cfg.set_bits) != reg_cfg.set_bits)) {
PX4_DEBUG("0x%02hhX: 0x%02hhX (0x%02hhX not set)", (uint8_t)reg_cfg.reg, reg_value, reg_cfg.set_bits);
success = false;
}
if (reg_cfg.clear_bits && ((reg_value & reg_cfg.clear_bits) != 0)) {
PX4_DEBUG("0x%02hhX: 0x%02hhX (0x%02hhX not cleared)", (uint8_t)reg_cfg.reg, reg_value, reg_cfg.clear_bits);
success = false;
}
return success;
}
uint16_t ADIS16607::RegisterRead(Register reg)
{
uint8_t cmd[4];
cmd[0] = (static_cast<uint8_t>(reg) | DIR_READ);
transfer(&cmd[0], &cmd[0], 4);
return (uint16_t)((cmd[2] << 8) | cmd[3]);
}
void ADIS16607::RegisterWrite(Register reg, uint16_t value)
{
uint8_t cmd[3];
cmd[0] = static_cast<uint8_t>(reg);
cmd[1] = (value >> 8) & 0xFF;
cmd[2] = value & 0xFF;
transfer(&cmd[0], nullptr, 3);
}
void ADIS16607::RegisterSetAndClearBits(Register reg, uint16_t setbits, uint16_t clearbits)
{
const uint16_t orig_val = RegisterRead(reg);
uint16_t val = (orig_val & ~clearbits) | setbits;
if (orig_val != val) {
RegisterWrite(reg, val);
}
}
@@ -0,0 +1,134 @@
/****************************************************************************
*
* Copyright (c) 2026 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.
*
****************************************************************************/
/**
* @file ADIS16607.hpp
*
* Driver for the Analog Devices ADIS16607 connected via SPI.
*
*/
#pragma once
#include "Analog_Devices_ADIS16607_registers.hpp"
#include <drivers/drv_hrt.h>
#include <lib/drivers/accelerometer/PX4Accelerometer.hpp>
#include <lib/drivers/device/spi.h>
#include <lib/drivers/gyroscope/PX4Gyroscope.hpp>
#include <lib/geo/geo.h>
#include <lib/perf/perf_counter.h>
#include <px4_platform_common/atomic.h>
#include <px4_platform_common/i2c_spi_buses.h>
using namespace Analog_Devices_ADIS16607;
class ADIS16607 : public device::SPI, public I2CSPIDriver<ADIS16607>
{
public:
ADIS16607(const I2CSPIDriverConfig &config);
~ADIS16607() override;
static void print_usage();
void RunImpl();
int init() override;
void print_status() override;
private:
void exit_and_cleanup() override;
struct register_config_t {
Register reg;
uint16_t set_bits{0};
uint16_t clear_bits{0};
};
int probe() override;
bool Reset();
bool Configure();
static int DataReadyInterruptCallback(int irq, void *context, void *arg);
void DataReady();
bool DataReadyInterruptConfigure();
bool DataReadyInterruptDisable();
bool RegisterCheck(const register_config_t &reg_cfg);
uint16_t RegisterRead(Register reg);
void RegisterWrite(Register reg, uint16_t value);
void RegisterSetAndClearBits(Register reg, uint16_t setbits, uint16_t clearbits);
const spi_drdy_gpio_t _drdy_gpio;
PX4Accelerometer _px4_accel;
PX4Gyroscope _px4_gyro;
perf_counter_t _reset_perf{perf_alloc(PC_COUNT, MODULE_NAME": reset")};
perf_counter_t _bad_transfer_perf{perf_alloc(PC_COUNT, MODULE_NAME": bad transfer")};
perf_counter_t _perf_crc_bad{perf_counter_t(perf_alloc(PC_COUNT, MODULE_NAME": CRC16 bad"))};
perf_counter_t _drdy_missed_perf{nullptr};
hrt_abstime _reset_timestamp{0};
int _failure_count{0};
px4::atomic<hrt_abstime> _drdy_timestamp_sample{0};
bool _data_ready_interrupt_enabled{false};
bool _self_test_passed{false};
enum class STATE : uint8_t {
RESET,
WAIT_FOR_RESET,
SELF_TEST_CHECK,
CONFIGURE,
READ,
} _state{STATE::RESET};
register_config_t _register_cfg[3] {
// Register | Set bits, Clear bits
{Register::USER_GPIO_CFG1, USER_GPIO_CFG1_BIT::GPIO3_DR, 0},
{
Register::USER_DATA_CFG,
USER_DATA_CFG_BIT::WORD_SIZE_32 | USER_DATA_CFG_BIT::TEMPERATURE_EN | USER_DATA_CFG_BIT::DATA_CNTR_EN |
USER_DATA_CFG_BIT::Z_GYRO_EN | USER_DATA_CFG_BIT::Y_GYRO_EN | USER_DATA_CFG_BIT::X_GYRO_EN |
USER_DATA_CFG_BIT::Z_ACCEL_EN | USER_DATA_CFG_BIT::Y_ACCEL_EN | USER_DATA_CFG_BIT::X_ACCEL_EN,
USER_DATA_CFG_BIT::Z_DELTANG_EN | USER_DATA_CFG_BIT::Y_DELTANG_EN | USER_DATA_CFG_BIT::X_DELTANG_EN |
USER_DATA_CFG_BIT::Z_DELTVEL_EN | USER_DATA_CFG_BIT::Y_DELTVEL_EN | USER_DATA_CFG_BIT::X_DELTVEL_EN
},
{Register::MSC_CTRL, MSC_CTRL_BIT::FILT_BW_500Hz, 0},
};
};
@@ -0,0 +1,137 @@
/****************************************************************************
*
* Copyright (c) 2026 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.
*
****************************************************************************/
/**
* @file Analog_Devices_ADIS16607_registers.hpp
*
* Analog Devices ADIS16607 registers.
*
*/
#pragma once
#include <cstdint>
// TODO: move to a central header
static constexpr uint16_t Bit0 = (1 << 0);
static constexpr uint16_t Bit1 = (1 << 1);
static constexpr uint16_t Bit2 = (1 << 2);
static constexpr uint16_t Bit3 = (1 << 3);
static constexpr uint16_t Bit4 = (1 << 4);
static constexpr uint16_t Bit5 = (1 << 5);
static constexpr uint16_t Bit6 = (1 << 6);
static constexpr uint16_t Bit7 = (1 << 7);
static constexpr uint16_t Bit8 = (1 << 8);
static constexpr uint16_t Bit9 = (1 << 9);
static constexpr uint16_t Bit10 = (1 << 10);
static constexpr uint16_t Bit11 = (1 << 11);
static constexpr uint16_t Bit12 = (1 << 12);
static constexpr uint16_t Bit13 = (1 << 13);
static constexpr uint16_t Bit14 = (1 << 14);
static constexpr uint16_t Bit15 = (1 << 15);
namespace Analog_Devices_ADIS16607
{
static constexpr uint32_t SPI_SPEED = 10 * 1000 * 1000; // 10 MHz SPI serial interface
static constexpr uint16_t DIR_READ = 0x80;
static constexpr uint16_t DEVICE_IDENTIFICATION = 0x6000;
static constexpr uint16_t SPI_HALFDUPLEX_KEY_VALUE = 0xB4B4;
static constexpr uint32_t SAMPLE_INTERVAL_US = 125; // 8000 Hz
enum class Register : uint16_t {
DEV_ID = 0x00,
DIAG_STAT = 0x05,
USER_GPIO_CFG1 = 0x2F,
SPI_HALFDUPLEX_KEY = 0x32,
USER_DATA_CFG = 0x34,
USER_FIFO_CFG = 0x35,
SOFT_RESET = 0x36,
MSC_CTRL = 0x39,
};
// DIAG_STAT
enum DIAG_STAT_BIT : uint16_t {
Gyro_CST_fault = Bit15, // The gyro continuous self-test has failed.
Accelerometer_CST_fault = Bit14, // An accelerometer continuous self-test has failed
Gyro_fault = Bit13, // The gyro sensor has been disabled
Accelerometer_overload_or_fault = Bit12, // The accelerometer has been disabled
Power_supplies_fault = Bit11, // Fault in Any of the Power Supplies
SDSP_fault = Bit10, // SDSP Combined Error Status
BL_fault = Bit9, // Bootloader Fault
FW_fault = Bit8, // Firmware Faults.
SYNC_LOST = Bit2, // DPLL Has lost its sync input
DPLL_UnLocked = Bit1, // Status of the DPLL
FIFO_Threshold_Met = Bit0, // FIFO contains at least the desired number of samples
};
// USER_GPIO_CFG1
enum USER_GPIO_CFG1_BIT : uint16_t {
GPIO3_DR = Bit9, // Configure GPIO pins(GPIO3 as DR)
};
// USER_DATA_CFG
enum USER_DATA_CFG_BIT : uint16_t {
WORD_SIZE_32 = Bit15, // 32-bit Output Word Length
DATA_CNTR_EN = Bit14, // Enable Output Data Counter
TEMPERATURE_EN = Bit12, // Enable Temperature Sensor
Z_DELTANG_EN = Bit11,
Y_DELTANG_EN = Bit10,
X_DELTANG_EN = Bit9,
Z_DELTVEL_EN = Bit8,
Y_DELTVEL_EN = Bit7,
X_DELTVEL_EN = Bit6,
Z_GYRO_EN = Bit5,
Y_GYRO_EN = Bit4,
X_GYRO_EN = Bit3,
Z_ACCEL_EN = Bit2,
Y_ACCEL_EN = Bit1,
X_ACCEL_EN = Bit0,
};
// USER_FIFO_CFG
enum USER_FIFO_CFG_BIT : uint16_t {
CLEAR_FIFOB = Bit15, // Clear the FIFO pointers to reset it
};
// SOFT_RESET
enum SOFT_RESET_BIT : uint16_t {
RESET = Bit0, // Trigger soft reset
};
// MSC_CTRL
enum MSC_CTRL_BIT : uint16_t {
FILT_BW_500Hz = Bit8, // fc= 500 Hz
Self_test_1 = Bit6, // enable Self-Test mode
};
} // namespace Analog_Devices_ADIS16607
@@ -0,0 +1,47 @@
############################################################################
#
# Copyright (c) 2026 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 drivers__imu__analog_devices__adis16607
MAIN adis16607
COMPILE_FLAGS
SRCS
ADIS16607.cpp
ADIS16607.hpp
adis16607_main.cpp
Analog_Devices_ADIS16607_registers.hpp
DEPENDS
drivers_accelerometer
drivers_gyroscope
px4_work_queue
)
@@ -0,0 +1,5 @@
menuconfig DRIVERS_IMU_ANALOG_DEVICES_ADIS16607
bool "ADIS16607"
default n
---help---
Enable support for analog_devices ADIS16607
@@ -0,0 +1,87 @@
/****************************************************************************
*
* Copyright (c) 2026 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 "ADIS16607.hpp"
#include <px4_platform_common/getopt.h>
#include <px4_platform_common/module.h>
void ADIS16607::print_usage()
{
PRINT_MODULE_USAGE_NAME("adis16607", "driver");
PRINT_MODULE_USAGE_SUBCATEGORY("imu");
PRINT_MODULE_USAGE_COMMAND("start");
PRINT_MODULE_USAGE_PARAMS_I2C_SPI_DRIVER(false, true);
PRINT_MODULE_USAGE_PARAM_INT('R', 0, 0, 35, "Rotation", true);
PRINT_MODULE_USAGE_DEFAULT_COMMANDS();
}
extern "C" int adis16607_main(int argc, char *argv[])
{
int ch;
using ThisDriver = ADIS16607;
BusCLIArguments cli{false, true};
cli.default_spi_frequency = SPI_SPEED;
while ((ch = cli.getOpt(argc, argv, "R:")) != EOF) {
switch (ch) {
case 'R':
cli.rotation = (enum Rotation)atoi(cli.optArg());
break;
}
}
const char *verb = cli.optArg();
if (!verb) {
ThisDriver::print_usage();
return -1;
}
BusInstanceIterator iterator(MODULE_NAME, cli, DRV_IMU_DEVTYPE_ADIS16607);
if (!strcmp(verb, "start")) {
return ThisDriver::module_start(cli, iterator);
}
if (!strcmp(verb, "stop")) {
return ThisDriver::module_stop(iterator);
}
if (!strcmp(verb, "status")) {
return ThisDriver::module_status(iterator);
}
ThisDriver::print_usage();
return -1;
}