From 296aecab00c8617c1142d4d12f479ee8290998d6 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Sat, 22 Jul 2023 18:18:29 +1000 Subject: [PATCH] Make I2C mag optional --- source/Core/BSP/Pinecil/configuration.h | 15 ++++++++------- source/Core/BSP/Pinecilv2/configuration.h | 1 + source/Core/Drivers/Si7210.cpp | 2 ++ source/Core/Drivers/Si7210.h | 5 ++++- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/source/Core/BSP/Pinecil/configuration.h b/source/Core/BSP/Pinecil/configuration.h index 06d2e7c4..f60cc99f 100644 --- a/source/Core/BSP/Pinecil/configuration.h +++ b/source/Core/BSP/Pinecil/configuration.h @@ -86,7 +86,7 @@ #define POWER_PULSE_DEFAULT 0 #else #define POWER_PULSE_DEFAULT 5 -#endif /* Pinecil */ +#endif /* Pinecil */ #define POWER_PULSE_WAIT_DEFAULT 4 // Default rate of the power pulse: 4*2500 = 10000 ms = 10 s #define POWER_PULSE_DURATION_DEFAULT 1 // Default duration of the power pulse: 1*250 = 250 ms @@ -145,12 +145,13 @@ #define MIN_BOOST_TEMP_C 250 // The min settable temp for boost mode °C #define MIN_BOOST_TEMP_F 480 // The min settable temp for boost mode °F -#define POW_PD 1 -#define POW_PD_EXT 0 -#define POW_QC 1 -#define POW_DC 1 -#define POW_QC_20V 1 -#define ENABLE_QC2 1 +#define POW_PD 1 +#define POW_PD_EXT 0 +#define POW_QC 1 +#define POW_DC 1 +#define POW_QC_20V 1 +#define ENABLE_QC2 1 +#define MAG_SLEEP_SUPPORT 1 #define TEMP_TMP36 #define ACCEL_BMA #define ACCEL_SC7 diff --git a/source/Core/BSP/Pinecilv2/configuration.h b/source/Core/BSP/Pinecilv2/configuration.h index 5297f3a4..f9e6bacc 100644 --- a/source/Core/BSP/Pinecilv2/configuration.h +++ b/source/Core/BSP/Pinecilv2/configuration.h @@ -152,6 +152,7 @@ #define POW_QC_20V 1 // Supported features #define POW_EPR 1 #define ENABLE_QC2 1 +#define MAG_SLEEP_SUPPORT 1 #define DEVICE_HAS_VALIDATION_SUPPORT #define TEMP_NTC #define ACCEL_BMA diff --git a/source/Core/Drivers/Si7210.cpp b/source/Core/Drivers/Si7210.cpp index 642e481c..546c7c1a 100644 --- a/source/Core/Drivers/Si7210.cpp +++ b/source/Core/Drivers/Si7210.cpp @@ -13,6 +13,7 @@ #include "I2C_Wrapper.hpp" #include "Si7210_defines.h" #include +#ifdef MAG_SLEEP_SUPPORT bool Si7210::detect() { return FRToSI2C::wakePart(SI7210_ADDRESS); } bool Si7210::init() { @@ -175,3 +176,4 @@ bool Si7210::set_high_range() { worked &= write_reg(SI7210_A5, 0, val); return worked; } +#endif // MAG_SLEEP_SUPPORT \ No newline at end of file diff --git a/source/Core/Drivers/Si7210.h b/source/Core/Drivers/Si7210.h index 305c91ea..2bbc46be 100644 --- a/source/Core/Drivers/Si7210.h +++ b/source/Core/Drivers/Si7210.h @@ -7,7 +7,10 @@ #ifndef CORE_DRIVERS_SI7210_H_ #define CORE_DRIVERS_SI7210_H_ +#include "configuration.h" #include + +#ifdef MAG_SLEEP_SUPPORT class Si7210 { public: // Return true if present @@ -23,5 +26,5 @@ private: static bool get_field_strength(int16_t *field); static bool set_high_range(); }; - +#endif // MAG_SLEEP_SUPPORT #endif /* CORE_DRIVERS_SI7210_H_ */