diff --git a/libraries/SITL/SIM_Airspeed_DLVR.cpp b/libraries/SITL/SIM_Airspeed_DLVR.cpp index 265185fae4456..e00a1864d6fc8 100644 --- a/libraries/SITL/SIM_Airspeed_DLVR.cpp +++ b/libraries/SITL/SIM_Airspeed_DLVR.cpp @@ -1,5 +1,7 @@ #include "SIM_Airspeed_DLVR.h" +#if AP_SIM_AIRSPEEDDLVR_ENABLED + #include "SITL.h" int SITL::Airspeed_DLVR::rdwr(I2C::i2c_rdwr_ioctl_data *&data) @@ -68,3 +70,5 @@ void SITL::Airspeed_DLVR::update(const class Aircraft &aircraft) // To Do: Add a sensor board temperature offset parameter temperature = AP_Baro::get_temperatureC_for_alt_amsl(sim_alt); } + +#endif // AP_SIM_AIRSPEEDDLVR_ENABLED diff --git a/libraries/SITL/SIM_Airspeed_DLVR.h b/libraries/SITL/SIM_Airspeed_DLVR.h index cb21efdb514e4..629c84a3ada41 100644 --- a/libraries/SITL/SIM_Airspeed_DLVR.h +++ b/libraries/SITL/SIM_Airspeed_DLVR.h @@ -2,6 +2,14 @@ #include "SIM_I2CDevice.h" +#include + +#ifndef AP_SIM_AIRSPEEDDLVR_ENABLED +#define AP_SIM_AIRSPEEDDLVR_ENABLED (CONFIG_HAL_BOARD == HAL_BOARD_SITL) +#endif + +#if AP_SIM_AIRSPEEDDLVR_ENABLED + namespace SITL { class Airspeed_DLVR : public I2CDevice @@ -26,3 +34,5 @@ class Airspeed_DLVR : public I2CDevice }; } // namespace SITL + +#endif // AP_SIM_AIRSPEEDDLVR_ENABLED diff --git a/libraries/SITL/SIM_BattMonitor_SMBus_Maxell.cpp b/libraries/SITL/SIM_BattMonitor_SMBus_Maxell.cpp index eaf1c1b19fb63..168a8c67248bc 100644 --- a/libraries/SITL/SIM_BattMonitor_SMBus_Maxell.cpp +++ b/libraries/SITL/SIM_BattMonitor_SMBus_Maxell.cpp @@ -1,5 +1,7 @@ #include "SIM_BattMonitor_SMBus_Maxell.h" +#if AP_SIM_BATTMONITORSMBUSMAXELL_ENABLED + SITL::Maxell::Maxell() : SIM_BattMonitor_SMBus_Generic() { @@ -15,3 +17,5 @@ SITL::Maxell::Maxell() : set_register(SMBusBattGenericDevReg::SERIAL, (uint16_t)37); } + +#endif // AP_SIM_BATTMONITORSMBUSMAXELL_ENABLED diff --git a/libraries/SITL/SIM_BattMonitor_SMBus_Maxell.h b/libraries/SITL/SIM_BattMonitor_SMBus_Maxell.h index 5652b48cbdd87..1ec8df5bb8121 100644 --- a/libraries/SITL/SIM_BattMonitor_SMBus_Maxell.h +++ b/libraries/SITL/SIM_BattMonitor_SMBus_Maxell.h @@ -1,3 +1,11 @@ +#include + +#ifndef AP_SIM_BATTMONITORSMBUSMAXELL_ENABLED +#define AP_SIM_BATTMONITORSMBUSMAXELL_ENABLED (CONFIG_HAL_BOARD == HAL_BOARD_SITL) +#endif + +#if AP_SIM_BATTMONITORSMBUSMAXELL_ENABLED + #include "SIM_BattMonitor_SMBus_Generic.h" #include @@ -25,3 +33,5 @@ class Maxell : public SIM_BattMonitor_SMBus_Generic }; } // namespace SITL + +#endif // AP_SIM_BATTMONITORSMBUSMAXELL_ENABLED diff --git a/libraries/SITL/SIM_BattMonitor_SMBus_Rotoye.cpp b/libraries/SITL/SIM_BattMonitor_SMBus_Rotoye.cpp index adadfda70ea24..577e87c4106f2 100644 --- a/libraries/SITL/SIM_BattMonitor_SMBus_Rotoye.cpp +++ b/libraries/SITL/SIM_BattMonitor_SMBus_Rotoye.cpp @@ -1,4 +1,7 @@ #include "SIM_BattMonitor_SMBus_Rotoye.h" + +#if AP_SIM_BATTMONITORSMBUSROTOYE_ENABLED + #include SITL::Rotoye::Rotoye() : @@ -28,3 +31,5 @@ void SITL::Rotoye::update(const class Aircraft &aircraft) set_register(SMBusBattRotoyeDevReg::TEMP_EXT, int16_t(outside_temp + 100)); // it's a little warmer inside.... (10 degrees here) } } + +#endif // AP_SIM_BATTMONITORSMBUSROTOYE_ENABLED diff --git a/libraries/SITL/SIM_BattMonitor_SMBus_Rotoye.h b/libraries/SITL/SIM_BattMonitor_SMBus_Rotoye.h index a7617249b9db2..b7ab466338e2d 100644 --- a/libraries/SITL/SIM_BattMonitor_SMBus_Rotoye.h +++ b/libraries/SITL/SIM_BattMonitor_SMBus_Rotoye.h @@ -1,3 +1,11 @@ +#include + +#ifndef AP_SIM_BATTMONITORSMBUSROTOYE_ENABLED +#define AP_SIM_BATTMONITORSMBUSROTOYE_ENABLED (CONFIG_HAL_BOARD == HAL_BOARD_SITL) +#endif + +#if AP_SIM_BATTMONITORSMBUSROTOYE_ENABLED + #include "SIM_BattMonitor_SMBus_Generic.h" #include @@ -33,3 +41,5 @@ class Rotoye : public SIM_BattMonitor_SMBus_Generic }; } // namespace SITL + +#endif // AP_SIM_BATTMONITORSMBUSROTOYE_ENABLED diff --git a/libraries/SITL/SIM_I2C.cpp b/libraries/SITL/SIM_I2C.cpp index 8d1b1daf0aaa9..3d0220497ce86 100644 --- a/libraries/SITL/SIM_I2C.cpp +++ b/libraries/SITL/SIM_I2C.cpp @@ -24,6 +24,7 @@ #include "SIM_I2C.h" #include "SIM_ToshibaLED.h" #include "SIM_MaxSonarI2CXL.h" +#include "SIM_BattMonitor_SMBus_Generic.h" #include "SIM_BattMonitor_SMBus_Maxell.h" #include "SIM_BattMonitor_SMBus_Rotoye.h" #include "SIM_Airspeed_DLVR.h" @@ -59,20 +60,38 @@ static IgnoredI2CDevice ignored; #if AP_SIM_TOSHIBALED_ENABLED static ToshibaLED toshibaled; #endif +#if AP_SIM_MAXSONARI2CXL_ENABLED static MaxSonarI2CXL maxsonari2cxl; static MaxSonarI2CXL maxsonari2cxl_2; +#endif +#if AP_SIM_BATTMONITORSMBUSMAXELL_ENABLED static Maxell maxell; +#endif +#if AP_SIM_BATTMONITORSMBUSROTOYE_ENABLED static Rotoye rotoye; +#endif static SIM_BattMonitor_SMBus_Generic smbus_generic; +#if AP_SIM_AIRSPEEDDLVR_ENABLED static Airspeed_DLVR airspeed_dlvr; +#endif +#if AP_SIM_TEMPERATURETSYS01_ENABLED static TSYS01 tsys01; +#endif #if AP_SIM_TSYS03_ENABLED static TSYS03 tsys03; #endif +#if AP_SIM_TEMPERATUREMCP9600_ENABLED static MCP9600 mcp9600; +#endif +#if AP_SIM_ICM40609_ENABLED static ICM40609 icm40609; +#endif +#if AP_SIM_MS5525_ENABLED static MS5525 ms5525; +#endif +#if AP_SIM_MS5611_ENABLED static MS5611 ms5611; +#endif #if AP_SIM_LP5562_ENABLED static LP5562 lp5562; #endif @@ -95,25 +114,43 @@ struct i2c_device_at_address { uint8_t addr; I2CDevice &device; } i2c_devices[] { +#if AP_SIM_MAXSONARI2CXL_ENABLED { 0, 0x70, maxsonari2cxl }, // RNGFNDx_TYPE = 2, RNGFNDx_ADDR = 112 +#endif +#if AP_SIM_TEMPERATUREMCP9600_ENABLED { 0, 0x60, mcp9600 }, // 0x60 is low address +#endif +#if AP_SIM_MAXSONARI2CXL_ENABLED { 0, 0x71, maxsonari2cxl_2 }, // RNGFNDx_TYPE = 2, RNGFNDx_ADDR = 113 +#endif +#if AP_SIM_ICM40609_ENABLED { 1, 0x01, icm40609 }, +#endif #if AP_SIM_TOSHIBALED_ENABLED { 1, 0x55, toshibaled }, #endif { 1, 0x38, ignored }, // NCP5623 { 1, 0x39, ignored }, // NCP5623C { 1, 0x40, ignored }, // KellerLD +#if AP_SIM_MS5525_ENABLED { 1, 0x76, ms5525 }, // MS5525: ARSPD_TYPE = 4 +#endif #if AP_SIM_INA3221_ENABLED { 1, 0x42, ina3221 }, #endif +#if AP_SIM_TEMPERATURETSYS01_ENABLED { 1, 0x77, tsys01 }, +#endif +#if AP_SIM_BATTMONITORSMBUSROTOYE_ENABLED { 1, 0x0B, rotoye }, // Rotoye: BATTx_MONITOR 19, BATTx_I2C_ADDR 13 +#endif +#if AP_SIM_BATTMONITORSMBUSMAXELL_ENABLED { 2, 0x0B, maxell }, // Maxell: BATTx_MONITOR 16, BATTx_I2C_ADDR 13 +#endif { 3, 0x0B, smbus_generic}, // BATTx_MONITOR 7, BATTx_I2C_ADDR 13 +#if AP_SIM_AIRSPEEDDLVR_ENABLED { 2, 0x28, airspeed_dlvr }, // ARSPD_TYPE = 7 5inch H2O sensor +#endif #if AP_SIM_LP5562_ENABLED { 2, 0x30, lp5562 }, // LP5562 RGB LED driver #endif @@ -126,7 +163,9 @@ struct i2c_device_at_address { #if AP_SIM_TSYS03_ENABLED { 2, 0x40, tsys03 }, #endif +#if AP_SIM_MS5611_ENABLED { 2, 0x77, ms5611 }, // MS5611: BARO_PROBE_EXT = 2 +#endif #if AP_SIM_COMPASS_QMC5883L_ENABLED { 2, 0x0D, qmc5883l }, #endif diff --git a/libraries/SITL/SIM_ICM40609.h b/libraries/SITL/SIM_ICM40609.h index 121b82b957f6f..a1416c20aadfb 100644 --- a/libraries/SITL/SIM_ICM40609.h +++ b/libraries/SITL/SIM_ICM40609.h @@ -1,5 +1,13 @@ #include "SIM_Invensense_v3.h" +#include + +#ifndef AP_SIM_ICM40609_ENABLED +#define AP_SIM_ICM40609_ENABLED (CONFIG_HAL_BOARD == HAL_BOARD_SITL) +#endif + +#if AP_SIM_ICM40609_ENABLED + namespace SITL { class ICM40609DevReg : public InvensenseV3DevReg { @@ -21,3 +29,5 @@ class ICM40609 : public InvensenseV3 }; } // namespace SITL + +#endif // AP_SIM_ICM40609_ENABLED diff --git a/libraries/SITL/SIM_MS5525.cpp b/libraries/SITL/SIM_MS5525.cpp index 760c4202f92a9..30ae091c398d2 100644 --- a/libraries/SITL/SIM_MS5525.cpp +++ b/libraries/SITL/SIM_MS5525.cpp @@ -1,5 +1,7 @@ #include "SIM_MS5525.h" +#if AP_SIM_MS5525_ENABLED + #include using namespace SITL; @@ -72,3 +74,5 @@ void MS5525::get_pressure_temperature_readings(float &P_Pa, float &Temp_C) const uint8_t instance = 0; // TODO: work out which sensor this is P_Pa = AP::sitl()->state.airspeed_raw_pressure[instance] + AP::sitl()->airspeed[instance].offset; } + +#endif // AP_SIM_MS5525_ENABLED diff --git a/libraries/SITL/SIM_MS5525.h b/libraries/SITL/SIM_MS5525.h index f64b82ff0b383..04644c26f74ac 100644 --- a/libraries/SITL/SIM_MS5525.h +++ b/libraries/SITL/SIM_MS5525.h @@ -1,5 +1,13 @@ #include "SIM_MS5XXX.h" +#include + +#ifndef AP_SIM_MS5525_ENABLED +#define AP_SIM_MS5525_ENABLED (CONFIG_HAL_BOARD == HAL_BOARD_SITL) +#endif + +#if AP_SIM_MS5525_ENABLED + #include namespace SITL { @@ -43,3 +51,5 @@ class MS5525 : public MS5XXX }; } // namespace SITL + +#endif // AP_SIM_MS5525_ENABLED diff --git a/libraries/SITL/SIM_MS5611.cpp b/libraries/SITL/SIM_MS5611.cpp index d205665d5ef88..cce4927711e86 100644 --- a/libraries/SITL/SIM_MS5611.cpp +++ b/libraries/SITL/SIM_MS5611.cpp @@ -1,5 +1,7 @@ #include "SIM_MS5611.h" +#if AP_SIM_MS5611_ENABLED + #include #include @@ -121,3 +123,5 @@ void MS5611::get_pressure_temperature_readings(float &P_Pa, float &Temp_C) // TO DO add in wind correction by inheritting from AP_Baro_SITL_Generic? // P_Pa += AP_Baro_SITL::wind_pressure_correction(instance); } + +#endif // AP_SIM_MS5611_ENABLED diff --git a/libraries/SITL/SIM_MS5611.h b/libraries/SITL/SIM_MS5611.h index 7822a470d460a..8742c8e111800 100644 --- a/libraries/SITL/SIM_MS5611.h +++ b/libraries/SITL/SIM_MS5611.h @@ -1,5 +1,13 @@ #include "SIM_MS5XXX.h" +#include + +#ifndef AP_SIM_MS5611_ENABLED +#define AP_SIM_MS5611_ENABLED (CONFIG_HAL_BOARD == HAL_BOARD_SITL) +#endif + +#if AP_SIM_MS5611_ENABLED + #include namespace SITL { @@ -43,3 +51,5 @@ class MS5611 : public MS5XXX }; } // namespace SITL + +#endif // AP_SIM_MS5611_ENABLED diff --git a/libraries/SITL/SIM_MaxSonarI2CXL.h b/libraries/SITL/SIM_MaxSonarI2CXL.h index a18d981745fd9..36ba0ffb052d3 100644 --- a/libraries/SITL/SIM_MaxSonarI2CXL.h +++ b/libraries/SITL/SIM_MaxSonarI2CXL.h @@ -2,6 +2,14 @@ #include "SIM_I2CDevice.h" +#include + +#ifndef AP_SIM_MAXSONARI2CXL_ENABLED +#define AP_SIM_MAXSONARI2CXL_ENABLED (CONFIG_HAL_BOARD == HAL_BOARD_SITL) +#endif + +#if AP_SIM_MAXSONARI2CXL_ENABLED + namespace SITL { class MaxSonarI2CXL : public I2CDevice, public I2CCommandResponseDevice @@ -29,3 +37,5 @@ class MaxSonarI2CXL : public I2CDevice, public I2CCommandResponseDevice }; } // namespace SITL + +#endif // AP_SIM_MAXSONARI2CXL_ENABLED diff --git a/libraries/SITL/SIM_Temperature_MCP9600.cpp b/libraries/SITL/SIM_Temperature_MCP9600.cpp index c05e7221504fa..1a399ab24c83d 100644 --- a/libraries/SITL/SIM_Temperature_MCP9600.cpp +++ b/libraries/SITL/SIM_Temperature_MCP9600.cpp @@ -1,5 +1,7 @@ #include "SIM_Temperature_MCP9600.h" +#if AP_SIM_TEMPERATUREMCP9600_ENABLED + using namespace SITL; #include @@ -65,3 +67,5 @@ int MCP9600::rdwr(I2C::i2c_rdwr_ioctl_data *&data) { return I2CRegisters_ConfigurableLength::rdwr(data); } + +#endif // AP_SIM_TEMPERATUREMCP9600_ENABLED diff --git a/libraries/SITL/SIM_Temperature_MCP9600.h b/libraries/SITL/SIM_Temperature_MCP9600.h index c0d2f3ae1ae21..721d2682c0668 100644 --- a/libraries/SITL/SIM_Temperature_MCP9600.h +++ b/libraries/SITL/SIM_Temperature_MCP9600.h @@ -1,5 +1,13 @@ #include "SIM_I2CDevice.h" +#include + +#ifndef AP_SIM_TEMPERATUREMCP9600_ENABLED +#define AP_SIM_TEMPERATUREMCP9600_ENABLED (CONFIG_HAL_BOARD == HAL_BOARD_SITL) +#endif + +#if AP_SIM_TEMPERATUREMCP9600_ENABLED + /* Simulator for the MCP9600 temperature sensor @@ -36,3 +44,5 @@ class MCP9600 : public I2CDevice, private I2CRegisters_ConfigurableLength }; } // namespace SITL + +#endif // AP_SIM_TEMPERATUREMCP9600_ENABLED diff --git a/libraries/SITL/SIM_Temperature_TSYS01.cpp b/libraries/SITL/SIM_Temperature_TSYS01.cpp index 5785a731527ae..6593026abfc65 100644 --- a/libraries/SITL/SIM_Temperature_TSYS01.cpp +++ b/libraries/SITL/SIM_Temperature_TSYS01.cpp @@ -1,5 +1,7 @@ #include "SIM_Temperature_TSYS01.h" +#if AP_SIM_TEMPERATURETSYS01_ENABLED + #include constexpr const int32_t SITL::TSYS01::_k[5]; @@ -196,3 +198,5 @@ float SITL::TSYS01::get_sim_temperature() const // To Do: Add a sensor board temperature offset parameter return AP_Baro::get_temperatureC_for_alt_amsl(sim_alt) + 25; } + +#endif // AP_SIM_TEMPERATURETSYS01_ENABLED diff --git a/libraries/SITL/SIM_Temperature_TSYS01.h b/libraries/SITL/SIM_Temperature_TSYS01.h index 5ad9bff832119..8c406ddec6ab5 100644 --- a/libraries/SITL/SIM_Temperature_TSYS01.h +++ b/libraries/SITL/SIM_Temperature_TSYS01.h @@ -1,5 +1,13 @@ #include "SIM_I2CDevice.h" +#include + +#ifndef AP_SIM_TEMPERATURETSYS01_ENABLED +#define AP_SIM_TEMPERATURETSYS01_ENABLED (CONFIG_HAL_BOARD == HAL_BOARD_SITL) +#endif + +#if AP_SIM_TEMPERATURETSYS01_ENABLED + /* Simulator for the TSYS01 temperature sensor @@ -63,3 +71,5 @@ class TSYS01 : public I2CDevice }; } // namespace SITL + +#endif // AP_SIM_TEMPERATURETSYS01_ENABLED