Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create and use AP_PERIPH_IMU_ENABLED #29232

Merged
merged 2 commits into from
Feb 7, 2025
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
2 changes: 1 addition & 1 deletion Tools/AP_Periph/AP_Periph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ void AP_Periph_FW::init()
baro.init();
#endif

#ifdef HAL_PERIPH_ENABLE_IMU
#if AP_PERIPH_IMU_ENABLED
if (g.imu_sample_rate) {
imu.init(g.imu_sample_rate);
if (imu.get_accel_count() > 0 || imu.get_gyro_count() > 0) {
Expand Down
4 changes: 2 additions & 2 deletions Tools/AP_Periph/AP_Periph.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class AP_Periph_FW {
void send_relposheading_msg();
void can_baro_update();
void can_airspeed_update();
#ifdef HAL_PERIPH_ENABLE_IMU
#if AP_PERIPH_IMU_ENABLED
void can_imu_update();
#endif

Expand Down Expand Up @@ -235,7 +235,7 @@ class AP_Periph_FW {
AP_Baro baro;
#endif

#ifdef HAL_PERIPH_ENABLE_IMU
#if AP_PERIPH_IMU_ENABLED
AP_InertialSensor imu;
#endif

Expand Down
2 changes: 1 addition & 1 deletion Tools/AP_Periph/Parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ const AP_Param::Info AP_Periph_FW::var_info[] = {
#endif


#ifdef HAL_PERIPH_ENABLE_IMU
#if AP_PERIPH_IMU_ENABLED
// @Param: IMU_SAMPLE_RATE
// @DisplayName: IMU Sample Rate
// @Description: IMU Sample Rate
Expand Down
2 changes: 1 addition & 1 deletion Tools/AP_Periph/Parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class Parameters {
AP_Int8 efi_port;
#endif

#ifdef HAL_PERIPH_ENABLE_IMU
#if AP_PERIPH_IMU_ENABLED
AP_Int16 imu_sample_rate;
#endif

Expand Down
4 changes: 2 additions & 2 deletions Tools/AP_Periph/imu.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "AP_Periph.h"

#ifdef HAL_PERIPH_ENABLE_IMU
#if AP_PERIPH_IMU_ENABLED
#include <dronecan_msgs.h>

extern const AP_HAL::HAL &hal;
Expand Down Expand Up @@ -59,4 +59,4 @@ void AP_Periph_FW::can_imu_update(void)
total_size);
}
}
#endif // HAL_PERIPH_ENABLE_IMU
#endif // AP_PERIPH_IMU_ENABLED
2 changes: 1 addition & 1 deletion Tools/ardupilotwaf/boards.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ def configure_env(self, cfg, env):
HAL_PERIPH_ENABLE_AIRSPEED = 1,
AP_PERIPH_MAG_ENABLED = 1,
AP_PERIPH_BARO_ENABLED = 1,
HAL_PERIPH_ENABLE_IMU = 1,
AP_PERIPH_IMU_ENABLED = 1,
AP_PERIPH_RANGEFINDER_ENABLED = 1,
AP_PERIPH_BATTERY_ENABLED = 1,
AP_PERIPH_BATTERY_BALANCE_ENABLED = 0,
Expand Down
5 changes: 4 additions & 1 deletion libraries/AP_HAL_ChibiOS/hwdef/CubeNode-ETH/hwdef.dat
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ include ../CubeNode/hwdef.dat
undef PE0
undef PE1
undef PC12
undef HAL_PERIPH_ENABLE_IMU
undef AP_PERIPH_IMU_ENABLED
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually we'd group this with the enable, but this is fine

undef HAL_GCS_ENABLED

# disable IMU
def AP_PERIPH_IMU_ENABLED 0

# need to use UART8 to get RTS/CTS
PE1 UART8_TX UART8
PE0 UART8_RX UART8
Expand Down
2 changes: 1 addition & 1 deletion libraries/AP_HAL_ChibiOS/hwdef/CubeNode/hwdef.dat
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ SPIDEV icm45686 SPI3 DEVID4 IMU_CS MODE0 24*MHZ 24*MHZ

IMU Invensensev3 SPI:icm45686 ROTATION_NONE

define HAL_PERIPH_ENABLE_IMU
define AP_PERIPH_IMU_ENABLED 1

# Periph GCS
define HAL_GCS_ENABLED 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ define AP_PERIPH_MAG_ENABLED 1
define AP_PERIPH_BARO_ENABLED 1
define HAL_PERIPH_ENABLE_RC_OUT
define HAL_PERIPH_ENABLE_NOTIFY
define HAL_PERIPH_ENABLE_IMU
define AP_PERIPH_IMU_ENABLED 1
define HAL_LOGGING_ENABLED TRUE


Expand Down
2 changes: 1 addition & 1 deletion libraries/AP_HAL_ChibiOS/hwdef/CubeOrange-periph/hwdef.dat
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ define AP_PERIPH_MAG_ENABLED 1
define AP_PERIPH_BARO_ENABLED 1
define HAL_PERIPH_ENABLE_RC_OUT
define HAL_PERIPH_ENABLE_NOTIFY
define HAL_PERIPH_ENABLE_IMU
define AP_PERIPH_IMU_ENABLED 1

define AP_KDECAN_ENABLED 1

Expand Down
3 changes: 1 addition & 2 deletions libraries/AP_HAL_ChibiOS/hwdef/HolybroG4_GPS/hwdef.dat
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,12 @@ SPIDEV icm42688 SPI1 DEVID1 ICM_CS MODE0 24*MHZ 24*MHZ

IMU Invensensev3 SPI:icm42688 ROTATION_YAW_180

define HAL_PERIPH_ENABLE_IMU
define AP_PERIPH_IMU_ENABLED 1

# GPS+MAG+LEDs
define AP_PERIPH_GPS_ENABLED 1
define AP_PERIPH_MAG_ENABLED 1
define AP_PERIPH_BARO_ENABLED 1
define HAL_PERIPH_ENABLE_IMU
define HAL_PERIPH_ENABLE_NOTIFY
define HAL_PERIPH_ENABLE_RC_OUT

Expand Down
10 changes: 8 additions & 2 deletions libraries/AP_HAL_ChibiOS/hwdef/scripts/defaults_periph.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@
#ifdef HAL_PERIPH_ENABLE_RANGEFINDER
#error "Change 'define HAL_PERIPH_ENABLE_RANGEFINDER' to 'define AP_PERIPH_RANGEFINDER_ENABLED 1'"
#endif
#ifdef HAL_PERIPH_ENABLE_IMU
#error "Change 'define HAL_PERIPH_ENABLE_IMU' to 'define AP_PERIPH_IMU_ENABLED 1'"
#endif

/*
* defaults for various AP_Periph features:
Expand All @@ -206,6 +209,9 @@
#ifndef AP_PERIPH_RANGEFINDER_ENABLED
#define AP_PERIPH_RANGEFINDER_ENABLED 0
#endif
#ifndef AP_PERIPH_IMU_ENABLED
#define AP_PERIPH_IMU_ENABLED 0
#endif

/*
* turning on of ArduPilot features based on which AP_Periph features
Expand All @@ -217,6 +223,8 @@
#define AP_COMPASS_ENABLED AP_PERIPH_MAG_ENABLED
#define AP_BARO_ENABLED AP_PERIPH_BARO_ENABLED
#define AP_RANGEFINDER_ENABLED AP_PERIPH_RANGEFINDER_ENABLED
#define AP_INERTIALSENSOR_ENABLED AP_PERIPH_IMU_ENABLED
#define AP_INERTIALSENSOR_ALLOW_NO_SENSORS AP_PERIPH_IMU_ENABLED

/*
* GPS Backends - we selectively turn backends on.
Expand Down Expand Up @@ -406,8 +414,6 @@
#define AP_RCPROTOCOL_ENABLED defined(HAL_PERIPH_ENABLE_RCIN)
#define AP_RTC_ENABLED defined(HAL_PERIPH_ENABLE_RTC)
#define HAL_VISUALODOM_ENABLED defined(HAL_PERIPH_ENABLE_VISUALODOM)
#define AP_INERTIALSENSOR_ENABLED defined(HAL_PERIPH_ENABLE_IMU)
#define AP_INERTIALSENSOR_ALLOW_NO_SENSORS defined(HAL_PERIPH_ENABLE_IMU)
#define AP_INERTIALSENSOR_HARMONICNOTCH_ENABLED 0

#ifndef AP_BOOTLOADER_ALWAYS_ERASE
Expand Down
Loading