diff --git a/LICENSE.md b/LICENSE.md
index f618c0e..bd09ac9 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -1,6 +1,8 @@
MIT License
-Copyright (c) 2025 SparkFun Electronics
+
+Copyright (c) 2024-2025 SparkFun Electronics
+
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -19,3 +21,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+
diff --git a/README.md b/README.md
index a448c45..e8f57c1 100644
--- a/README.md
+++ b/README.md
@@ -1,49 +1,85 @@
-SparkFun XM125 A121 Arduino Library
-========================================
-[](https://www.sparkfun.com/products/24540)
+
-[*SparkFun Pulsed Coherent Radar Sensor – Acconeer XM125 (Qwiic) (SEN-24540)*](https://www.sparkfun.com/products/24540)
+# SparkFun Pulsed Coherent Radar Sensor – Acconeer XM125
-This is the SparkFun library for the Acconeer Entry+ Module XM125 with the A121 60GHz Pulsed Coherent Radar sensor and I2C interface.
+Arduino Library for the SparkFun Pulsed Coherent Radar Sensor
+
+
+
+
+
+
-Repository Contents
--------------------
-* **/examples** - Example sketches for the library (.ino). Run these from the Arduino IDE.
-* **/src** - Source files for the library (.cpp, .h).
-* **/docs** - Datasheet and application note for the XM125 and A121.
-* **keywords.txt** - Keywords from this library that will be highlighted in the Arduino IDE.
-* **library.properties** - General library properties for the Arduino package manager.
-* **[CONTRIBUTING.md](./CONTRIBUTING.md)** - guidance on how to contribute to this library.
+The [SparkFun Pulsed Coherent Radar Sensor - Acconeer XM125 (SEN-24540)](https://www.sparkfun.com/sparkfun-pulsed-coherent-radar-sensor-acconeer-xm125-qwiic.html) brings powerful 60 GHz radar technology to your projects. This sensor isn't limited to surface detection; it can see through walls, cabinets, and even pockets (depending on the material), making it perfect for unique applications. Measure distances with millimeter precision, detect motion, the speed of an object, or even gestures!
+The XM125 boasts an impressive range of up to 20 meters, allowing you to create long-range sensing projects. The actual measurable distance is dependent on the object size, shape, dielectric properties, and lens (e.g. water level measurements up to 20 meters with lens utilization, human presence detection up to 7 meters with lens-free utilization). Despite its power, the sensor has remarkably low in power consumption, which is ideal for battery-powered applications. The real magic lies in the sensor's ability to do more than measure distance; the XM125 can differentiate between stationary objects and moving targets using pulsed coherent radar. This means you can sense an object's presence and how fast something is moving!
-Documentation
---------------
+Looking for the board that matches this library - pick up a [SparkFun Pulsed Coherent Radar Sensor - Acconeer XM125 (Qwiic)](https://www.sparkfun.com/sparkfun-pulsed-coherent-radar-sensor-acconeer-xm125-qwiic.html) at www.sparkfun.com.
-* **[Installing an Arduino Library Guide](https://learn.sparkfun.com/tutorials/installing-an-arduino-library)** - Basic information on how to install an Arduino library.
-* **[Hookup Guide](https://docs.sparkfun.com/SparkFun_Qwiic_Pulsed_Radar_Sensor_XM125)** - Basic hookup guide for the SparkFUn Qwiic Pulsed Coherent Radar Sensor - XM125.
-* **[Product Repository](https://github.com/sparkfun/SparkFun_Qwiic_Pulsed_Radar_Sensor_XM125)** - Main repository for the SparkFun Qwiic XM125 (including hardware files)
+### *Upgrading to Version 2.\* from Version 1.\**
+Version 2.0+ of this library is not compatible with Version 1.* implementations/use. For Version 2.0, the single class defined by the library, `SparkFunXM125`, was divided into two distinct classes:
-Products that use this Library
----------------------------------
+* SparkFunXM125Distance - Used when the XM125 is running the ***Distance*** application
+* SparkFunXM125Presence - Used when the XM125 is running the ***Presence*** application
-* [*SEN-24540*](https://www.sparkfun.com/products/24540)
+Moving to use Version 2.0 of the library just requires changing the class name used in your sketch - from `SparkFunXM125` to either `SparkFunXM125Distance` or `SparkFunXM125Presence`
+## Functionality
-License Information
--------------------
+The SparkFun Pulsed Coherent Radar sensor can run as an I2C client device, or as a standalone development board. This library is used when the sensor is operating as a standalone I2C device.
-This product is _**open source**_!
+When running as a I2C client device, the Acconeer XM125 is loaded with a specific firmware application from Acconeer.
-Please review the LICENSE.md file for license information.
+The *SparkFun Pulsed Coherent Radar Sensor - Acconeer XM125* comes with the ***Presence Detector*** firmware loaded, which is accessible using the ***Presence*** focused methods in this library.
-If you have any questions or concerns on licensing, please contact technical support on our [SparkFun forums](https://forum.sparkfun.com/viewforum.php?f=152).
+This library also supports the ***Distance Detection*** application firmware from Acconeer. To enable this functionally, the ***Distance Detection*** firmware must be loaded onto the *SparkFun Pulsed Coherent Radar Sensor - Acconeer XM125* board. The firmware is available from [Acconeer](https://developer.acconeer.com/home/a121-docs-software/xm125-xe125/) as part of the XM125/A121 SDK. The files are located in the `out/` folder - with naming patter of `i2c_*_detector.bin`. Install instructions are noted in our [Hook Up Guide](https://docs.sparkfun.com/SparkFun_Qwiic_Pulsed_Radar_Sensor_XM125/introduction/) for the product.
-Distributed as-is; no warranty is given.
-- Your friends at SparkFun.
+This library provides a extensive interface that enables the following functionality/interaction with the SparkFun Pulsed Coherent Radar Sensor when the sensor is operating as an I2C sensor device:
+
+|Function|Firmware|
+|---|---|
+|Distance Detection | `i2c_distance_detector` |
+|Presence Detection | `i2c_presence_detector` |
+
+## General Use
+
+### TO DO
+
+
+## Examples
+
+The following examples are provided with the library
+
+| Example | Description |
+|---|---|
+|[Presence Basic Readings](examples/Example01_PresenceBasicReadings/Example01_PresenceBasicReadings.ino)| The sensor is initialized, then the presence distance values will print out to the terminal.|
+| [Presence GPIO 0 Usage](examples/Example02_PresenceGPIO0Usage/Example02_PresenceGPIO0Usage.ino)|The sensor is initialized, then the presence values will print out to the terminal and trigger the GPIO0 pin high when there is a presence detected. |
+|[Presence Serial Plotter](examples/Example03_PresenceSerialPlotter/Example03_PresenceSerialPlotter.ino)|The sensor is initialized, then the presence values will print out to the terminal and the serial monitor.|
+|[Presence Advanced Readings](examples/Example04_PresenceAdvancedReadings/Example04_PresenceAdvancedReadings.ino)|The sensor is initialized, then the presence distance, intra-presence, and inter-presence values will be printed to the terminal.|
+|[Presence Advanced Settings](examples/Example05_PresenceAdvancedSettings/Example05_PresenceAdvancedSettings.ino)|The sensor is initialized, then the presence distance values will print out to the terminal just as they do in example one. If you wish to change the settings of the device, do so before applying the configuration.|
+|[Distance Basic Readings](examples/Example06_DistanceBasicReadings/Example06_DistanceBasicReadings.ino)|The sensor is initialized, then the distance values will print out to the terminal in mm. |
+|[Distance Threshold Settings](examples/Example07_DistanceThresholdSettings/Example07_DistanceThresholdSettings.ino)|The sensor is initialized, then the distance amplitude, and strength , fixed amplitude, and sensitivity thresholds are set. |
+|[Distance Serial Plotter](examples/Example08_DistanceSerialPlotter/Example08_DistanceSerialPlotter.ino)|This example prints out the distance values of the 0 distance channels to the serial plotter tool in Arduino.|
+|[Distance Advanced Settings](examples/Example09_DistanceAdvancedSettings/Example09_DistanceAdvancedSettings.ino)|The sensor is initialized, then the distance (mm) and advanced values are output to the terminal. |
+
+
+## Documentation
+
+The full API and use documentation for this library is provided [here](https://docs.sparkfun.com/SparkFun_Qwiic_XM125_Arduino_Library/). For a quick reference, the main methods available in the library are listed [here](https://docs.sparkfun.com/SparkFun_Qwiic_XM125_Arduino_Library/class_qw_dev_x_m125.html).
+
+Curious about the hardware this board works with - visit the SparkFun Pulsed Coherent Radar Sensor [hardware repository](https://github.com/sparkfun/SparkFun_Qwiic_Pulsed_Radar_Sensor_XM125).
+
+The Hookup Guide for the SparkFun Qwiic Soil Moisture Sensor is available [here](https://docs.sparkfun.com/SparkFun_Qwiic_Pulsed_Radar_Sensor_XM125/introduction/).
+
+## License Information
+
+This product is ***open source***!
+
+This product is licensed using the [MIT Open Source License](https://opensource.org/license/mit).
+
-__
diff --git a/docs/images/gh-banner-2025-xm125.png b/docs/images/gh-banner-2025-xm125.png
new file mode 100644
index 0000000..fc7defb
Binary files /dev/null and b/docs/images/gh-banner-2025-xm125.png differ
diff --git a/examples/Example01_PresenceBasicReadings/Example01_PresenceBasicReadings.ino b/examples/Example01_PresenceBasicReadings/Example01_PresenceBasicReadings.ino
index a6846c8..705e75f 100644
--- a/examples/Example01_PresenceBasicReadings/Example01_PresenceBasicReadings.ino
+++ b/examples/Example01_PresenceBasicReadings/Example01_PresenceBasicReadings.ino
@@ -4,14 +4,14 @@
Using the Acconeer XM125 A121 60GHz Pulsed Coherent Radar Sensor.
This example shows how operate the XM125 when the device is in Presence Reading Mode.
- The sensor is initialized, then the presence distance values will print out
+ The sensor is initialized, then the presence distance values will print out
to the terminal.
By: Madison Chodikov
SparkFun Electronics
Date: 2024/1/22
SparkFun code, firmware, and software is released under the MIT License.
- Please see LICENSE.md for further details.
+ Please see LICENSE.md for further details.
Hardware Connections:
QWIIC --> QWIIC
@@ -21,15 +21,15 @@
Feel like supporting our work? Buy a board from SparkFun!
https://www.sparkfun.com/products/ - Qwiic XM125 Breakout
*/
-#include
#include "SparkFun_Qwiic_XM125_Arduino_Library.h"
+#include
-SfeXM125 radarSensor;
+SparkFunXM125Presence radarSensor;
// I2C default address
uint8_t i2cAddress = SFE_XM125_I2C_ADDRESS;
-// Presence distance values
+// Presence distance values
uint32_t distance = 0;
// Error statuses
@@ -39,39 +39,45 @@ int32_t setupError = 0;
int32_t presValError = 0;
int32_t detectorError = 0;
+// Presence range in mm used
+#define MY_XM125_RANGE_START 200
+#define MY_XM125_RANGE_END 1000
void setup()
{
// Start serial
Serial.begin(115200);
+
+ Serial.println("");
+ Serial.println("-------------------------------------------------------");
Serial.println("XM125 Example 1: Basic Presence Readings");
+ Serial.println("-------------------------------------------------------");
Serial.println("");
Wire.begin();
// If begin is successful (1), then start example
- int startErr = radarSensor.begin(i2cAddress, Wire);
- if(startErr == 1)
- {
- Serial.println("Begin");
- }
- else // Otherwise, infinite loop
+ bool success = radarSensor.begin(i2cAddress, Wire);
+ if (success == false)
{
- Serial.print("Start Error Code: ");
- Serial.println(startErr);
Serial.println("Device failed to setup - Freezing code.");
- while(1); // Runs forever
+ while (1)
+ ; // Runs forever
}
// Start the sensor with default register values
- int32_t setupError = radarSensor.presenceDetectorStart();
- if(setupError != 0)
+ int32_t setupError = radarSensor.presenceDetectorStart(MY_XM125_RANGE_START, MY_XM125_RANGE_END);
+ if (setupError != 0)
{
- Serial.print("Presence Detection Start Setup Error: ");
- Serial.println(setupError);
+ Serial.print("Presence Detection Start Setup Error: ");
+ Serial.println(setupError);
}
-
- // New line and delay for easier reading
+ Serial.print("Presense Detection Started - range: ");
+ Serial.print(MY_XM125_RANGE_START);
+ Serial.print("mm to ");
+ Serial.print(MY_XM125_RANGE_END);
+ Serial.println("mm");
Serial.println();
+
delay(500);
}
@@ -80,28 +86,32 @@ void loop()
// Busy wait loop until data is ready
radarSensor.presenceBusyWait();
- // Get the presence distance value and print out if no errors
+ // Get the presence distance value and print out if no errors.
+ // Note - this returns if Presense is detected now, or since last check (sticky)
presValError = radarSensor.getPresenceDistanceValuemm(distance);
- if(presValError == 0)
+ if (presValError == 0)
{
- Serial.print("Presence Detected: ");
- Serial.print(distance);
- Serial.println("mm");
- //Serial.print(distance * .01);
- //Serial.println("cm");
- //Serial.print(distance * .001);
- //Serial.println("m");
- //Serial.print(distance * .001);
- //Serial.println("m");
- //Serial.print(distance * .03937008);
- //Serial.println("In");
+ Serial.print("Presence Detected: ");
+ // if distance is > 0, presence is detected, else it is not
+ if (distance > 0)
+ {
+ Serial.print("YES - Distance: ");
+ Serial.print(distance);
+ Serial.print("mm, ");
+ Serial.print(distance * .1);
+ Serial.print("cm, ");
+ Serial.print(distance * .001);
+ Serial.print("m, ");
+ Serial.print(distance * .03937008);
+ Serial.println("In");
+ }
+ else
+ Serial.println("NO");
}
else
- {
- Serial.println("Error returning presence distance value");
- }
+ Serial.println("Error returning presence distance value");
- // Delay 0.5 seconds between readings
- delay(500);
+ // Delay 2.5 seconds between readings
+ delay(2500);
}
diff --git a/examples/Example02_PresenceGPIO0Usage/Example02_PresenceGPIO0Usage.ino b/examples/Example02_PresenceGPIO0Usage/Example02_PresenceGPIO0Usage.ino
index fb9d347..71c993a 100644
--- a/examples/Example02_PresenceGPIO0Usage/Example02_PresenceGPIO0Usage.ino
+++ b/examples/Example02_PresenceGPIO0Usage/Example02_PresenceGPIO0Usage.ino
@@ -4,14 +4,14 @@
Using the Acconeer XM125 A121 60GHz Pulsed Coherent Radar Sensor.
This example shows how operate the XM125 when the device is in Presence Reading Mode.
- The sensor is initialized, then the presence values will print out to the terminal
- and trigger the GPIO0 pin high when there is a presence detected.
+ The sensor is initialized, then the presence values will print out to the terminal
+ and trigger the GPIO0 pin high when there is a presence detected.
By: Madison Chodikov
SparkFun Electronics
Date: 2024/1/22
SparkFun code, firmware, and software is released under the MIT License.
- Please see LICENSE.md for further details.
+ Please see LICENSE.md for further details.
Hardware Connections:
QWIIC --> QWIIC
@@ -21,15 +21,15 @@
Feel like supporting our work? Buy a board from SparkFun!
https://www.sparkfun.com/products/ - Qwiic XM125 Breakout
*/
-#include
#include "SparkFun_Qwiic_XM125_Arduino_Library.h"
+#include
-SfeXM125 radarSensor;
+SparkFunXM125Presence radarSensor;
// I2C default address
uint8_t i2cAddress = SFE_XM125_I2C_ADDRESS;
-// Presence distance values
+// Presence distance values
uint32_t distance = 0;
uint32_t presenceDetected = 0;
uint32_t presenceDetectedSticky = 0;
@@ -46,14 +46,14 @@ void setup()
{
// Start serial
Serial.begin(115200);
- Serial.println("XM125 Example 2: Presence GPIO0 Pin Usage");
+ Serial.println("XM125 Example 2: Presence GPIO0 Pin Usage");
Serial.println("");
Wire.begin();
// If begin is successful (0), then start example
int startErr = radarSensor.begin(i2cAddress, Wire);
- if(startErr == 1)
+ if (startErr == 1)
{
Serial.println("Begin");
}
@@ -62,64 +62,65 @@ void setup()
Serial.print("Start Error Code: ");
Serial.println(startErr);
Serial.println("Device failed to setup - Freezing code.");
- while(1); // Runs forever
+ while (1)
+ ; // Runs forever
}
delay(200);
- // Presence Sensor Setup
+ // Presence Sensor Setup
// Reset sensor configuration to reapply configuration registers
radarSensor.setPresenceCommand(SFE_XM125_PRESENCE_RESET_MODULE);
- // Check error and busy bits
+ // Check error and busy bits
radarSensor.getPresenceDetectorErrorStatus(errorStatus);
- if(errorStatus != 0)
+ if (errorStatus != 0)
{
- Serial.print("Detector status error: ");
- Serial.println(errorStatus);
+ Serial.print("Detector status error: ");
+ Serial.println(errorStatus);
}
delay(100);
- // Turn presence detection on GPIO0 on
- if(radarSensor.setPresenceDetectionOnGPIO(1) != 0)
+ // Turn presence detection on GPIO0 on
+ if (radarSensor.setPresenceDetectionOnGPIO(1) != 0)
{
- Serial.println("GPIO0 Pin Setup Error");
+ Serial.println("GPIO0 Pin Setup Error");
}
radarSensor.getPresenceDetectionOnGPIO(gpioUsage);
Serial.print("GPIO0 Detection Status: ");
Serial.println(gpioUsage);
- // Apply configuration
- if(radarSensor.setPresenceCommand(SFE_XM125_PRESENCE_APPLY_CONFIGURATION) != 0)
+ // Apply configuration
+ if (radarSensor.setPresenceCommand(SFE_XM125_PRESENCE_APPLY_CONFIGURATION) != 0)
{
- // Check for errors
- radarSensor.getPresenceDetectorErrorStatus(errorStatus);
- if(errorStatus != 0)
- {
- Serial.print("Detector status error: ");
- Serial.println(errorStatus);
- }
-
- Serial.println("Configuration application error");
+ // Check for errors
+ radarSensor.getPresenceDetectorErrorStatus(errorStatus);
+ if (errorStatus != 0)
+ {
+ Serial.print("Detector status error: ");
+ Serial.println(errorStatus);
+ }
+
+ Serial.println("Configuration application error");
}
// Poll detector status until busy bit is cleared
- if(radarSensor.presenceBusyWait() != 0)
+ if (radarSensor.presenceBusyWait() != 0)
{
- Serial.print("Busy wait error");
+ Serial.print("Busy wait error");
}
- // Check detector status
+ // Check detector status
radarSensor.getPresenceDetectorErrorStatus(errorStatus);
- if(errorStatus != 0)
+ if (errorStatus != 0)
{
- Serial.print("Detector status error: ");
- Serial.println(errorStatus);
+ Serial.print("Detector status error: ");
+ Serial.println(errorStatus);
}
Serial.println();
-
+
delay(1000);
}
@@ -131,15 +132,15 @@ void loop()
// Get the presence distance value and print out if no errors
presValError = radarSensor.getPresenceDistanceValuemm(distance);
- if(presValError == 0)
+ if (presValError == 0)
{
- Serial.print("Presence Detected: ");
- Serial.print(distance);
- Serial.println("mm");
+ Serial.print("Presence Detected: ");
+ Serial.print(distance);
+ Serial.println("mm");
}
else
{
- Serial.println("Error returning presence distance value");
+ Serial.println("Error returning presence distance value");
}
// Delay 0.5 seconds between readings
diff --git a/examples/Example03_PresenceSerialPlotter/Example03_PresenceSerialPlotter.ino b/examples/Example03_PresenceSerialPlotter/Example03_PresenceSerialPlotter.ino
index 21d15b1..319ace7 100644
--- a/examples/Example03_PresenceSerialPlotter/Example03_PresenceSerialPlotter.ino
+++ b/examples/Example03_PresenceSerialPlotter/Example03_PresenceSerialPlotter.ino
@@ -11,7 +11,7 @@
SparkFun Electronics
Date: 2024/1/22
SparkFun code, firmware, and software is released under the MIT License.
- Please see LICENSE.md for further details.
+ Please see LICENSE.md for further details.
Hardware Connections:
QWIIC --> QWIIC
@@ -21,15 +21,15 @@
Feel like supporting our work? Buy a board from SparkFun!
https://www.sparkfun.com/products/ - Qwiic XM125 Breakout
*/
-#include
#include "SparkFun_Qwiic_XM125_Arduino_Library.h"
+#include
-SfeXM125 radarSensor;
+SparkFunXM125Presence radarSensor;
// I2C default address
uint8_t i2cAddress = SFE_XM125_I2C_ADDRESS;
-// Presence distance values
+// Presence distance values
uint32_t distance = 0;
uint32_t presenceDetected = 0;
uint32_t presenceDetectedSticky = 0;
@@ -52,7 +52,7 @@ void setup()
// If begin is successful (0), then start example
int startErr = radarSensor.begin(i2cAddress, Wire);
- if(startErr == 1)
+ if (startErr == 1)
{
Serial.println("Begin");
}
@@ -61,17 +61,18 @@ void setup()
Serial.print("Start Error Code: ");
Serial.println(startErr);
Serial.println("Device failed to setup - Freezing code.");
- while(1); // Runs forever
+ while (1)
+ ; // Runs forever
}
delay(200);
// Start the sensor with default register values
int32_t setupError = radarSensor.presenceDetectorStart();
- if(setupError != 0)
+ if (setupError != 0)
{
- Serial.print("Presence Detection Start Setup Error: ");
- Serial.println(setupError);
+ Serial.print("Presence Detection Start Setup Error: ");
+ Serial.println(setupError);
}
// New line and delay for easier reading
@@ -87,10 +88,10 @@ void loop()
// Get the presence distance value and print out if no errors
presValError = radarSensor.getPresenceDistanceValuemm(distance);
- if(presValError == 0)
+ if (presValError == 0)
{
- radarSensor.getPresenceDistance(distance);
- Serial.println(distance);
+ radarSensor.getPresenceDistance(distance);
+ Serial.println(distance);
}
// Delay 0.5 seconds between readings
diff --git a/examples/Example04_PresenceAdvancedReadings/Example04_PresenceAdvancedReadings.ino b/examples/Example04_PresenceAdvancedReadings/Example04_PresenceAdvancedReadings.ino
index 4d72c56..512f80d 100644
--- a/examples/Example04_PresenceAdvancedReadings/Example04_PresenceAdvancedReadings.ino
+++ b/examples/Example04_PresenceAdvancedReadings/Example04_PresenceAdvancedReadings.ino
@@ -4,14 +4,14 @@
Using the Acconeer XM125 A121 60GHz Pulsed Coherent Radar Sensor.
This example shows how operate the XM125 when the device is in Presence Reading Mode.
- The sensor is initialized, then the presence distance, intra-presence, and
+ The sensor is initialized, then the presence distance, intra-presence, and
inter-presence values will be printed to the terminal.
By: Madison Chodikov
SparkFun Electronics
Date: 2024/1/22
SparkFun code, firmware, and software is released under the MIT License.
- Please see LICENSE.md for further details.
+ Please see LICENSE.md for further details.
Hardware Connections:
QWIIC --> QWIIC
@@ -21,15 +21,15 @@
Feel like supporting our work? Buy a board from SparkFun!
https://www.sparkfun.com/products/ - Qwiic XM125 Breakout
*/
-#include
#include "SparkFun_Qwiic_XM125_Arduino_Library.h"
+#include
-SfeXM125 radarSensor;
+SparkFunXM125Presence radarSensor;
// I2C default address
uint8_t i2cAddress = SFE_XM125_I2C_ADDRESS;
-// Presence distance values
+// Presence distance values
uint32_t distance = 0;
uint32_t presenceDetected = 0;
uint32_t presenceDetectedSticky = 0;
@@ -53,7 +53,7 @@ void setup()
// If begin is successful (1), then start example
int startErr = radarSensor.begin(i2cAddress, Wire);
- if(startErr == 1)
+ if (startErr == 1)
{
Serial.println("Begin");
}
@@ -62,17 +62,18 @@ void setup()
Serial.print("Start Error Code: ");
Serial.println(startErr);
Serial.println("Device failed to setup - Freezing code.");
- while(1); // Runs forever
+ while (1)
+ ; // Runs forever
}
delay(200);
// Start the sensor with default register values
int32_t setupError = radarSensor.presenceDetectorStart();
- if(setupError != 0)
+ if (setupError != 0)
{
- Serial.print("Presence Detection Start Setup Error: ");
- Serial.println(setupError);
+ Serial.print("Presence Detection Start Setup Error: ");
+ Serial.println(setupError);
}
// New line and delay for easier reading
@@ -82,52 +83,52 @@ void setup()
void loop()
{
- // Check error bits
+ // Check error bits
radarSensor.getPresenceDetectorErrorStatus(errorStatus);
- if(errorStatus != 0)
+ if (errorStatus != 0)
{
- Serial.print("Detector status error: ");
- Serial.println(errorStatus);
+ Serial.print("Detector status error: ");
+ Serial.println(errorStatus);
}
-
- // Start detector
- if(radarSensor.setPresenceCommand(SFE_XM125_PRESENCE_START_DETECTOR) != 0)
+
+ // Start detector
+ if (radarSensor.setPresenceCommand(SFE_XM125_PRESENCE_START_DETECTOR) != 0)
{
- Serial.println("Start detector error");
+ Serial.println("Start detector error");
}
-
+
// Poll detector status until busy bit is cleared - CHECK ON THIS!
- if(radarSensor.presenceBusyWait() != 0)
+ if (radarSensor.presenceBusyWait() != 0)
{
- Serial.println("Busy wait error");
+ Serial.println("Busy wait error");
}
-
- // Verify that no error bits are set in the detector status register
+
+ // Verify that no error bits are set in the detector status register
radarSensor.getPresenceDetectorErrorStatus(errorStatus);
- if(errorStatus != 0)
+ if (errorStatus != 0)
{
- Serial.print("Detector status error: ");
- Serial.println(errorStatus);
+ Serial.print("Detector status error: ");
+ Serial.println(errorStatus);
}
// Read detector result register and determine detection status
radarSensor.getPresenceDetectorPresenceDetected(presenceDetected);
radarSensor.getPresenceDetectorPresenceStickyDetected(presenceDetectedSticky);
-
- if((presenceDetected == 1) | (presenceDetectedSticky == 1))
+
+ if ((presenceDetected == 1) || (presenceDetectedSticky == 1))
{
- radarSensor.getPresenceDistance(distance);
- Serial.print("Presence Detected: ");
- Serial.print(distance);
- Serial.println("mm");
-
- radarSensor.getPresenceIntraPresenceScore(intraScore);
- radarSensor.getPresenceInterPresenceScore(interScore);
-
- Serial.print("Intra-Presence Score: ");
- Serial.println(intraScore);
- Serial.print("Inter-Presence Score: ");
- Serial.println(interScore);
+ radarSensor.getPresenceDistance(distance);
+ Serial.print("Presence Detected: ");
+ Serial.print(distance);
+ Serial.println("mm");
+
+ radarSensor.getPresenceIntraPresenceScore(intraScore);
+ radarSensor.getPresenceInterPresenceScore(interScore);
+
+ Serial.print("Intra-Presence Score: ");
+ Serial.println(intraScore);
+ Serial.print("Inter-Presence Score: ");
+ Serial.println(interScore);
}
// Delay 0.5 second between readings
diff --git a/examples/Example05_PresenceAdvancedSettings/Example05_PresenceAdvancedSettings.ino b/examples/Example05_PresenceAdvancedSettings/Example05_PresenceAdvancedSettings.ino
index 2292a6a..3988041 100644
--- a/examples/Example05_PresenceAdvancedSettings/Example05_PresenceAdvancedSettings.ino
+++ b/examples/Example05_PresenceAdvancedSettings/Example05_PresenceAdvancedSettings.ino
@@ -4,7 +4,7 @@
Using the Acconeer XM125 A121 60GHz Pulsed Coherent Radar Sensor.
This example shows how operate the XM125 when the device is in Presence Reading Mode.
- The sensor is initialized, then the presence distance values will print out
+ The sensor is initialized, then the presence distance values will print out
to the terminal just as they do in example one. If you wish to change the settings
of the device, do so before applying the configuration.
@@ -12,7 +12,7 @@
SparkFun Electronics
Date: 2024/1/22
SparkFun code, firmware, and software is released under the MIT License.
- Please see LICENSE.md for further details.
+ Please see LICENSE.md for further details.
Hardware Connections:
QWIIC --> QWIIC
@@ -22,15 +22,15 @@
Feel like supporting our work? Buy a board from SparkFun!
https://www.sparkfun.com/products/ - Qwiic XM125 Breakout
*/
-#include
#include "SparkFun_Qwiic_XM125_Arduino_Library.h"
+#include
-SfeXM125 radarSensor;
+SparkFunXM125Presence radarSensor;
// I2C default address
uint8_t i2cAddress = SFE_XM125_I2C_ADDRESS;
-// Presence distance values
+// Presence distance values
uint32_t distance = 0;
uint32_t presenceDetected = 0;
uint32_t presenceDetectedSticky = 0;
@@ -55,7 +55,7 @@ void setup()
// If begin is successful (1), then start example
int startErr = radarSensor.begin(i2cAddress, Wire);
- if(startErr == 1)
+ if (startErr == 1)
{
Serial.println("Begin");
}
@@ -64,7 +64,8 @@ void setup()
Serial.print("Start Error Code: ");
Serial.println(startErr);
Serial.println("Device failed to setup - Freezing code.");
- while(1); // Runs forever
+ while (1)
+ ; // Runs forever
}
delay(200);
@@ -73,109 +74,109 @@ void setup()
// Reset sensor configuration to reapply configuration registers
radarSensor.setPresenceCommand(SFE_XM125_PRESENCE_RESET_MODULE);
- // Check error and busy bits
+ // Check error and busy bits
radarSensor.getPresenceDetectorErrorStatus(errorStatus);
- if(errorStatus != 0)
+ if (errorStatus != 0)
{
- Serial.print("Detector status error: ");
- Serial.println(errorStatus);
+ Serial.print("Detector status error: ");
+ Serial.println(errorStatus);
}
delay(100);
-
- // Set Start register
- if(radarSensor.setPresenceStart(beginReading) != 0)
+
+ // Set Start register
+ if (radarSensor.setPresenceStart(beginReading) != 0)
{
- Serial.println("Presence Start Error");
+ Serial.println("Presence Start Error");
}
radarSensor.getPresenceStart(startVal);
Serial.print("Start Val: ");
Serial.println(startVal);
-
+
delay(100);
- // Set End register
- if(radarSensor.setPresenceEnd(endReading) != 0)
+ // Set End register
+ if (radarSensor.setPresenceEnd(endReading) != 0)
{
- Serial.println("Presence End Error");
+ Serial.println("Presence End Error");
}
radarSensor.getPresenceEnd(endVal);
Serial.print("End Val: ");
Serial.println(endVal);
delay(100);
- // Apply configuration
- if(radarSensor.setPresenceCommand(SFE_XM125_PRESENCE_APPLY_CONFIGURATION) != 0)
+ // Apply configuration
+ if (radarSensor.setPresenceCommand(SFE_XM125_PRESENCE_APPLY_CONFIGURATION) != 0)
{
- // Check for errors
- radarSensor.getPresenceDetectorErrorStatus(errorStatus);
- if(errorStatus != 0)
- {
- Serial.print("Detector status error: ");
- Serial.println(errorStatus);
- }
-
- Serial.println("Configuration application error");
+ // Check for errors
+ radarSensor.getPresenceDetectorErrorStatus(errorStatus);
+ if (errorStatus != 0)
+ {
+ Serial.print("Detector status error: ");
+ Serial.println(errorStatus);
+ }
+
+ Serial.println("Configuration application error");
}
// Poll detector status until busy bit is cleared
- if(radarSensor.presenceBusyWait() != 0)
+ if (radarSensor.presenceBusyWait() != 0)
{
- Serial.print("Busy wait error");
+ Serial.print("Busy wait error");
}
- // Check detector status
+ // Check detector status
radarSensor.getPresenceDetectorErrorStatus(errorStatus);
- if(errorStatus != 0)
+ if (errorStatus != 0)
{
- Serial.print("Detector status error: ");
- Serial.println(errorStatus);
+ Serial.print("Detector status error: ");
+ Serial.println(errorStatus);
}
Serial.println();
-
+
delay(1000);
}
void loop()
{
- // Check error bits
+ // Check error bits
radarSensor.getPresenceDetectorErrorStatus(errorStatus);
- if(errorStatus != 0)
+ if (errorStatus != 0)
{
- Serial.print("Detector status error: ");
- Serial.println(errorStatus);
+ Serial.print("Detector status error: ");
+ Serial.println(errorStatus);
}
-
- // Start detector
- if(radarSensor.setPresenceCommand(SFE_XM125_PRESENCE_START_DETECTOR) != 0)
+
+ // Start detector
+ if (radarSensor.setPresenceCommand(SFE_XM125_PRESENCE_START_DETECTOR) != 0)
{
- Serial.println("Start detector error");
+ Serial.println("Start detector error");
}
-
+
// Poll detector status until busy bit is cleared - CHECK ON THIS!
- if(radarSensor.presenceBusyWait() != 0)
+ if (radarSensor.presenceBusyWait() != 0)
{
- Serial.println("Busy wait error");
+ Serial.println("Busy wait error");
}
-
- // Verify that no error bits are set in the detector status register
+
+ // Verify that no error bits are set in the detector status register
radarSensor.getPresenceDetectorErrorStatus(errorStatus);
- if(errorStatus != 0)
+ if (errorStatus != 0)
{
- Serial.print("Detector status error: ");
- Serial.println(errorStatus);
+ Serial.print("Detector status error: ");
+ Serial.println(errorStatus);
}
// Read detector result register and determine detection status
radarSensor.getPresenceDetectorPresenceDetected(presenceDetected);
radarSensor.getPresenceDetectorPresenceStickyDetected(presenceDetectedSticky);
-
- if((presenceDetected == 1) | (presenceDetectedSticky == 1))
+
+ if ((presenceDetected == 1) | (presenceDetectedSticky == 1))
{
- radarSensor.getPresenceDistance(distance);
- Serial.print("Presence Detected: ");
- Serial.print(distance);
- Serial.println("mm");
+ radarSensor.getPresenceDistance(distance);
+ Serial.print("Presence Detected: ");
+ Serial.print(distance);
+ Serial.println("mm");
}
// Delay 1 second between readings
diff --git a/examples/Example06_DistanceBasicReadings/Example06_DistanceBasicReadings.ino b/examples/Example06_DistanceBasicReadings/Example06_DistanceBasicReadings.ino
index 288764d..5e217ce 100644
--- a/examples/Example06_DistanceBasicReadings/Example06_DistanceBasicReadings.ino
+++ b/examples/Example06_DistanceBasicReadings/Example06_DistanceBasicReadings.ino
@@ -4,14 +4,14 @@
Using the Acconeer XM125 A121 60GHz Pulsed Coherent Radar Sensor.
This example shows how operate the XM125 when the device is in Distance Reading Mode.
- The sensor is initialized, then the distance values will print out to the terminal in
- mm.
+ The sensor is initialized, then the distance values will print out to the terminal in
+ mm.
By: Madison Chodikov
SparkFun Electronics
Date: 2024/1/22
SparkFun code, firmware, and software is released under the MIT License.
- Please see LICENSE.md for further details.
+ Please see LICENSE.md for further details.
Hardware Connections:
QWIIC --> QWIIC
@@ -21,74 +21,54 @@
Feel like supporting our work? Buy a board from SparkFun!
https://www.sparkfun.com/products/ - Qwiic XM125 Breakout
*/
-#include
#include "SparkFun_Qwiic_XM125_Arduino_Library.h"
+#include
-SfeXM125 radarSensor;
+SparkFunXM125Distance radarSensor;
// I2C default address
uint8_t i2cAddress = SFE_XM125_I2C_ADDRESS;
-// Setup Variables
-uint32_t startVal = 0;
-uint32_t endVal = 0;
-uint32_t numDistances = 9;
-uint32_t calibrateNeeded = 0;
-uint32_t measDistErr = 0;
-
-// Error statuses
-uint32_t errorStatus = 0;
-uint32_t distanceSetupError = 0;
-
-// Distance Variables
-uint32_t distancePeakStrength0 = 0;
-uint32_t distancePeak0 = 0;
-uint32_t distancePeakStrength1 = 0;
-uint32_t distancePeak1 = 0;
-uint32_t distancePeakStrength2 = 0;
-uint32_t distancePeak2 = 0;
-uint32_t distancePeakStrength3 = 0;
-uint32_t distancePeak3 = 0;
-uint32_t distancePeakStrength4 = 0;
-uint32_t distancePeak4 = 0;
-uint32_t distancePeakStrength5 = 0;
-uint32_t distancePeak5 = 0;
-uint32_t distancePeakStrength6 = 0;
-uint32_t distancePeak6 = 0;
-uint32_t distancePeakStrength7 = 0;
-uint32_t distancePeak7 = 0;
-uint32_t distancePeakStrength8 = 0;
-uint32_t distancePeak8 = 0;
-uint32_t distancePeakStrength9= 0;
-uint32_t distancePeak9 = 0;
+// Presence range in mm used
+#define MY_XM125_RANGE_START 200
+#define MY_XM125_RANGE_END 2000
void setup()
{
// Start serial
Serial.begin(115200);
+
+ Serial.println("");
+ Serial.println("-------------------------------------------------------");
Serial.println("XM125 Example 6: Basic Distance Readings");
+ Serial.println("-------------------------------------------------------");
Serial.println("");
Wire.begin();
// If begin is successful (0), then start example
- if(radarSensor.begin(i2cAddress, Wire) == 1)
- {
- Serial.println("Begin");
- }
- else // Otherwise, infinite loop
+ if (radarSensor.begin(i2cAddress, Wire) == false)
{
Serial.println("Device failed to setup - Freezing code.");
- while(1); // Runs forever
+ while (1)
+ ; // Runs forever
}
-
- int32_t setupError = radarSensor.distanceBegin();
- if(setupError != 0)
+ Serial.println("Starting Sensor...");
+ Serial.println();
+ // Start the sensor with the specified range values
+ int32_t setupError = radarSensor.distanceBegin(MY_XM125_RANGE_START, MY_XM125_RANGE_END);
+ if (setupError != 0)
{
- Serial.print("Distance Detection Start Setup Error: ");
- Serial.println(setupError);
+ Serial.print("Distance Detection Start Setup Error: ");
+ Serial.println(setupError);
}
-
+ Serial.println();
+ Serial.print("Distance Detection Started - range: ");
+ Serial.print(MY_XM125_RANGE_START);
+ Serial.print("mm to ");
+ Serial.print(MY_XM125_RANGE_END);
+ Serial.println("mm");
+ Serial.println();
// New-line and 0.5 second delay for easier reading
Serial.println();
delay(500);
@@ -96,117 +76,69 @@ void setup()
void loop()
{
- distanceSetupError = radarSensor.distanceDetectorReadingSetup();
- if(distanceSetupError != 0)
+ uint32_t retCode = radarSensor.distanceDetectorReadingSetup();
+ if (retCode != 0)
{
- Serial.print("Distance Reading Setup Error: ");
- Serial.println(distanceSetupError);
+ Serial.print("Distance Reading Setup Error: ");
+ Serial.println(retCode);
}
- // Read PeakX Distance and PeakX Strength registers for the number of distances detected
- radarSensor.getDistancePeak0Distance(distancePeak0);
- radarSensor.getDistancePeak0Strength(distancePeakStrength0);
- radarSensor.getDistancePeak1Distance(distancePeak1);
- radarSensor.getDistancePeak1Strength(distancePeakStrength1);
- radarSensor.getDistancePeak2Distance(distancePeak2);
- radarSensor.getDistancePeak2Strength(distancePeakStrength2);
- radarSensor.getDistancePeak3Distance(distancePeak3);
- radarSensor.getDistancePeak3Strength(distancePeakStrength3);
- radarSensor.getDistancePeak4Distance(distancePeak4);
- radarSensor.getDistancePeak4Strength(distancePeakStrength4);
- radarSensor.getDistancePeak5Distance(distancePeak5);
- radarSensor.getDistancePeak5Strength(distancePeakStrength5);
- radarSensor.getDistancePeak6Distance(distancePeak6);
- radarSensor.getDistancePeak6Strength(distancePeakStrength6);
- radarSensor.getDistancePeak7Distance(distancePeak7);
- radarSensor.getDistancePeak7Strength(distancePeakStrength7);
- radarSensor.getDistancePeak8Distance(distancePeak8);
- radarSensor.getDistancePeak8Strength(distancePeakStrength8);
- radarSensor.getDistancePeak9Distance(distancePeak9);
- radarSensor.getDistancePeak9Strength(distancePeakStrength9);
-
- // If a peak distance was detected, then read out the distance and strength
- if (distancePeak0 != 0)
- {
- Serial.print("Peak0 Distance, Strength: ");
- Serial.print(distancePeak0);
- Serial.print("mm, ");
- Serial.println(distancePeakStrength0);
- Serial.println();
- }
- if (distancePeak1 != 0)
- {
- Serial.print("Peak1 Distance, Strength: ");
- Serial.print(distancePeak1);
- Serial.print("mm, ");
- Serial.println(distancePeakStrength1);
- Serial.println();
- }
- if (distancePeak2 != 0)
- {
- Serial.print("Peak2 Distance, Strength: ");
- Serial.print(distancePeak2);
- Serial.print("mm, ");
- Serial.println(distancePeakStrength2);
- Serial.println();
- }
- if (distancePeak3 != 0)
- {
- Serial.print("Peak3 Distance, Strength: ");
- Serial.print(distancePeak3);
- Serial.print("mm, ");
- Serial.println(distancePeakStrength3);
- Serial.println();
- }
- if (distancePeak4 != 0)
- {
- Serial.print("Peak4 Distance, Strength: ");
- Serial.print(distancePeak4);
- Serial.print("mm, ");
- Serial.println(distancePeakStrength4);
- Serial.println();
- }
- if (distancePeak5 != 0)
- {
- Serial.print("Peak5 Distance, Strength: ");
- Serial.print(distancePeak5);
- Serial.print("mm, ");
- Serial.println(distancePeakStrength5);
- Serial.println();
- }
- if (distancePeak6 != 0)
- {
- Serial.print("Peak6 Distance, Strength: ");
- Serial.print(distancePeak6);
- Serial.print("mm, ");
- Serial.println(distancePeakStrength6);
- Serial.println();
- }
- if (distancePeak7 != 0)
- {
- Serial.print("Peak7 Distance, Strength: ");
- Serial.print(distancePeak7);
- Serial.print("mm, ");
- Serial.println(distancePeakStrength7);
- Serial.println();
- }
- if (distancePeak8 != 0)
+ // How many distance values were detected? (0-9)
+ uint32_t numDistances = 0;
+ radarSensor.getDistanceNumberDistances(numDistances);
+
+ if (numDistances == 0)
+ Serial.print(".");
+ else
{
- Serial.print("Peak8 Distance, Strength: ");
- Serial.print(distancePeak8);
- Serial.print("mm, ");
- Serial.println(distancePeakStrength8);
- Serial.println();
+ Serial.println();
+ Serial.print("Number of Values Detected: ");
+ Serial.println(numDistances);
}
- if (distancePeak9 != 0)
+
+ uint32_t distance = 0;
+ int32_t distanceStrength = 0;
+ for (uint32_t i = 0; i < numDistances; i++)
{
- Serial.print("Peak9 Distance, Strength: ");
- Serial.print(distancePeak9);
- Serial.print("mm, ");
- Serial.println(distancePeakStrength9);
- Serial.println();
+ if (radarSensor.getDistancePeakDistance(i, distance) != ksfTkErrOk)
+ {
+ Serial.print("Error retrieving Distance Peak ");
+ Serial.print(i);
+ Serial.println();
+ continue;
+ }
+ Serial.print(" Distance Peak ");
+ Serial.print(i);
+ Serial.print(": ");
+ if (distance < 100)
+ {
+ Serial.print(distance);
+ Serial.print("mm");
+ }
+ else if (distance < 1000)
+ {
+ Serial.print(distance * 0.1);
+ Serial.print("cm");
+ }
+ else
+ {
+ Serial.print(distance * 0.001);
+ Serial.print("m");
+ }
+
+ if (radarSensor.getDistancePeakStrength(i, distanceStrength) != ksfTkErrOk)
+ {
+ Serial.print("Error retrieving Distance Peak Strength");
+ Serial.print(i);
+ Serial.println();
+ continue;
+ }
+ Serial.print(" Distance Peak Strength ");
+ Serial.print(i);
+ Serial.print(": ");
+ Serial.println(distanceStrength);
}
- // Half a second delay for easier readings
- delay(500);
+ // delay before next reading
+ delay(2500);
}
diff --git a/examples/Example07_DistanceThresholdSettings/Example07_DistanceThresholdSettings.ino b/examples/Example07_DistanceThresholdSettings/Example07_DistanceThresholdSettings.ino
index d215f2b..bd4e1ab 100644
--- a/examples/Example07_DistanceThresholdSettings/Example07_DistanceThresholdSettings.ino
+++ b/examples/Example07_DistanceThresholdSettings/Example07_DistanceThresholdSettings.ino
@@ -1,17 +1,17 @@
/*
- Example 7: Distance Threshold Settings
-
+ Example 7: Distance Threshold Settings
+
Using the Acconeer XM125 A121 60GHz Pulsed Coherent Radar Sensor.
This example shows how operate the XM125 when the device is in Distance Reading Mode.
- The sensor is initialized, then the distance amplitude, and strength , fixed
- amplitude, and sensitivity thresholds are set.
+ The sensor is initialized, then the distance amplitude, and strength , fixed
+ amplitude, and sensitivity thresholds are set.
By: Madison Chodikov
SparkFun Electronics
Date: 2024/1/22
SparkFun code, firmware, and software is released under the MIT License.
- Please see LICENSE.md for further details.
+ Please see LICENSE.md for further details.
Hardware Connections:
QWIIC --> QWIIC
@@ -21,28 +21,28 @@
Feel like supporting our work? Buy a board from SparkFun!
https://www.sparkfun.com/products/ - Qwiic XM125 Breakout
*/
-#include
#include "SparkFun_Qwiic_XM125_Arduino_Library.h"
+#include
-SfeXM125 radarSensor;
+SparkFunXM125Distance radarSensor;
// I2C default address
uint8_t i2cAddress = SFE_XM125_I2C_ADDRESS;
-// Setup Variables
+// Setup Variables
uint32_t startVal = 0;
uint32_t endVal = 0;
uint32_t numDistances = 9;
uint32_t calibrateNeeded = 0;
uint32_t measDistErr = 0;
-// Error statuses
+// Error statuses
uint32_t errorStatus = 0;
-// Distance Variables
-uint32_t distancePeakStrength0 = 0;
+// Distance Variables
+int32_t distancePeakStrength0 = 0;
uint32_t distancePeak0 = 0;
-uint32_t distancePeakStrength1 = 0;
+int32_t distancePeakStrength1 = 0;
uint32_t distancePeak1 = 0;
void setup()
@@ -55,46 +55,47 @@ void setup()
Wire.begin();
// If begin is successful (0), then start example
- if(radarSensor.begin(i2cAddress, Wire) == 1)
+ if (radarSensor.begin(i2cAddress, Wire) == 1)
{
Serial.println("Begin");
}
else // Otherwise, infinite loop
{
Serial.println("Device failed to setup - Freezing code.");
- while(1); // Runs forever
+ while (1)
+ ; // Runs forever
}
- // Distance Sensor Setup
+ // Distance Sensor Setup
// Reset sensor configuration to reapply configuration registers
radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_RESET_MODULE);
radarSensor.distanceBusyWait();
- // Check error and busy bits
+ // Check error and busy bits
radarSensor.getDistanceDetectorErrorStatus(errorStatus);
- if(errorStatus != 0)
+ if (errorStatus != 0)
{
- Serial.print("Detector status error: ");
- Serial.println(errorStatus);
+ Serial.print("Detector status error: ");
+ Serial.println(errorStatus);
}
delay(100);
-
- // Set Start register
- if(radarSensor.setDistanceStart(100) != 0)
+
+ // Set Start register
+ if (radarSensor.setDistanceStart(100) != 0)
{
- Serial.println("Distance Start Error");
+ Serial.println("Distance Start Error");
}
radarSensor.getDistanceStart(startVal);
Serial.print("Start Val: ");
Serial.println(startVal);
-
+
delay(100);
- // Set End register
- if(radarSensor.setDistanceEnd(4000) != 0)
+ // Set End register
+ if (radarSensor.setDistanceEnd(4000) != 0)
{
- Serial.println("Distance End Error");
+ Serial.println("Distance End Error");
}
radarSensor.getDistanceEnd(endVal);
Serial.print("End Val: ");
@@ -104,113 +105,112 @@ void setup()
// Set Distance Threshold Settings - Threshold Sensitivity (range: 0 to 1000)
radarSensor.setDistanceThresholdSensitivity(100);
- // Set Fixed Amplitude Threshold
+ // Set Fixed Amplitude Threshold
radarSensor.setDistanceFixedAmpThreshold(100);
- // Apply configuration
- if(radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_APPLY_CONFIGURATION) != 0)
+ // Apply configuration
+ if (radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_APPLY_CONFIGURATION) != 0)
{
- // Check for errors
- radarSensor.getDistanceDetectorErrorStatus(errorStatus);
- if(errorStatus != 0)
- {
- Serial.print("Detector status error: ");
- Serial.println(errorStatus);
- }
-
- Serial.println("Configuration application error");
+ // Check for errors
+ radarSensor.getDistanceDetectorErrorStatus(errorStatus);
+ if (errorStatus != 0)
+ {
+ Serial.print("Detector status error: ");
+ Serial.println(errorStatus);
+ }
+
+ Serial.println("Configuration application error");
}
// Poll detector status until busy bit is cleared
- if(radarSensor.distanceBusyWait() != 0)
+ if (radarSensor.distanceBusyWait() != 0)
{
- Serial.print("Busy wait error");
+ Serial.print("Busy wait error");
}
- // Check detector status
+ // Check detector status
radarSensor.getDistanceDetectorErrorStatus(errorStatus);
- if(errorStatus != 0)
+ if (errorStatus != 0)
{
- Serial.print("Detector status error: ");
- Serial.println(errorStatus);
+ Serial.print("Detector status error: ");
+ Serial.println(errorStatus);
}
Serial.println();
delay(1000);
-
}
void loop()
{
- // Check error bits
+ // Check error bits
radarSensor.getDistanceDetectorErrorStatus(errorStatus);
- if(errorStatus != 0)
+ if (errorStatus != 0)
{
- Serial.print("Detector status error: ");
- Serial.println(errorStatus);
+ Serial.print("Detector status error: ");
+ Serial.println(errorStatus);
}
-
- // Start detector
- if(radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_START_DETECTOR) != 0)
+
+ // Start detector
+ if (radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_START_DETECTOR) != 0)
{
- Serial.println("Start detector error");
+ Serial.println("Start detector error");
}
-
+
// Poll detector status until busy bit is cleared - CHECK ON THIS!
- if(radarSensor.distanceBusyWait() != 0)
+ if (radarSensor.distanceBusyWait() != 0)
{
- Serial.println("Busy wait error");
+ Serial.println("Busy wait error");
}
-
- // Verify that no error bits are set in the detector status register
+
+ // Verify that no error bits are set in the detector status register
radarSensor.getDistanceDetectorErrorStatus(errorStatus);
- if(errorStatus != 0)
+ if (errorStatus != 0)
{
- Serial.print("Detector status error: ");
- Serial.println(errorStatus);
+ Serial.print("Detector status error: ");
+ Serial.println(errorStatus);
}
// Check MEASURE_DISTANCE_ERROR for measurement failed
radarSensor.getDistanceMeasureDistanceError(measDistErr);
- if(measDistErr == 1)
+ if (measDistErr == 1)
{
- Serial.println("Measure Distance Error");
+ Serial.println("Measure Distance Error");
}
- // Recalibrate device if calibration error is triggered
+ // Recalibrate device if calibration error is triggered
radarSensor.getDistanceCalibrationNeeded(calibrateNeeded);
- if(calibrateNeeded == 1)
+ if (calibrateNeeded == 1)
{
- Serial.println("Calibration Needed - Recalibrating.. ");
- // Calibrate device (write RECALIBRATE command)
- radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_RECALIBRATE);
+ Serial.println("Calibration Needed - Recalibrating.. ");
+ // Calibrate device (write RECALIBRATE command)
+ radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_RECALIBRATE);
}
- // Read PeakX Distance and PeakX Strength registers for the number of distances detected
+ // Read PeakX Distance and PeakX Strength registers for the number of distances detected
radarSensor.getDistancePeak0Distance(distancePeak0);
radarSensor.getDistancePeak0Strength(distancePeakStrength0);
radarSensor.getDistancePeak1Distance(distancePeak1);
radarSensor.getDistancePeak1Strength(distancePeakStrength1);
// Read out 2 distances and peaks with threshold settings adjusted
- if (distancePeak0 != 0)
+ if (distancePeak0 != 0)
{
- Serial.print("Peak0 Distance, Strength: ");
- Serial.print(distancePeak0);
- Serial.print("mm, ");
- Serial.println(distancePeakStrength0);
- Serial.println();
+ Serial.print("Peak0 Distance, Strength: ");
+ Serial.print(distancePeak0);
+ Serial.print("mm, ");
+ Serial.println(distancePeakStrength0);
+ Serial.println();
}
- if (distancePeak1 != 0)
+ if (distancePeak1 != 0)
{
- Serial.print("Peak1 Distance, Strength: ");
- Serial.print(distancePeak1);
- Serial.print("mm, ");
- Serial.println(distancePeakStrength1);
- Serial.println();
+ Serial.print("Peak1 Distance, Strength: ");
+ Serial.print(distancePeak1);
+ Serial.print("mm, ");
+ Serial.println(distancePeakStrength1);
+ Serial.println();
}
- // Half a second delay for easier readings
+ // Half a second delay for easier readings
delay(500);
}
diff --git a/examples/Example08_DistanceSerialPlotter/Example08_DistanceSerialPlotter.ino b/examples/Example08_DistanceSerialPlotter/Example08_DistanceSerialPlotter.ino
index f64d52d..ca7bc3e 100644
--- a/examples/Example08_DistanceSerialPlotter/Example08_DistanceSerialPlotter.ino
+++ b/examples/Example08_DistanceSerialPlotter/Example08_DistanceSerialPlotter.ino
@@ -3,14 +3,14 @@
Using the Acconeer XM125 A121 60GHz Pulsed Coherent Radar Sensor.
- This example prints out the distance values of the 0 distance
- channels to the serial plotter tool in Arduino.
+ This example prints out the distance values of the 0 distance
+ channels to the serial plotter tool in Arduino.
By: Madison Chodikov
SparkFun Electronics
Date: 2024/1/22
SparkFun code, firmware, and software is released under the MIT License.
- Please see LICENSE.md for further details.
+ Please see LICENSE.md for further details.
Hardware Connections:
QWIIC --> QWIIC
@@ -20,18 +20,18 @@
Feel like supporting our work? Buy a board from SparkFun!
https://www.sparkfun.com/products/ - Qwiic XM125 Breakout
*/
-#include
#include "SparkFun_Qwiic_XM125_Arduino_Library.h"
+#include
-SfeXM125 radarSensor;
+SparkFunXM125Distance radarSensor;
// I2C default address
uint8_t i2cAddress = SFE_XM125_I2C_ADDRESS;
-// Error statuses
+// Error statuses
uint32_t distanceSetupError = 0;
-// Distance Variables
+// Distance Variables
uint32_t distancePeak0 = 0;
void setup()
@@ -44,21 +44,22 @@ void setup()
Wire.begin();
// If begin is successful (0), then start example
- if(radarSensor.begin(i2cAddress, Wire) == 1)
+ if (radarSensor.begin(i2cAddress, Wire) == 1)
{
Serial.println("Begin");
}
else // Otherwise, infinite loop
{
Serial.println("Device failed to setup - Freezing code.");
- while(1); // Runs forever
+ while (1)
+ ; // Runs forever
}
int32_t setupError = radarSensor.distanceBegin();
- if(setupError != 0)
+ if (setupError != 0)
{
- Serial.print("Distance Detection Start Setup Error: ");
- Serial.println(setupError);
+ Serial.print("Distance Detection Start Setup Error: ");
+ Serial.println(setupError);
}
// New-line and 0.5 second delay for easier reading
@@ -69,22 +70,21 @@ void setup()
void loop()
{
distanceSetupError = radarSensor.distanceDetectorReadingSetup();
- if(distanceSetupError != 0)
+ if (distanceSetupError != 0)
{
- Serial.print("Distance Reading Setup Error: ");
- Serial.println(distanceSetupError);
+ Serial.print("Distance Reading Setup Error: ");
+ Serial.println(distanceSetupError);
}
- // Read PeakX Distance and PeakX Strength registers for the number of distances detected
+ // Read PeakX Distance and PeakX Strength registers for the number of distances detected
radarSensor.getDistancePeak0Distance(distancePeak0);
// If a peak distance was detected, then read out the distance and strength
- if (distancePeak0 != 0)
+ if (distancePeak0 != 0)
{
- Serial.prinlnt(distancePeak0);
+ Serial.println(distancePeak0);
}
- // Half a second delay for easier readings
+ // Half a second delay for easier readings
delay(500);
-
}
diff --git a/examples/Example09_DistanceAdvancedSettings/Example09_DistanceAdvancedSettings.ino b/examples/Example09_DistanceAdvancedSettings/Example09_DistanceAdvancedSettings.ino
index ffc19de..4f5b255 100644
--- a/examples/Example09_DistanceAdvancedSettings/Example09_DistanceAdvancedSettings.ino
+++ b/examples/Example09_DistanceAdvancedSettings/Example09_DistanceAdvancedSettings.ino
@@ -4,14 +4,14 @@
Using the Acconeer XM125 A121 60GHz Pulsed Coherent Radar Sensor.
This example shows how operate the XM125 when the device is in Distance Reading Mode.
- The sensor is initialized, then the distance values will print out to the terminal in
- mm.
+ The sensor is initialized, then the distance values will print out to the terminal in
+ mm.
By: Madison Chodikov
SparkFun Electronics
Date: 2024/1/22
SparkFun code, firmware, and software is released under the MIT License.
- Please see LICENSE.md for further details.
+ Please see LICENSE.md for further details.
Hardware Connections:
QWIIC --> QWIIC
@@ -21,15 +21,15 @@
Feel like supporting our work? Buy a board from SparkFun!
https://www.sparkfun.com/products/ - Qwiic XM125 Breakout
*/
-#include
#include "SparkFun_Qwiic_XM125_Arduino_Library.h"
+#include
-SfeXM125 radarSensor;
+SparkFunXM125Distance radarSensor;
// I2C default address
uint8_t i2cAddress = SFE_XM125_I2C_ADDRESS;
-// Setup Variables
+// Setup Variables
uint32_t startVal = 0;
uint32_t endVal = 0;
uint32_t numDistances = 9;
@@ -38,30 +38,12 @@ uint32_t measDistErr = 0;
uint32_t beginReading = 300;
uint32_t endReading = 7000;
-// Error statuses
+// Error statuses
uint32_t errorStatus = 0;
-// Distance Variables
-uint32_t distancePeakStrength0 = 0;
-uint32_t distancePeak0 = 0;
-uint32_t distancePeakStrength1 = 0;
-uint32_t distancePeak1 = 0;
-uint32_t distancePeakStrength2 = 0;
-uint32_t distancePeak2 = 0;
-uint32_t distancePeakStrength3 = 0;
-uint32_t distancePeak3 = 0;
-uint32_t distancePeakStrength4 = 0;
-uint32_t distancePeak4 = 0;
-uint32_t distancePeakStrength5 = 0;
-uint32_t distancePeak5 = 0;
-uint32_t distancePeakStrength6 = 0;
-uint32_t distancePeak6 = 0;
-uint32_t distancePeakStrength7 = 0;
-uint32_t distancePeak7 = 0;
-uint32_t distancePeakStrength8 = 0;
-uint32_t distancePeak8 = 0;
-uint32_t distancePeakStrength9= 0;
-uint32_t distancePeak9 = 0;
+// Distance Variables
+int32_t distancePeakStrength = 0;
+uint32_t distancePeak = 0;
void setup()
{
@@ -73,235 +55,188 @@ void setup()
Wire.begin();
// If begin is successful (0), then start example
- if(radarSensor.begin(i2cAddress, Wire) == 1)
+ if (radarSensor.begin(i2cAddress, Wire) == 1)
{
Serial.println("Begin");
}
else // Otherwise, infinite loop
{
Serial.println("Device failed to setup - Freezing code.");
- while(1); // Runs forever
+ while (1)
+ ; // Runs forever
}
- // Distance Sensor Setup
+ // Distance Sensor Setup
// Reset sensor configuration to reapply configuration registers
radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_RESET_MODULE);
radarSensor.distanceBusyWait();
- // Check error and busy bits
+ // Check error and busy bits
radarSensor.getDistanceDetectorErrorStatus(errorStatus);
- if(errorStatus != 0)
+ if (errorStatus != 0)
{
- Serial.print("Detector status error: ");
- Serial.println(errorStatus);
+ Serial.print("Detector status error: ");
+ Serial.println(errorStatus);
}
delay(100);
-
- // Set Start register
- if(radarSensor.setDistanceStart(beginReading) != 0)
+
+ // Set Start register
+ if (radarSensor.setDistanceStart(beginReading) != 0)
{
- Serial.println("Distance Start Error");
+ Serial.println("Distance Start Error");
}
radarSensor.getDistanceStart(startVal);
Serial.print("Start Val: ");
Serial.println(startVal);
-
+
delay(100);
- // Set End register
- if(radarSensor.setDistanceEnd(endReading) != 0)
+ // Set End register
+ if (radarSensor.setDistanceEnd(endReading) != 0)
{
- Serial.println("Distance End Error");
+ Serial.println("Distance End Error");
}
radarSensor.getDistanceEnd(endVal);
Serial.print("End Val: ");
Serial.println(endVal);
delay(100);
- // Apply configuration
- if(radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_APPLY_CONFIGURATION) != 0)
+ // Apply configuration
+ if (radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_APPLY_CONFIGURATION) != 0)
{
- // Check for errors
- radarSensor.getDistanceDetectorErrorStatus(errorStatus);
- if(errorStatus != 0)
- {
- Serial.print("Detector status error: ");
- Serial.println(errorStatus);
- }
-
- Serial.println("Configuration application error");
+ // Check for errors
+ radarSensor.getDistanceDetectorErrorStatus(errorStatus);
+ if (errorStatus != 0)
+ {
+ Serial.print("Detector status error: ");
+ Serial.println(errorStatus);
+ }
+
+ Serial.println("Configuration application error");
}
// Poll detector status until busy bit is cleared
- if(radarSensor.distanceBusyWait() != 0)
+ if (radarSensor.distanceBusyWait() != 0)
{
- Serial.print("Busy wait error");
+ Serial.print("Busy wait error");
}
- // Check detector status
+ // Check detector status
radarSensor.getDistanceDetectorErrorStatus(errorStatus);
- if(errorStatus != 0)
+ if (errorStatus != 0)
{
- Serial.print("Detector status error: ");
- Serial.println(errorStatus);
+ Serial.print("Detector status error: ");
+ Serial.println(errorStatus);
}
Serial.println();
delay(1000);
-
}
+// Handy helpful output function
+
+void outputResults(uint sample, uint32_t distance, int32_t strength)
+{
+ if (distance == 0)
+ return;
+ Serial.print("Peak");
+ Serial.print(sample);
+ Serial.print("Distance, Strength: ");
+
+ Serial.print(distance);
+ Serial.print("mm, ");
+ Serial.println(strength);
+ Serial.println();
+}
void loop()
{
- // Check error bits
+ // Check error bits
radarSensor.getDistanceDetectorErrorStatus(errorStatus);
- if(errorStatus != 0)
+ if (errorStatus != 0)
{
- Serial.print("Detector status error: ");
- Serial.println(errorStatus);
+ Serial.print("Detector status error: ");
+ Serial.println(errorStatus);
}
-
- // Start detector
- if(radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_START_DETECTOR) != 0)
+
+ // Start detector
+ if (radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_START_DETECTOR) != 0)
{
- Serial.println("Start detector error");
+ Serial.println("Start detector error");
}
-
+
// Poll detector status until busy bit is cleared - CHECK ON THIS!
- if(radarSensor.distanceBusyWait() != 0)
+ if (radarSensor.distanceBusyWait() != 0)
{
- Serial.println("Busy wait error");
+ Serial.println("Busy wait error");
}
-
- // Verify that no error bits are set in the detector status register
+
+ // Verify that no error bits are set in the detector status register
radarSensor.getDistanceDetectorErrorStatus(errorStatus);
- if(errorStatus != 0)
+ if (errorStatus != 0)
{
- Serial.print("Detector status error: ");
- Serial.println(errorStatus);
+ Serial.print("Detector status error: ");
+ Serial.println(errorStatus);
}
// Check MEASURE_DISTANCE_ERROR for measurement failed
radarSensor.getDistanceMeasureDistanceError(measDistErr);
- if(measDistErr == 1)
+ if (measDistErr == 1)
{
- Serial.println("Measure Distance Error");
+ Serial.println("Measure Distance Error");
}
- // Recalibrate device if calibration error is triggered
+ // Recalibrate device if calibration error is triggered
radarSensor.getDistanceCalibrationNeeded(calibrateNeeded);
- if(calibrateNeeded == 1)
+ if (calibrateNeeded == 1)
{
- Serial.println("Calibration Needed - Recalibrating.. ");
- // Calibrate device (write RECALIBRATE command)
- radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_RECALIBRATE);
+ Serial.println("Calibration Needed - Recalibrating.. ");
+ // Calibrate device (write RECALIBRATE command)
+ radarSensor.setDistanceCommand(SFE_XM125_DISTANCE_RECALIBRATE);
}
- // Read PeakX Distance and PeakX Strength registers for the number of distances detected
- radarSensor.getDistancePeak0Distance(distancePeak0);
- radarSensor.getDistancePeak0Strength(distancePeakStrength0);
- radarSensor.getDistancePeak1Distance(distancePeak1);
- radarSensor.getDistancePeak1Strength(distancePeakStrength1);
- radarSensor.getDistancePeak2Distance(distancePeak2);
- radarSensor.getDistancePeak2Strength(distancePeakStrength2);
- radarSensor.getDistancePeak3Distance(distancePeak3);
- radarSensor.getDistancePeak3Strength(distancePeakStrength3);
- radarSensor.getDistancePeak4Distance(distancePeak4);
- radarSensor.getDistancePeak4Strength(distancePeakStrength4);
- radarSensor.getDistancePeak5Distance(distancePeak5);
- radarSensor.getDistancePeak5Strength(distancePeakStrength5);
- radarSensor.getDistancePeak6Distance(distancePeak6);
- radarSensor.getDistancePeak6Strength(distancePeakStrength6);
- radarSensor.getDistancePeak7Distance(distancePeak7);
- radarSensor.getDistancePeak7Strength(distancePeakStrength7);
- radarSensor.getDistancePeak8Distance(distancePeak8);
- radarSensor.getDistancePeak8Strength(distancePeakStrength8);
- radarSensor.getDistancePeak9Distance(distancePeak9);
- radarSensor.getDistancePeak9Strength(distancePeakStrength9);
-
- if (distancePeak0 != 0)
- {
- Serial.print("Peak0 Distance, Strength: ");
- Serial.print(distancePeak0);
- Serial.print("mm, ");
- Serial.println(distancePeakStrength0);
- Serial.println();
- }
- if (distancePeak1 != 0)
- {
- Serial.print("Peak1 Distance, Strength: ");
- Serial.print(distancePeak1);
- Serial.print("mm, ");
- Serial.println(distancePeakStrength1);
- Serial.println();
- }
- if (distancePeak2 != 0)
- {
- Serial.print("Peak2 Distance, Strength: ");
- Serial.print(distancePeak2);
- Serial.print("mm, ");
- Serial.println(distancePeakStrength2);
- Serial.println();
- }
- if (distancePeak3 != 0)
- {
- Serial.print("Peak3 Distance, Strength: ");
- Serial.print(distancePeak3);
- Serial.print("mm, ");
- Serial.println(distancePeakStrength3);
- Serial.println();
- }
- if (distancePeak4 != 0)
- {
- Serial.print("Peak4 Distance, Strength: ");
- Serial.print(distancePeak4);
- Serial.print("mm, ");
- Serial.println(distancePeakStrength4);
- Serial.println();
- }
- if (distancePeak5 != 0)
- {
- Serial.print("Peak5 Distance, Strength: ");
- Serial.print(distancePeak5);
- Serial.print("mm, ");
- Serial.println(distancePeakStrength5);
- Serial.println();
- }
- if (distancePeak6 != 0)
- {
- Serial.print("Peak6 Distance, Strength: ");
- Serial.print(distancePeak6);
- Serial.print("mm, ");
- Serial.println(distancePeakStrength6);
- Serial.println();
- }
- if (distancePeak7 != 0)
- {
- Serial.print("Peak7 Distance, Strength: ");
- Serial.print(distancePeak7);
- Serial.print("mm, ");
- Serial.println(distancePeakStrength7);
- Serial.println();
- }
- if (distancePeak8 != 0)
- {
- Serial.print("Peak8 Distance, Strength: ");
- Serial.print(distancePeak8);
- Serial.print("mm, ");
- Serial.println(distancePeakStrength8);
- Serial.println();
- }
- if (distancePeak9 != 0)
- {
- Serial.print("Peak9 Distance, Strength: ");
- Serial.print(distancePeak9);
- Serial.print("mm, ");
- Serial.println(distancePeakStrength9);
- Serial.println();
- }
+ // Read PeakX Distance and PeakX Strength registers for the number of distances detected
+ radarSensor.getDistancePeak0Distance(distancePeak);
+ radarSensor.getDistancePeak0Strength(distancePeakStrength);
+ outputResults(0, distancePeak, distancePeakStrength);
+
+ radarSensor.getDistancePeak1Distance(distancePeak);
+ radarSensor.getDistancePeak1Strength(distancePeakStrength);
+ outputResults(1, distancePeak, distancePeakStrength);
+
+ radarSensor.getDistancePeak2Distance(distancePeak);
+ radarSensor.getDistancePeak2Strength(distancePeakStrength);
+ outputResults(2, distancePeak, distancePeakStrength);
+
+ radarSensor.getDistancePeak3Distance(distancePeak);
+ radarSensor.getDistancePeak3Strength(distancePeakStrength);
+ outputResults(3, distancePeak, distancePeakStrength);
+
+ radarSensor.getDistancePeak4Distance(distancePeak);
+ radarSensor.getDistancePeak4Strength(distancePeakStrength);
+ outputResults(4, distancePeak, distancePeakStrength);
+
+ radarSensor.getDistancePeak5Distance(distancePeak);
+ radarSensor.getDistancePeak5Strength(distancePeakStrength);
+ outputResults(5, distancePeak, distancePeakStrength);
+
+ radarSensor.getDistancePeak6Distance(distancePeak);
+ radarSensor.getDistancePeak6Strength(distancePeakStrength);
+ outputResults(6, distancePeak, distancePeakStrength);
+
+ radarSensor.getDistancePeak7Distance(distancePeak);
+ radarSensor.getDistancePeak7Strength(distancePeakStrength);
+ outputResults(7, distancePeak, distancePeakStrength);
+
+ radarSensor.getDistancePeak8Distance(distancePeak);
+ radarSensor.getDistancePeak8Strength(distancePeakStrength);
+ outputResults(8, distancePeak, distancePeakStrength);
+
+ radarSensor.getDistancePeak9Distance(distancePeak);
+ radarSensor.getDistancePeak9Strength(distancePeakStrength);
+ outputResults(9, distancePeak, distancePeakStrength);
- // Half a second delay for easier readings
+ // Half a second delay for easier readings
delay(500);
}
diff --git a/keywords.txt b/keywords.txt
index 22dbb7c..8668a5a 100644
--- a/keywords.txt
+++ b/keywords.txt
@@ -17,7 +17,6 @@ sfe_xm125_presence_command_t KEYWORD1
#########################################################
begin KEYWORD2
-returnRegister KEYWORD2
distanceBegin KEYWORD2
distanceDetectorReadingSetup KEYWORD2
getDistanceDetectorVersion KEYWORD2
diff --git a/library.properties b/library.properties
index 5f53259..08e5df5 100644
--- a/library.properties
+++ b/library.properties
@@ -1,11 +1,11 @@
name=SparkFun XM125 Arduino Library
-version=1.0.4
+version=2.0.0
author=SparkFun Electronics
maintainer=SparkFun Electronics
sentence=An Arduino library to make use of the Qwiic XM125 A121 Pulsed Radar Module from Acconeer.
-paragraph=This is the SparkFun library for the Acconeer Entry+ Module XM125 with the A121 60GHz Pulsed Coherent Radar sensor and I2C interface.
+paragraph=This is the SparkFun library for the Acconeer Entry+ Module XM125 with the A121 60GHz Pulsed Coherent Radar sensor and I2C interface. NOTE: Version 2.0 or greater of this library is not backward compatiable with version 1 - the library object has changed - see examples
category=Sensors
url=https://github.com/sparkfun/SparkFun_Qwiic_XM125_Arduino_Library
architectures=*
-depends=SparkFun Toolkit (<1.0.0)
-includes=SparkFun_Qwiic_XM125_Arduino_Library.h, sfeQwiicXM125.h, sfeXM125Regs.h
+depends=SparkFun Toolkit (>=1.0.0)
+includes=SparkFun_Qwiic_XM125_Arduino_Library.h
diff --git a/src/SparkFun_Qwiic_XM125_Arduino_Library.h b/src/SparkFun_Qwiic_XM125_Arduino_Library.h
index 2bd7cd9..c79588a 100644
--- a/src/SparkFun_Qwiic_XM125_Arduino_Library.h
+++ b/src/SparkFun_Qwiic_XM125_Arduino_Library.h
@@ -1,31 +1,118 @@
-#include "sfeQwiicXM125.h"
+
+/*!
+ * @file SparkFun_Qwiic_XM125_Arduino_Library.h
+ * @brief Arduino header file for the SparkFun Pulsed Coherent Radar Sensor - Acconeer XM125 (Qwiic)
+ *
+ * This file contains the class definitions for the SparkFun Pulsed Coherent Radar Sensor Arduino library,
+ * including methods for initialization, distance and presence detection, and configuration.
+ * It uses I2C to communicate with the device.
+ *
+ * @author SparkFun Electronics
+ * @date 2024
+ * @copyright Copyright (c) 2024-2025, SparkFun Electronics Inc. This project is released under the MIT License.
+ *
+ * SPDX-License-Identifier: MIT
+ */
+#pragma once
+
+// To make the Arduino machine happy, include the toolkit header before the core implementation for this device
+
+// clang-format off
+#include
+#include "sfTk/sfDevXM125Core.h"
+#include "sfTk/sfDevXM125Distance.h"
+#include "sfTk/sfDevXM125Presence.h"
+// clang-format on
+
#include
#include
-class SfeXM125 : public QwDevXM125
+/**
+ * @class SparkFunXM125Distance
+ * @brief Arduino class for the SparkFun Pulsed Coherent Radar Sensor - Acconeer XM125 (Qwiic) for distance detection.
+ *
+ * This class provides methods for initializing the sensor, checking connection status, and configuring the device
+ * for distance detection using I2C communication.
+ */
+class SparkFunXM125Distance : public sfDevXM125Distance
+{
+ public:
+ SparkFunXM125Distance()
+ {
+ }
+
+ /**
+ * @brief Sets up Arduino I2C driver using the specified I2C address then calls the super class begin.
+ *
+ * @param deviceAddress Address of the I2C device. Default is SFE_XM125_I2C_ADDRESS.
+ * @param wirePort Wire port of the I2C device. Default is Wire.
+ * @return True if successful, false otherwise.
+ */
+ bool begin(uint8_t deviceAddress = SFE_XM125_I2C_ADDRESS, TwoWire &wirePort = Wire)
+ {
+ // Give the I2C port provided by the user to the I2C bus class.
+ _i2cBus.init(wirePort, deviceAddress);
+
+ // Initialize the system - return results
+ return this->sfDevXM125Distance::begin(&_i2cBus) == ksfTkErrOk;
+ }
+
+ /**
+ * @brief Checks if the device is connected.
+ *
+ * @return True if the sensor is connected, false otherwise.
+ */
+ bool isConnected()
+ {
+ return _i2cBus.ping() == ksfTkErrOk;
+ }
+
+ private:
+ // I2C bus class
+ sfTkArdI2C _i2cBus;
+};
+
+/**
+ * @class SparkFunXM125Presence
+ * @brief Arduino class for the SparkFun Pulsed Coherent Radar Sensor - Acconeer XM125 (Qwiic) for presence detection.
+ *
+ * This class provides methods for initializing the sensor, checking connection status, and configuring the device
+ * for presence detection using I2C communication.
+ */
+class SparkFunXM125Presence : public sfDevXM125Presence
{
- public:
-
- SfeXM125()
- {
- }
-
- /// @brief Sets up Arduino I2C driver using the specified I2C address then calls the super class begin.
- /// @param address Address of the I2C device.
- /// @param wirePort Wire port of the I2C device.
- /// @return True if successful, false otherwise.
- bool begin(uint8_t deviceAddress = SFE_XM125_I2C_ADDRESS, TwoWire &wirePort = Wire)
- {
- // Give the I2C port provided by the user to the I2C bus class.
- _i2cBus.init(wirePort, deviceAddress);
-
- // Initialize the system - return results
- return this->QwDevXM125::begin(&_i2cBus) == 0;
- }
-
- private:
-
- // I2C bus class
- sfeTkArdI2C _i2cBus;
- //QwDevXM125::QwI2C _i2cBus; // original code
-};
\ No newline at end of file
+ public:
+ SparkFunXM125Presence()
+ {
+ }
+
+ /**
+ * @brief Sets up Arduino I2C driver using the specified I2C address then calls the super class begin.
+ *
+ * @param deviceAddress Address of the I2C device. Default is SFE_XM125_I2C_ADDRESS.
+ * @param wirePort Wire port of the I2C device. Default is Wire.
+ * @return True if successful, false otherwise.
+ */
+ bool begin(uint8_t deviceAddress = SFE_XM125_I2C_ADDRESS, TwoWire &wirePort = Wire)
+ {
+ // Give the I2C port provided by the user to the I2C bus class.
+ _i2cBus.init(wirePort, deviceAddress);
+
+ // Initialize the system - return results
+ return this->sfDevXM125Presence::begin(&_i2cBus) == ksfTkErrOk;
+ }
+
+ /**
+ * @brief Checks if the device is connected.
+ *
+ * @return True if the sensor is connected, false otherwise.
+ */
+ bool isConnected()
+ {
+ return _i2cBus.ping() == ksfTkErrOk;
+ }
+
+ private:
+ // I2C bus class
+ sfTkArdI2C _i2cBus;
+};
diff --git a/src/sfTk/sfDevXM125Core.cpp b/src/sfTk/sfDevXM125Core.cpp
new file mode 100644
index 0000000..d185d42
--- /dev/null
+++ b/src/sfTk/sfDevXM125Core.cpp
@@ -0,0 +1,39 @@
+/**
+ * @file sfDevXM125Core.cpp
+ * @brief Implementation of the SparkFun Qwiic XM125 Library - Core object
+ *
+ * This is the core for object that is used to control/setup/connect to the XM125 device.
+ * Additional functionality - via templates - add added to this core to support the
+ * various applications supported by the XM125 device.
+ *
+ *
+ *
+ * The file includes the object lifecycle methods, and Toolkit bus instance data.
+ *
+ * @author SparkFun Electronics
+ * @date 2024-2025
+ * @copyright Copyright (c) 2024-2025, SparkFun Electronics Inc. This project is released under the MIT License.
+ *
+ * SPDX-License-Identifier: MIT
+ */
+#include "sfDevXM125Core.h"
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Core::begin(sfTkII2C *theBus)
+{
+ if (theBus == nullptr)
+ return ksfTkErrBusNotInit;
+
+ // Check if the provided address is valid
+ if (theBus->address() != SFE_XM125_I2C_ADDRESS)
+ return ksfTkErrFail;
+
+ // Sets communication bus
+ _theBus = theBus;
+
+ // set the byte order to BIG Endian - the sensor works with Big E
+ _theBus->setByteOrder(sfTkByteOrder::BigEndian);
+
+ // return the value of ping
+ return theBus->ping();
+}
diff --git a/src/sfTk/sfDevXM125Core.h b/src/sfTk/sfDevXM125Core.h
new file mode 100644
index 0000000..e370457
--- /dev/null
+++ b/src/sfTk/sfDevXM125Core.h
@@ -0,0 +1,40 @@
+/**
+ * @file sfDevXM125.h
+ * @brief Header of the SparkFun Qwiic XM125 Library.
+ *
+ * This file contains the header declares of the functions for interfacing with
+ * the SparkFun Qwiic XM125 distance and presence detector using I2C communication.
+ *
+ * @author SparkFun Electronics
+ * @date 2024-2025
+ * @copyright Copyright (c) 2024-2025, SparkFun Electronics Inc. This project is released under the MIT License.
+ *
+ * SPDX-License-Identifier: MIT
+ */
+#pragma once
+
+#include
+
+#include
+// Bus interfaces
+#include
+
+// The I2C address for the device
+const uint16_t SFE_XM125_I2C_ADDRESS = 0x52;
+
+class sfDevXM125Core
+{
+ public:
+ /// @brief Initializer
+ sfDevXM125Core() : _theBus{nullptr} {};
+
+ /// @brief This function begins the examples/communication.
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ virtual sfTkError_t begin(sfTkII2C *theBus = nullptr);
+
+ virtual ~sfDevXM125Core() {};
+
+ protected:
+ // our toolkit bus
+ sfTkII2C *_theBus;
+};
diff --git a/src/sfTk/sfDevXM125Distance.cpp b/src/sfTk/sfDevXM125Distance.cpp
new file mode 100644
index 0000000..17be1d6
--- /dev/null
+++ b/src/sfTk/sfDevXM125Distance.cpp
@@ -0,0 +1,984 @@
+/**
+ * @file sfDevXM125Distance.h
+ * @brief Implementation of the SparkFun Qwiic XM125 Library - Methods for the Distance app
+ *
+ * This file contains the implementation methods for the distance detection functionality. This
+ * is done using a template, which is then paired with the core class to provide the desired
+ * functionality.
+ *
+ * For this paying attention - yes, this is an example of Curiously Recurring Template Pattern (CRTP)
+ * design pattern - https://www.fluentcpp.com/2017/05/12/curiously-recurring-template-pattern/
+ *
+ * @author SparkFun Electronics
+ * @date 2024-2025
+ * @copyright Copyright (c) 2024-2025, SparkFun Electronics Inc. This project is released under the MIT License.
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#include "sfDevXM125Distance.h"
+
+//------------------------------------------------------------------
+// begin method - overrides the super class begin -
+//
+sfTkError_t sfDevXM125Distance::begin(sfTkII2C *theBus)
+{
+ // call super to get the device connection working
+ sfTkError_t retVal = sfDevXM125Core::begin(theBus);
+ if (retVal != ksfTkErrOk)
+ return retVal;
+
+ // Check errors from device application
+ uint32_t distanceError = 0;
+ retVal = getDistanceDetectorError(distanceError);
+ if (retVal != ksfTkErrOk)
+ return retVal;
+
+ // Additional checks for distance errors
+ if (distanceError != 0)
+ return ksfTkErrFail; // Indicating distance error
+
+ return ksfTkErrOk;
+}
+//------------------------------------------------------------------
+int32_t sfDevXM125Distance::distanceBegin(uint32_t startRange, uint32_t endRange)
+{
+ uint32_t errorStatus = 0;
+
+ // *** Distance Sensor Setup ***
+ // Reset sensor configuration to reapply configuration registers
+ setDistanceCommand(SFE_XM125_DISTANCE_RESET_MODULE);
+ sftk_delay_ms(100);
+
+ distanceBusyWait();
+
+ // Check error and busy bits
+ if (getDistanceDetectorErrorStatus(errorStatus) != 0)
+ {
+ return 1;
+ }
+
+ if (errorStatus != 0)
+ {
+ return 2;
+ }
+
+ // Set Start register
+ if (setDistanceStart(startRange) != 0)
+ {
+ return 3;
+ }
+ sftk_delay_ms(100); // give time for command to set
+
+ // Set End register
+ if (setDistanceEnd(endRange) != 0)
+ {
+ return 4;
+ }
+ sftk_delay_ms(100); // give time for command to set
+
+ // Apply configuration and calibrate.
+ if (setDistanceCommand(SFE_XM125_DISTANCE_APPLY_CONFIGURATION) != 0)
+ {
+ // Check for errors
+ getDistanceDetectorErrorStatus(errorStatus);
+ if (errorStatus != 0)
+ {
+ return 5;
+ }
+
+ return 6;
+ }
+
+ // Poll detector status until busy bit is cleared
+ if (distanceBusyWait() != 0)
+ {
+ return 7;
+ }
+
+ // Check detector status
+ getDistanceDetectorErrorStatus(errorStatus);
+ if (errorStatus != 0)
+ {
+ return 7;
+ }
+
+ // Return 0 on no error
+ return 0;
+}
+
+//--------------------------------------------------------------------------------
+int32_t sfDevXM125Distance::distanceDetectorReadingSetup()
+{
+ uint32_t errorStatus = 0;
+ uint32_t calibrateNeeded = 0;
+ uint32_t measDistErr = 0;
+
+ // Check error bits
+ getDistanceDetectorErrorStatus(errorStatus);
+ if (errorStatus != 0)
+ {
+ return 1;
+ }
+
+ // Start detector
+ if (setDistanceCommand(SFE_XM125_DISTANCE_START_DETECTOR) != 0)
+ {
+ return 2;
+ }
+ sftk_delay_ms(100); // give time for command to set
+
+ // Poll detector status until busy bit is cleared - CHECK ON THIS!
+ if (distanceBusyWait() != 0)
+ {
+ return 3;
+ }
+
+ // Verify that no error bits are set in the detector status register
+ getDistanceDetectorErrorStatus(errorStatus);
+ if (errorStatus != 0)
+ {
+ return 4;
+ }
+ sftk_delay_ms(100);
+
+ // Check MEASURE_DISTANCE_ERROR for measurement failed
+ getDistanceMeasureDistanceError(measDistErr);
+ if (measDistErr == 1)
+ {
+ return 5;
+ }
+ sftk_delay_ms(100);
+
+ // Recalibrate device if calibration error is triggered
+ getDistanceCalibrationNeeded(calibrateNeeded);
+ if (calibrateNeeded == 1)
+ {
+ setDistanceCommand(SFE_XM125_DISTANCE_RECALIBRATE);
+ return 6;
+ }
+ sftk_delay_ms(100);
+
+ return 0;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistanceDetectorVersion(uint32_t &major, uint32_t &minor, uint32_t &patch)
+{
+ sfTkError_t retVal;
+ uint32_t regVal = 0;
+
+ // Read from 16-Bit Register
+ size_t readBytes = 0;
+ retVal = _theBus->readRegister(SFE_XM125_DISTANCE_VERSION, (uint8_t *)®Val, sizeof(uint32_t), readBytes);
+ regVal = sftk_byte_swap(regVal);
+
+ // Mask unused bits from register
+ major = (regVal & SFE_XM125_DISTANCE_MAJOR_VERSION_MASK) >> SFE_XM125_DISTANCE_MAJOR_VERSION_MASK_SHIFT;
+ minor = (regVal & SFE_XM125_DISTANCE_MINOR_VERSION_MASK) >> SFE_XM125_DISTANCE_MINOR_VERSION_MASK_SHIFT;
+ patch = regVal & SFE_XM125_DISTANCE_PATCH_VERSION_MASK;
+
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistanceDetectorError(uint32_t &error)
+{
+ // Read from 16-Bit Register
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_PROTOCOL_STATUS, (uint8_t *)&error, sizeof(uint32_t), readBytes);
+ error = sftk_byte_swap(error);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistanceDetectorErrorStatus(uint32_t &status)
+{
+ sfTkError_t retVal;
+ uint32_t regVal = 0;
+ size_t readBytes = 0;
+ retVal = _theBus->readRegister(SFE_XM125_DISTANCE_DETECTOR_STATUS, (uint8_t *)®Val, sizeof(uint32_t), readBytes);
+ regVal = sftk_byte_swap(regVal);
+
+ // No error
+ status = 0;
+
+ if (retVal != ksfTkErrOk)
+ return retVal;
+
+ // Any errors - if not, skip the big bit check pachinko if-else below
+ if ((regVal & SFE_XM125_DISTANCE_ALL_ERROR_MASK) == 0)
+ return ksfTkErrOk;
+ // okay some bit is set...
+
+ if (SFTK_CHECK_BITS_SET(regVal, SFE_XM125_DISTANCE_RSS_REGISTER_ERROR_MASK))
+ status = 1;
+
+ else if (SFTK_CHECK_BITS_SET(regVal, SFE_XM125_DISTANCE_CONFIG_CREATE_ERROR_MASK))
+ status = 2;
+
+ else if (SFTK_CHECK_BITS_SET(regVal, SFE_XM125_DISTANCE_SENSOR_CREATE_ERROR_MASK))
+ status = 3;
+
+ else if (SFTK_CHECK_BITS_SET(regVal, SFE_XM125_DISTANCE_DETECTOR_CREATE_ERROR_MASK))
+ status = 5;
+
+ else if (SFTK_CHECK_BITS_SET(regVal, SFE_XM125_DISTANCE_DETECTOR_BUFFER_ERROR_MASK))
+ status = 6;
+
+ else if (SFTK_CHECK_BITS_SET(regVal, SFE_XM125_DISTANCE_SENSOR_BUFFER_ERROR_MASK))
+ status = 7;
+
+ else if (SFTK_CHECK_BITS_SET(regVal, SFE_XM125_DISTANCE_CALIBRATION_BUFFER_ERROR_MASK))
+ status = 8;
+
+ else if (SFTK_CHECK_BITS_SET(regVal, SFE_XM125_DISTANCE_CONFIG_APPLY_ERROR_MASK))
+ status = 9;
+
+ else if (SFTK_CHECK_BITS_SET(regVal, SFE_XM125_DISTANCE_SENSOR_CALIBRATE_ERROR_MASK))
+ status = 10;
+
+ else if (SFTK_CHECK_BITS_SET(regVal, SFE_XM125_DISTANCE_DETECTOR_CALIBRATE_ERROR_MASK))
+ status = 11;
+
+ else if (SFTK_CHECK_BITS_SET(regVal, SFE_XM125_DISTANCE_DETECTOR_ERROR_MASK))
+ status = 12;
+
+ else if (SFTK_CHECK_BITS_SET(regVal, SFE_XM125_DISTANCE_BUSY_MASK))
+ status = 13;
+
+ return ksfTkErrOk; // return 0 with no errors
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistanceMeasureCounter(uint32_t &counter)
+{
+ // Read from 16-Bit Register
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_MEASURE_COUNTER, (uint8_t *)&counter, sizeof(uint32_t), readBytes);
+ counter = sftk_byte_swap(counter);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistanceDetectorStatus(uint32_t &status)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_DETECTOR_STATUS, (uint8_t *)&status, sizeof(uint32_t), readBytes);
+ status = sftk_byte_swap(status);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistanceNumberDistances(uint32_t &distance)
+{
+ sfTkError_t retVal;
+ uint32_t regVal = 0;
+
+ // Read from 16-Bit Register
+ size_t readBytes = 0;
+ retVal = _theBus->readRegister(SFE_XM125_DISTANCE_RESULT, (uint8_t *)®Val, sizeof(uint32_t), readBytes);
+ regVal = sftk_byte_swap(regVal);
+
+ // Mask unused bits from register
+ distance = (regVal & SFE_XM125_DISTANCE_NUMBER_DISTANCES_MASK);
+
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistanceNearStartEdge(uint32_t &edge)
+{
+ sfTkError_t retVal;
+ uint32_t regVal = 0;
+
+ // Read from 16-Bit Register
+ size_t readBytes = 0;
+ retVal = _theBus->readRegister(SFE_XM125_DISTANCE_RESULT, (uint8_t *)®Val, sizeof(uint32_t), readBytes);
+ regVal = sftk_byte_swap(regVal);
+
+ // Mask unused bits from register
+ edge = (regVal & SFE_XM125_DISTANCE_NEAR_START_EDGE_MASK) >> SFE_XM125_DISTANCE_NEAR_START_EDGE_MASK_SHIFT;
+
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistanceCalibrationNeeded(uint32_t &calibrate)
+{
+ sfTkError_t retVal;
+ uint32_t regVal = 0;
+
+ // Read from 16-Bit Register
+ size_t readBytes = 0;
+ retVal = _theBus->readRegister(SFE_XM125_DISTANCE_RESULT, (uint8_t *)®Val, sizeof(uint32_t), readBytes);
+ regVal = sftk_byte_swap(regVal);
+
+ // Mask unused bits from register
+ calibrate =
+ (regVal & SFE_XM125_DISTANCE_CALIBRATION_NEEDED_MASK) >> SFE_XM125_DISTANCE_CALIBRATION_NEEDED_MASK_SHIFT;
+
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistanceMeasureDistanceError(uint32_t &error)
+{
+ sfTkError_t retVal;
+ uint32_t regVal = 0;
+
+ // Read from 16-Bit Register
+ size_t readBytes = 0;
+ retVal = _theBus->readRegister(SFE_XM125_DISTANCE_RESULT, (uint8_t *)®Val, sizeof(uint32_t), readBytes);
+ regVal = sftk_byte_swap(regVal);
+
+ // Mask unused bits from register
+ error = (regVal & SFE_XM125_DISTANCE_MEASURE_DISTANCE_ERROR_MASK) >>
+ SFE_XM125_DISTANCE_MEASURE_DISTANCE_ERROR_MASK_SHIFT;
+
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistanceTemperature(int16_t &temperature)
+{
+ sfTkError_t retVal;
+ uint32_t regVal = 0;
+
+ // Read from 16-Bit Register
+ size_t readBytes = 0;
+ retVal = _theBus->readRegister(SFE_XM125_DISTANCE_RESULT, (uint8_t *)®Val, sizeof(uint32_t), readBytes);
+ if (retVal != ksfTkErrOk)
+ return retVal;
+
+ regVal = sftk_byte_swap(regVal);
+
+ // Mask unused bits from register
+ temperature = static_cast((regVal & SFE_XM125_DISTANCE_TEMPERATURE_MASK) >>
+ SFE_XM125_DISTANCE_TEMPERATURE_MASK_SHIFT);
+
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+// Generic distance peak distance method
+sfTkError_t sfDevXM125Distance::getDistancePeakDistance(uint8_t num, uint32_t &peak)
+{
+
+ switch (num)
+ {
+ case 0:
+ return getDistancePeak0Distance(peak);
+ break;
+
+ case 1:
+ return getDistancePeak1Distance(peak);
+ break;
+ case 2:
+ return getDistancePeak2Distance(peak);
+ break;
+ case 3:
+ return getDistancePeak3Distance(peak);
+ break;
+ case 4:
+ return getDistancePeak4Distance(peak);
+ break;
+ case 5:
+ return getDistancePeak5Distance(peak);
+ break;
+ case 6:
+ return getDistancePeak6Distance(peak);
+ break;
+ case 7:
+ return getDistancePeak7Distance(peak);
+ break;
+ case 8:
+ return getDistancePeak8Distance(peak);
+ break;
+ case 9:
+ return getDistancePeak9Distance(peak);
+ break;
+ default:
+ return ksfTkErrFail;
+ break;
+ }
+}
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistancePeak0Distance(uint32_t &peak)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_PEAK0_DISTANCE, (uint8_t *)&peak, sizeof(uint32_t), readBytes);
+ peak = sftk_byte_swap(peak);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistancePeak1Distance(uint32_t &peak)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_PEAK1_DISTANCE, (uint8_t *)&peak, sizeof(uint32_t), readBytes);
+ peak = sftk_byte_swap(peak);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistancePeak2Distance(uint32_t &peak)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_PEAK2_DISTANCE, (uint8_t *)&peak, sizeof(uint32_t), readBytes);
+ peak = sftk_byte_swap(peak);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistancePeak3Distance(uint32_t &peak)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_PEAK3_DISTANCE, (uint8_t *)&peak, sizeof(uint32_t), readBytes);
+ peak = sftk_byte_swap(peak);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistancePeak4Distance(uint32_t &peak)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_PEAK4_DISTANCE, (uint8_t *)&peak, sizeof(uint32_t), readBytes);
+ peak = sftk_byte_swap(peak);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistancePeak5Distance(uint32_t &peak)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_PEAK5_DISTANCE, (uint8_t *)&peak, sizeof(uint32_t), readBytes);
+ peak = sftk_byte_swap(peak);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistancePeak6Distance(uint32_t &peak)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_PEAK6_DISTANCE, (uint8_t *)&peak, sizeof(uint32_t), readBytes);
+ peak = sftk_byte_swap(peak);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistancePeak7Distance(uint32_t &peak)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_PEAK7_DISTANCE, (uint8_t *)&peak, sizeof(uint32_t), readBytes);
+ peak = sftk_byte_swap(peak);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistancePeak8Distance(uint32_t &peak)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_PEAK8_DISTANCE, (uint8_t *)&peak, sizeof(uint32_t), readBytes);
+ peak = sftk_byte_swap(peak);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistancePeak9Distance(uint32_t &peak)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_PEAK9_DISTANCE, (uint8_t *)&peak, sizeof(uint32_t), readBytes);
+ peak = sftk_byte_swap(peak);
+ return retVal;
+}
+//--------------------------------------------------------------------------------
+// Generic distance peak strength method
+sfTkError_t sfDevXM125Distance::getDistancePeakStrength(uint8_t num, int32_t &peak)
+{
+
+ switch (num)
+ {
+ case 0:
+ return getDistancePeak0Strength(peak);
+ break;
+
+ case 1:
+ return getDistancePeak1Strength(peak);
+ break;
+ case 2:
+ return getDistancePeak2Strength(peak);
+ break;
+ case 3:
+ return getDistancePeak3Strength(peak);
+ break;
+ case 4:
+ return getDistancePeak4Strength(peak);
+ break;
+ case 5:
+ return getDistancePeak5Strength(peak);
+ break;
+ case 6:
+ return getDistancePeak6Strength(peak);
+ break;
+ case 7:
+ return getDistancePeak7Strength(peak);
+ break;
+ case 8:
+ return getDistancePeak8Strength(peak);
+ break;
+ case 9:
+ return getDistancePeak9Strength(peak);
+ break;
+ default:
+ return ksfTkErrFail;
+ break;
+ }
+}
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistancePeak0Strength(int32_t &peak)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_PEAK0_STRENGTH, (uint8_t *)&peak, sizeof(int32_t), readBytes);
+ peak = sftk_byte_swap(peak);
+
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistancePeak1Strength(int32_t &peak)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_PEAK1_STRENGTH, (uint8_t *)&peak, sizeof(int32_t), readBytes);
+ peak = sftk_byte_swap(peak);
+
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistancePeak2Strength(int32_t &peak)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_PEAK2_STRENGTH, (uint8_t *)&peak, sizeof(int32_t), readBytes);
+ peak = sftk_byte_swap(peak);
+
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistancePeak3Strength(int32_t &peak)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_PEAK3_STRENGTH, (uint8_t *)&peak, sizeof(int32_t), readBytes);
+ peak = sftk_byte_swap(peak);
+
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistancePeak4Strength(int32_t &peak)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_PEAK4_STRENGTH, (uint8_t *)&peak, sizeof(int32_t), readBytes);
+ peak = sftk_byte_swap(peak);
+
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistancePeak5Strength(int32_t &peak)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_PEAK5_STRENGTH, (uint8_t *)&peak, sizeof(int32_t), readBytes);
+ peak = sftk_byte_swap(peak);
+
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistancePeak6Strength(int32_t &peak)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_PEAK6_STRENGTH, (uint8_t *)&peak, sizeof(int32_t), readBytes);
+ peak = sftk_byte_swap(peak);
+
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistancePeak7Strength(int32_t &peak)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_PEAK7_STRENGTH, (uint8_t *)&peak, sizeof(int32_t), readBytes);
+ peak = sftk_byte_swap(peak);
+
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistancePeak8Strength(int32_t &peak)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_PEAK8_STRENGTH, (uint8_t *)&peak, sizeof(int32_t), readBytes);
+ peak = sftk_byte_swap(peak);
+
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistancePeak9Strength(int32_t &peak)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_PEAK9_STRENGTH, (uint8_t *)&peak, sizeof(int32_t), readBytes);
+ peak = sftk_byte_swap(peak);
+
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistanceStart(uint32_t &startVal)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_START, (uint8_t *)&startVal, sizeof(uint32_t), readBytes);
+ startVal = sftk_byte_swap(startVal);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::setDistanceStart(uint32_t start)
+{
+ start = sftk_byte_swap(start);
+ return _theBus->writeRegister(SFE_XM125_DISTANCE_START, (uint8_t *)&start, sizeof(uint32_t));
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistanceEnd(uint32_t &end)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal = _theBus->readRegister(SFE_XM125_DISTANCE_END, (uint8_t *)&end, sizeof(uint32_t), readBytes);
+ end = sftk_byte_swap(end);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::setDistanceEnd(uint32_t end)
+{
+ end = sftk_byte_swap(end);
+ return _theBus->writeRegister(SFE_XM125_DISTANCE_END, (uint8_t *)&end, sizeof(uint32_t));
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistanceMaxStepLength(uint32_t &length)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_MAX_STEP_LENGTH, (uint8_t *)&length, sizeof(uint32_t), readBytes);
+ length = sftk_byte_swap(length);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::setDistanceMaxStepLength(uint32_t length)
+{
+ length = sftk_byte_swap(length);
+ return _theBus->writeRegister(SFE_XM125_DISTANCE_MAX_STEP_LENGTH, (uint8_t *)&length, sizeof(uint32_t));
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistanceCloseRangeLeakageCancellation(bool &range)
+{
+ size_t readBytes = 0;
+ uint8_t readVal = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_CLOSE_RANGE_LEAKAGE, (uint8_t *)&readVal, sizeof(uint8_t), readBytes);
+ if (retVal != ksfTkErrOk)
+ return retVal;
+
+ range = (readVal == 0) ? false : true;
+ return ksfTkErrOk;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::setDistanceCloseRangeLeakageCancellation(bool range)
+{
+ uint8_t value = range ? 1 : 0;
+ return _theBus->writeRegister(SFE_XM125_DISTANCE_CLOSE_RANGE_LEAKAGE, &value, sizeof(value));
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistanceSignalQuality(uint32_t &signal)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_SIGNAL_QUALITY, (uint8_t *)&signal, sizeof(uint32_t), readBytes);
+ signal = sftk_byte_swap(signal);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::setDistanceSignalQuality(uint32_t signal)
+{
+ signal = sftk_byte_swap(signal);
+ return _theBus->writeRegister(SFE_XM125_DISTANCE_SIGNAL_QUALITY, (uint8_t *)&signal, sizeof(uint32_t));
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistanceMaxProfile(uint32_t &profile)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_MAX_PROFILE, (uint8_t *)&profile, sizeof(uint32_t), readBytes);
+ profile = sftk_byte_swap(profile);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::setDistanceMaxProfile(uint32_t profile)
+{
+ profile = sftk_byte_swap(profile);
+ return _theBus->writeRegister(SFE_XM125_DISTANCE_MAX_PROFILE, (uint8_t *)&profile, sizeof(uint32_t));
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistanceThresholdMethod(uint32_t &method)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_THRESHOLD_METHOD, (uint8_t *)&method, sizeof(uint32_t), readBytes);
+ method = sftk_byte_swap(method);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::setDistanceThresholdMethod(uint32_t method)
+{
+ method = sftk_byte_swap(method);
+ return _theBus->writeRegister(SFE_XM125_DISTANCE_THRESHOLD_METHOD, (uint8_t *)&method, sizeof(uint32_t));
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistancePeakSorting(uint32_t &peak)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_PEAK_SORTING, (uint8_t *)&peak, sizeof(uint32_t), readBytes);
+ peak = sftk_byte_swap(peak);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::setDistancePeakSorting(uint32_t peak)
+{
+ peak = sftk_byte_swap(peak);
+ return _theBus->writeRegister(SFE_XM125_DISTANCE_PEAK_SORTING, (uint8_t *)&peak, sizeof(uint32_t));
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistanceNumFramesRecordedThreshold(uint32_t &thresh)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal = _theBus->readRegister(SFE_XM125_DISTANCE_NUM_FRAMES_RECORDED_THRESH, (uint8_t *)&thresh,
+ sizeof(uint32_t), readBytes);
+ thresh = sftk_byte_swap(thresh);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::setDistanceNumFramesRecordedThreshold(uint32_t thresh)
+{
+ thresh = sftk_byte_swap(thresh);
+ return _theBus->writeRegister(SFE_XM125_DISTANCE_NUM_FRAMES_RECORDED_THRESH, (uint8_t *)&thresh, sizeof(uint32_t));
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistanceFixedAmpThreshold(uint32_t &thresh)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal = _theBus->readRegister(SFE_XM125_DISTANCE_FIXED_AMPLITUDE_THRESHOLD_VAL, (uint8_t *)&thresh,
+ sizeof(uint32_t), readBytes);
+ thresh = sftk_byte_swap(thresh);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::setDistanceFixedAmpThreshold(uint32_t thresh)
+{
+ thresh = sftk_byte_swap(thresh);
+ return _theBus->writeRegister(SFE_XM125_DISTANCE_FIXED_AMPLITUDE_THRESHOLD_VAL, (uint8_t *)&thresh,
+ sizeof(uint32_t));
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistanceThresholdSensitivity(uint32_t &thresh)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal = _theBus->readRegister(SFE_XM125_DISTANCE_THREHSOLD_SENSITIVITY, (uint8_t *)&thresh,
+ sizeof(uint32_t), readBytes);
+ thresh = sftk_byte_swap(thresh);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::setDistanceThresholdSensitivity(uint32_t thresh)
+{
+ thresh = sftk_byte_swap(thresh);
+ return _theBus->writeRegister(SFE_XM125_DISTANCE_THREHSOLD_SENSITIVITY, (uint8_t *)&thresh, sizeof(uint32_t));
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistanceReflectorShape(uint32_t &shape)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_REFLECTOR_SHAPE, (uint8_t *)&shape, sizeof(uint32_t), readBytes);
+ shape = sftk_byte_swap(shape);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::setDistanceReflectorShape(uint32_t shape)
+{
+ shape = sftk_byte_swap(shape);
+ return _theBus->writeRegister(SFE_XM125_DISTANCE_REFLECTOR_SHAPE, (uint8_t *)&shape, sizeof(uint32_t));
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistanceFixedStrengthThresholdValue(int32_t &thresh)
+{
+ size_t readBytes = 0;
+ sfTkError_t retVal = _theBus->readRegister(SFE_XM125_DISTANCE_FIXED_STRENGTH_THRESHOLD_VAL, (uint8_t *)&thresh,
+ sizeof(uint32_t), readBytes);
+ thresh = sftk_byte_swap(thresh);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::setDistanceFixedStrengthThresholdValue(int32_t thresh)
+{
+ thresh = sftk_byte_swap(thresh);
+ return _theBus->writeRegister(SFE_XM125_DISTANCE_FIXED_STRENGTH_THRESHOLD_VAL, (uint8_t *)&thresh, sizeof(int32_t));
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::getDistanceMeasureOneWakeup(bool &measure)
+{
+ size_t readBytes = 0;
+ uint8_t value;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_MEASURE_ON_WAKEUP, (uint8_t *)&value, sizeof(uint8_t), readBytes);
+ measure = static_cast(value);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::setDistanceMeasureOneWakeup(bool measure)
+{
+ uint8_t value = static_cast(measure);
+ return _theBus->writeRegister(SFE_XM125_DISTANCE_MEASURE_ON_WAKEUP, (uint8_t *)&value, sizeof(uint8_t));
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::setDistanceCommand(uint32_t command)
+{
+ command = sftk_byte_swap(command);
+ return _theBus->writeRegister(SFE_XM125_DISTANCE_COMMAND, (uint8_t *)&command, sizeof(uint32_t));
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::distanceApplyConfiguration()
+{
+ return setDistanceCommand(SFE_XM125_DISTANCE_APPLY_CONFIGURATION);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::distanceStart()
+{
+ return setDistanceCommand(SFE_XM125_DISTANCE_START_DETECTOR);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::distanceStop()
+{
+ return setDistanceCommand(SFE_XM125_DISTANCE_STOP_DETECTOR);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::distanceCalibrate()
+{
+ return setDistanceCommand(SFE_XM125_DISTANCE_CALIBRATE);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::distanceRecalibrate()
+{
+ return setDistanceCommand(SFE_XM125_DISTANCE_RECALIBRATE);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::distanceEnableUartLogs()
+{
+ return setDistanceCommand(SFE_XM125_DISTANCE_ENABLE_UART_LOGS);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::distanceDisableUartLogs()
+{
+ return setDistanceCommand(SFE_XM125_DISTANCE_DISABLE_UART_LOGS);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::distanceLogConfiguration()
+{
+ return setDistanceCommand(SFE_XM125_DISTANCE_LOG_CONFIGURATION);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::distanceReset()
+{
+ return setDistanceCommand(SFE_XM125_DISTANCE_RESET_MODULE);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Distance::distanceBusyWait()
+{
+ sfTkError_t retVal = 0;
+ uint32_t regVal = 0;
+
+ size_t readBytes = 0;
+ retVal = _theBus->readRegister(SFE_XM125_DISTANCE_DETECTOR_STATUS, (uint8_t *)®Val, sizeof(uint32_t), readBytes);
+ regVal = sftk_byte_swap(regVal);
+
+ // Poll Detector Status until Busy bit is cleared
+ while (((regVal & SFE_XM125_DISTANCE_DETECTOR_STATUS_MASK) >> SFE_XM125_DISTANCE_DETECTOR_STATUS_MASK_SHIFT) != 0)
+ {
+ retVal =
+ _theBus->readRegister(SFE_XM125_DISTANCE_DETECTOR_STATUS, (uint8_t *)®Val, sizeof(uint32_t), readBytes);
+ regVal = sftk_byte_swap(regVal);
+ }
+
+ return retVal;
+}
\ No newline at end of file
diff --git a/src/sfTk/sfDevXM125Distance.h b/src/sfTk/sfDevXM125Distance.h
new file mode 100644
index 0000000..487888f
--- /dev/null
+++ b/src/sfTk/sfDevXM125Distance.h
@@ -0,0 +1,698 @@
+/**
+ * @file sfDevXM125Distance.h
+ * @brief Header of the SparkFun Qwiic XM125 Library.
+ *
+ * This file contains the header the Distance Application object
+ *
+ * @author SparkFun Electronics
+ * @date 2024-2025
+ * @copyright Copyright (c) 2024-2025, SparkFun Electronics Inc. This project is released under the MIT License.
+ *
+ * SPDX-License-Identifier: MIT
+ */
+#pragma once
+
+#include "sfDevXM125Core.h"
+
+// Defines
+
+/* ****************************** Distance Values ****************************** */
+
+const uint32_t SFE_XM125_DISTANCE_MAJOR_VERSION_MASK = 0xffff0000;
+const uint32_t SFE_XM125_DISTANCE_MINOR_VERSION_MASK = 0x0000ff00;
+const uint32_t SFE_XM125_DISTANCE_PATCH_VERSION_MASK = 0x000000ff;
+const uint32_t SFE_XM125_DISTANCE_NUMBER_DISTANCES_MASK = 0x0000000f;
+const uint32_t SFE_XM125_DISTANCE_NEAR_START_EDGE_MASK = 0x00000100;
+const uint32_t SFE_XM125_DISTANCE_MEASURE_DISTANCE_ERROR_MASK = 0x00000400;
+const uint32_t SFE_XM125_DISTANCE_TEMPERATURE_MASK = 0xffff0000;
+const uint32_t SFE_XM125_DISTANCE_RSS_REGISTER_OK_MASK = 0x00000001;
+const uint32_t SFE_XM125_DISTANCE_CONFIG_CREATE_OK_MASK = 0x00000002;
+const uint32_t SFE_XM125_DISTANCE_SENSOR_CREATE_OK_MASK = 0x00000004;
+const uint32_t SFE_XM125_DISTANCE_DETECTOR_CREATE_OK_MASK = 0x00000008;
+const uint32_t SFE_XM125_DISTANCE_DETECTOR_BUFFER_OK_MASK = 0x00000010;
+const uint32_t SFE_XM125_DISTANCE_SENSOR_BUFFER_OK_MASK = 0x00000020;
+const uint32_t SFE_XM125_DISTANCE_CALIBRATION_BUFFER_OK_MASK = 0x00000040;
+const uint32_t SFE_XM125_DISTANCE_CONFIG_APPLY_OK_MASK = 0x00000080;
+const uint32_t SFE_XM125_DISTANCE_SENSOR_CALIBRATE_OK_MASK = 0x00000100;
+const uint32_t SFE_XM125_DISTANCE_DETECTOR_CALIBRATE_OK_MASK = 0x00000200;
+const uint32_t SFE_XM125_DISTANCE_RSS_REGISTER_ERROR_MASK = 0x00010000;
+const uint32_t SFE_XM125_DISTANCE_CONFIG_CREATE_ERROR_MASK = 0x00020000;
+const uint32_t SFE_XM125_DISTANCE_SENSOR_CREATE_ERROR_MASK = 0x00040000;
+const uint32_t SFE_XM125_DISTANCE_DETECTOR_CREATE_ERROR_MASK = 0x00080000;
+const uint32_t SFE_XM125_DISTANCE_DETECTOR_BUFFER_ERROR_MASK = 0x00100000;
+const uint32_t SFE_XM125_DISTANCE_SENSOR_BUFFER_ERROR_MASK = 0x00200000;
+const uint32_t SFE_XM125_DISTANCE_CALIBRATION_BUFFER_ERROR_MASK = 0x00400000;
+const uint32_t SFE_XM125_DISTANCE_CONFIG_APPLY_ERROR_MASK = 0x00800000;
+const uint32_t SFE_XM125_DISTANCE_SENSOR_CALIBRATE_ERROR_MASK = 0x01000000;
+const uint32_t SFE_XM125_DISTANCE_DETECTOR_CALIBRATE_ERROR_MASK = 0x02000000;
+const uint32_t SFE_XM125_DISTANCE_DETECTOR_ERROR_MASK = 0x10000000;
+const uint32_t SFE_XM125_DISTANCE_BUSY_MASK = 0x80000000;
+const uint32_t SFE_XM125_DISTANCE_CALIBRATION_NEEDED_MASK = 0x00000200;
+
+const uint32_t SFE_XM125_DISTANCE_ALL_ERROR_MASK =
+ (SFE_XM125_DISTANCE_RSS_REGISTER_ERROR_MASK | SFE_XM125_DISTANCE_CONFIG_CREATE_ERROR_MASK |
+ SFE_XM125_DISTANCE_SENSOR_CREATE_ERROR_MASK | SFE_XM125_DISTANCE_DETECTOR_CREATE_ERROR_MASK |
+ SFE_XM125_DISTANCE_DETECTOR_BUFFER_ERROR_MASK | SFE_XM125_DISTANCE_SENSOR_BUFFER_ERROR_MASK |
+ SFE_XM125_DISTANCE_CALIBRATION_BUFFER_ERROR_MASK | SFE_XM125_DISTANCE_CONFIG_APPLY_ERROR_MASK |
+ SFE_XM125_DISTANCE_SENSOR_CALIBRATE_ERROR_MASK | SFE_XM125_DISTANCE_DETECTOR_CALIBRATE_ERROR_MASK |
+ SFE_XM125_DISTANCE_DETECTOR_ERROR_MASK | SFE_XM125_DISTANCE_BUSY_MASK);
+
+const uint32_t SFE_XM125_DISTANCE_MAJOR_VERSION_MASK_SHIFT = 16;
+const uint32_t SFE_XM125_DISTANCE_MINOR_VERSION_MASK_SHIFT = 8;
+const uint32_t SFE_XM125_DISTANCE_RSS_REGISTER_ERROR_MASK_SHIFT = 15;
+const uint32_t SFE_XM125_DISTANCE_CONFIG_CREATE_ERROR_MASK_SHIFT = 16;
+const uint32_t SFE_XM125_DISTANCE_SENSOR_CREATE_ERROR_MASK_SHIFT = 17;
+const uint32_t SFE_XM125_DISTANCE_DETECTOR_CREATE_ERROR_MASK_SHIFT = 18;
+const uint32_t SFE_XM125_DISTANCE_DETECTOR_BUFFER_ERROR_MASK_SHIFT = 19;
+const uint32_t SFE_XM125_DISTANCE_SENSOR_BUFFER_ERROR_MASK_SHIFT = 20;
+const uint32_t SFE_XM125_DISTANCE_CALIBRATION_BUFFER_ERROR_MASK_SHIFT = 21;
+const uint32_t SFE_XM125_DISTANCE_CONFIG_APPLY_ERROR_MASK_SHIFT = 22;
+const uint32_t SFE_XM125_DISTANCE_SENSOR_CALIBRATE_ERROR_MASK_SHIFT = 23;
+const uint32_t SFE_XM125_DISTANCE_DETECTOR_CALIBRATE_ERROR_MASK_SHIFT = 24;
+const uint32_t SFE_XM125_DISTANCE_DETECTOR_ERROR_MASK_SHIFT = 27;
+const uint32_t SFE_XM125_DISTANCE_BUSY_MASK_SHIFT = 30;
+const uint32_t SFE_XM125_DISTANCE_NEAR_START_EDGE_MASK_SHIFT = 8;
+const uint32_t SFE_XM125_DISTANCE_CALIBRATION_NEEDED_MASK_SHIFT = 9;
+const uint32_t SFE_XM125_DISTANCE_MEASURE_DISTANCE_ERROR_MASK_SHIFT = 10;
+const uint32_t SFE_XM125_DISTANCE_TEMPERATURE_MASK_SHIFT = 16;
+const uint32_t SFE_XM125_DISTANCE_DETECTOR_STATUS_MASK_SHIFT = 30;
+
+const uint32_t SFE_XM125_DISTANCE_DETECTOR_STATUS_MASK = 0b10010000111111110000000011111111;
+
+const uint16_t SFE_XM125_DISTANCE_VERSION = 0x00;
+typedef struct
+{
+ uint32_t distance_major : 16;
+ uint32_t distance_minor : 8;
+ uint32_t distance_patch : 8;
+} sfe_xm125_distance_version_t;
+
+const uint16_t SFE_XM125_DISTANCE_PROTOCOL_STATUS = 0x01;
+typedef struct
+{
+ uint32_t distance_protocol_state_error : 1;
+ uint32_t distance_packet_length_error : 1;
+ uint32_t distance_address_error : 1;
+ uint32_t distance_write_failed : 1;
+ uint32_t distance_write_to_read_only : 1;
+ uint32_t reserved1 : 27;
+} sfe_xm125_distance_protocol_status_t;
+
+const uint16_t SFE_XM125_DISTANCE_MEASURE_COUNTER = 0x02;
+
+const uint16_t SFE_XM125_DISTANCE_DETECTOR_STATUS = 0x03;
+typedef struct
+{
+ uint32_t distance_rss_register_ok : 1;
+ uint32_t distance_config_create_ok : 1;
+ uint32_t distance_sensor_create_ok : 1;
+ uint32_t distance_detector_create_ok : 1;
+ uint32_t distance_detector_buffer_ok : 1;
+ uint32_t distance_sensor_buffer_ok : 1;
+ uint32_t distance_calibration_buffer_ok : 1;
+ uint32_t distance_config_apply_ok : 1;
+ uint32_t distance_sensor_calibrate_ok : 1;
+ uint32_t distance_detector_calibrate_ok : 1;
+ uint32_t reserved1 : 6;
+ uint32_t distance_rss_register_error : 1;
+ uint32_t distance_config_create_error : 1;
+ uint32_t distance_sensor_create_error : 1;
+ uint32_t distance_detector_create_error : 1;
+ uint32_t distance_detector_buffer_error : 1;
+ uint32_t distance_sensor_buffer_error : 1;
+ uint32_t distance_calibration_buffer_error : 1;
+ uint32_t distance_config_apply_error : 1;
+ uint32_t distance_sensor_calibrate_error : 1;
+ uint32_t distance_detector_calibrate_error : 1;
+ uint32_t reserved2 : 2;
+ uint32_t distance_detector_error : 1;
+ uint32_t reserved3 : 2;
+ uint32_t distance_busy : 1;
+} sfe_xm125_distance_detector_status_t;
+
+const uint16_t SFE_XM125_DISTANCE_RESULT = 0x10;
+typedef struct
+{
+ uint32_t distance_num_distances : 4;
+ uint32_t rsvd1 : 4; // skips "reserved" bits
+ uint32_t distance_near_start_edge : 1;
+ uint32_t distance_calibration_needed : 1;
+ uint32_t distance_measure_distance_error : 1;
+ uint32_t reserved1 : 5;
+ uint32_t distance_temperature : 16;
+} sfe_xm125_distance_result_t;
+
+const uint16_t SFE_XM125_DISTANCE_PEAK0_DISTANCE = 0x11;
+const uint16_t SFE_XM125_DISTANCE_PEAK1_DISTANCE = 0x12;
+const uint16_t SFE_XM125_DISTANCE_PEAK2_DISTANCE = 0x13;
+const uint16_t SFE_XM125_DISTANCE_PEAK3_DISTANCE = 0x14;
+const uint16_t SFE_XM125_DISTANCE_PEAK4_DISTANCE = 0x15;
+const uint16_t SFE_XM125_DISTANCE_PEAK5_DISTANCE = 0x16;
+const uint16_t SFE_XM125_DISTANCE_PEAK6_DISTANCE = 0x17;
+const uint16_t SFE_XM125_DISTANCE_PEAK7_DISTANCE = 0x18;
+const uint16_t SFE_XM125_DISTANCE_PEAK8_DISTANCE = 0x19;
+const uint16_t SFE_XM125_DISTANCE_PEAK9_DISTANCE = 0x1a;
+const uint16_t SFE_XM125_DISTANCE_PEAK0_STRENGTH = 0x1b;
+const uint16_t SFE_XM125_DISTANCE_PEAK1_STRENGTH = 0x1c;
+const uint16_t SFE_XM125_DISTANCE_PEAK2_STRENGTH = 0x1d;
+const uint16_t SFE_XM125_DISTANCE_PEAK3_STRENGTH = 0x1e;
+const uint16_t SFE_XM125_DISTANCE_PEAK4_STRENGTH = 0x1f;
+const uint16_t SFE_XM125_DISTANCE_PEAK5_STRENGTH = 0x20;
+const uint16_t SFE_XM125_DISTANCE_PEAK6_STRENGTH = 0x21;
+const uint16_t SFE_XM125_DISTANCE_PEAK7_STRENGTH = 0x22;
+const uint16_t SFE_XM125_DISTANCE_PEAK8_STRENGTH = 0x23;
+const uint16_t SFE_XM125_DISTANCE_PEAK9_STRENGTH = 0x24;
+
+// Default Value: 250mm
+const uint16_t SFE_XM125_DISTANCE_START = 0x40;
+const uint16_t sfe_xm125_distance_start_default = 250;
+
+// Default Value: 3000mm
+const uint16_t SFE_XM125_DISTANCE_END = 0x41;
+const uint16_t sfe_xm125_distance_end_default = 3000;
+
+// Default Value: 0
+const uint16_t SFE_XM125_DISTANCE_MAX_STEP_LENGTH = 0x42;
+const uint16_t sfe_xm125_distance_max_step_length_default = 0;
+
+// Default Value: True
+const uint16_t SFE_XM125_DISTANCE_CLOSE_RANGE_LEAKAGE = 0x43;
+const bool sfe_xm125_distance_close_range_leakage_default = true;
+
+// Default Value: 15000
+const uint16_t SFE_XM125_DISTANCE_SIGNAL_QUALITY = 0x44;
+const uint16_t sfe_xm125_distance_signal_quality_default = 15000;
+
+// Default: PROFILE5 (enum)
+const uint16_t SFE_XM125_DISTANCE_MAX_PROFILE = 0x45;
+typedef enum
+{
+ XM125_DISTANCE_PROFILE1 = 1,
+ XM125_DISTANCE_PROFILE2 = 2,
+ XM125_DISTANCE_PROFILE3 = 3,
+ XM125_DISTANCE_PROFILE4 = 4,
+ XM125_DISTANCE_PROFILE5 = 5,
+} sfe_xm125_distance_profile_t;
+
+// Default Value: CFAR (enum)
+const uint16_t SFE_XM125_DISTANCE_THRESHOLD_METHOD = 0x46;
+typedef enum
+{
+ XM125_DISTANCE_FIXED_AMPLITUDE = 1,
+ XM125_DISTANCE_RECORDED = 2,
+ XM125_DISTANCE_CFAR = 3,
+ XM125_DISTANCE_FIXED_STRENGTH = 4,
+} sfe_xm125_distance_threshold_method_t;
+
+// Default Value: STRONGEST (enum)
+const uint16_t SFE_XM125_DISTANCE_PEAK_SORTING = 0x47;
+typedef enum
+{
+ XM125_DISTANCE_CLOSEST = 1,
+ XM125_DISTANCE_STRONGEST = 2,
+} sfe_xm125_distance_peak_sorting_t;
+
+// Default Value: 100
+const uint16_t SFE_XM125_DISTANCE_NUM_FRAMES_RECORDED_THRESH = 0x48;
+const uint16_t sfe_xm125_distance_num_frames_recorded_thresh_default = 100;
+
+// Default Value: 100000
+const uint16_t SFE_XM125_DISTANCE_FIXED_AMPLITUDE_THRESHOLD_VAL = 0x49;
+const uint32_t sfe_xm125_distance_fixed_amp_thresh_val_default = 100000;
+
+// Default Value: 500
+const uint16_t SFE_XM125_DISTANCE_THREHSOLD_SENSITIVITY = 0x4a;
+const uint16_t sfe_xm125_distance_threshold_sensitivity_default = 500;
+
+// Default Value: GENERIC
+const uint16_t SFE_XM125_DISTANCE_REFLECTOR_SHAPE = 0x4b;
+typedef enum
+{
+ XM125_DISTANCE_GENERIC = 1,
+ XM125_DISTANCE_PLANAR = 2,
+} sfe_xm125_distance_reflector_shape_t;
+
+// Default Value: 0
+const uint16_t SFE_XM125_DISTANCE_FIXED_STRENGTH_THRESHOLD_VAL = 0x4c;
+const uint16_t sfe_xm125_distance_fixed_strength_threshold_val_default = 0;
+
+// Default Value: False
+const uint16_t SFE_XM125_DISTANCE_MEASURE_ON_WAKEUP = 0x80;
+const bool sfe_xm125_distance_measure_on_wakup = false;
+
+const uint16_t SFE_XM125_DISTANCE_COMMAND = 0x100;
+typedef enum
+{
+ XM125_DISTANCE_APPLY_CONFIG_AND_CALIBRATE = 1,
+ XM125_DISTANCE_MEASURE_DISTANCE = 2,
+ XM125_DISTANCE_APPLY_CONFIGURATION = 3,
+ XM125_DISTANCE_CALIBRATE = 4,
+ XM125_DISTANCE_RECALIBRATE = 5,
+ XM125_DISTANCE_ENABLE_UART_LOGS = 32,
+ XM125_DISTANCE_DISABLE_UART_LOGS = 33,
+ XM125_DISTANCE_LOG_CONFIGURATION = 34,
+ XM125_DISTANCE_RESET_MODULE = 1381192737,
+} sfe_xm125_distance_command_t;
+
+const uint32_t SFE_XM125_DISTANCE_APPLY_CONFIGURATION = 1;
+const uint32_t SFE_XM125_DISTANCE_START_DETECTOR = 2;
+const uint32_t SFE_XM125_DISTANCE_STOP_DETECTOR = 3;
+const uint32_t SFE_XM125_DISTANCE_CALIBRATE = 4;
+const uint32_t SFE_XM125_DISTANCE_RECALIBRATE = 5;
+const uint32_t SFE_XM125_DISTANCE_ENABLE_UART_LOGS = 32;
+const uint32_t SFE_XM125_DISTANCE_DISABLE_UART_LOGS = 33;
+const uint32_t SFE_XM125_DISTANCE_LOG_CONFIGURATION = 34;
+const uint32_t SFE_XM125_DISTANCE_RESET_MODULE = 1381192737;
+
+// Distance class definition
+
+class sfDevXM125Distance : public sfDevXM125Core
+{
+ public:
+ /**
+ * @brief Initializes the distance detector device.
+ *
+ * This function sets up the I2C communication and performs initial checks
+ * to ensure the device is ready for operation.
+ *
+ * @param theBus Pointer to the I2C bus object. If nullptr, the default bus is used.
+ * @return ksfTkErrOk on success, or error code (value < -1) on failure.
+ */
+ sfTkError_t begin(sfTkII2C *theBus = nullptr);
+
+ /// @brief This function sets all the beginning values for a basic I2C
+ /// example to be run on the device for presence sensing.
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t distanceBegin(uint32_t start = sfe_xm125_distance_start_default,
+ uint32_t end = sfe_xm125_distance_end_default);
+
+ /// @brief This function does all the required checks and busy waits to
+ /// make sure the device is ready for distance readings.
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t distanceDetectorReadingSetup();
+
+ /// @brief This function returns the version number of the device
+ /// structure: major.minor.patch
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistanceDetectorVersion(uint32_t &major, uint32_t &minor, uint32_t &patch);
+
+ /// @brief This function returns if there was an error from the
+ /// protocol status register
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistanceDetectorError(uint32_t &error);
+
+ /// @brief This function returns the error status according to the bit
+ /// mask value for the distance devices errors and busy bit
+ /// @param status Error status of device (see function for exact error)
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistanceDetectorErrorStatus(uint32_t &status);
+
+ /// @brief This function returns the measure counter, the number of measurements
+ /// performed since restart.
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistanceMeasureCounter(uint32_t &counter);
+
+ /// @brief This function returns the status of the device if there are any issues
+ /// with any of the status's listed defined.
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistanceDetectorStatus(uint32_t &status);
+
+ /// @brief This function returns the number of detected distances.
+ /// @param distance Number of detected distances
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistanceNumberDistances(uint32_t &distance);
+
+ /// @brief This function returns the indication that there might be an object
+ /// near the start point of the measured range.
+ /// @param edge Flag to determine object in range
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistanceNearStartEdge(uint32_t &edge);
+
+ /// @brief This function returns the indication of a sensor calibration needed.
+ /// @param calibrate Flag to indicate calibration required
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistanceCalibrationNeeded(uint32_t &calibrate);
+
+ /// @brief This function returns if the measure command failed.
+ /// @param error Flag to indicate measure command error
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistanceMeasureDistanceError(uint32_t &error);
+
+ /// @brief This function returns the temperature in sensor during measurements
+ /// (in degree Celsius). Note that it has poor absolute accuracy and should
+ /// only be used for relative temperature measurements.
+ /// @param temperature Relative temperature of device
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistanceTemperature(int16_t &temperature);
+
+ //--------------------------------------------------------------------------------
+ // Generic distance peak distance method
+ /// @brief This function returns the distance to peak num
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// @param num Peak number to get distance (0-9)
+ /// @param peak Distance to peak num
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistancePeakDistance(uint8_t num, uint32_t &peak);
+
+ /// @brief This function returns the distance to peak 0
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistancePeak0Distance(uint32_t &peak);
+
+ /// @brief This function returns the distance to peak 1
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistancePeak1Distance(uint32_t &peak);
+
+ /// @brief This function returns the distance to peak 2
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistancePeak2Distance(uint32_t &peak);
+
+ /// @brief This function returns the distance to peak 3
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistancePeak3Distance(uint32_t &peak);
+
+ /// @brief This function returns the distance to peak 4
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistancePeak4Distance(uint32_t &peak);
+
+ /// @brief This function returns the distance to peak 5
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistancePeak5Distance(uint32_t &peak);
+
+ /// @brief This function returns the distance to peak 6
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistancePeak6Distance(uint32_t &peak);
+
+ /// @brief This function returns the distance to peak 7
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistancePeak7Distance(uint32_t &peak);
+
+ /// @brief This function returns the distance to peak 8
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistancePeak8Distance(uint32_t &peak);
+
+ /// @brief This function returns the distance to peak 9
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistancePeak9Distance(uint32_t &peak);
+
+ //--------------------------------------------------------------------------------
+ // Generic distance peak strength method
+ /// @brief This function returns the strength to peak num
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// @param num Peak number to get strength (0-9)
+ /// @param peak strength to peak num
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistancePeakStrength(uint8_t num, int32_t &peak);
+
+ /// @brief This function returns the strength of peak 0
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistancePeak0Strength(int32_t &peak);
+
+ /// @brief This function returns the strength of peak 1
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistancePeak1Strength(int32_t &peak);
+
+ /// @brief This function returns the strength of peak 2
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistancePeak2Strength(int32_t &peak);
+
+ /// @brief This function returns the strength of peak 3
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistancePeak3Strength(int32_t &peak);
+
+ /// @brief This function returns the strength of peak 4
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistancePeak4Strength(int32_t &peak);
+
+ /// @brief This function returns the strength of peak 5
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistancePeak5Strength(int32_t &peak);
+
+ /// @brief This function returns the strength of peak 6
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistancePeak6Strength(int32_t &peak);
+
+ /// @brief This function returns the strength of peak 7
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistancePeak7Strength(int32_t &peak);
+
+ /// @brief This function returns the strength of peak 8
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistancePeak8Strength(int32_t &peak);
+
+ /// @brief This function returns the strength of peak 9
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistancePeak9Strength(int32_t &peak);
+
+ /// @brief This function returns the start of measured interval
+ /// in millimeters.
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 250
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistanceStart(uint32_t &startVal);
+
+ /// @brief This function sets the start of measured interval in
+ /// millimeters.
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 250
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setDistanceStart(uint32_t start);
+
+ /// @brief This function returns the end of measured interval
+ /// in millimeters.
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 3000
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistanceEnd(uint32_t &end);
+
+ /// @brief This function sets the end of measured interval
+ /// in millimeters.
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 3000
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setDistanceEnd(uint32_t end);
+
+ /// @brief This function returns the used to limit step length.
+ /// If set to 0 (default), the step length is calculated
+ /// based on profile.
+ /// Default Value: 0
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistanceMaxStepLength(uint32_t &length);
+
+ /// @brief This function sets the used to limit step length.
+ /// If set to 0 (default), the step length is calculated
+ /// based on profile.
+ /// Default Value: 0
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setDistanceMaxStepLength(uint32_t length);
+
+ /// @brief This function reads if the close range leakage
+ /// cancellation logic is enabled.
+ /// Default Value: true
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistanceCloseRangeLeakageCancellation(bool &range);
+
+ /// @brief This function sets the close range leakage
+ /// cancellation logic.
+ /// Default Value: true
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setDistanceCloseRangeLeakageCancellation(bool range);
+
+ /// @brief This function returns the high signal quality in a
+ /// better SNR (because of higher HWAAS) and higher power consumption.
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 15000
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistanceSignalQuality(uint32_t &signal);
+
+ /// @brief This function sets the high signal quality in a
+ /// better SNR (because of higher HWAAS) and higher power consumption.
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 15000
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setDistanceSignalQuality(uint32_t signal);
+
+ /// @brief This function returns the max profile of the device.
+ /// Default value = PROFILE5
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistanceMaxProfile(uint32_t &profile);
+
+ /// @brief This function sets the max profile of the device
+ /// Default value = PROFILE5
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setDistanceMaxProfile(uint32_t profile);
+
+ /// @brief This function returns the threshold method
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistanceThresholdMethod(uint32_t &method);
+
+ /// @brief This function sets the threshold method
+ /// @param method Threshold method (enum)
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setDistanceThresholdMethod(uint32_t method);
+
+ /// @brief This function returns the peak sorting method
+ /// @param peak Peak sorting method
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistancePeakSorting(uint32_t &peak);
+
+ /// @brief This function sets the peak sorting method
+ /// @param peak Peak sorting method
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setDistancePeakSorting(uint32_t peak);
+
+ /// @brief This function returns the number frames to use for recorded threshold.
+ /// Default Value: 100
+ /// @param thresh Number of frames
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistanceNumFramesRecordedThreshold(uint32_t &thresh);
+
+ /// @brief This function sets the number frames to use for recorded threshold.
+ /// Default Value: 100
+ /// @param thresh Number of frames
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setDistanceNumFramesRecordedThreshold(uint32_t thresh);
+
+ /// @brief This function returns the fixed amplitude threshold value.
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 100000
+ /// @param thresh Fixed amplitude threshold value
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistanceFixedAmpThreshold(uint32_t &thresh);
+
+ /// @brief This function sets the fixed amplitude threshold value.
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 100000
+ /// @param thresh Fixed amplitude threshold value
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setDistanceFixedAmpThreshold(uint32_t thresh);
+
+ /// @brief This function returns the threshold sensitivity
+ /// (0 <= sensitivity <= 1000)
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 500
+ /// @param thresh& Threshold sensitivity
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistanceThresholdSensitivity(uint32_t &thresh);
+
+ /// @brief This function sets the threshold sensitivity
+ /// (0 <= sensitivity <= 1000)
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 500
+ /// @param thresh Threshold sensitivity
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setDistanceThresholdSensitivity(uint32_t thresh);
+
+ /// @brief This function returns the reflector shape
+ /// Default Value: GENERIC
+ /// @param shape Generic or planar reflection
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistanceReflectorShape(uint32_t &shape);
+
+ /// @brief This function sets the reflector shape
+ /// Default Value: GENERIC
+ /// @param shape Generic or planar reflection
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setDistanceReflectorShape(uint32_t shape);
+
+ /// @brief This function returns the fixed strength threshold value.
+ /// Default Value: 0
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// @param thresh fixed threshold strength value
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistanceFixedStrengthThresholdValue(int32_t &thresh);
+
+ /// @brief This function sets the fixed strength threshold value.
+ /// Default Value: 0
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// @param thresh fixed threshold strength value
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setDistanceFixedStrengthThresholdValue(int32_t thresh);
+
+ /// @brief This function returns the measure on wakeup status.
+ /// Default Value: false
+ /// @param measure Measure on wakeup occurrence
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getDistanceMeasureOneWakeup(bool &measure);
+
+ /// @brief This function sets the measure on wakeup status.
+ /// Default Value: false
+ /// @param measure Measure on wakeup occurrence
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setDistanceMeasureOneWakeup(bool measure);
+
+ /// @brief This function sets the specific execute command as defined in the
+ /// datasheet on Page 25, Section 6.2.40 Command.
+ /// @param apply Enable configuration and calibrate
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setDistanceCommand(uint32_t command);
+
+ /// @brief This function applies the configuration to the device by
+ /// writing the defined value to the distance command register
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t distanceApplyConfiguration();
+
+ /// @brief This function starts the device by writing the defined
+ /// start value to the distance command register
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t distanceStart();
+
+ /// @brief This function stops the device by writing the defined
+ /// stop value to the distance command register
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t distanceStop();
+
+ /// @brief This function calibrates the device by writing the defined
+ /// calibration value to the distance command register
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t distanceCalibrate();
+
+ /// @brief This function recalibrates the device by writing the defined
+ /// recalibrate value to the distance command register
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t distanceRecalibrate();
+
+ /// @brief This function enables the uart logs of the device by
+ /// writing the defined value to the distance command register
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t distanceEnableUartLogs();
+
+ /// @brief This function disables the uart logs of the device by
+ /// writing the defined value to the distance command register
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t distanceDisableUartLogs();
+
+ /// @brief This function enables the configuration log of the device
+ /// by writing the defined value to the distance command register
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t distanceLogConfiguration();
+
+ /// @brief This function resets the distance detector settings
+ /// of the device
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t distanceReset();
+
+ /// @brief Completes a busy wait loop while the device is uploading
+ /// information by waiting for the status
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t distanceBusyWait();
+};
\ No newline at end of file
diff --git a/src/sfTk/sfDevXM125Presence.cpp b/src/sfTk/sfDevXM125Presence.cpp
new file mode 100644
index 0000000..7092457
--- /dev/null
+++ b/src/sfTk/sfDevXM125Presence.cpp
@@ -0,0 +1,637 @@
+/**
+ * @file sfDevXM125Presence.cpp
+ * @brief Implementation of the SparkFun Qwiic XM125 Library.
+ *
+ * This file contains the implementation of the class for the presence detection functionality.
+ *
+ * @author SparkFun Electronics
+ * @date 2024-2025
+ * @copyright Copyright (c) 2024-2025, SparkFun Electronics Inc. This project is released under the MIT License.
+ *
+ * SPDX-License-Identifier: MIT
+ */
+#include "sfDevXM125Presence.h"
+
+sfTkError_t sfDevXM125Presence::begin(sfTkII2C *theBus)
+{
+ // call super to get the device connection working
+ sfTkError_t retVal = sfDevXM125Core::begin(theBus);
+ if (retVal != ksfTkErrOk)
+ return retVal;
+
+ // Check errors from device application
+ uint32_t presenceError = 0;
+ retVal = getPresenceDetectorError(presenceError);
+ if (retVal != ksfTkErrOk)
+ return retVal;
+
+ // Additional checks for presence errors
+ if (presenceError != 0)
+ return ksfTkErrFail; // Indicating presence error
+
+ return ksfTkErrOk;
+}
+//-------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::presenceDetectorStart(uint32_t startValue, uint32_t endValue)
+{
+ // *** Presence Sensor Setup ***
+ uint32_t errorStatus = 0;
+
+ // Reset sensor configuration to reapply configuration registers
+ if (setPresenceCommand(SFE_XM125_PRESENCE_RESET_MODULE) != ksfTkErrOk)
+ return 1;
+
+ sftk_delay_ms(100); // give time for command to set
+
+ // Check detector status error and busy bits
+ if (getPresenceDetectorErrorStatus(errorStatus) != ksfTkErrOk)
+ return 2;
+
+ if (errorStatus != 0)
+ return 3;
+
+ // Set Presence Start register
+ if (setPresenceStart(startValue) != ksfTkErrOk)
+ return 4;
+
+ sftk_delay_ms(100); // give time for command to set
+
+ // Set End register
+ if (setPresenceEnd(endValue) != ksfTkErrOk)
+ return 5;
+
+ sftk_delay_ms(100); // give time for command to set
+
+ // Apply configuration
+ if (setPresenceCommand(SFE_XM125_PRESENCE_APPLY_CONFIGURATION) != ksfTkErrOk)
+ {
+ // Check for errors
+ getPresenceDetectorErrorStatus(errorStatus);
+ return errorStatus != 0 ? 6 : 7;
+ }
+
+ sftk_delay_ms(100); // give time for command to set
+
+ // Poll detector status until busy bit is cleared
+ if (presenceBusyWait() != ksfTkErrOk)
+ return 8;
+
+ // Check detector error status
+ sfTkError_t retVal = getPresenceDetectorErrorStatus(errorStatus);
+ if (retVal != ksfTkErrOk || errorStatus != 0)
+ return 9;
+
+ // If no errors, return 0
+ return ksfTkErrOk;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceDistanceValuemm(uint32_t &presenceVal)
+{
+ // Check error bits
+ uint32_t errorStatus = 0;
+ uint32_t presenceStatus = 0;
+
+ sfTkError_t retVal = getPresenceDetectorErrorStatus(errorStatus);
+ if (retVal != ksfTkErrOk || errorStatus != 0)
+ return ksfTkErrFail;
+
+ // Start detector
+ if (setPresenceCommand(SFE_XM125_PRESENCE_START_DETECTOR) != ksfTkErrOk)
+ return ksfTkErrFail;
+
+ sftk_delay_ms(100);
+
+ // Poll detector status until busy bit is cleared
+ if (presenceBusyWait() != ksfTkErrOk)
+ return ksfTkErrFail;
+
+ // Verify that no error bits are set in the detector status register
+ retVal = getPresenceDetectorErrorStatus(errorStatus);
+ if (retVal != ksfTkErrOk || errorStatus != 0)
+ return ksfTkErrFail;
+
+ // Read from 16-Bit Register to get the presence detection status
+ if (_theBus->readRegister(SFE_XM125_PRESENCE_RESULT, presenceStatus) != ksfTkErrOk)
+ return ksfTkErrFail;
+
+ // Presence detected NOW or since last check (sticky)
+ bool bPresenceDetected = ((presenceStatus & SFE_XM125_PRESENCE_DETECTED_MASK) != 0) ||
+ ((presenceStatus & SFE_XM125_PRESENCE_DETECTED_STICKY_MASK) != 0);
+
+ // If presence or a sticky presence is detected, get the distance and return
+ if (bPresenceDetected)
+ return getPresenceDistance(presenceVal);
+
+ // If no presence detected, return 0
+ presenceVal = 0;
+ return ksfTkErrOk;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceDetectorVersion(uint32_t &major, uint32_t &minor, uint32_t &patch)
+{
+ sfTkError_t retVal;
+ uint32_t regVal = 0;
+
+ // Read from 16-Bit Register
+ size_t readBytes = 0;
+ retVal = _theBus->readRegister(SFE_XM125_PRESENCE_VERSION, (uint8_t *)®Val, sizeof(regVal), readBytes);
+
+ // Mask unused bits from register
+ major = (regVal & SFE_XM125_PRESENCE_MAJOR_VERSION_MASK) >> SFE_XM125_PRESENCE_MAJOR_VERSION_MASK_SHIFT;
+ minor = (regVal & SFE_XM125_PRESENCE_MINOR_VERSION_MASK) >> SFE_XM125_PRESENCE_MINOR_VERSION_MASK_SHIFT;
+ patch = regVal & SFE_XM125_PRESENCE_PATCH_VERSION_MASK;
+
+ return retVal;
+}
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceDetectorError(uint32_t &error)
+{
+ return _theBus->readRegister(SFE_XM125_PRESENCE_PROTOCOL_STATUS, error);
+}
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceMeasureCounter(uint32_t &counter)
+{
+ return _theBus->readRegister(SFE_XM125_PRESENCE_MEASURE_COUNTER, counter);
+}
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceDetectorStatus(uint32_t &status)
+{
+ return _theBus->readRegister(SFE_XM125_PRESENCE_DETECTOR_STATUS, status);
+}
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceDetectorErrorStatus(uint32_t &status)
+{
+ sfTkError_t retVal = 0;
+ uint32_t regVal = 0;
+ retVal = _theBus->readRegister(SFE_XM125_PRESENCE_DETECTOR_STATUS, regVal);
+
+ // clear out status
+ status = 0;
+
+ if (retVal != ksfTkErrOk)
+ return retVal;
+ // Any errors - if not, skip the big bit check pachinko if-else below
+ if ((regVal & SFE_XM125_PRESENCE_ALL_ERROR_MASK) == 0)
+ return ksfTkErrOk;
+
+ // Check for errors
+ if (SFTK_CHECK_BITS_SET(regVal, SFE_XM125_PRESENCE_RSS_REGISTER_ERROR_MASK))
+ status = 1;
+
+ else if (SFTK_CHECK_BITS_SET(regVal, SFE_XM125_PRESENCE_CONFIG_CREATE_ERROR_MASK))
+ status = 2;
+
+ else if (SFTK_CHECK_BITS_SET(regVal, SFE_XM125_PRESENCE_SENSOR_CREATE_ERROR_MASK))
+ status = 3;
+
+ else if (SFTK_CHECK_BITS_SET(regVal, SFE_XM125_PRESENCE_SENSOR_CALIBRATE_ERROR_MASK))
+ status = 4;
+
+ else if (SFTK_CHECK_BITS_SET(regVal, SFE_XM125_PRESENCE_DETECTOR_CREATE_ERROR_MASK))
+ status = 5;
+
+ else if (SFTK_CHECK_BITS_SET(regVal, SFE_XM125_PRESENCE_DETECTOR_BUFFER_ERROR_MASK))
+ status = 6;
+
+ else if (SFTK_CHECK_BITS_SET(regVal, SFE_XM125_PRESENCE_SENSOR_BUFFER_ERROR_MASK))
+ status = 7;
+
+ else if (SFTK_CHECK_BITS_SET(regVal, SFE_XM125_PRESENCE_CONFIG_APPLY_ERROR_MASK))
+ status = 8;
+
+ else if (SFTK_CHECK_BITS_SET(regVal, SFE_XM125_PRESENCE_DETECTOR_REG_ERROR_MASK))
+ status = 9;
+
+ else if (SFTK_CHECK_BITS_SET(regVal, SFE_XM125_PRESENCE_DETECTOR_ERROR_MASK))
+ status = 10;
+
+ else if (SFTK_CHECK_BITS_SET(regVal, SFE_XM125_PRESENCE_BUSY_MASK))
+ status = 11;
+
+ // return 0 with no errors
+ return ksfTkErrOk;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceDetectorPresenceDetected(uint32_t &detected)
+{
+ // Read from 16-Bit Register
+ sfTkError_t retVal = _theBus->readRegister(SFE_XM125_PRESENCE_RESULT, detected);
+
+ // Mask unused bits from register
+ if (retVal == ksfTkErrOk)
+ detected = (detected & SFE_XM125_PRESENCE_DETECTED_MASK);
+
+ return retVal;
+}
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceDetectorPresenceStickyDetected(uint32_t &sticky)
+{
+
+ // Read from 16-Bit Register
+ sfTkError_t retVal = _theBus->readRegister(SFE_XM125_PRESENCE_RESULT, sticky);
+
+ // Mask unused bits from register
+ if (retVal == ksfTkErrOk)
+ sticky = (sticky & SFE_XM125_PRESENCE_DETECTED_STICKY_MASK) >> 1;
+
+ return retVal;
+}
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceDetectorRegError(uint32_t &error)
+{
+ sfTkError_t retVal = _theBus->readRegister(SFE_XM125_PRESENCE_RESULT, error);
+
+ // Mask unused bits from register
+ if (retVal == ksfTkErrOk)
+ error = (error & SFE_XM125_PRESENCE_DETECTOR_ERROR_MASK) >> SFE_XM125_PRESENCE_DETECTOR_ERROR_MASK_SHIFT;
+
+ return retVal;
+}
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceTemperature(uint32_t &temp)
+{
+ sfTkError_t retVal = _theBus->readRegister(SFE_XM125_PRESENCE_DISTANCE, temp);
+
+ // Mask unused bits from register
+ temp = (temp & SFE_XM125_PRESENCE_TEMPERATURE_MASK) >> SFE_XM125_PRESENCE_TEMPERATURE_MASK_SHIFT;
+
+ return retVal;
+}
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceDistance(uint32_t &distance)
+{
+ return _theBus->readRegister(SFE_XM125_PRESENCE_DISTANCE, distance);
+}
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceIntraPresenceScore(uint32_t &intra)
+{
+ return _theBus->readRegister(SFE_XM125_INTRA_PRESENCE_SCORE, intra);
+}
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceInterPresenceScore(uint32_t &inter)
+{
+ return _theBus->readRegister(SFE_XM125_INTER_PRESENCE, inter);
+}
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceSweepsPerFrame(uint32_t &sweeps)
+{
+ return _theBus->readRegister(SFE_XM125_PRESENCE_SWEEPS_PER_FRAME, sweeps);
+}
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::setPresenceSweepsPerFrame(uint32_t sweeps)
+{
+ return _theBus->writeRegister(SFE_XM125_PRESENCE_SWEEPS_PER_FRAME, sweeps);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceInterFramePresenceTimeout(uint32_t &time)
+{
+ return _theBus->readRegister(SFE_XM125_PRESENCE_INTER_FRAME_TIMEOUT, time);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::setPresenceInterFramePresenceTimeout(uint32_t time)
+{
+ return _theBus->writeRegister(SFE_XM125_PRESENCE_INTER_FRAME_TIMEOUT, time);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceInterPhaseBoostEnabled(bool &en)
+{
+ size_t readBytes = 0;
+ uint8_t value;
+ sfTkError_t retVal = _theBus->readRegister(SFE_XM125_PRESENCE_INTER_PHASE_BOOST_ENABLED, (uint8_t *)&value,
+ sizeof(uint8_t), readBytes);
+ en = (value != 0);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::setPresenceInterPhaseBoostEnabled(bool en)
+{
+ uint8_t value = en ? 1 : 0;
+ return _theBus->writeRegisterUInt8(SFE_XM125_PRESENCE_INTER_PHASE_BOOST_ENABLED, value);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceIntraDetectionEnabled(bool &en)
+{
+ uint8_t value;
+ sfTkError_t retVal = _theBus->readRegisterUInt8(SFE_XM125_PRESENCE_INTRA_DETECTION_ENABLED, value);
+
+ en = (value != 0);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::setPresenceInterDetectionEnabled(bool en)
+{
+ uint8_t value = en ? 1 : 0;
+ return _theBus->writeRegister(SFE_XM125_PRESENCE_INTRA_DETECTION_ENABLED, (uint8_t *)&value, sizeof(uint8_t));
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceFrameRate(uint32_t &rate)
+{
+ return _theBus->readRegister(SFE_XM125_PRESENCE_FRAME_RATE, rate);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::setPresenceFrameRate(uint32_t rate)
+{
+ return _theBus->writeRegister(SFE_XM125_PRESENCE_FRAME_RATE, rate);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceIntraDetectionThreshold(uint32_t &thresh)
+{
+ return _theBus->readRegister(SFE_XM125_PRESENCE_INTRA_DETECTION_THRESHOLD, thresh);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::setPresenceIntraDetectionThreshold(uint32_t thresh)
+{
+ return _theBus->writeRegister(SFE_XM125_PRESENCE_INTRA_DETECTION_THRESHOLD, thresh);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceInterDetectionThreshold(uint32_t &thresh)
+{
+ return _theBus->readRegister(SFE_XM125_PRESENCE_INTER_DETECTION_THRESHOLD, thresh);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::setPresenceInterDetectionThreshold(uint32_t thresh)
+{
+ return _theBus->writeRegister(SFE_XM125_PRESENCE_INTER_DETECTION_THRESHOLD, thresh);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceInterFrameDeviationTime(uint32_t &time)
+{
+ return _theBus->readRegister(SFE_XM125_PRESENCE_INTER_FRAME_DEVIATION, time);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::setPresenceInterFrameDeviationTime(uint32_t time)
+{
+ return _theBus->writeRegister(SFE_XM125_PRESENCE_INTER_FRAME_DEVIATION, time);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceInterFrameFastCutoff(uint32_t &cut)
+{
+ return _theBus->readRegister(SFE_XM125_PRESENCE_INTER_FRAME_FAST_CUTOFF, cut);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::setPresenceInterFrameFastCutoff(uint32_t cut)
+{
+ return _theBus->writeRegister(SFE_XM125_PRESENCE_INTER_FRAME_FAST_CUTOFF, cut);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceInterFrameSlowCutoff(uint32_t &cut)
+{
+ return _theBus->readRegister(SFE_XM125_PRESENCE_INTER_FRAME_SLOW_CUTOFF, cut);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::setPresenceInterFrameSlowCutoff(uint32_t cut)
+{
+ return _theBus->writeRegister(SFE_XM125_PRESENCE_INTER_FRAME_SLOW_CUTOFF, cut);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceIntraFrameTimeConst(uint32_t &time)
+{
+ return _theBus->readRegister(SFE_XM125_PRESENCE_INTRA_FRAME_TIME_CONST, time);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::setPresenceIntraFrameTimeConst(uint32_t time)
+{
+ return _theBus->writeRegister(SFE_XM125_PRESENCE_INTRA_FRAME_TIME_CONST, time);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceIntraOutputTimeConst(uint32_t &time)
+{
+ return _theBus->readRegister(SFE_XM125_PRESENCE_INTRA_OUTPUT_TIME_CONST, time);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::setPresenceIntraOutputTimeConst(uint32_t time)
+{
+ return _theBus->writeRegister(SFE_XM125_PRESENCE_INTRA_OUTPUT_TIME_CONST, time);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceInterOutputTimeConst(uint32_t &time)
+{
+ return _theBus->readRegister(SFE_XM125_PRESENCE_INTER_OUTPUT_TIME_CONST, time);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::setPresenceInterOutputTimeConst(uint32_t time)
+{
+ return _theBus->writeRegister(SFE_XM125_PRESENCE_INTER_OUTPUT_TIME_CONST, time);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceAutoProfileEn(bool &en)
+{
+ size_t readBytes = 0;
+ uint8_t value;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_PRESENCE_AUTO_PROFILE_ENABLED, (uint8_t *)&value, sizeof(uint8_t), readBytes);
+ en = (value != 0);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::setPresenceAutoProfileEn(bool en)
+{
+ uint8_t value = en ? 1 : 0;
+ return _theBus->writeRegister(SFE_XM125_PRESENCE_AUTO_PROFILE_ENABLED, (uint8_t *)&value, sizeof(uint8_t));
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceAutoStepLengthEn(bool &en)
+{
+ size_t readBytes = 0;
+ uint8_t value;
+ sfTkError_t retVal = _theBus->readRegister(SFE_XM125_PRESENCE_AUTO_STEP_LENGTH_ENABLED, (uint8_t *)&value,
+ sizeof(uint8_t), readBytes);
+ en = (value != 0);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::setPresenceAutoStepLengthEn(bool en)
+{
+ uint8_t value = en ? 1 : 0;
+ return _theBus->writeRegister(SFE_XM125_PRESENCE_AUTO_STEP_LENGTH_ENABLED, (uint8_t *)&value, sizeof(uint8_t));
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceManualProfile(uint32_t &prof)
+{
+ return _theBus->readRegister(SFE_XM125_PRESENCE_MANUAL_PROFILE, prof);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::setPresenceManualProfile(uint32_t prof)
+{
+ return _theBus->writeRegister(SFE_XM125_PRESENCE_MANUAL_PROFILE, prof);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceManualStepLength(uint32_t &length)
+{
+ return _theBus->readRegister(SFE_XM125_PRESENCE_MANUAL_STEP_LENGTH, length);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::setPresenceManualStepLength(uint32_t length)
+{
+ return _theBus->writeRegister(SFE_XM125_PRESENCE_MANUAL_STEP_LENGTH, length);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceStart(uint32_t &start)
+{
+ return _theBus->readRegister(SFE_XM125_PRESENCE_START, start);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::setPresenceStart(uint32_t start)
+{
+ return _theBus->writeRegister(SFE_XM125_PRESENCE_START, start);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceEnd(uint32_t &end)
+{
+ return _theBus->readRegister(SFE_XM125_PRESENCE_END, end);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::setPresenceEnd(uint32_t end)
+{
+ return _theBus->writeRegister(SFE_XM125_PRESENCE_END, end);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceResetFilters(bool &reset)
+{
+
+ size_t readBytes = 0;
+ uint8_t value;
+ sfTkError_t retVal =
+ _theBus->readRegister(SFE_XM125_PRESENCE_RESET_FILTERS_ON_PREPARE, &value, sizeof(uint8_t), readBytes);
+ reset = (value != 0);
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::setPresenceResetFilters(bool reset)
+{
+ uint8_t value = reset ? 1 : 0;
+ return _theBus->writeRegister(SFE_XM125_PRESENCE_RESET_FILTERS_ON_PREPARE, &value, sizeof(uint8_t));
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceHWAAS(uint32_t &avg)
+{
+ return _theBus->readRegister(SFE_XM125_PRESENCE_HWAAS, avg);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::setPresenceHWAAS(uint32_t avg)
+{
+ return _theBus->writeRegister(SFE_XM125_PRESENCE_HWAAS, avg);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceDetectionOnGPIO(uint32_t &detected)
+{
+ return _theBus->readRegister(SFE_XM125_PRESENCE_DETECTION_ON_GPIO, detected);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::setPresenceDetectionOnGPIO(uint32_t detected)
+{
+ return _theBus->writeRegister(SFE_XM125_PRESENCE_DETECTION_ON_GPIO, detected);
+}
+
+sfTkError_t sfDevXM125Presence::setPresenceCommand(uint32_t cmd)
+{
+ return _theBus->writeRegister(SFE_XM125_PRESENCE_COMMAND, cmd);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::presenceApplyConfiguration()
+{
+ return setPresenceCommand(SFE_XM125_PRESENCE_START_DETECTOR);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::presenceStart()
+{
+ return setPresenceCommand(SFE_XM125_PRESENCE_START_DETECTOR);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::presenceStop()
+{
+ return setPresenceCommand(SFE_XM125_PRESENCE_STOP_DETECTOR);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::presenceEnableUartLogs()
+{
+ return setPresenceCommand(SFE_XM125_PRESENCE_ENABLE_UART_LOGS);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::presenceDisableUartLogs()
+{
+ return setPresenceCommand(SFE_XM125_PRESENCE_DISABLE_UART_LOGS);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::presenceLogConfiguration()
+{
+ return setPresenceCommand(SFE_XM125_PRESENCE_LOG_CONFIGURATION);
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::getPresenceBusy(uint32_t &busy)
+{
+ // Read from 16-Bit Register
+
+ sfTkError_t retVal = _theBus->readRegister(SFE_XM125_PRESENCE_DETECTOR_STATUS, busy);
+
+ // Mask unused bits from register
+ busy = (busy & SFE_XM125_PRESENCE_BUSY_MASK) >> SFE_XM125_PRESENCE_BUSY_MASK_SHIFT;
+
+ return retVal;
+}
+
+//--------------------------------------------------------------------------------
+sfTkError_t sfDevXM125Presence::presenceBusyWait()
+{
+ uint32_t regVal = 0;
+
+ sfTkError_t retVal = _theBus->readRegister(SFE_XM125_PRESENCE_DETECTOR_STATUS, regVal);
+
+ // Poll Detector Status until Busy bit is cleared
+ while (((regVal & SFE_XM125_PRESENCE_BUSY_MASK) >> 30) != 0)
+ retVal = _theBus->readRegister(SFE_XM125_PRESENCE_DETECTOR_STATUS, regVal);
+
+ return retVal;
+}
\ No newline at end of file
diff --git a/src/sfTk/sfDevXM125Presence.h b/src/sfTk/sfDevXM125Presence.h
new file mode 100644
index 0000000..41fa9a0
--- /dev/null
+++ b/src/sfTk/sfDevXM125Presence.h
@@ -0,0 +1,707 @@
+/**
+ * @file sfDevXM125Presence.h
+ * @brief Header of the SparkFun Qwiic XM125 Library.
+ *
+ * This file contains the header the Presence Application object
+ *
+ * @author SparkFun Electronics
+ * @date 2024-2025
+ * @copyright Copyright (c) 2024-2025, SparkFun Electronics Inc. This project is released under the MIT License.
+ *
+ * SPDX-License-Identifier: MIT
+ */
+#pragma once
+
+#include "sfDevXM125Core.h"
+
+// Defines
+
+// defines and data structs
+/* ****************************** Presence Values ****************************** */
+
+const uint32_t SFE_XM125_PRESENCE_DETECTOR_STATUS_MASK = 0b10010000111111110000000011111111;
+
+const uint32_t SFE_XM125_PRESENCE_DETECTED_MASK = 0x00000001;
+const uint32_t SFE_XM125_PRESENCE_DETECTED_STICKY_MASK = 0x00000002;
+const uint32_t SFE_XM125_PRESENCE_DETECTOR_ERROR_MASK = 0x00008000;
+const uint32_t SFE_XM125_PRESENCE_TEMPERATURE_MASK = 0xffff0000;
+const uint32_t SFE_XM125_PRESENCE_MAJOR_VERSION_MASK = 0xffff0000;
+const uint32_t SFE_XM125_PRESENCE_MINOR_VERSION_MASK = 0x0000ff00;
+const uint32_t SFE_XM125_PRESENCE_PATCH_VERSION_MASK = 0x000000ff;
+
+const uint32_t SFE_XM125_PRESENCE_RSS_REGISTER_OK_MASK = 0x00000001;
+const uint32_t SFE_XM125_PRESENCE_CONFIG_CREATE_OK_MASK = 0x00000002;
+const uint32_t SFE_XM125_PRESENCE_SENSOR_CREATE_OK_MASK = 0x00000004;
+const uint32_t SFE_XM125_PRESENCE_SENSOR_CALIBRATE_OK_MASK = 0x00000008;
+const uint32_t SFE_XM125_PRESENCE_DETECTOR_CREATE_OK_MASK = 0x00000010;
+const uint32_t SFE_XM125_PRESENCE_DETECTOR_BUFFER_OK_MASK = 0x00000020;
+const uint32_t SFE_XM125_PRESENCE_SENSOR_BUFFER_OK_MASK = 0x00000040;
+const uint32_t SFE_XM125_PRESENCE_CONFIG_APPLY_OK_MASK = 0x00000080;
+const uint32_t SFE_XM125_PRESENCE_RSS_REGISTER_ERROR_MASK = 0x00010000;
+const uint32_t SFE_XM125_PRESENCE_CONFIG_CREATE_ERROR_MASK = 0x00020000;
+const uint32_t SFE_XM125_PRESENCE_SENSOR_CREATE_ERROR_MASK = 0x00040000;
+const uint32_t SFE_XM125_PRESENCE_SENSOR_CALIBRATE_ERROR_MASK = 0x00080000;
+const uint32_t SFE_XM125_PRESENCE_DETECTOR_CREATE_ERROR_MASK = 0x00100000;
+const uint32_t SFE_XM125_PRESENCE_DETECTOR_BUFFER_ERROR_MASK = 0x00200000;
+const uint32_t SFE_XM125_PRESENCE_SENSOR_BUFFER_ERROR_MASK = 0x00400000;
+const uint32_t SFE_XM125_PRESENCE_CONFIG_APPLY_ERROR_MASK = 0x00800000;
+const uint32_t SFE_XM125_PRESENCE_DETECTOR_REG_ERROR_MASK = 0x10000000;
+const uint32_t SFE_XM125_PRESENCE_BUSY_MASK = 0x80000000;
+
+const uint32_t SFE_XM125_PRESENCE_ALL_ERROR_MASK =
+ (SFE_XM125_PRESENCE_RSS_REGISTER_ERROR_MASK | SFE_XM125_PRESENCE_CONFIG_CREATE_ERROR_MASK |
+ SFE_XM125_PRESENCE_SENSOR_CREATE_ERROR_MASK | SFE_XM125_PRESENCE_SENSOR_CALIBRATE_ERROR_MASK |
+ SFE_XM125_PRESENCE_DETECTOR_CREATE_ERROR_MASK | SFE_XM125_PRESENCE_DETECTOR_BUFFER_ERROR_MASK |
+ SFE_XM125_PRESENCE_SENSOR_BUFFER_ERROR_MASK | SFE_XM125_PRESENCE_CONFIG_APPLY_ERROR_MASK |
+ SFE_XM125_PRESENCE_DETECTOR_REG_ERROR_MASK | SFE_XM125_PRESENCE_DETECTOR_ERROR_MASK |
+ SFE_XM125_PRESENCE_BUSY_MASK);
+
+const uint32_t SFE_XM125_PRESENCE_MAJOR_VERSION_MASK_SHIFT = 16;
+const uint32_t SFE_XM125_PRESENCE_MINOR_VERSION_MASK_SHIFT = 8;
+const uint32_t SFE_XM125_PRESENCE_RSS_REGISTER_ERROR_MASK_SHIFT = 15;
+const uint32_t SFE_XM125_PRESENCE_CONFIG_CREATE_ERROR_MASK_SHIFT = 16;
+const uint32_t SFE_XM125_PRESENCE_SENSOR_CREATE_ERROR_MASK_SHIFT = 17;
+const uint32_t SFE_XM125_PRESENCE_SENSOR_CALIBRATE_ERROR_MASK_SHIFT = 18;
+const uint32_t SFE_XM125_PRESENCE_DETECTOR_CREATE_ERROR_MASK_SHIFT = 19;
+const uint32_t SFE_XM125_PRESENCE_DETECTOR_BUFFER_ERROR_MASK_SHIFT = 20;
+const uint32_t SFE_XM125_PRESENCE_SENSOR_BUFFER_ERROR_MASK_SHIFT = 21;
+const uint32_t SFE_XM125_PRESENCE_CONFIG_APPLY_ERROR_MASK_SHIFT = 22;
+const uint32_t SFE_XM125_PRESENCE_DETECTOR_REG_ERROR_MASK_SHIFT = 27;
+const uint32_t SFE_XM125_PRESENCE_DETECTOR_ERROR_MASK_SHIFT = 14;
+const uint32_t SFE_XM125_PRESENCE_TEMPERATURE_MASK_SHIFT = 16;
+const uint32_t SFE_XM125_PRESENCE_BUSY_MASK_SHIFT = 30;
+
+const uint16_t SFE_XM125_PRESENCE_VERSION = 0x00;
+typedef struct
+{
+ uint32_t presence_major : 16;
+ uint32_t presence_minor : 8;
+ uint32_t presence_patch : 8;
+} sfe_xm125_presence_version_t;
+
+const uint16_t SFE_XM125_PRESENCE_PROTOCOL_STATUS = 0x01;
+typedef struct
+{
+ uint32_t presence_protocol_state_error : 1;
+ uint32_t presence_packet_length_error : 1;
+ uint32_t presence_address_error : 1;
+ uint32_t presence_write_failed : 1;
+ uint32_t presence_write_to_read_only : 1;
+ uint32_t reserved1 : 27;
+} sfe_xm125_presence_protocol_status_t;
+
+const uint16_t SFE_XM125_PRESENCE_MEASURE_COUNTER = 0x02;
+
+const uint16_t SFE_XM125_PRESENCE_DETECTOR_STATUS = 0x03;
+typedef struct
+{
+ uint32_t presence_rss_register_ok : 1;
+ uint32_t presence_config_create_ok : 1;
+ uint32_t presence_sensor_create_ok : 1;
+ uint32_t presence_sensor_calibrate_ok : 1;
+ uint32_t presence_detector_create_ok : 1;
+ uint32_t presence_detector_buffer_ok : 1;
+ uint32_t presence_sensor_buffer_ok : 1;
+ uint32_t presence_config_apply_ok : 1;
+ uint32_t reserved1 : 8;
+ uint32_t presence_rss_register_error : 1;
+ uint32_t presence_config_create_error : 1;
+ uint32_t presence_sensor_create_error : 1;
+ uint32_t presence_sensor_calibrate_error : 1;
+ uint32_t presence_detector_create_error : 1;
+ uint32_t presence_detector_buffer_error : 1;
+ uint32_t presence_sensor_buffer_error : 1;
+ uint32_t presence_config_apply_error : 1;
+ uint32_t reserved2 : 4;
+ uint32_t presence_detector_error : 1;
+ uint32_t reserved3 : 2;
+ uint32_t presence_busy : 1;
+
+} sfe_xm125_presence_detector_status_t;
+
+const uint16_t SFE_XM125_PRESENCE_RESULT = 0x10;
+typedef struct
+{
+ uint32_t presence_detected : 1;
+ uint32_t presence_detected_sticky : 1;
+ uint32_t reserved1 : 13;
+ uint32_t presence_detector_error : 1;
+ uint32_t presence_temperature : 16;
+} sfe_xm125_presence_result_t;
+
+const uint16_t SFE_XM125_PRESENCE_DISTANCE = 0x11;
+const uint16_t SFE_XM125_INTRA_PRESENCE_SCORE = 0x12;
+const uint16_t SFE_XM125_INTER_PRESENCE = 0x13;
+
+const uint16_t SFE_XM125_PRESENCE_SWEEPS_PER_FRAME = 0x40;
+const uint16_t sfe_xm125_presence_sweeps_per_frame_default = 16;
+
+const uint16_t SFE_XM125_PRESENCE_INTER_FRAME_TIMEOUT = 0x41;
+const uint16_t sfe_xm125_presence_inter_frame_timeout_default = 3;
+
+const uint16_t SFE_XM125_PRESENCE_INTER_PHASE_BOOST_ENABLED = 0x42;
+const bool sfe_xm125_presence_inter_phase_boost_enabled_default = false;
+
+const uint16_t SFE_XM125_PRESENCE_INTRA_DETECTION_ENABLED = 0x43;
+const bool sfe_xm125_presence_intra_detection_enabled_default = true;
+
+const uint16_t SFE_XM125_PRESENCE_INTER_DETECTION_ENABLED = 0x44;
+const bool sfe_xm125_presence_inter_detection_enabled_default = true;
+
+const uint16_t SFE_XM125_PRESENCE_FRAME_RATE = 0x45;
+const uint16_t sfe_xm125_presence_frame_rate_default = 12000;
+
+const uint16_t SFE_XM125_PRESENCE_INTRA_DETECTION_THRESHOLD = 0x46;
+const uint16_t sfe_xm125_presence_intra_detection_threshold_default = 1300;
+
+const uint16_t SFE_XM125_PRESENCE_INTER_DETECTION_THRESHOLD = 0x47;
+const uint16_t sfe_xm125_presence_inter_detection_threshold_default = 1000;
+
+const uint16_t SFE_XM125_PRESENCE_INTER_FRAME_DEVIATION = 0x48;
+const uint16_t sfe_xm125_presence_inter_frame_deviation_default = 500;
+
+const uint16_t SFE_XM125_PRESENCE_INTER_FRAME_FAST_CUTOFF = 0x49;
+const uint16_t sfe_xm125_presence_inter_frame_fast_cutoff_default = 6000;
+
+const uint16_t SFE_XM125_PRESENCE_INTER_FRAME_SLOW_CUTOFF = 0x4a;
+const uint16_t sfe_xm125_presence_inter_frame_slow_cutoff_default = 200;
+
+const uint16_t SFE_XM125_PRESENCE_INTRA_FRAME_TIME_CONST = 0x4b;
+const uint16_t sfe_xm125_presence_intra_frame_time_const_default = 150;
+
+const uint16_t SFE_XM125_PRESENCE_INTRA_OUTPUT_TIME_CONST = 0x4c;
+const uint16_t sfe_xm125_presence_intra_output_time_const_default = 300;
+
+const uint16_t SFE_XM125_PRESENCE_INTER_OUTPUT_TIME_CONST = 0x4d;
+const uint16_t sfe_xm125_presence_inter_output_time_const_default = 2000;
+
+const uint16_t SFE_XM125_PRESENCE_AUTO_PROFILE_ENABLED = 0x4e;
+const bool sfe_xm125_presence_auto_profile_enabled_default = true;
+
+const uint16_t SFE_XM125_PRESENCE_AUTO_STEP_LENGTH_ENABLED = 0x4f;
+const bool sfe_xm125_presence_auto_step_length_enabled_default = true;
+
+const uint16_t SFE_XM125_PRESENCE_MANUAL_PROFILE = 0x50;
+typedef enum
+{
+ XM125_PRESENCE_PROFILE1 = 1,
+ XM125_PRESENCE_PROFILE2 = 2,
+ XM125_PRESENCE_PROFILE3 = 3,
+ XM125_PRESENCE_PROFILE4 = 4,
+ XM125_PRESENCE_PROFILE5 = 5,
+} sfe_xm125_presence_manual_profile_t;
+
+const uint16_t SFE_XM125_PRESENCE_MANUAL_STEP_LENGTH = 0x51;
+const uint16_t sfe_xm125_presence_manual_step_length_default = 72;
+
+const uint16_t SFE_XM125_PRESENCE_START = 0x52;
+const uint16_t sfe_xm125_presence_start_default = 250;
+
+const uint16_t SFE_XM125_PRESENCE_END = 0x53;
+const uint16_t sfe_xm125_presence_end_default = 2500;
+
+const uint16_t SFE_XM125_PRESENCE_RESET_FILTERS_ON_PREPARE = 0x54;
+const bool sfe_xm125_presence_reset_filters_on_prepare_default = true;
+
+const uint16_t SFE_XM125_PRESENCE_HWAAS = 0x55;
+const uint16_t sfe_xm125_presence_hwaas_default = 32;
+
+const uint16_t SFE_XM125_PRESENCE_DETECTION_ON_GPIO = 0x80;
+const bool sfe_xm125_presence_detection_on_gpio_default = false;
+
+const uint16_t SFE_XM125_PRESENCE_COMMAND = 0x100;
+typedef enum
+{
+ XM125_PRESENCE_APPLY_CONFIGURATION = 1,
+ XM125_PRESENCE_START_DETECTOR = 2,
+ XM125_PRESENCE_STOP_DETECTOR = 3,
+ XM125_PRESENCE_ENABLE_UART_LOGS = 32,
+ XM125_PRESENCE_DISABLE_UART_LOGS = 33,
+ XM125_PRESENCE_LOG_CONFIGURATION = 34,
+ XM125_PRESENCE_RESET_MODULE = 138119737,
+} sfe_xm125_presence_command_t;
+
+const uint32_t SFE_XM125_PRESENCE_APPLY_CONFIGURATION = 1;
+const uint32_t SFE_XM125_PRESENCE_START_DETECTOR = 2;
+const uint32_t SFE_XM125_PRESENCE_STOP_DETECTOR = 3;
+const uint32_t SFE_XM125_PRESENCE_ENABLE_UART_LOGS = 32;
+const uint32_t SFE_XM125_PRESENCE_DISABLE_UART_LOGS = 33;
+const uint32_t SFE_XM125_PRESENCE_LOG_CONFIGURATION = 34;
+const uint32_t SFE_XM125_PRESENCE_RESET_MODULE = 1381192737;
+
+// Presence class definition
+
+class sfDevXM125Presence : public sfDevXM125Core
+{
+ public:
+ /**
+ * @brief Initializes the Presence detector device.
+ *
+ * This function sets up the I2C communication and performs initial checks
+ * to ensure the device is ready for operation.
+ *
+ * @param theBus Pointer to the I2C bus object. If nullptr, the default bus is used.
+ * @return ksfTkErrOk on success, or error code (value < -1) on failure.
+ */
+ sfTkError_t begin(sfTkII2C *theBus = nullptr) override;
+ /// @brief This function sets all the beginning values for a basic I2C
+ /// example to be run on the device for presence sensing.
+ /// @param start Start value for presence sensing in mm - default value is 1000
+ /// @param end End value for presence sensing in mm - default value is 5000
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t presenceDetectorStart(uint32_t start = 1000, uint32_t end = 5000);
+
+ /// @brief This function returns the presence value of the register
+ /// with all the checks in place as per the I2C Datasheet.
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceDistanceValuemm(uint32_t &presenceVal);
+
+ /// @brief This function returns the RSS version number
+ /// @param version Version number
+ /// @param patch Patch version number
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceDetectorVersion(uint32_t &major, uint32_t &minor, uint32_t &patch);
+
+ /// @brief This function returns the protocol state erorr
+ /// @param state Error code for device
+ /// 0 = Protocol state error
+ /// 1 = Packet length error
+ /// 2 = Address error
+ /// 3 = Write failed
+ /// 4 = Write to read only
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceDetectorError(uint32_t &error);
+
+ /// @brief This function returns the measure counter; the number of
+ /// measurements performed since restart.
+ /// @param counter number of measurements
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceMeasureCounter(uint32_t &counter);
+
+ /// @brief This function returns the detector status flags. See page 17, section
+ /// 6.2.4 Detector Status
+ /// @param status Status detector flag
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceDetectorStatus(uint32_t &status);
+
+ /// @brief This function returns the error status according to the bit
+ /// mask value for the presence devices errors and busy bit
+ /// @param status Error status of device (see function for exact error)
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceDetectorErrorStatus(uint32_t &status);
+
+ /// @brief This function returns if there was presence detected
+ /// @param detected Presence Detected
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceDetectorPresenceDetected(uint32_t &detected);
+
+ /// @brief This function returns if there was presence detected, sticky bit with
+ /// clear on read.
+ /// @param sticky Sticky Presence Detected
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceDetectorPresenceStickyDetected(uint32_t &sticky);
+
+ /// @brief This function returns the indication that the presence detector
+ /// failed.
+ /// @param calibrate Indication of sensor calibration
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceDetectorRegError(uint32_t &error);
+
+ /// @brief This function returns the temperature in sensor during measurement (in
+ /// degree Celsius). Note that it has poor absolute accuracy and should only
+ /// be used for relative temperature measurements.
+ /// @param temp Relative temperature
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceTemperature(uint32_t &temp);
+
+ /// @brief This function returns the distance, in millimeters, for the detected
+ /// presence.
+ /// @param distance distance in mm
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceDistance(uint32_t &distance);
+
+ /// @brief This function returns the measure of amount of fast motion detected.
+ /// @param intra Measure of fast motion
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceIntraPresenceScore(uint32_t &intra);
+
+ /// @brief This function returns the measure of amount of slow motion detected.
+ /// @param inter Measure of slow motion
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceInterPresenceScore(uint32_t &inter);
+
+ /// @brief This function returns the number of sweeps that will be
+ /// captured in each frame (measurement).
+ /// Default Value: 16 seconds
+ /// @param sweeps Number of sweeps
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceSweepsPerFrame(uint32_t &sweeps);
+
+ /// @brief This function sets the number of sweeps that will be
+ /// captured in each frame (measurement).
+ /// Default Value: 16 seconds
+ /// @param sweeps Number of sweeps
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setPresenceSweepsPerFrame(uint32_t sweeps);
+
+ /// @brief Returns the number of seconds the inter-frame presence score needs to decrease before
+ /// exponential scaling starts for faster decline. Should be between 0 and 30 where 0
+ /// means no timeout.
+ /// Default Value: 3 seconds
+ /// @param time Number of seconds
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceInterFramePresenceTimeout(uint32_t &time);
+
+ /// @brief Sets the number of seconds the inter-frame presence score needs to decrease before
+ /// exponential scaling starts for faster decline. Should be between 0 and 30 where 0
+ /// means no timeout.
+ /// Default Value: 3 seconds
+ /// @param time Number of seconds
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setPresenceInterFramePresenceTimeout(uint32_t time);
+
+ /// @brief This function returns the enable to increase detection of slow
+ /// motions by utilizing the phase information in the Sparse IQ data
+ /// @param en Enables increased detection
+ /// Default Value: false
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceInterPhaseBoostEnabled(bool &en);
+
+ /// @brief This function sets the enable to increase detection of slow
+ /// motions by utilizing the phase information in the Sparse IQ data
+ /// @param en Enables increased detection
+ /// Default Value: false
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setPresenceInterPhaseBoostEnabled(bool en);
+
+ /// @brief This function returns the bit to enable to detect faster
+ /// movements inside frames.
+ /// Default Value: true
+ /// @param en Enables faster detection
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceIntraDetectionEnabled(bool &en);
+
+ /// @brief This function returns the bit to enable to detect slower
+ /// movements between frames.
+ /// Default Value: true
+ /// @param en Enables faster detection
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setPresenceInterDetectionEnabled(bool en);
+
+ /// @brief This function returns the presence detector frame rate.
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 12000 mHz
+ /// @param rate Frame rate, in mHz
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceFrameRate(uint32_t &rate);
+
+ /// @brief This function sets the presence detector frame rate.
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 12000 mHz
+ /// @param rate Frame rate, in mHz
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setPresenceFrameRate(uint32_t rate);
+
+ /// @brief This function returns the threshold for detecting faster
+ /// movements inside frames.
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 1300
+ /// @param thresh threshold for faster movements
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceIntraDetectionThreshold(uint32_t &thresh);
+
+ /// @brief This function sets the threshold for detecting faster
+ /// movements inside frames.
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 1300
+ /// @param thresh threshold for faster movements
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setPresenceIntraDetectionThreshold(uint32_t thresh);
+
+ /// @brief This function returns the threshold for detecting slower
+ /// movements inside frames.
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 1000
+ /// @param thresh threshold for faster movements
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceInterDetectionThreshold(uint32_t &thresh);
+
+ /// @brief This function sets the threshold for detecting slower
+ /// movements inside frames.
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 1000
+ /// @param thresh threshold for faster movements
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setPresenceInterDetectionThreshold(uint32_t thresh);
+
+ /// @brief This function returns the time constant of the low pass
+ /// filter for the inter-frame deviation between fast and slow.
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 500 ms
+ /// @param time time in ms
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceInterFrameDeviationTime(uint32_t &time);
+
+ /// @brief This function sets the time constant of the low pass
+ /// filter for the inter-frame deviation between fast and slow.
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 500 ms
+ /// @param time time in ms
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setPresenceInterFrameDeviationTime(uint32_t time);
+
+ /// @brief This function returns the cutoff frequency of the low pass
+ /// filter for the fast filtered absolute sweep mean.
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 6000 mHz
+ /// @param cut cutoff frequency in mHz
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceInterFrameFastCutoff(uint32_t &cut);
+
+ /// @brief This function sets the cutoff frequency of the low pass
+ /// filter for the fast filtered absolute sweep mean.
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 6000 mHz
+ /// @param cut cutoff frequency in mHz
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setPresenceInterFrameFastCutoff(uint32_t cut);
+
+ /// @brief This function returns the cutoff frequency of the low pass
+ /// filter for the slow filtered absolute sweep mean.
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 200 mHz
+ /// @param cut cutoff frequency in mHz
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceInterFrameSlowCutoff(uint32_t &cut);
+
+ /// @brief This function sets the cutoff frequency of the low pass
+ /// filter for the slow filtered absolute sweep mean.
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 200 mHz
+ /// @param cut cutoff frequency in mHz
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setPresenceInterFrameSlowCutoff(uint32_t cut);
+
+ /// @brief This functions returns time constant for the depthwise
+ /// filtering in the intra-frame part
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 150ms
+ /// @param time time const in ms
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceIntraFrameTimeConst(uint32_t &time);
+
+ /// @brief This functions sets time constant for the depthwise
+ /// filtering in the intra-frame part
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 150ms
+ /// @param time time const in ms
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setPresenceIntraFrameTimeConst(uint32_t time);
+
+ /// @brief This function returns time constant for the output in
+ /// the intra-frame part
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 300ms
+ /// @param time time const in ms
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceIntraOutputTimeConst(uint32_t &time);
+
+ /// @brief This function sets the time constant for the output in
+ /// the intra-frame part
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 300ms
+ /// @param time time const in ms
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setPresenceIntraOutputTimeConst(uint32_t time);
+
+ /// @brief This function returns time constant for the output in
+ /// the inter-frame part
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 2000ms
+ /// @param time time const in ms
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceInterOutputTimeConst(uint32_t &time);
+
+ /// @brief This function sets the time constant for the output in
+ /// the inter-frame part
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 2000ms
+ /// @param time time const in ms
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setPresenceInterOutputTimeConst(uint32_t time);
+
+ /// @brief This function returns if enable/disable for the automatic
+ /// selection of profile based on start point of measurement.
+ /// Default Value: true
+ /// @param en enable/disable selection
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceAutoProfileEn(bool &en);
+
+ /// @brief This function enables/disables the automatic selection
+ /// of profile based on start point of measurement.
+ /// Default Value: true
+ /// @param en enable/disable selection
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setPresenceAutoProfileEn(bool en);
+
+ /// @brief This function returns the Enable/Disable
+ /// automatic selection of step length based on the profile.
+ /// @param en Enable/disable selection
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceAutoStepLengthEn(bool &en);
+
+ /// @brief This function Enables/Disables automatic selection
+ /// of step length based on the profile.
+ /// @param en Enable/disable selection
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setPresenceAutoStepLengthEn(bool en);
+
+ /// @brief This function returns the profile in use. The profile will only
+ /// be used if profile auto selection was disabled.
+ /// @param prof Profile to use (enum)
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceManualProfile(uint32_t &prof);
+
+ /// @brief This function sets the profile to use. The profile will only
+ /// be used if profile auto selection was disabled.
+ /// @param prof Profile to use (enum)
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setPresenceManualProfile(uint32_t prof);
+
+ /// @brief THis function returns the number of steps between each data point.
+ /// NOTE: The manual step length will only be used if step length auto selection
+ /// was disabled
+ /// Default Value: 72
+ /// @param length number of steps
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceManualStepLength(uint32_t &length);
+
+ /// @brief THis function returns the number of steps between each data point.
+ /// NOTE: The manual step length will only be used if step length auto selection
+ /// was disabled
+ /// Default Value: 72
+ /// @param length number of steps
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setPresenceManualStepLength(uint32_t length);
+
+ /// @brief This function returns the start of measured interval in mm.
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 300mm
+ /// @param start measured start interval in mm
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceStart(uint32_t &start);
+
+ /// @brief This function sets the start of measured interval in mm.
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 300mm
+ /// @param start measured start interval in mm
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setPresenceStart(uint32_t start);
+
+ /// @brief This function returns the end point of measurement
+ /// interval in millimeters.
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 2500
+ /// @param end End point of measurement in mm
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceEnd(uint32_t &end);
+
+ /// @brief This function returns the end point of measurement
+ /// interval in millimeters.
+ /// Note: This value is a factor 1000 larger than the RSS value
+ /// Default Value: 2500
+ /// @param end End point of measurement in mm
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setPresenceEnd(uint32_t end);
+
+ /// @brief This function returns if the device is enabled/disabled
+ /// for the reset of the presence filters during start/restart.
+ /// Default Value: true
+ /// @param reset enabled/disabled
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceResetFilters(bool &reset);
+
+ /// @brief This function sets if the device is enabled/disabled
+ /// for the reset of the presence filters during start/restart .
+ /// Default Value: true
+ /// @param reset enabled/disabled
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setPresenceResetFilters(bool reset);
+
+ /// @brief This function returns the hardware accelerated average
+ /// sampled (HWAAS).
+ /// Default Value: 32
+ /// @param avg average samples
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceHWAAS(uint32_t &avg);
+
+ /// @brief This function sets the hardware accelerated average
+ /// sampled (HWAAS).
+ /// Default Value: 32
+ /// @param avg average samples
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setPresenceHWAAS(uint32_t avg);
+
+ /// @brief This function returns the output presence detection on
+ /// generic GPIO.
+ /// @param detected Output presence detected
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceDetectionOnGPIO(uint32_t &detected);
+
+ /// @brief This function returns the output presence detection on
+ /// generic GPIO.
+ /// @param detected Output presence detected
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setPresenceDetectionOnGPIO(uint32_t detected);
+
+ /// @brief This function sets the execute command
+ /// @param cmd command to send to device
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t setPresenceCommand(uint32_t cmd);
+
+ /// @brief This function applies the configuration to the device by
+ /// writing the defined value to the presence command register
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t presenceApplyConfiguration();
+
+ /// @brief This function starts the device by writing the defined
+ /// start value to the presence command register
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t presenceStart();
+
+ /// @brief This function stops the device by writing the defined
+ /// stop value to the presence command register
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t presenceStop();
+
+ /// @brief This function enables the uart logs of the device by
+ /// writing the defined value to the presence command register
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t presenceEnableUartLogs();
+
+ /// @brief This function disables the uart logs of the device by
+ /// writing the defined value to the presence command register
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t presenceDisableUartLogs();
+
+ /// @brief This function enables the configuration log of the device
+ /// by writing the defined value to the presence command register
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t presenceLogConfiguration();
+
+ /// @brief This function resets the presence detector settings
+ /// of the device
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t presenceReset();
+
+ /// @brief This function returns the busy bit of the presence status register
+ /// @param busy Device busy or not
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t getPresenceBusy(uint32_t &busy);
+
+ /// @brief Completes a busy wait loop while the device is uploading
+ /// information by waiting for the status. Checks the error status register
+ /// to wait until errors are completed/gone
+ /// @return ksfTkErrOk on success, or error code (value < -1)
+ sfTkError_t presenceBusyWait();
+};
\ No newline at end of file
diff --git a/src/sfeQwiicXM125.cpp b/src/sfeQwiicXM125.cpp
deleted file mode 100644
index a62eeb0..0000000
--- a/src/sfeQwiicXM125.cpp
+++ /dev/null
@@ -1,1466 +0,0 @@
-#include "SparkFun_Qwiic_XM125_Arduino_Library.h"
-#include "sfeQwiicXM125.h"
-
-QwDevXM125::QwDevXM125()
-{
- //
-}
-
-bool QwDevXM125::begin(sfeTkII2C *theBus)
-{
- if(theBus == nullptr)
- {
- return kSTkErrFail;
- }
-
- // Check if the provided address is valid
- if(theBus->address() != SFE_XM125_I2C_ADDRESS)
- {
- return kSTkErrFail;
- }
-
- // Sets communication bus
- _theBus = theBus;
-
- // Check errors from device
- uint32_t distanceError = 0;
- uint32_t presenceError = 0;
- int32_t distFuncErr = 0;
- int32_t presFuncErr = 0;
-
- distFuncErr = getDistanceDetectorError(distanceError);
- presFuncErr = getDistanceDetectorError(presenceError);
- if(distanceError != 0 )
- {
- return -1;
- }
- if(presenceError != 0)
- {
- return -2;
- }
- if((distFuncErr != 0)|| (presFuncErr != 0))
- {
- return -3;
- }
-
- // If no errors, return 0
- return 0;
-}
-
-// --------------------- I2C Disance Detector Functions ---------------------
-int32_t QwDevXM125::distanceBegin()
-{
- uint32_t errorStatus = 0;
-
- // *** Distance Sensor Setup ***
- // Reset sensor configuration to reapply configuration registers
- setDistanceCommand(SFE_XM125_DISTANCE_RESET_MODULE);
- delay(100);
-
- distanceBusyWait();
-
- // Check error and busy bits
- if(getDistanceDetectorErrorStatus(errorStatus) != 0)
- {
- return 1;
- }
-
- if(errorStatus != 0)
- {
- return 2;
- }
-
- // Set Start register
- if(setDistanceStart(sfe_xm125_distance_start_default) != 0)
- {
- return 3;
- }
- delay(100); // give time for command to set
-
- // Set End register
- if(setDistanceEnd(sfe_xm125_distance_end_default) != 0)
- {
- return 4;
- }
- delay(100); // give time for command to set
-
- // Apply configuration
- if(setDistanceCommand(SFE_XM125_DISTANCE_APPLY_CONFIGURATION) != 0)
- {
- // Check for errors
- getDistanceDetectorErrorStatus(errorStatus);
- if(errorStatus != 0)
- {
- return 5;
- }
-
- return 6;
- }
-
- // Poll detector status until busy bit is cleared
- if(distanceBusyWait() != 0)
- {
- return 7;
- }
-
- // Check detector status
- getDistanceDetectorErrorStatus(errorStatus);
- if(errorStatus != 0)
- {
- return 7;
- }
-
- // Return 0 on no error
- return 0;
-}
-
-int32_t QwDevXM125::distanceDetectorReadingSetup()
-{
- uint32_t errorStatus = 0;
- uint32_t calibrateNeeded = 0;
- uint32_t measDistErr = 0;
-
- // Check error bits
- getDistanceDetectorErrorStatus(errorStatus);
- if(errorStatus != 0)
- {
- return 1;
- }
-
- // Start detector
- if(setDistanceCommand(SFE_XM125_DISTANCE_START_DETECTOR) != 0)
- {
- return 2;
- }
- delay(100); // give time for command to set
-
- // Poll detector status until busy bit is cleared - CHECK ON THIS!
- if(distanceBusyWait() != 0)
- {
- return 3;
- }
-
- // Verify that no error bits are set in the detector status register
- getDistanceDetectorErrorStatus(errorStatus);
- if(errorStatus != 0)
- {
- return 4;
- }
- delay(100);
-
- // Check MEASURE_DISTANCE_ERROR for measurement failed
- getDistanceMeasureDistanceError(measDistErr);
- if(measDistErr == 1)
- {
- return 5;
- }
- delay(100);
-
- // Recalibrate device if calibration error is triggered
- getDistanceCalibrationNeeded(calibrateNeeded);
- if(calibrateNeeded == 1)
- {
- setDistanceCommand(SFE_XM125_DISTANCE_RECALIBRATE);
- return 6;
- }
- delay(100);
-
- return 0;
-}
-
-int32_t QwDevXM125::getDistanceDetectorVersion(uint32_t &major, uint32_t &minor, uint32_t &patch)
-{
- int32_t retVal;
- uint32_t regVal = 0;
-
- // Read from 16-Bit Register
- size_t readBytes = 0;
- retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_VERSION, (uint8_t*)®Val, 4, readBytes);
- regVal = __builtin_bswap32(regVal);
-
- // Mask unused bits from register
- major = (regVal & SFE_XM125_DISTANCE_MAJOR_VERSION_MASK) >> SFE_XM125_DISTANCE_MAJOR_VERSION_MASK_SHIFT;
- minor = (regVal & SFE_XM125_DISTANCE_MINOR_VERSION_MASK) >> SFE_XM125_DISTANCE_MINOR_VERSION_MASK_SHIFT;
- patch = regVal & SFE_XM125_DISTANCE_PATCH_VERSION_MASK;
-
- return retVal;
-}
-
-int32_t QwDevXM125::getDistanceDetectorError(uint32_t &error)
-{
- // Read from 16-Bit Register
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_PROTOCOL_STATUS, (uint8_t*)&error, 4, readBytes);
- error = __builtin_bswap32(error);
- return retVal;
-}
-
-int32_t QwDevXM125::getDistanceDetectorErrorStatus(uint32_t &status)
-{
- int32_t retVal;
- uint32_t regVal = 0;
- size_t readBytes = 0;
- retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_DETECTOR_STATUS, (uint8_t*)®Val, 4, readBytes);
- regVal = __builtin_bswap32(regVal);
-
- if(retVal != 0)
- {
- return -1;
- }
-
- if(((regVal & SFE_XM125_DISTANCE_RSS_REGISTER_ERROR_MASK) >> SFE_XM125_DISTANCE_RSS_REGISTER_ERROR_MASK_SHIFT) != 0)
- {
- status = 1;
- return 0;
- }
- else if(((regVal & SFE_XM125_DISTANCE_CONFIG_CREATE_ERROR_MASK) >> SFE_XM125_DISTANCE_CONFIG_CREATE_ERROR_MASK_SHIFT) != 0)
- {
- status = 2;
- return 0;
- }
- else if(((regVal & SFE_XM125_DISTANCE_SENSOR_CREATE_ERROR_MASK) >> SFE_XM125_DISTANCE_SENSOR_CREATE_ERROR_MASK_SHIFT) != 0)
- {
- status = 3;
- return 0;
- }
- else if(((regVal & SFE_XM125_DISTANCE_DETECTOR_CREATE_ERROR_MASK) >> SFE_XM125_DISTANCE_DETECTOR_CREATE_ERROR_MASK_SHIFT) != 0)
- {
- status = 5;
- return 0;
- }
- else if(((regVal & SFE_XM125_DISTANCE_DETECTOR_BUFFER_ERROR_MASK) >> SFE_XM125_DISTANCE_DETECTOR_BUFFER_ERROR_MASK_SHIFT) != 0)
- {
- status = 6;
- return 0;
- }
- else if(((regVal & SFE_XM125_DISTANCE_SENSOR_BUFFER_ERROR_MASK) >> SFE_XM125_DISTANCE_SENSOR_BUFFER_ERROR_MASK_SHIFT) != 0)
- {
- status = 7;
- return 0;
- }
- else if(((regVal & SFE_XM125_DISTANCE_CALIBRATION_BUFFER_ERROR_MASK) >> SFE_XM125_DISTANCE_CALIBRATION_BUFFER_ERROR_MASK_SHIFT) != 0)
- {
- status = 8;
- return 0;
- }
- else if(((regVal & SFE_XM125_DISTANCE_CONFIG_APPLY_ERROR_MASK) >> SFE_XM125_DISTANCE_CONFIG_APPLY_ERROR_MASK_SHIFT) != 0)
- {
- status = 9;
- return 0;
- }
- else if(((regVal & SFE_XM125_DISTANCE_SENSOR_CALIBRATE_ERROR_MASK) >> SFE_XM125_DISTANCE_SENSOR_CALIBRATE_ERROR_MASK_SHIFT) != 0)
- {
- status = 10;
- return 0;
- }
- else if(((regVal & SFE_XM125_DISTANCE_DETECTOR_CALIBRATE_ERROR_MASK) >> SFE_XM125_DISTANCE_DETECTOR_CALIBRATE_ERROR_MASK_SHIFT) != 0)
- {
- status = 11;
- return 0;
- }
- else if(((regVal & SFE_XM125_DISTANCE_DETECTOR_ERROR_MASK) >> SFE_XM125_DISTANCE_DETECTOR_ERROR_MASK_SHIFT) != 0)
- {
- status = 12;
- return 0;
- }
- else if(((regVal & SFE_XM125_DISTANCE_BUSY_MASK) >> SFE_XM125_DISTANCE_BUSY_MASK_SHIFT) != 0)
- {
- status = 13;
- return 0;
- }
-
- return 0; // return 0 with no errors
-}
-
-int32_t QwDevXM125::getDistanceMeasureCounter(uint32_t &counter)
-{
- // Read from 16-Bit Register
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_MEASURE_COUNTER, (uint8_t*)&counter, 4, readBytes);
- counter = __builtin_bswap32(counter);
- return retVal;
-}
-
-int32_t QwDevXM125::getDistanceDetectorStatus(uint32_t &status)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_DETECTOR_STATUS, (uint8_t*)&status, 4, readBytes);
- status = __builtin_bswap32(status);
- return retVal;
-}
-
-int32_t QwDevXM125::getDistanceNumberDistances(uint32_t &distance)
-{
- int32_t retVal;
- uint32_t regVal = 0;
-
- // Read from 16-Bit Register
- size_t readBytes = 0;
- retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_RESULT, (uint8_t*)®Val, 4, readBytes);
- regVal = __builtin_bswap32(regVal);
-
- // Mask unused bits from register
- distance = (regVal & SFE_XM125_DISTANCE_NUMBER_DISTANCES_MASK);
-
- return retVal;
-}
-
-int32_t QwDevXM125::getDistanceNearStartEdge(uint32_t &edge)
-{
- int32_t retVal;
- uint32_t regVal = 0;
-
- // Read from 16-Bit Register
- size_t readBytes = 0;
- retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_RESULT, (uint8_t*)®Val, 4, readBytes);
- regVal = __builtin_bswap32(regVal);
-
- // Mask unused bits from register
- edge = (regVal & SFE_XM125_DISTANCE_NEAR_START_EDGE_MASK) >> SFE_XM125_DISTANCE_NEAR_START_EDGE_MASK_SHIFT;
-
- return retVal;
-}
-
-int32_t QwDevXM125::getDistanceCalibrationNeeded(uint32_t &calibrate)
-{
- int32_t retVal;
- uint32_t regVal = 0;
-
- // Read from 16-Bit Register
- size_t readBytes = 0;
- retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_RESULT, (uint8_t*)®Val, 4, readBytes);
- regVal = __builtin_bswap32(regVal);
-
- // Mask unused bits from register
- calibrate = (regVal & SFE_XM125_DISTANCE_CALIBRATION_NEEDED_MASK) >> SFE_XM125_DISTANCE_CALIBRATION_NEEDED_MASK_SHIFT;
-
- return retVal;
-}
-
-int32_t QwDevXM125::getDistanceMeasureDistanceError(uint32_t &error)
-{
- int32_t retVal;
- uint32_t regVal = 0;
-
- // Read from 16-Bit Register
- size_t readBytes = 0;
- retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_RESULT, (uint8_t*)®Val, 4, readBytes);
- regVal = __builtin_bswap32(regVal);
-
- // Mask unused bits from register
- error = (regVal & SFE_XM125_DISTANCE_MEASURE_DISTANCE_ERROR_MASK) >> SFE_XM125_DISTANCE_MEASURE_DISTANCE_ERROR_MASK_SHIFT;
-
- return retVal;
-}
-
-int32_t QwDevXM125::getDistanceTemperature(uint32_t &temperature)
-{
- int32_t retVal;
- uint32_t regVal = 0;
-
- // Read from 16-Bit Register
- size_t readBytes = 0;
- retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_RESULT, (uint8_t*)®Val, 4, readBytes);
- regVal = __builtin_bswap32(regVal);
-
- // Mask unused bits from register
- temperature = (regVal & SFE_XM125_DISTANCE_TEMPERATURE_MASK) >> SFE_XM125_DISTANCE_TEMPERATURE_MASK_SHIFT;
-
- return retVal;
-}
-
-int32_t QwDevXM125::getDistancePeak0Distance(uint32_t &peak)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_PEAK0_DISTANCE, (uint8_t*)&peak, 4, readBytes);
- peak = __builtin_bswap32(peak);
- return retVal;
-}
-
-int32_t QwDevXM125::getDistancePeak1Distance(uint32_t &peak)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_PEAK1_DISTANCE, (uint8_t*)&peak, 4, readBytes);
- peak = __builtin_bswap32(peak);
- return retVal;
-}
-
-int32_t QwDevXM125::getDistancePeak2Distance(uint32_t &peak)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_PEAK2_DISTANCE, (uint8_t*)&peak, 4, readBytes);
- peak = __builtin_bswap32(peak);
- return retVal;
-}
-
-int32_t QwDevXM125::getDistancePeak3Distance(uint32_t &peak)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_PEAK3_DISTANCE, (uint8_t*)&peak, 4, readBytes);
- peak = __builtin_bswap32(peak);
- return retVal;
-}
-
-int32_t QwDevXM125::getDistancePeak4Distance(uint32_t &peak)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_PEAK4_DISTANCE, (uint8_t*)&peak, 4, readBytes);
- peak = __builtin_bswap32(peak);
- return retVal;
-}
-
-int32_t QwDevXM125::getDistancePeak5Distance(uint32_t &peak)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_PEAK5_DISTANCE, (uint8_t*)&peak, 4, readBytes);
- peak = __builtin_bswap32(peak);
- return retVal;
-}
-
-int32_t QwDevXM125::getDistancePeak6Distance(uint32_t &peak)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_PEAK6_DISTANCE, (uint8_t*)&peak, 4, readBytes);
- peak = __builtin_bswap32(peak);
- return retVal;
-}
-
-int32_t QwDevXM125::getDistancePeak7Distance(uint32_t &peak)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_PEAK7_DISTANCE, (uint8_t*)&peak, 4, readBytes);
- peak = __builtin_bswap32(peak);
- return retVal;
-}
-
-int32_t QwDevXM125::getDistancePeak8Distance(uint32_t &peak)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_PEAK8_DISTANCE, (uint8_t*)&peak, 4, readBytes);
- peak = __builtin_bswap32(peak);
- return retVal;
-}
-
-int32_t QwDevXM125::getDistancePeak9Distance(uint32_t &peak)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_PEAK9_DISTANCE, (uint8_t*)&peak, 4, readBytes);
- peak = __builtin_bswap32(peak);
- return retVal;
-}
-
-int32_t QwDevXM125::getDistancePeak0Strength(uint32_t &peak)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_PEAK0_STRENGTH, (uint8_t*)&peak, 4, readBytes);
- peak = __builtin_bswap32(peak);
- peak = peak/1000;
- return retVal;
-}
-
-int32_t QwDevXM125::getDistancePeak1Strength(uint32_t &peak)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_PEAK1_STRENGTH, (uint8_t*)&peak, 4, readBytes);
- peak = __builtin_bswap32(peak);
- peak = peak/1000;
- return retVal;
-}
-
-int32_t QwDevXM125::getDistancePeak2Strength(uint32_t &peak)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_PEAK2_STRENGTH, (uint8_t*)&peak, 4, readBytes);
- peak = __builtin_bswap32(peak);
- peak = peak/1000;
- return retVal;
-}
-
-int32_t QwDevXM125::getDistancePeak3Strength(uint32_t &peak)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_PEAK3_STRENGTH, (uint8_t*)&peak, 4, readBytes);
- peak = __builtin_bswap32(peak);
- peak = peak/1000;
- return retVal;
-}
-
-int32_t QwDevXM125::getDistancePeak4Strength(uint32_t &peak)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_PEAK4_STRENGTH, (uint8_t*)&peak, 4, readBytes);
- peak = __builtin_bswap32(peak);
- peak = peak/1000;
- return retVal;
-}
-
-int32_t QwDevXM125::getDistancePeak5Strength(uint32_t &peak)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_PEAK5_STRENGTH, (uint8_t*)&peak, 4, readBytes);
- peak = __builtin_bswap32(peak);
- peak = peak/1000;
- return retVal;
-}
-
-int32_t QwDevXM125::getDistancePeak6Strength(uint32_t &peak)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_PEAK6_STRENGTH, (uint8_t*)&peak, 4, readBytes);
- peak = __builtin_bswap32(peak);
- peak = peak/1000;
- return retVal;
-}
-
-int32_t QwDevXM125::getDistancePeak7Strength(uint32_t &peak)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_PEAK7_STRENGTH, (uint8_t*)&peak, 4, readBytes);
- peak = __builtin_bswap32(peak);
- peak = peak/1000;
- return retVal;
-}
-
-int32_t QwDevXM125::getDistancePeak8Strength(uint32_t &peak)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_PEAK8_STRENGTH, (uint8_t*)&peak, 4, readBytes);
- peak = __builtin_bswap32(peak);
- peak = peak/1000;
- return retVal;
-}
-
-int32_t QwDevXM125::getDistancePeak9Strength(uint32_t &peak)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_PEAK9_STRENGTH, (uint8_t*)&peak, 4, readBytes);
- peak = __builtin_bswap32(peak);
- peak = peak/1000;
- return retVal;
-}
-
-int32_t QwDevXM125::getDistanceStart(uint32_t &startVal)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_START, (uint8_t*)&startVal, 4, readBytes);
- startVal = __builtin_bswap32(startVal);
- return retVal;
-}
-
-int32_t QwDevXM125::setDistanceStart(uint32_t start)
-{
- start = __builtin_bswap32(start);
- return _theBus->writeRegister16Region(SFE_XM125_DISTANCE_START, (uint8_t*)&start, 4);
-}
-
-int32_t QwDevXM125::getDistanceEnd(uint32_t &end)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_END, (uint8_t*)&end, 4, readBytes);
- end = __builtin_bswap32(end);
- return retVal;
-}
-
-int32_t QwDevXM125::setDistanceEnd(uint32_t end)
-{
- end = __builtin_bswap32(end);
- return _theBus->writeRegister16Region(SFE_XM125_DISTANCE_END, (uint8_t*)&end, 4);
-}
-
-int32_t QwDevXM125::getDistanceMaxStepLength(uint32_t &length)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_MAX_STEP_LENGTH, (uint8_t*)&length, 4, readBytes);
- length = __builtin_bswap32(length);
- return retVal;
-}
-
-int32_t QwDevXM125::setDistanceMaxStepLength(uint32_t length)
-{
- length = __builtin_bswap32(length);
- return _theBus->writeRegister16Region(SFE_XM125_DISTANCE_MAX_STEP_LENGTH, (uint8_t*)&length, 4);
-}
-
-int32_t QwDevXM125::getDistanceCloseRangeLeakageCancellation(bool &range)
-{
- size_t readBytes = 0;
- return _theBus->readRegister16Region(SFE_XM125_DISTANCE_CLOSE_RANGE_LEAKAGE, (uint8_t*)&range, 4, readBytes);
-}
-
-int32_t QwDevXM125::setDistanceCloseRangeLeakageCancellation(bool range)
-{
- return _theBus->writeRegister16Region(SFE_XM125_DISTANCE_CLOSE_RANGE_LEAKAGE, (uint8_t*)&range, 4);
-}
-
-int32_t QwDevXM125::getDistanceSignalQuality(uint32_t &signal)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_SIGNAL_QUALITY, (uint8_t*)&signal, 4, readBytes);
- signal = __builtin_bswap32(signal);
- return retVal;
-}
-
-int32_t QwDevXM125::setDistanceSignalQuality(uint32_t signal)
-{
- signal = __builtin_bswap32(signal);
- return _theBus->writeRegister16Region(SFE_XM125_DISTANCE_SIGNAL_QUALITY, (uint8_t*)&signal, 4);
-}
-
-int32_t QwDevXM125::getDistanceMaxProfile(uint32_t &profile)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_MAX_PROFILE, (uint8_t*)&profile, 4, readBytes);
- profile = __builtin_bswap32(profile);
- return retVal;
-}
-
-int32_t QwDevXM125::setDistanceMaxProfile(uint32_t profile)
-{
- profile = __builtin_bswap32(profile);
- return _theBus->writeRegister16Region(SFE_XM125_DISTANCE_MAX_PROFILE, (uint8_t*)&profile, 4);
-}
-
-int32_t QwDevXM125::getDistanceThresholdMethod(uint32_t &method)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_THRESHOLD_METHOD, (uint8_t*)&method, 4, readBytes);
- method = __builtin_bswap32(method);
- return retVal;
-}
-
-int32_t QwDevXM125::setDistanceThresholdMethod(uint32_t method)
-{
- method = __builtin_bswap32(method);
- return _theBus->writeRegister16Region(SFE_XM125_DISTANCE_THRESHOLD_METHOD, (uint8_t*)&method, 4);
-}
-
-int32_t QwDevXM125::getDistancePeakSorting(uint32_t &peak)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_PEAK_SORTING, (uint8_t*)&peak, 4, readBytes);
- peak = __builtin_bswap32(peak);
- return retVal;
-}
-
-int32_t QwDevXM125::setDistancePeakSorting(uint32_t peak)
-{
- peak = __builtin_bswap32(peak);
- return _theBus->writeRegister16Region(SFE_XM125_DISTANCE_PEAK_SORTING, (uint8_t*)&peak, 4);
-}
-
-int32_t QwDevXM125::getDistanceNumFramesRecordedThreshold(uint32_t &thresh)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_NUM_FRAMES_RECORDED_THRESH, (uint8_t*)&thresh, 4, readBytes);
- thresh = __builtin_bswap32(thresh);
- return retVal;
-}
-
-int32_t QwDevXM125::setDistanceNumFramesRecordedThreshold(uint32_t thresh)
-{
- thresh = __builtin_bswap32(thresh);
- return _theBus->writeRegister16Region(SFE_XM125_DISTANCE_NUM_FRAMES_RECORDED_THRESH, (uint8_t*)&thresh, 4);
-}
-
-int32_t QwDevXM125::getDistanceFixedAmpThreshold(uint32_t &thresh)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_FIXED_AMPLITUDE_THRESHOLD_VAL, (uint8_t*)&thresh, 4, readBytes);
- thresh = __builtin_bswap32(thresh);
- return retVal;
-}
-
-int32_t QwDevXM125::setDistanceFixedAmpThreshold(uint32_t thresh)
-{
- thresh = __builtin_bswap32(thresh);
- return _theBus->writeRegister16Region(SFE_XM125_DISTANCE_FIXED_AMPLITUDE_THRESHOLD_VAL, (uint8_t*)&thresh, 4);
-}
-
-int32_t QwDevXM125::getDistanceThresholdSensitivity(uint32_t &thresh)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_THREHSOLD_SENSITIVITY, (uint8_t*)&thresh, 4, readBytes);
- thresh = __builtin_bswap32(thresh);
- return retVal;
-}
-
-int32_t QwDevXM125::setDistanceThresholdSensitivity(uint32_t thresh)
-{
- thresh = __builtin_bswap32(thresh);
- return _theBus->writeRegister16Region(SFE_XM125_DISTANCE_THREHSOLD_SENSITIVITY, (uint8_t*)&thresh, 4);
-}
-
-int32_t QwDevXM125::getDistanceReflectorShape(uint32_t &shape)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_REFLECTOR_SHAPE, (uint8_t*)&shape, 4, readBytes);
- shape = __builtin_bswap32(shape);
- return retVal;
-}
-
-int32_t QwDevXM125::setDistanceReflectorShape(uint32_t shape)
-{
- shape = __builtin_bswap32(shape);
- return _theBus->writeRegister16Region(SFE_XM125_DISTANCE_REFLECTOR_SHAPE, (uint8_t*)&shape, 4);
-}
-
-int32_t QwDevXM125::getDistanceFixedStrengthThresholdValue(int32_t &thresh)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_FIXED_STRENGTH_THRESHOLD_VAL, (uint8_t*)&thresh, 4, readBytes);
- thresh = __builtin_bswap32(thresh);
- return retVal;
-}
-
-int32_t QwDevXM125::setDistanceFixedStrengthThresholdValue(int32_t thresh)
-{
- thresh = __builtin_bswap32(thresh);
- return _theBus->writeRegister16Region(SFE_XM125_DISTANCE_FIXED_STRENGTH_THRESHOLD_VAL, (uint8_t*)&thresh, 4);
-}
-
-int32_t QwDevXM125::getDistanceMeasureOneWakeup(bool &measure)
-{
- size_t readBytes = 0;
- return _theBus->readRegister16Region(SFE_XM125_DISTANCE_MEASURE_ON_WAKEUP, (uint8_t*)&measure, 4, readBytes);
-}
-
-int32_t QwDevXM125::setDistanceMeasureOneWakeup(bool measure)
-{
- return _theBus->writeRegister16Region(SFE_XM125_DISTANCE_MEASURE_ON_WAKEUP, (uint8_t*)&measure, 4);
-}
-
-int32_t QwDevXM125::setDistanceCommand(uint32_t command)
-{
- command = __builtin_bswap32(command);
- return _theBus->writeRegister16Region(SFE_XM125_DISTANCE_COMMAND, (uint8_t*)&command, 4);
-}
-
-int32_t QwDevXM125::distanceApplyConfiguration()
-{
- return setDistanceCommand(SFE_XM125_DISTANCE_APPLY_CONFIGURATION);
-}
-
-int32_t QwDevXM125::distanceStart()
-{
- return setDistanceCommand(SFE_XM125_DISTANCE_START_DETECTOR);
-}
-
-int32_t QwDevXM125::distanceStop()
-{
- return setDistanceCommand(SFE_XM125_DISTANCE_STOP_DETECTOR);
-}
-
-int32_t QwDevXM125::distanceCalibrate()
-{
- return setDistanceCommand(SFE_XM125_DISTANCE_CALIBRATE);
-}
-
-int32_t QwDevXM125::distanceRecalibrate()
-{
- return setDistanceCommand(SFE_XM125_DISTANCE_RECALIBRATE);
-}
-
-int32_t QwDevXM125::distanceEnableUartLogs()
-{
- return setDistanceCommand(SFE_XM125_DISTANCE_ENABLE_UART_LOGS);
-}
-
-int32_t QwDevXM125::distanceDisableUartLogs()
-{
- return setDistanceCommand(SFE_XM125_DISTANCE_DISABLE_UART_LOGS);
-}
-
-int32_t QwDevXM125::distanceLogConfiguration()
-{
- return setDistanceCommand(SFE_XM125_DISTANCE_LOG_CONFIGURATION);
-}
-
-int32_t QwDevXM125::distanceReset()
-{
- return setDistanceCommand(SFE_XM125_DISTANCE_RESET_MODULE);
-}
-
-int32_t QwDevXM125::distanceBusyWait()
-{
- int32_t retVal = 0;
- uint32_t regVal = 0;
-
- size_t readBytes = 0;
- retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_DETECTOR_STATUS, (uint8_t*)®Val, 4, readBytes);
- regVal = __builtin_bswap32(regVal);
-
- // Poll Detector Status until Busy bit is cleared
- while(((regVal & SFE_XM125_DISTANCE_DETECTOR_STATUS_MASK) >> SFE_XM125_DISTANCE_DETECTOR_STATUS_MASK_SHIFT) != 0)
- {
- retVal = _theBus->readRegister16Region(SFE_XM125_DISTANCE_DETECTOR_STATUS, (uint8_t*)®Val, 4, readBytes);
- regVal = __builtin_bswap32(regVal);
- }
-
- // Return error code if non-zero
- if(retVal != 0)
- {
- return retVal;
- }
- return 0; // 0 on success
-}
-
-// --------------------- I2C Presence Detector Functions ---------------------
-
-int32_t QwDevXM125::presenceDetectorStart()
-{
- // *** Presence Sensor Setup ***
- uint32_t errorStatus = 0;
-
- // Reset sensor configuration to reapply configuration registers
- if(setPresenceCommand(SFE_XM125_PRESENCE_RESET_MODULE) != 0)
- {
- return 1;
- }
- delay(100); // give time for command to set
-
- // Check detector status error and busy bits
- if(getPresenceDetectorErrorStatus(errorStatus) != 0)
- {
- return 2;
- }
- if(errorStatus != 0)
- {
- return 3;
- }
-
- // Set Presence Start register
- if(setPresenceStart(300) != 0)
- {
- return 4;
- }
- delay(100); // give time for command to set
-
- // Set End register
- if(setPresenceEnd(2500) != 0)
- {
- return 5;
- }
- delay(100); // give time for command to set
-
- // Apply configuration
- if(setPresenceCommand(SFE_XM125_PRESENCE_APPLY_CONFIGURATION) != 0)
- {
- // Check for errors
- getPresenceDetectorErrorStatus(errorStatus);
- if(errorStatus != 0)
- {
- return 6;
- }
-
- return 7;
- }
- delay(100); // give time for command to set
-
- // Poll detector status until busy bit is cleared
- if(presenceBusyWait() != 0)
- {
- return 8;
- }
-
- // Check detector error status
- getPresenceDetectorErrorStatus(errorStatus);
- if(errorStatus != 0)
- {
- return 9;
- }
-
- // If no errors, return 0
- return 0;
-}
-
-int32_t QwDevXM125::getPresenceDistanceValuemm(uint32_t &presenceVal)
-{
- // Check error bits
- uint32_t errorStatus = 0;
- uint32_t presenceDetected = 0;
- uint32_t presenceDetectedSticky = 0;
-
- getPresenceDetectorErrorStatus(errorStatus);
- if(errorStatus != 0)
- {
- return 1;
- }
-
- // Start detector
- if(setPresenceCommand(SFE_XM125_PRESENCE_START_DETECTOR) != 0)
- {
- return 2;
- }
- delay(100);
-
- // Poll detector status until busy bit is cleared - CHECK ON THIS!
- if(presenceBusyWait() != 0)
- {
- return 3;
- }
-
- // Verify that no error bits are set in the detector status register
- getPresenceDetectorErrorStatus(errorStatus);
- if(errorStatus != 0)
- {
- return 4;
- }
-
- // Read detector result register and determine detection status
- getPresenceDetectorPresenceDetected(presenceDetected);
- getPresenceDetectorPresenceStickyDetected(presenceDetectedSticky);
-
- if((presenceDetected == 1) | (presenceDetectedSticky == 1))
- {
- getPresenceDistance(presenceVal);
- }
- return 0;
-}
-
-int32_t QwDevXM125::getPresenceDetectorVersion(uint32_t &major, uint32_t &minor, uint32_t &patch)
-{
- int32_t retVal;
- uint32_t regVal = 0;
-
- // Read from 16-Bit Register
- size_t readBytes = 0;
- retVal = _theBus->readRegister16Region(SFE_XM125_PRESENCE_VERSION, (uint8_t*)®Val, 4, readBytes);
-
- // Mask unused bits from register
- major = (regVal & SFE_XM125_PRESENCE_MAJOR_VERSION_MASK) >> SFE_XM125_PRESENCE_MAJOR_VERSION_MASK_SHIFT;
- minor = (regVal & SFE_XM125_PRESENCE_MINOR_VERSION_MASK) >> SFE_XM125_PRESENCE_MINOR_VERSION_MASK_SHIFT;
- patch = regVal & SFE_XM125_PRESENCE_PATCH_VERSION_MASK;
-
- return retVal;
-}
-
-int32_t QwDevXM125::getPresenceDetectorError(uint32_t &error)
-{
- size_t readBytes = 0;
- return _theBus->readRegister16Region(SFE_XM125_PRESENCE_PROTOCOL_STATUS, (uint8_t*)&error, 4, readBytes);
-}
-
-int32_t QwDevXM125::getPresenceMeasureCounter(uint32_t &counter)
-{
- size_t readBytes = 0;
- return _theBus->readRegister16Region(SFE_XM125_PRESENCE_MEASURE_COUNTER, (uint8_t*)&counter, 4, readBytes);
-}
-
-int32_t QwDevXM125::getPresenceDetectorStatus(uint32_t &status)
-{
- size_t readBytes = 0;
- return _theBus->readRegister16Region(SFE_XM125_PRESENCE_DETECTOR_STATUS, (uint8_t*)&status, 4, readBytes);
-}
-
-int32_t QwDevXM125::getPresenceDetectorErrorStatus(uint32_t &status)
-{
- int32_t retVal = 0;
- uint32_t regVal = 0;
- size_t readBytes = 0;
- retVal = _theBus->readRegister16Region(SFE_XM125_PRESENCE_DETECTOR_STATUS, (uint8_t*)®Val, 4, readBytes);
- regVal = __builtin_bswap32(regVal);
-
- if(retVal != 0)
- {
- return -1;
- }
-
- if(((regVal & SFE_XM125_PRESENCE_RSS_REGISTER_ERROR_MASK) >> SFE_XM125_PRESENCE_RSS_REGISTER_ERROR_MASK_SHIFT) != 0)
- {
- status = 1;
- return 0;
- }
- else if(((regVal & SFE_XM125_PRESENCE_CONFIG_CREATE_ERROR_MASK) >> SFE_XM125_PRESENCE_CONFIG_CREATE_ERROR_MASK_SHIFT) != 0)
- {
- status = 2;
- return 0;
- }
- else if(((regVal & SFE_XM125_PRESENCE_SENSOR_CREATE_ERROR_MASK) >> SFE_XM125_PRESENCE_SENSOR_CREATE_ERROR_MASK_SHIFT) != 0)
- {
- status = 3;
- return 0;
- }
- else if(((regVal & SFE_XM125_PRESENCE_SENSOR_CALIBRATE_ERROR_MASK) >> SFE_XM125_PRESENCE_SENSOR_CALIBRATE_ERROR_MASK_SHIFT) != 0)
- {
- status = 4;
- return 0;
- }
- else if(((regVal & SFE_XM125_PRESENCE_DETECTOR_CREATE_ERROR_MASK) >> SFE_XM125_PRESENCE_DETECTOR_CREATE_ERROR_MASK_SHIFT) != 0)
- {
- status = 5;
- return 0;
- }
- else if(((regVal & SFE_XM125_PRESENCE_DETECTOR_BUFFER_ERROR_MASK) >> SFE_XM125_PRESENCE_DETECTOR_BUFFER_ERROR_MASK_SHIFT) != 0)
- {
- status = 6;
- return 0;
- }
- else if(((regVal & SFE_XM125_PRESENCE_SENSOR_BUFFER_ERROR_MASK) >> SFE_XM125_PRESENCE_SENSOR_BUFFER_ERROR_MASK_SHIFT) != 0)
- {
- status = 7;
- return 0;
- }
- else if(((regVal & SFE_XM125_PRESENCE_CONFIG_APPLY_ERROR_MASK) >> SFE_XM125_PRESENCE_CONFIG_APPLY_ERROR_MASK_SHIFT) != 0)
- {
- status = 8;
- return 0;
- }
- else if(((regVal & SFE_XM125_PRESENCE_DETECTOR_REG_ERROR_MASK) >> SFE_XM125_PRESENCE_DETECTOR_REG_ERROR_MASK_SHIFT) != 0)
- {
- status = 9;
- return 0;
- }
-
- // return 0 with no errors
- return 0;
-}
-
-
-int32_t QwDevXM125::getPresenceDetectorPresenceDetected(uint32_t &detected)
-{
- uint32_t regVal = 0;
-
- // Read from 16-Bit Register
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_PRESENCE_RESULT, (uint8_t*)®Val, 4, readBytes);
-
- regVal = __builtin_bswap32(regVal);
-
- // Mask unused bits from register
- detected = (regVal & SFE_XM125_PRESENCE_DETECTED_MASK);
-
- return retVal;
-}
-
-int32_t QwDevXM125::getPresenceDetectorPresenceStickyDetected(uint32_t &sticky)
-{
- uint32_t regVal = 0;
-
- // Read from 16-Bit Register
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_PRESENCE_RESULT, (uint8_t*)®Val, 4, readBytes);
-
- regVal = __builtin_bswap32(regVal);
-
- // Mask unused bits from register
- sticky = (regVal & SFE_XM125_PRESENCE_DETECTED_STICKY_MASK) >> 1;
-
- return retVal;
-}
-
-int32_t QwDevXM125::getPresenceDetectorRegError(uint32_t &error)
-{
- uint32_t regVal = 0;
-
- // Read from 16-Bit Register
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_PRESENCE_RESULT, (uint8_t*)®Val, 4, readBytes);
-
- regVal = __builtin_bswap32(regVal);
-
- // Mask unused bits from register
- error = (regVal & SFE_XM125_PRESENCE_DETECTOR_ERROR_MASK) >> SFE_XM125_PRESENCE_DETECTOR_ERROR_MASK_SHIFT;
-
- return retVal;
-}
-
-int32_t QwDevXM125::getPresenceTemperature(uint32_t &temp)
-{
- uint32_t regVal = 0;
-
- // Read from 16-Bit Register
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_PRESENCE_DISTANCE, (uint8_t*)®Val, 4, readBytes);
-
- // Mask unused bits from register
- temp = (regVal & SFE_XM125_PRESENCE_TEMPERATURE_MASK) >> SFE_XM125_PRESENCE_TEMPERATURE_MASK_SHIFT;
-
- return retVal;
-}
-
-int32_t QwDevXM125::getPresenceDistance(uint32_t &distance)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_PRESENCE_DISTANCE, (uint8_t*)&distance, 4, readBytes);
- distance = __builtin_bswap32(distance);
- return retVal;
-}
-
-int32_t QwDevXM125::getPresenceIntraPresenceScore(uint32_t &intra)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_INTRA_PRESENCE_SCORE, (uint8_t*)&intra, 4, readBytes);
- intra = __builtin_bswap32(intra);
- return retVal;
-}
-
-int32_t QwDevXM125::getPresenceInterPresenceScore(uint32_t &inter)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_INTER_PRESENCE, (uint8_t*)&inter, 4, readBytes);
- inter = __builtin_bswap32(inter);
- return retVal;
-}
-
-int32_t QwDevXM125::getPresenceSweepsPerFrame(uint32_t &sweeps)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_INTRA_PRESENCE_SCORE, (uint8_t*)&sweeps, 4, readBytes);
- sweeps = __builtin_bswap32(sweeps);
- return retVal;
-}
-
-int32_t QwDevXM125::setPresenceSweepsPerFrame(uint32_t sweeps)
-{
- return _theBus->writeRegister16Region(SFE_XM125_PRESENCE_SWEEPS_PER_FRAME, (uint8_t*)&sweeps, 4);
-}
-
-int32_t QwDevXM125::getPresenceInterFramePresenceTimeout(uint32_t &time)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_PRESENCE_INTER_FRAME_TIMEOUT, (uint8_t*)&time, 4, readBytes);
- time = __builtin_bswap32(time);
- return retVal;
-}
-
-int32_t QwDevXM125::setPresenceInterFramePresenceTimeout(uint32_t time)
-{
- return _theBus->writeRegister16Region(SFE_XM125_PRESENCE_INTER_FRAME_TIMEOUT, (uint8_t*)&time, 4);
-}
-
-int32_t QwDevXM125::getPresenceInterPhaseBoostEnabled(bool &en)
-{
- size_t readBytes = 0;
- return _theBus->readRegister16Region(SFE_XM125_PRESENCE_INTER_PHASE_BOOST_ENABLED, (uint8_t*)&en, 4, readBytes);
-}
-
-int32_t QwDevXM125::setPresenceInterPhaseBoostEnabled(bool en)
-{
- return _theBus->writeRegister16Region(SFE_XM125_PRESENCE_INTER_PHASE_BOOST_ENABLED, (uint8_t*)&en, 4);
-}
-
-int32_t QwDevXM125::getPresenceIntraDetectionEnabled(bool &en)
-{
- size_t readBytes = 0;
- return _theBus->readRegister16Region(SFE_XM125_PRESENCE_INTRA_DETECTION_ENABLED, (uint8_t*)&en, 4, readBytes);
-}
-
-int32_t QwDevXM125::setPresenceInterDetectionEnabled(bool en)
-{
- return _theBus->writeRegister16Region(SFE_XM125_PRESENCE_INTRA_DETECTION_ENABLED, (uint8_t*)&en, 4);
-}
-
-int32_t QwDevXM125::getPresenceFrameRate(uint32_t &rate)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_PRESENCE_FRAME_RATE, (uint8_t*)&rate, 4, readBytes);
- rate = __builtin_bswap32(rate);
- return retVal;
-}
-
-int32_t QwDevXM125::setPresenceFrameRate(uint32_t rate)
-{
- rate = __builtin_bswap32(rate);
- return _theBus->writeRegister16Region(SFE_XM125_PRESENCE_FRAME_RATE, (uint8_t*)&rate, 4);
-}
-
-int32_t QwDevXM125::getPresenceIntraDetectionThreshold(uint32_t &thresh)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_PRESENCE_INTRA_DETECTION_THRESHOLD, (uint8_t*)&thresh, 4, readBytes);
- thresh = __builtin_bswap32(thresh);
- return retVal;
-}
-
-int32_t QwDevXM125::setPresenceIntraDetectionThreshold(uint32_t thresh)
-{
- thresh = __builtin_bswap32(thresh);
- return _theBus->writeRegister16Region(SFE_XM125_PRESENCE_INTRA_DETECTION_THRESHOLD, (uint8_t*)&thresh, 4);
-}
-
-int32_t QwDevXM125::getPresenceInterDetectionThreshold(uint32_t &thresh)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_PRESENCE_INTRA_DETECTION_THRESHOLD, (uint8_t*)&thresh, 4, readBytes);
- thresh = __builtin_bswap32(thresh);
- return retVal;
-}
-
-int32_t QwDevXM125::setPresenceInterDetectionThreshold(uint32_t thresh)
-{
- thresh = __builtin_bswap32(thresh);
- return _theBus->writeRegister16Region(SFE_XM125_PRESENCE_INTER_DETECTION_THRESHOLD, (uint8_t*)&thresh, 4);
-}
-
-int32_t QwDevXM125::getPresenceInterFrameDeviationTime(uint32_t &time)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_PRESENCE_INTER_FRAME_DEVIATION, (uint8_t*)&time, 4, readBytes);
- time = __builtin_bswap32(time);
- return retVal;
-}
-
-int32_t QwDevXM125::setPresenceInterFrameDeviationTime(uint32_t time)
-{
- time = __builtin_bswap32(time);
- return _theBus->writeRegister16Region(SFE_XM125_PRESENCE_INTER_FRAME_DEVIATION, (uint8_t*)&time, 4);
-}
-
-int32_t QwDevXM125::getPresenceInterFrameFastCutoff(uint32_t &cut)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_PRESENCE_INTER_FRAME_FAST_CUTOFF, (uint8_t*)&cut, 4, readBytes);
- cut = __builtin_bswap32(cut);
- return retVal;
-}
-
-int32_t QwDevXM125::setPresenceInterFrameFastCutoff(uint32_t cut)
-{
- cut = __builtin_bswap32(cut);
- return _theBus->writeRegister16Region(SFE_XM125_PRESENCE_INTER_FRAME_FAST_CUTOFF, (uint8_t*)&cut, 4);
-}
-
-int32_t QwDevXM125::getPresenceInterFrameSlowCutoff(uint32_t &cut)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_PRESENCE_INTER_FRAME_SLOW_CUTOFF, (uint8_t*)&cut, 4, readBytes);
- cut = __builtin_bswap32(cut);
- return retVal;
-}
-
-int32_t QwDevXM125::setPresenceInterFrameSlowCutoff(uint32_t cut)
-{
- cut = __builtin_bswap32(cut);
- return _theBus->writeRegister16Region(SFE_XM125_PRESENCE_INTER_FRAME_SLOW_CUTOFF, (uint8_t*)&cut, 4);
-}
-
-int32_t QwDevXM125::getPresenceIntraFrameTimeConst(uint32_t &time)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_PRESENCE_INTRA_FRAME_TIME_CONST, (uint8_t*)&time, 4, readBytes);
- time = __builtin_bswap32(time);
- return retVal;
-}
-
-int32_t QwDevXM125::setPresenceIntraFrameTimeConst(uint32_t time)
-{
- time = __builtin_bswap32(time);
- return _theBus->writeRegister16Region(SFE_XM125_PRESENCE_INTRA_FRAME_TIME_CONST, (uint8_t*)&time, 4);
-}
-
-int32_t QwDevXM125::getPresenceIntraOutputTimeConst(uint32_t &time)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_PRESENCE_INTRA_OUTPUT_TIME_CONST, (uint8_t*)&time, 4, readBytes);
- time = __builtin_bswap32(time);
- return retVal;
-}
-
-int32_t QwDevXM125::setPresenceIntraOutputTimeConst(uint32_t time)
-{
- time = __builtin_bswap32(time);
- return _theBus->writeRegister16Region(SFE_XM125_PRESENCE_INTRA_OUTPUT_TIME_CONST, (uint8_t*)&time, 4);
-}
-
-int32_t QwDevXM125::getPresenceInterOutputTimeConst(uint32_t &time)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_PRESENCE_INTER_OUTPUT_TIME_CONST, (uint8_t*)&time, 4, readBytes);
- time = __builtin_bswap32(time);
- return retVal;
-}
-
-int32_t QwDevXM125::setPresenceInterOutputTimeConst(uint32_t time)
-{
- time = __builtin_bswap32(time);
- return _theBus->writeRegister16Region(SFE_XM125_PRESENCE_INTER_OUTPUT_TIME_CONST, (uint8_t*)&time, 4);
-}
-
-int32_t QwDevXM125::getPresenceAutoProfileEn(bool &en)
-{
- size_t readBytes = 0;
- return _theBus->readRegister16Region(SFE_XM125_PRESENCE_AUTO_PROFILE_ENABLED, (uint8_t*)&en, 4, readBytes);
-}
-
-int32_t QwDevXM125::setPresenceAutoProfileEn(bool en)
-{
- return _theBus->writeRegister16Region(SFE_XM125_PRESENCE_AUTO_PROFILE_ENABLED, (uint8_t*)&en, 4);
-}
-
-int32_t QwDevXM125::getPresenceAutoStepLengthEn(bool &en)
-{
- size_t readBytes = 0;
- return _theBus->readRegister16Region(SFE_XM125_PRESENCE_AUTO_STEP_LENGTH_ENABLED, (uint8_t*)&en, 4, readBytes);
-}
-
-int32_t QwDevXM125::setPresenceAutoStepLengthEn(bool en)
-{
- return _theBus->writeRegister16Region(SFE_XM125_PRESENCE_AUTO_STEP_LENGTH_ENABLED, (uint8_t*)&en, 4);
-}
-
-int32_t QwDevXM125::getPresenceManualProfile(uint32_t &prof)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_PRESENCE_MANUAL_PROFILE, (uint8_t*)&prof, 4, readBytes);
- prof = __builtin_bswap32(prof);
- return retVal;
-}
-
-int32_t QwDevXM125::setPresenceManualProfile(uint32_t prof)
-{
- prof = __builtin_bswap32(prof);
- return _theBus->writeRegister16Region(SFE_XM125_PRESENCE_MANUAL_PROFILE, (uint8_t*)&prof, 4);
-}
-
-int32_t QwDevXM125::getPresenceManualStepLength(uint32_t &length)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_PRESENCE_MANUAL_STEP_LENGTH, (uint8_t*)&length, 4, readBytes);
- length = __builtin_bswap32(length);
- return retVal;
-}
-
-int32_t QwDevXM125::setPresenceManualStepLength(uint32_t length)
-{
- length = __builtin_bswap32(length);
- return _theBus->writeRegister16Region(SFE_XM125_PRESENCE_MANUAL_STEP_LENGTH, (uint8_t*)&length, 4);
-}
-
-int32_t QwDevXM125::getPresenceStart(uint32_t &start)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_PRESENCE_START, (uint8_t*)&start, 4, readBytes);
- start = __builtin_bswap32(start);
- return retVal;
-}
-
-int32_t QwDevXM125::setPresenceStart(uint32_t start)
-{
- start = __builtin_bswap32(start);
- return _theBus->writeRegister16Region(SFE_XM125_PRESENCE_START, (uint8_t*)&start, 4);
-}
-
-int32_t QwDevXM125::getPresenceEnd(uint32_t &end)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_PRESENCE_END, (uint8_t*)&end, 4, readBytes);
- end = __builtin_bswap32(end);
- return retVal;
-}
-
-int32_t QwDevXM125::setPresenceEnd(uint32_t end)
-{
- end = __builtin_bswap32(end);
- return _theBus->writeRegister16Region(SFE_XM125_PRESENCE_END, (uint8_t*)&end, 4);
-}
-
-int32_t QwDevXM125::getPresenceResetFilters(bool &reset)
-{
- size_t readBytes = 0;
- return _theBus->readRegister16Region(SFE_XM125_PRESENCE_RESET_FILTERS_ON_PREPARE, (uint8_t*)&reset, 4, readBytes);
-}
-
-int32_t QwDevXM125::setPresenceResetFilters(bool reset)
-{
- return _theBus->writeRegister16Region(SFE_XM125_PRESENCE_RESET_FILTERS_ON_PREPARE, (uint8_t*)&reset, 4);
-}
-
-int32_t QwDevXM125::getPresenceHWAAS(uint32_t &avg)
-{
- size_t readBytes = 0;
- return _theBus->readRegister16Region(SFE_XM125_PRESENCE_HWAAS, (uint8_t*)&avg, 4, readBytes);
-}
-
-int32_t QwDevXM125::setPresenceHWAAS(uint32_t avg)
-{
- return _theBus->writeRegister16Region(SFE_XM125_PRESENCE_HWAAS, (uint8_t*)&avg, 4);
-}
-
-int32_t QwDevXM125::getPresenceDetectionOnGPIO(uint32_t &detected)
-{
- size_t readBytes = 0;
- int32_t retVal = _theBus->readRegister16Region(SFE_XM125_PRESENCE_DETECTION_ON_GPIO, (uint8_t*)&detected, 4, readBytes);
- detected = __builtin_bswap32(detected);
- return retVal;
-}
-
-int32_t QwDevXM125::setPresenceDetectionOnGPIO(uint32_t detected)
-{
- detected = __builtin_bswap32(detected);
- return _theBus->writeRegister16Region(SFE_XM125_PRESENCE_DETECTION_ON_GPIO, (uint8_t*)&detected, 4);
-}
-
-int32_t QwDevXM125::setPresenceCommand(uint32_t cmd)
-{
- cmd = __builtin_bswap32(cmd);
- return _theBus->writeRegister16Region(SFE_XM125_PRESENCE_COMMAND, (uint8_t*)&cmd, 4);
-}
-
-int32_t QwDevXM125::presenceApplyConfiguration()
-{
- return setPresenceCommand(SFE_XM125_PRESENCE_START_DETECTOR);
-}
-
-int32_t QwDevXM125::presenceStart()
-{
- return setPresenceCommand(SFE_XM125_PRESENCE_START_DETECTOR);
-}
-
-int32_t QwDevXM125::presencestop()
-{
- return setPresenceCommand(SFE_XM125_PRESENCE_STOP_DETECTOR);
-}
-
-int32_t QwDevXM125::presenceEnableUartLogs()
-{
- return setPresenceCommand(SFE_XM125_PRESENCE_ENABLE_UART_LOGS);
-}
-
-int32_t QwDevXM125::presenceDisableUartLogs()
-{
- return setPresenceCommand(SFE_XM125_PRESENCE_DISABLE_UART_LOGS);
-}
-
-int32_t QwDevXM125::presenceLogConfiguration()
-{
- return setPresenceCommand(SFE_XM125_PRESENCE_LOG_CONFIGURATION);
-}
-
-int32_t QwDevXM125::getPresenceBusy(uint32_t &busy)
-{
- int32_t retVal;
- uint32_t regVal = 0;
-
- // Read from 16-Bit Register
- size_t readBytes = 0;
- retVal = _theBus->readRegister16Region(SFE_XM125_PRESENCE_DETECTOR_STATUS, (uint8_t*)®Val, 4, readBytes);
-
- busy = __builtin_bswap32(busy);
- // Mask unused bits from register
- busy = (regVal & SFE_XM125_PRESENCE_BUSY_MASK) >> SFE_XM125_PRESENCE_BUSY_MASK_SHIFT;
-
- return retVal;
-}
-
-int32_t QwDevXM125::presenceBusyWait()
-{
- int32_t retVal = 0;
- uint32_t regVal = 0;
-
- size_t readBytes = 0;
- retVal = _theBus->readRegister16Region(SFE_XM125_PRESENCE_DETECTOR_STATUS, (uint8_t*)®Val, 4, readBytes);
- regVal = __builtin_bswap32(regVal);
-
- // Poll Detector Status until Busy bit is cleared
- while(((regVal & SFE_XM125_PRESENCE_BUSY_MASK) >> 30) != 0)
- {
- retVal = _theBus->readRegister16Region(SFE_XM125_PRESENCE_DETECTOR_STATUS, (uint8_t*)®Val, 4, readBytes);
- regVal = __builtin_bswap32(regVal);
- }
-
- if(retVal != 0)
- {
- return retVal;
- }
- return 0; // 0 on success
-}
diff --git a/src/sfeQwiicXM125.h b/src/sfeQwiicXM125.h
deleted file mode 100644
index 6e29431..0000000
--- a/src/sfeQwiicXM125.h
+++ /dev/null
@@ -1,880 +0,0 @@
-#pragma once
-
-#include "SparkFun_Toolkit.h"
-#include "sfeXM125Regs.h"
-
-class QwDevXM125
-{
- public:
- /// @brief Initializer
- QwDevXM125();
-
- /// @brief This function begins the examples/communication.
- /// @return Error code (0 no error)
- bool begin(sfeTkII2C *theBus = nullptr);
-
- int32_t returnRegister(uint32_t ®Val);
-
- // --------------------- I2C Disance Detector Functions ---------------------
-
- /// @brief This function sets all the beginning values for a basic I2C
- /// example to be run on the device for presence sensing.
- /// @return Error code (0 no error)
- int32_t distanceBegin();
-
- /// @brief This function does all the required checks and busy waits to
- /// make sure the device is ready for distance readings.
- /// @return Error code (0 no error)
- int32_t distanceDetectorReadingSetup();
-
- /// @brief This function returns the version number of the device
- /// structure: major.minor.patch
- /// @return Error code (0 no error)
- int32_t getDistanceDetectorVersion(uint32_t &major, uint32_t &minor, uint32_t &patch);
-
- /// @brief This function returns if there was an error from the
- /// protocol status register
- /// @return Error code (0 no error)
- int32_t getDistanceDetectorError(uint32_t &error);
-
- /// @brief This function returns the error status according to the bit
- /// mask value for the distance devices errors and busy bit
- /// @param status Error status of device (see function for exact error)
- /// @return Error code (0 no error)
- int32_t getDistanceDetectorErrorStatus(uint32_t &status);
-
- /// @brief This function returns the measure counter, the number of measurements
- /// performed since restart.
- /// @return Error code (0 no error)
- int32_t getDistanceMeasureCounter(uint32_t &counter);
-
- /// @brief This function returns the status of the device if there are any issues
- /// with any of the status's listed defined.
- /// @return Error code (0 no error)
- int32_t getDistanceDetectorStatus(uint32_t &status);
-
- /// @brief This function returns the number of detected distances.
- /// @param distance Number of detected distances
- /// @return Error code (0 no error)
- int32_t getDistanceNumberDistances(uint32_t &distance);
-
- /// @brief This function returns the indication that there might be an object
- /// near the start point of the measured range.
- /// @param edge Flag to determine object in range
- /// @return Error code (0 no error)
- int32_t getDistanceNearStartEdge(uint32_t &edge);
-
- /// @brief This function returns the indication of a sensor calibration needed.
- /// @param calibrate Flag to indicate calibration required
- /// @return Error code (0 no error)
- int32_t getDistanceCalibrationNeeded(uint32_t &calibrate);
-
- /// @brief This function returns if the measure command failed.
- /// @param error Flag to indicate measure command error
- /// @return Error code (0 no error)
- int32_t getDistanceMeasureDistanceError(uint32_t &error);
-
- /// @brief This function returns the temperature in sensor during measurements
- /// (in degree Celsius). Note that it has poor absolute accuracy and should
- /// only be used for relative temperature measurements.
- /// @param temperature Relative tempertaure of device
- /// @return Error code (0 no error)
- int32_t getDistanceTemperature(uint32_t &temperature);
-
- /// @brief This function returns the distance to peak 0
- /// Note: This value is a factor 1000 larger than the RSS value
- /// @return Error code (0 no error)
- int32_t getDistancePeak0Distance(uint32_t &peak);
-
- /// @brief This function returns the distance to peak 1
- /// Note: This value is a factor 1000 larger than the RSS value
- /// @return Error code (0 no error)
- int32_t getDistancePeak1Distance(uint32_t &peak);
-
- /// @brief This function returns the distance to peak 2
- /// Note: This value is a factor 1000 larger than the RSS value
- /// @return Error code (0 no error)
- int32_t getDistancePeak2Distance(uint32_t &peak);
-
- /// @brief This function returns the distance to peak 3
- /// Note: This value is a factor 1000 larger than the RSS value
- /// @return Error code (0 no error)
- int32_t getDistancePeak3Distance(uint32_t &peak);
-
- /// @brief This function returns the distance to peak 4
- /// Note: This value is a factor 1000 larger than the RSS value
- /// @return Error code (0 no error)
- int32_t getDistancePeak4Distance(uint32_t &peak);
-
- /// @brief This function returns the distance to peak 5
- /// Note: This value is a factor 1000 larger than the RSS value
- /// @return Error code (0 no error)
- int32_t getDistancePeak5Distance(uint32_t &peak);
-
- /// @brief This function returns the distance to peak 6
- /// Note: This value is a factor 1000 larger than the RSS value
- /// @return Error code (0 no error)
- int32_t getDistancePeak6Distance(uint32_t &peak);
-
- /// @brief This function returns the distance to peak 7
- /// Note: This value is a factor 1000 larger than the RSS value
- /// @return Error code (0 no error)
- int32_t getDistancePeak7Distance(uint32_t &peak);
-
- /// @brief This function returns the distance to peak 8
- /// Note: This value is a factor 1000 larger than the RSS value
- /// @return Error code (0 no error)
- int32_t getDistancePeak8Distance(uint32_t &peak);
-
- /// @brief This function returns the distance to peak 9
- /// Note: This value is a factor 1000 larger than the RSS value
- /// @return Error code (0 no error)
- int32_t getDistancePeak9Distance(uint32_t &peak);
-
- /// @brief This function returns the strength of peak 0
- /// Note: This value is a factor 1000 larger than the RSS value
- /// @return Error code (0 no error)
- int32_t getDistancePeak0Strength(uint32_t &peak);
-
- /// @brief This function returns the strength of peak 1
- /// Note: This value is a factor 1000 larger than the RSS value
- /// @return Error code (0 no error)
- int32_t getDistancePeak1Strength(uint32_t &peak);
-
- /// @brief This function returns the strength of peak 2
- /// Note: This value is a factor 1000 larger than the RSS value
- /// @return Error code (0 no error)
- int32_t getDistancePeak2Strength(uint32_t &peak);
-
- /// @brief This function returns the strength of peak 3
- /// Note: This value is a factor 1000 larger than the RSS value
- /// @return Error code (0 no error)
- int32_t getDistancePeak3Strength(uint32_t &peak);
-
- /// @brief This function returns the strength of peak 4
- /// Note: This value is a factor 1000 larger than the RSS value
- /// @return Error code (0 no error)
- int32_t getDistancePeak4Strength(uint32_t &peak);
-
- /// @brief This function returns the strength of peak 5
- /// Note: This value is a factor 1000 larger than the RSS value
- /// @return Error code (0 no error)
- int32_t getDistancePeak5Strength(uint32_t &peak);
-
- /// @brief This function returns the strength of peak 6
- /// Note: This value is a factor 1000 larger than the RSS value
- /// @return Error code (0 no error)
- int32_t getDistancePeak6Strength(uint32_t &peak);
-
- /// @brief This function returns the strength of peak 7
- /// Note: This value is a factor 1000 larger than the RSS value
- /// @return Error code (0 no error)
- int32_t getDistancePeak7Strength(uint32_t &peak);
-
- /// @brief This function returns the strength of peak 8
- /// Note: This value is a factor 1000 larger than the RSS value
- /// @return Error code (0 no error)
- int32_t getDistancePeak8Strength(uint32_t &peak);
-
- /// @brief This function returns the strength of peak 9
- /// Note: This value is a factor 1000 larger than the RSS value
- /// @return Error code (0 no error)
- int32_t getDistancePeak9Strength(uint32_t &peak);
-
- /// @brief This function returns the start of measured interval
- /// in millimeters.
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 250
- /// @return Error code (0 no error)
- int32_t getDistanceStart(uint32_t &startVal);
-
- /// @brief This function sets the start of measured interval in
- /// millimeters.
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 250
- /// @return Error code (0 no error)
- int32_t setDistanceStart(uint32_t start);
-
- /// @brief This function returns the end of measured interval
- /// in millimeters.
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 3000
- /// @return Error code (0 no error)
- int32_t getDistanceEnd(uint32_t &end);
-
- /// @brief This function sets the end of measured interval
- /// in millimeters.
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 3000
- /// @return Error code (0 no error)
- int32_t setDistanceEnd(uint32_t end);
-
- /// @brief This function returns the used to limit step length.
- /// If set to 0 (default), the step length is calculated
- /// based on profile.
- /// Default Value: 0
- /// @return Error code (0 no error)
- int32_t getDistanceMaxStepLength(uint32_t &length);
-
- /// @brief This function sets the used to limit step length.
- /// If set to 0 (default), the step length is calculated
- /// based on profile.
- /// Default Value: 0
- /// @return Error code (0 no error)
- int32_t setDistanceMaxStepLength(uint32_t length);
-
- /// @brief This function reads if the close range leakage
- /// cancellation logic is enabled.
- /// Default Value: true
- /// @return Error code (0 no error)
- int32_t getDistanceCloseRangeLeakageCancellation(bool &range);
-
- /// @brief This function sets the close range leakage
- /// cancellation logic.
- /// Default Value: true
- /// @return Error code (0 no error)
- int32_t setDistanceCloseRangeLeakageCancellation(bool range);
-
- /// @brief This function returns the high signal quality in a
- /// better SNR (because of higher HWAAS) and higher power consumption.
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 15000
- /// @return Error code (0 no error)
- int32_t getDistanceSignalQuality(uint32_t &signal);
-
- /// @brief This function sets the high signal quality in a
- /// better SNR (because of higher HWAAS) and higher power consumption.
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 15000
- /// @return Error code (0 no error)
- int32_t setDistanceSignalQuality(uint32_t signal);
-
- /// @brief This function returns the max profile of the device.
- /// Default value = PROFILE5
- /// @return Error code (0 no error)
- int32_t getDistanceMaxProfile(uint32_t &profile);
-
- /// @brief This function sets the max profile of the device
- /// Default value = PROFILE5
- /// @return Error code (0 no error)
- int32_t setDistanceMaxProfile(uint32_t profile);
-
- /// @brief This function returns the threshold method
- /// @return Error code (0 no error)
- int32_t getDistanceThresholdMethod(uint32_t &method);
-
- /// @brief This function sets the threshold method
- /// @param method Threshold method (enum)
- /// @return Error code (0 no error)
- int32_t setDistanceThresholdMethod(uint32_t method);
-
- /// @brief This function returns the peak sorting method
- /// @param peak Peak sorting method
- /// @return Error code (0 no error)
- int32_t getDistancePeakSorting(uint32_t &peak);
-
- /// @brief This function sets the peak sorting method
- /// @param peak Peak sorting method
- /// @return Error code (0 no error)
- int32_t setDistancePeakSorting(uint32_t peak);
-
- /// @brief This function returns the number frames to use for recorded threshold.
- /// Default Value: 100
- /// @param thresh Number of frames
- /// @return Error code (0 no error)
- int32_t getDistanceNumFramesRecordedThreshold(uint32_t &thresh);
-
- /// @brief This function sets the number frames to use for recorded threshold.
- /// Default Value: 100
- /// @param thresh Number of frames
- /// @return Error code (0 no error)
- int32_t setDistanceNumFramesRecordedThreshold(uint32_t thresh);
-
- /// @brief This function returns the fixed amplitude threshold value.
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 100000
- /// @param thresh Fixed amplitude threshold value
- /// @return Error code (0 no error)
- int32_t getDistanceFixedAmpThreshold(uint32_t &thresh);
-
- /// @brief This function sets the fixed amplitude threshold value.
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 100000
- /// @param thresh Fixed amplitude threshold value
- /// @return Error code (0 no error)
- int32_t setDistanceFixedAmpThreshold(uint32_t thresh);
-
- /// @brief This function returns the threshold sensitivity
- /// (0 <= sensitivity <= 1000)
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 500
- /// @param thresh& Threshold sensitivity
- /// @return Error code (0 no error)
- int32_t getDistanceThresholdSensitivity(uint32_t &thresh);
-
- /// @brief This function sets the threshold sensitivity
- /// (0 <= sensitivity <= 1000)
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 500
- /// @param thresh Threshold sensitivity
- /// @return Error code (0 no error)
- int32_t setDistanceThresholdSensitivity(uint32_t thresh);
-
- /// @brief This function returns the reflector shape
- /// Default Value: GENERIC
- /// @param shape Generic or planar reflection
- /// @return Error code (0 no error)
- int32_t getDistanceReflectorShape(uint32_t &shape);
-
- /// @brief This function sets the reflector shape
- /// Default Value: GENERIC
- /// @param shape Generic or planar reflection
- /// @return Error code (0 no error)
- int32_t setDistanceReflectorShape(uint32_t shape);
-
- /// @brief This function returns the fixed strength threshold value.
- /// Default Value: 0
- /// Note: This value is a factor 1000 larger than the RSS value
- /// @param thresh fixed threshold strength value
- /// @return Error code (0 no error)
- int32_t getDistanceFixedStrengthThresholdValue(int32_t &thresh);
-
- /// @brief This function sets the fixed strength threshold value.
- /// Default Value: 0
- /// Note: This value is a factor 1000 larger than the RSS value
- /// @param thresh fixed threshold strength value
- /// @return Error code (0 no error)
- int32_t setDistanceFixedStrengthThresholdValue(int32_t thresh);
-
- /// @brief This function returns the measure on wakeup status.
- /// Default Value: false
- /// @param measure Measure on wakeup occurance
- /// @return Error code (0 no error)
- int32_t getDistanceMeasureOneWakeup(bool &measure);
-
- /// @brief This function sets the measure on wakeup status.
- /// Default Value: false
- /// @param measure Measure on wakeup occurance
- /// @return Error code (0 no error)
- int32_t setDistanceMeasureOneWakeup(bool measure);
-
- /// @brief This function sets the specific execute command as defined in the
- /// datasheet on Page 25, Section 6.2.40 Command.
- /// @param apply Enable configuration and calibrate
- /// @return Error code (0 no error)
- int32_t setDistanceCommand(uint32_t command);
-
- /// @brief This function applies the configuration to the device by
- /// writing the defined value to the distance command register
- /// @return Error code (0 no error)
- int32_t distanceApplyConfiguration();
-
- /// @brief This function starts the device by writing the defined
- /// start value to the distance command register
- /// @return Error code (0 no error)
- int32_t distanceStart();
-
- /// @brief This function stops the device by writing the defined
- /// stop value to the distance command register
- /// @return Error code (0 no error)
- int32_t distanceStop();
-
- /// @brief This function calibrates the device by writing the defined
- /// calibration value to the distance command register
- /// @return Error code (0 no error)
- int32_t distanceCalibrate();
-
- /// @brief This function recalibrates the device by writing the defined
- /// recalibrate value to the distance command register
- /// @return Error code (0 no error)
- int32_t distanceRecalibrate();
-
- /// @brief This function enables the uart logs of the device by
- /// writing the defined value to the distance command register
- /// @return Error code (0 no error)
- int32_t distanceEnableUartLogs();
-
- /// @brief This function disables the uart logs of the device by
- /// writing the defined value to the distance command register
- /// @return Error code (0 no error)
- int32_t distanceDisableUartLogs();
-
- /// @brief This function enables the configuration log of the device
- /// by writing the defined value to the distance command register
- /// @return Error code (0 no error)
- int32_t distanceLogConfiguration();
-
- /// @brief This function resets the distance detector settings
- /// of the device
- /// @return Error code (0 no error)
- int32_t distanceReset();
-
- /// @brief Completes a busy wait loop while the device is uploading
- /// information by waiting for the status
- /// @return Error code (0 no error)
- int32_t distanceBusyWait();
-
- // --------------------- I2C Presence Detector Functions ---------------------
-
- /// @brief This function sets all the beginning values for a basic I2C
- /// example to be run on the device for presence sensing.
- /// @return Error code (0 no error)
- int32_t presenceDetectorStart();
-
- /// @brief This function returns the presence value of the register
- /// with all the checks in place as per the I2C Datasheet.
- /// @return Error code (0 no error)
- int32_t getPresenceDistanceValuemm(uint32_t &presenceVal);
-
- /// @brief This function returns the RSS version number
- /// @param version Version number
- /// @param patch Patch version number
- /// @return Error code (0 no error)
- int32_t getPresenceDetectorVersion(uint32_t &major, uint32_t &minor, uint32_t &patch);
-
- /// @brief This function returns the protocol state erorr
- /// @param state Error code for device
- /// 0 = Protocol state error
- /// 1 = Packet length error
- /// 2 = Address error
- /// 3 = Write failed
- /// 4 = Write to read only
- /// @return Error code (0 no error)
- int32_t getPresenceDetectorError(uint32_t &error);
-
- /// @brief This function returns the measure counter; the number of
- /// measurements performed since restart.
- /// @param counter number of measurements
- /// @return Error code (0 no error)
- int32_t getPresenceMeasureCounter(uint32_t &counter);
-
- /// @brief This function returns the detector status flags. See page 17, section
- /// 6.2.4 Detector Status
- /// @param status Status detector flag
- /// @return Error code (0 no error)
- int32_t getPresenceDetectorStatus(uint32_t &status);
-
- /// @brief This function returns the error status according to the bit
- /// mask value for the presence devices errors and busy bit
- /// @param status Error status of device (see function for exact error)
- /// @return Error code (0 no error)
- int32_t getPresenceDetectorErrorStatus(uint32_t &status);
-
- /// @brief This function returns if there was presence detected
- /// @param detected Presence Detected
- /// @return Error code (0 no error)
- int32_t getPresenceDetectorPresenceDetected(uint32_t &detected);
-
- /// @brief This function returns if there was presence detected, sticky bit with
- /// clear on read.
- /// @param sticky Sticky Presence Detected
- /// @return Error code (0 no error)
- int32_t getPresenceDetectorPresenceStickyDetected(uint32_t &sticky);
-
- /// @brief This function returns the indication that the presence detector
- /// failed.
- /// @param calibrate Indication of sensor calibration
- /// @return Error code (0 no error)
- int32_t getPresenceDetectorRegError(uint32_t &error);
-
- /// @brief This function returns the temperature in sensor during measurement (in
- /// degree Celsius). Note that it has poor absolute accuracy and should only
- /// be used for relavtive temperature measurements.
- /// @param temp Relative temperature
- /// @return Error code (0 no error)
- int32_t getPresenceTemperature(uint32_t &temp);
-
- /// @brief This function returns the distance, in millimeters, for the detected
- /// presence.
- /// @param distance distance in mm
- /// @return Error code (0 no error)
- int32_t getPresenceDistance(uint32_t &distance);
-
- /// @brief This function returns the measure of amount of fast motion detected.
- /// @param intra Measure of fast motion
- /// @return Error code (0 no error)
- int32_t getPresenceIntraPresenceScore(uint32_t &intra);
-
- /// @brief This function returns the measure of amount of slow motion detected.
- /// @param inter Measure of slow motion
- /// @return Error code (0 no error)
- int32_t getPresenceInterPresenceScore(uint32_t &inter);
-
- /// @brief This function returns the number of sweeps that will be
- /// captured in each frame (measurement).
- /// Default Value: 16 seconds
- /// @param sweeps Number of sweeps
- /// @return Error code (0 no error)
- int32_t getPresenceSweepsPerFrame(uint32_t &sweeps);
-
- /// @brief This function sets the number of sweeps that will be
- /// captured in each frame (measurement).
- /// Default Value: 16 seconds
- /// @param sweeps Number of sweeps
- /// @return Error code (0 no error)
- int32_t setPresenceSweepsPerFrame(uint32_t sweeps);
-
- /// @brief Returns the number of seconds the inter-frame presence score needs to decrease before
- /// exponential scaling starts for faster decline. Should be between 0 and 30 where 0
- /// means no timeout.
- /// Default Value: 3 seconds
- /// @param time Number of seconds
- /// @return Error code (0 no error)
- int32_t getPresenceInterFramePresenceTimeout(uint32_t &time);
-
- /// @brief Sets the number of seconds the inter-frame presence score needs to decrease before
- /// exponential scaling starts for faster decline. Should be between 0 and 30 where 0
- /// means no timeout.
- /// Default Value: 3 seconds
- /// @param time Number of seconds
- /// @return Error code (0 no error)
- int32_t setPresenceInterFramePresenceTimeout(uint32_t time);
-
- /// @brief This function returns the enable to increase detection of slow
- /// motions by utilizing the phase information in the Sparse IQ data
- /// @param en Enables increased detection
- /// Default Value: false
- /// @return Error code (0 no error)
- int32_t getPresenceInterPhaseBoostEnabled(bool &en);
-
- /// @brief This function sets the enable to increase detection of slow
- /// motions by utilizing the phase information in the Sparse IQ data
- /// @param en Enables increased detection
- /// Default Value: false
- /// @return Error code (0 no error)
- int32_t setPresenceInterPhaseBoostEnabled(bool en);
-
- /// @brief This function returns the bit to enable to detect faster
- /// movements inside frames.
- /// Default Value: true
- /// @param en Enables faster detection
- /// @return Error code (0 no error)
- int32_t getPresenceIntraDetectionEnabled(bool &en);
-
- /// @brief This function returns the bit to enable to detect slower
- /// movements between frames.
- /// Default Value: true
- /// @param en Enables faster detection
- /// @return Error code (0 no error)
- int32_t setPresenceInterDetectionEnabled(bool en);
-
- /// @brief This function returns the presence detector frame rate.
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 12000 mHz
- /// @param rate Frame rate, in mHz
- /// @return Error code (0 no error)
- int32_t getPresenceFrameRate(uint32_t &rate);
-
- /// @brief This function sets the presence detector frame rate.
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 12000 mHz
- /// @param rate Frame rate, in mHz
- /// @return Error code (0 no error)
- int32_t setPresenceFrameRate(uint32_t rate);
-
- /// @brief This function returns the threshold for detecting faster
- /// movements inside frames.
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 1300
- /// @param thresh threshold for faster movements
- /// @return Error code (0 no error)
- int32_t getPresenceIntraDetectionThreshold(uint32_t &thresh);
-
- /// @brief This function sets the threshold for detecting faster
- /// movements inside frames.
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 1300
- /// @param thresh threshold for faster movements
- /// @return Error code (0 no error)
- int32_t setPresenceIntraDetectionThreshold(uint32_t thresh);
-
- /// @brief This function returns the threshold for detecting slower
- /// movements inside frames.
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 1000
- /// @param thresh threshold for faster movements
- /// @return Error code (0 no error)
- int32_t getPresenceInterDetectionThreshold(uint32_t &thresh);
-
- /// @brief This function sets the threshold for detecting slower
- /// movements inside frames.
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 1000
- /// @param thresh threshold for faster movements
- /// @return Error code (0 no error)
- int32_t setPresenceInterDetectionThreshold(uint32_t thresh);
-
- /// @brief This function returns the time constant of the low pass
- /// filter for the inter-frame deviation between fast and slow.
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 500 ms
- /// @param time time in ms
- /// @return Error code (0 no error)
- int32_t getPresenceInterFrameDeviationTime(uint32_t &time);
-
- /// @brief This function sets the time constant of the low pass
- /// filter for the inter-frame deviation between fast and slow.
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 500 ms
- /// @param time time in ms
- /// @return Error code (0 no error)
- int32_t setPresenceInterFrameDeviationTime(uint32_t time);
-
- /// @brief This function returns the cutoff frequency of the low pass
- /// filter for the fast filtered absolute sweep mean.
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 6000 mHz
- /// @param cut cutoff frequency in mHz
- /// @return Error code (0 no error)
- int32_t getPresenceInterFrameFastCutoff(uint32_t &cut);
-
- /// @brief This function sets the cutoff frequency of the low pass
- /// filter for the fast filtered absolute sweep mean.
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 6000 mHz
- /// @param cut cutoff frequency in mHz
- /// @return Error code (0 no error)
- int32_t setPresenceInterFrameFastCutoff(uint32_t cut);
-
- /// @brief This function returns the cutoff frequency of the low pass
- /// filter for the slow filtered absolute sweep mean.
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 200 mHz
- /// @param cut cutoff frequency in mHz
- /// @return Error code (0 no error)
- int32_t getPresenceInterFrameSlowCutoff(uint32_t &cut);
-
- /// @brief This function sets the cutoff frequency of the low pass
- /// filter for the slow filtered absolute sweep mean.
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 200 mHz
- /// @param cut cutoff frequency in mHz
- /// @return Error code (0 no error)
- int32_t setPresenceInterFrameSlowCutoff(uint32_t cut);
-
- /// @brief This functions returns time constant for the depthwise
- /// filtering in the intra-frame part
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 150ms
- /// @param time time const in ms
- /// @return Error code (0 no error)
- int32_t getPresenceIntraFrameTimeConst(uint32_t &time);
-
- /// @brief This functions sets time constant for the depthwise
- /// filtering in the intra-frame part
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 150ms
- /// @param time time const in ms
- /// @return Error code (0 no error)
- int32_t setPresenceIntraFrameTimeConst(uint32_t time);
-
- /// @brief This function returns time constant for the output in
- /// the intra-frame part
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 300ms
- /// @param time time const in ms
- /// @return Error code (0 no error)
- int32_t getPresenceIntraOutputTimeConst(uint32_t &time);
-
- /// @brief This function sets the time constant for the output in
- /// the intra-frame part
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 300ms
- /// @param time time const in ms
- /// @return Error code (0 no error)
- int32_t setPresenceIntraOutputTimeConst(uint32_t time);
-
- /// @brief This function returns time constant for the output in
- /// the inter-frame part
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 2000ms
- /// @param time time const in ms
- /// @return Error code (0 no error)
- int32_t getPresenceInterOutputTimeConst(uint32_t &time);
-
- /// @brief This function sets the time constant for the output in
- /// the inter-frame part
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 2000ms
- /// @param time time const in ms
- /// @return Error code (0 no error)
- int32_t setPresenceInterOutputTimeConst(uint32_t time);
-
- /// @brief This function returns if enable/disable for the automatic
- /// selection of profile based on start point of measurement.
- /// Default Value: true
- /// @param en enable/disable selection
- /// @return Error code (0 no error)
- int32_t getPresenceAutoProfileEn(bool &en);
-
- /// @brief This function enables/disables the automatic selection
- /// of profile based on start point of measurement.
- /// Default Value: true
- /// @param en enable/disable selection
- /// @return Error code (0 no error)
- int32_t setPresenceAutoProfileEn(bool en);
-
- /// @brief This function returns the Enable/Disable
- /// automatic selection of step length based on the profile.
- /// @param en Enable/disable selection
- /// @return Error code (0 no error)
- int32_t getPresenceAutoStepLengthEn(bool &en);
-
- /// @brief This function Enables/Disables automatic selection
- /// of step length based on the profile.
- /// @param en Enable/disable selection
- /// @return Error code (0 no error)
- int32_t setPresenceAutoStepLengthEn(bool en);
-
- /// @brief This function returns the profile in use. The profile will only
- /// be used if profile auto selection was disabled.
- /// @param prof Profile to use (enum)
- /// @return Error code (0 no error)
- int32_t getPresenceManualProfile(uint32_t &prof);
-
- /// @brief This function sets the profile to use. The profile will only
- /// be used if profile auto selection was disabled.
- /// @param prof Profile to use (enum)
- /// @return Error code (0 no error)
- int32_t setPresenceManualProfile(uint32_t prof);
-
- /// @brief THis function returns the number of steps between each data point.
- /// NOTE: The manual step length will only be used if step length auto selection
- /// was disabled
- /// Default Value: 72
- /// @param length number of steps
- /// @return Error code (0 no error)
- int32_t getPresenceManualStepLength(uint32_t &length);
-
- /// @brief THis function returns the number of steps between each data point.
- /// NOTE: The manual step length will only be used if step length auto selection
- /// was disabled
- /// Default Value: 72
- /// @param length number of steps
- /// @return Error code (0 no error)
- int32_t setPresenceManualStepLength(uint32_t length);
-
- /// @brief This function returns the start of measured interval in mm.
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 300mm
- /// @param start measured start interval in mm
- /// @return Error code (0 no error)
- int32_t getPresenceStart(uint32_t &start);
-
- /// @brief This function sets the start of measured interval in mm.
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 300mm
- /// @param start measured start interval in mm
- /// @return Error code (0 no error)
- int32_t setPresenceStart(uint32_t start);
-
- /// @brief This function returns the end point of measurement
- /// interval in millimeters.
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 2500
- /// @param end End point of measurement in mm
- /// @return Error code (0 no error)
- int32_t getPresenceEnd(uint32_t &end);
-
- /// @brief This function returns the end point of measurement
- /// interval in millimeters.
- /// Note: This value is a factor 1000 larger than the RSS value
- /// Default Value: 2500
- /// @param end End point of measurement in mm
- /// @return Error code (0 no error)
- int32_t setPresenceEnd(uint32_t end);
-
- /// @brief This function returns if the device is enabled/disabled
- /// for the reset of the presence filters during start/restart.
- /// Default Value: true
- /// @param reset enabled/disabled
- /// @return Error code (0 no error)
- int32_t getPresenceResetFilters(bool &reset);
-
- /// @brief This function sets if the device is enabled/disabled
- /// for the reset of the presence filters during start/restart .
- /// Default Value: true
- /// @param reset enabled/disabled
- /// @return Error code (0 no error)
- int32_t setPresenceResetFilters(bool reset);
-
- /// @brief This function returns the hardware accelerated average
- /// sampled (HWAAS).
- /// Default Value: 32
- /// @param avg average samples
- /// @return Error code (0 no error)
- int32_t getPresenceHWAAS(uint32_t &avg);
-
- /// @brief This function sets the hardware accelerated average
- /// sampled (HWAAS).
- /// Default Value: 32
- /// @param avg average samples
- /// @return Error code (0 no error)
- int32_t setPresenceHWAAS(uint32_t avg);
-
- /// @brief This function returns the output presence detection on
- /// generic GPIO.
- /// @param detected Output presence detected
- /// @return Error code (0 no error)
- int32_t getPresenceDetectionOnGPIO(uint32_t &detected);
-
- /// @brief This function returns the output presence detection on
- /// generic GPIO.
- /// @param detected Output presence detected
- /// @return Error code (0 no error)
- int32_t setPresenceDetectionOnGPIO(uint32_t detected);
-
- /// @brief This function sets the execute command
- /// @param cmd command to send to device
- /// @return Error code (0 no error)
- int32_t setPresenceCommand(uint32_t cmd);
-
- /// @brief This function applies the configuration to the device by
- /// writing the defined value to the presence command register
- /// @return Error code (0 no error)
- int32_t presenceApplyConfiguration();
-
- /// @brief This function starts the device by writing the defined
- /// start value to the presence command register
- /// @return Error code (0 no error)
- int32_t presenceStart();
-
- /// @brief This function stops the device by writing the defined
- /// stop value to the presence command register
- /// @return Error code (0 no error)
- int32_t presencestop();
-
- /// @brief This function enables the uart logs of the device by
- /// writing the defined value to the presence command register
- /// @return Error code (0 no error)
- int32_t presenceEnableUartLogs();
-
- /// @brief This function disables the uart logs of the device by
- /// writing the defined value to the presence command register
- /// @return Error code (0 no error)
- int32_t presenceDisableUartLogs();
-
- /// @brief This function enables the configuration log of the device
- /// by writing the defined value to the presence command register
- /// @return Error code (0 no error)
- int32_t presenceLogConfiguration();
-
- /// @brief This function resets the presence detector settings
- /// of the device
- /// @return Error code (0 no error)
- int32_t presenceReset();
-
- /// @brief This function returns the busy bit of the presence status register
- /// @param busy Device busy or not
- /// @return Error code (0 no error)
- int32_t getPresenceBusy(uint32_t &busy);
-
- /// @brief Completes a busy wait loop while the device is uploading
- /// information by waiting for the status. Checks the error status register
- /// to wait until errors are completed/gone
- /// @return Error code (0 no error)
- int32_t presenceBusyWait();
-
- protected:
- sfeTkII2C *_theBus;
-};
diff --git a/src/sfeXM125Regs.h b/src/sfeXM125Regs.h
deleted file mode 100644
index 4cea61b..0000000
--- a/src/sfeXM125Regs.h
+++ /dev/null
@@ -1,488 +0,0 @@
-// sfe_xm125_regs.h
-//
-// This is a library written for SparkFun Pulsed Coherent Radar Sensor - XM125
-//
-// SparkFun sells these boards at its website: www.sparkfun.com
-//
-// Do you like this library? Help support SparkFun. Buy a board!
-//
-// SparkFun Indoor Air Quality Sensor - XM125 (Qwiic) https://www.sparkfun.com/products/
-//
-// Written by Madison Chodikov @ SparkFun Electronics, January 2023
-//
-// Repository:
-// https://github.com/sparkfun/SparkFun_Qwiic_XM125_Arduino_Library/
-//
-// SparkFun code, firmware, and software is released under the MIT
-// License(http://opensource.org/licenses/MIT).
-//
-// SPDX-License-Identifier: MIT
-//
-// The MIT License (MIT)
-//
-// Copyright (c) 2022 SparkFun Electronics
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following conditions: The
-// above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED
-// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
-// NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
-// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-// The following defines the bits and registers of the ENS160.
-
-#include
-
-const uint16_t SFE_XM125_I2C_ADDRESS = 0x52;
-
-/* ****************************** Distance Values ****************************** */
-
-const uint32_t SFE_XM125_DISTANCE_MAJOR_VERSION_MASK = 0xffff0000;
-const uint32_t SFE_XM125_DISTANCE_MINOR_VERSION_MASK = 0x0000ff00;
-const uint32_t SFE_XM125_DISTANCE_PATCH_VERSION_MASK = 0x000000ff;
-const uint32_t SFE_XM125_DISTANCE_NUMBER_DISTANCES_MASK = 0x0000000f;
-const uint32_t SFE_XM125_DISTANCE_NEAR_START_EDGE_MASK = 0x00000100;
-const uint32_t SFE_XM125_DISTANCE_MEASURE_DISTANCE_ERROR_MASK = 0x00000400;
-const uint32_t SFE_XM125_DISTANCE_TEMPERATURE_MASK = 0xffff0000;
-const uint32_t SFE_XM125_DISTANCE_RSS_REGISTER_OK_MASK = 0x00000001;
-const uint32_t SFE_XM125_DISTANCE_CONFIG_CREATE_OK_MASK = 0x00000002;
-const uint32_t SFE_XM125_DISTANCE_SENSOR_CREATE_OK_MASK = 0x00000004;
-const uint32_t SFE_XM125_DISTANCE_DETECTOR_CREATE_OK_MASK = 0x00000008;
-const uint32_t SFE_XM125_DISTANCE_DETECTOR_BUFFER_OK_MASK = 0x00000010;
-const uint32_t SFE_XM125_DISTANCE_SENSOR_BUFFER_OK_MASK = 0x00000020;
-const uint32_t SFE_XM125_DISTANCE_CALIBRATION_BUFFER_OK_MASK = 0x00000040;
-const uint32_t SFE_XM125_DISTANCE_CONFIG_APPLY_OK_MASK = 0x00000080;
-const uint32_t SFE_XM125_DISTANCE_SENSOR_CALIBRATE_OK_MASK = 0x00000100;
-const uint32_t SFE_XM125_DISTANCE_DETECTOR_CALIBRATE_OK_MASK = 0x00000200;
-const uint32_t SFE_XM125_DISTANCE_RSS_REGISTER_ERROR_MASK = 0x00010000;
-const uint32_t SFE_XM125_DISTANCE_CONFIG_CREATE_ERROR_MASK = 0x00020000;
-const uint32_t SFE_XM125_DISTANCE_SENSOR_CREATE_ERROR_MASK = 0x00040000;
-const uint32_t SFE_XM125_DISTANCE_DETECTOR_CREATE_ERROR_MASK = 0x00080000;
-const uint32_t SFE_XM125_DISTANCE_DETECTOR_BUFFER_ERROR_MASK = 0x00100000;
-const uint32_t SFE_XM125_DISTANCE_SENSOR_BUFFER_ERROR_MASK = 0x00200000;
-const uint32_t SFE_XM125_DISTANCE_CALIBRATION_BUFFER_ERROR_MASK = 0x00400000;
-const uint32_t SFE_XM125_DISTANCE_CONFIG_APPLY_ERROR_MASK = 0x00800000;
-const uint32_t SFE_XM125_DISTANCE_SENSOR_CALIBRATE_ERROR_MASK = 0x01000000;
-const uint32_t SFE_XM125_DISTANCE_DETECTOR_CALIBRATE_ERROR_MASK = 0x02000000;
-const uint32_t SFE_XM125_DISTANCE_DETECTOR_ERROR_MASK = 0x10000000;
-const uint32_t SFE_XM125_DISTANCE_BUSY_MASK = 0x80000000;
-const uint32_t SFE_XM125_DISTANCE_CALIBRATION_NEEDED_MASK = 0x00000200;
-
-const uint32_t SFE_XM125_DISTANCE_MAJOR_VERSION_MASK_SHIFT = 16;
-const uint32_t SFE_XM125_DISTANCE_MINOR_VERSION_MASK_SHIFT = 8;
-const uint32_t SFE_XM125_DISTANCE_RSS_REGISTER_ERROR_MASK_SHIFT = 15;
-const uint32_t SFE_XM125_DISTANCE_CONFIG_CREATE_ERROR_MASK_SHIFT = 16;
-const uint32_t SFE_XM125_DISTANCE_SENSOR_CREATE_ERROR_MASK_SHIFT = 17;
-const uint32_t SFE_XM125_DISTANCE_DETECTOR_CREATE_ERROR_MASK_SHIFT = 18;
-const uint32_t SFE_XM125_DISTANCE_DETECTOR_BUFFER_ERROR_MASK_SHIFT = 19;
-const uint32_t SFE_XM125_DISTANCE_SENSOR_BUFFER_ERROR_MASK_SHIFT = 20;
-const uint32_t SFE_XM125_DISTANCE_CALIBRATION_BUFFER_ERROR_MASK_SHIFT = 21;
-const uint32_t SFE_XM125_DISTANCE_CONFIG_APPLY_ERROR_MASK_SHIFT = 22;
-const uint32_t SFE_XM125_DISTANCE_SENSOR_CALIBRATE_ERROR_MASK_SHIFT = 23;
-const uint32_t SFE_XM125_DISTANCE_DETECTOR_CALIBRATE_ERROR_MASK_SHIFT = 24;
-const uint32_t SFE_XM125_DISTANCE_DETECTOR_ERROR_MASK_SHIFT = 27;
-const uint32_t SFE_XM125_DISTANCE_BUSY_MASK_SHIFT = 30;
-const uint32_t SFE_XM125_DISTANCE_NEAR_START_EDGE_MASK_SHIFT = 8;
-const uint32_t SFE_XM125_DISTANCE_CALIBRATION_NEEDED_MASK_SHIFT = 9;
-const uint32_t SFE_XM125_DISTANCE_MEASURE_DISTANCE_ERROR_MASK_SHIFT = 10;
-const uint32_t SFE_XM125_DISTANCE_TEMPERATURE_MASK_SHIFT = 16;
-const uint32_t SFE_XM125_DISTANCE_DETECTOR_STATUS_MASK_SHIFT = 30;
-
-const uint32_t SFE_XM125_DISTANCE_DETECTOR_STATUS_MASK = 0b10010000111111110000000011111111;
-
-const uint16_t SFE_XM125_DISTANCE_VERSION = 0x00;
-typedef struct
-{
- uint32_t distance_major : 16;
- uint32_t distance_minor : 8;
- uint32_t distance_patch : 8;
-} sfe_xm125_distance_version_t;
-
-const uint16_t SFE_XM125_DISTANCE_PROTOCOL_STATUS = 0x01;
-typedef struct
-{
- uint32_t distance_protocol_state_error : 1;
- uint32_t distance_packet_length_error : 1;
- uint32_t distance_address_error : 1;
- uint32_t distance_write_failed : 1;
- uint32_t distance_write_to_read_only : 1;
- uint32_t reserved1 : 27;
-} sfe_xm125_distance_protocol_status_t;
-
-const uint16_t SFE_XM125_DISTANCE_MEASURE_COUNTER = 0x02;
-
-const uint16_t SFE_XM125_DISTANCE_DETECTOR_STATUS = 0x03;
-typedef struct
-{
- uint32_t distance_rss_register_ok : 1;
- uint32_t distance_config_create_ok : 1;
- uint32_t distance_sensor_create_ok : 1;
- uint32_t distance_detector_create_ok : 1;
- uint32_t distance_detector_buffer_ok : 1;
- uint32_t distance_sensor_buffer_ok : 1;
- uint32_t distance_calibration_buffer_ok : 1;
- uint32_t distance_config_apply_ok : 1;
- uint32_t distance_sensor_calibrate_ok : 1;
- uint32_t distance_detector_calibrate_ok : 1;
- uint32_t reserved1 : 6;
- uint32_t distance_rss_register_error : 1;
- uint32_t distance_config_create_error : 1;
- uint32_t distance_sensor_create_error : 1;
- uint32_t distance_detector_create_error : 1;
- uint32_t distance_detector_buffer_error : 1;
- uint32_t distance_sensor_buffer_error : 1;
- uint32_t distance_calibration_buffer_error : 1;
- uint32_t distance_config_apply_error : 1;
- uint32_t distance_sensor_calibrate_error : 1;
- uint32_t distance_detector_calibrate_error : 1;
- uint32_t reserved2 : 2;
- uint32_t distance_detector_error : 1;
- uint32_t reserved3 : 2;
- uint32_t distance_busy : 1;
-} sfe_xm125_distance_detector_status_t;
-
-const uint16_t SFE_XM125_DISTANCE_RESULT = 0x10;
-typedef struct
-{
- uint32_t distance_num_distances : 4;
- uint32_t rsvd1 : 4; // skips "reserved" bits
- uint32_t distance_near_start_edge : 1;
- uint32_t distance_calibration_needed : 1;
- uint32_t distance_measure_distance_error : 1;
- uint32_t reserved1 : 5;
- uint32_t distance_temperature : 16;
-} sfe_xm125_distance_result_t;
-
-const uint16_t SFE_XM125_DISTANCE_PEAK0_DISTANCE = 0x11;
-const uint16_t SFE_XM125_DISTANCE_PEAK1_DISTANCE = 0x12;
-const uint16_t SFE_XM125_DISTANCE_PEAK2_DISTANCE = 0x13;
-const uint16_t SFE_XM125_DISTANCE_PEAK3_DISTANCE = 0x14;
-const uint16_t SFE_XM125_DISTANCE_PEAK4_DISTANCE = 0x15;
-const uint16_t SFE_XM125_DISTANCE_PEAK5_DISTANCE = 0x16;
-const uint16_t SFE_XM125_DISTANCE_PEAK6_DISTANCE = 0x17;
-const uint16_t SFE_XM125_DISTANCE_PEAK7_DISTANCE = 0x18;
-const uint16_t SFE_XM125_DISTANCE_PEAK8_DISTANCE = 0x19;
-const uint16_t SFE_XM125_DISTANCE_PEAK9_DISTANCE = 0x1a;
-const uint16_t SFE_XM125_DISTANCE_PEAK0_STRENGTH = 0x1b;
-const uint16_t SFE_XM125_DISTANCE_PEAK1_STRENGTH = 0x1c;
-const uint16_t SFE_XM125_DISTANCE_PEAK2_STRENGTH = 0x1d;
-const uint16_t SFE_XM125_DISTANCE_PEAK3_STRENGTH = 0x1e;
-const uint16_t SFE_XM125_DISTANCE_PEAK4_STRENGTH = 0x1f;
-const uint16_t SFE_XM125_DISTANCE_PEAK5_STRENGTH = 0x20;
-const uint16_t SFE_XM125_DISTANCE_PEAK6_STRENGTH = 0x21;
-const uint16_t SFE_XM125_DISTANCE_PEAK7_STRENGTH = 0x22;
-const uint16_t SFE_XM125_DISTANCE_PEAK8_STRENGTH = 0x23;
-const uint16_t SFE_XM125_DISTANCE_PEAK9_STRENGTH = 0x24;
-
-// Default Value: 250
-const uint16_t SFE_XM125_DISTANCE_START = 0x40;
-const uint16_t sfe_xm125_distance_start_default = 250;
-
-// Default Value: 3000
-const uint16_t SFE_XM125_DISTANCE_END = 0x41;
-const uint16_t sfe_xm125_distance_end_default = 3000;
-
-// Default Value: 0
-const uint16_t SFE_XM125_DISTANCE_MAX_STEP_LENGTH = 0x42;
-const uint16_t sfe_xm125_distance_max_step_length_default = 0;
-
-// Default Value: True
-const uint16_t SFE_XM125_DISTANCE_CLOSE_RANGE_LEAKAGE = 0x43;
-const bool sfe_xm125_distance_close_range_leakage_default = true;
-
-// Default Value: 15000
-const uint16_t SFE_XM125_DISTANCE_SIGNAL_QUALITY = 0x44;
-const uint16_t sfe_xm125_distance_signal_quality_default = 15000;
-
-// Default: PROFILE5 (enum)
-const uint16_t SFE_XM125_DISTANCE_MAX_PROFILE = 0x45;
-typedef enum
-{
- XM125_DISTANCE_PROFILE1 = 1,
- XM125_DISTANCE_PROFILE2 = 2,
- XM125_DISTANCE_PROFILE3 = 3,
- XM125_DISTANCE_PROFILE4 = 4,
- XM125_DISTANCE_PROFILE5 = 5,
-} sfe_xm125_distance_profile_t;
-
-// Default Value: CFAR (enum)
-const uint16_t SFE_XM125_DISTANCE_THRESHOLD_METHOD = 0x46;
-typedef enum
-{
- XM125_DISTANCE_FIXED_AMPLITUDE = 1,
- XM125_DISTANCE_RECORDED = 2,
- XM125_DISTANCE_CFAR = 3,
- XM125_DISTANCE_FIXED_STRENGTH = 4,
-} sfe_xm125_distance_threshold_method_t;
-
-// Default Value: STRONGEST (enum)
-const uint16_t SFE_XM125_DISTANCE_PEAK_SORTING = 0x47;
-typedef enum
-{
- XM125_DISTANCE_CLOSEST = 1,
- XM125_DISTANCE_STRONGEST = 2,
-} sfe_xm125_distance_peak_sorting_t;
-
-// Default Value: 100
-const uint16_t SFE_XM125_DISTANCE_NUM_FRAMES_RECORDED_THRESH = 0x48;
-const uint16_t sfe_xm125_distance_num_frames_recorded_thresh_default = 100;
-
-// Default Value: 100000
-const uint16_t SFE_XM125_DISTANCE_FIXED_AMPLITUDE_THRESHOLD_VAL = 0x49;
-const uint32_t sfe_xm125_distance_fixed_amp_thresh_val_default = 100000;
-
-// Default Value: 500
-const uint16_t SFE_XM125_DISTANCE_THREHSOLD_SENSITIVITY = 0x4a;
-const uint16_t sfe_xm125_distance_threshold_sensitivity_default = 500;
-
-// Default Value: GENERIC
-const uint16_t SFE_XM125_DISTANCE_REFLECTOR_SHAPE = 0x4b;
-typedef enum
-{
- XM125_DISTANCE_GENERIC = 1,
- XM125_DISTANCE_PLANAR = 2,
-} sfe_xm125_distance_reflector_shape_t;
-
-// Default Value: 0
-const uint16_t SFE_XM125_DISTANCE_FIXED_STRENGTH_THRESHOLD_VAL = 0x4c;
-const uint16_t sfe_xm125_distance_fixed_strength_threshold_val_default = 0;
-
-// Default Value: False
-const uint16_t SFE_XM125_DISTANCE_MEASURE_ON_WAKEUP = 0x80;
-const bool sfe_xm125_distance_measure_on_wakup = false;
-
-const uint16_t SFE_XM125_DISTANCE_COMMAND = 0x100;
-typedef enum
-{
- XM125_DISTANCE_APPLY_CONFIG_AND_CALIBRATE = 1,
- XM125_DISTANCE_MEASURE_DISTANCE = 2,
- XM125_DISTANCE_APPLY_CONFIGURATION = 3,
- XM125_DISTANCE_CALIBRATE = 4,
- XM125_DISTANCE_RECALIBRATE = 5,
- XM125_DISTANCE_ENABLE_UART_LOGS = 32,
- XM125_DISTANCE_DISABLE_UART_LOGS = 33,
- XM125_DISTANCE_LOG_CONFIGURATION = 34,
- XM125_DISTANCE_RESET_MODULE = 1381192737,
-} sfe_xm125_distance_command_t;
-
-const uint32_t SFE_XM125_DISTANCE_APPLY_CONFIGURATION = 1;
-const uint32_t SFE_XM125_DISTANCE_START_DETECTOR = 2;
-const uint32_t SFE_XM125_DISTANCE_STOP_DETECTOR = 3;
-const uint32_t SFE_XM125_DISTANCE_CALIBRATE = 4;
-const uint32_t SFE_XM125_DISTANCE_RECALIBRATE = 5;
-const uint32_t SFE_XM125_DISTANCE_ENABLE_UART_LOGS = 32;
-const uint32_t SFE_XM125_DISTANCE_DISABLE_UART_LOGS = 33;
-const uint32_t SFE_XM125_DISTANCE_LOG_CONFIGURATION = 34;
-const uint32_t SFE_XM125_DISTANCE_RESET_MODULE = 1381192737;
-
-/* ****************************** Presence Values ****************************** */
-
-
-const uint32_t SFE_XM125_PRESENCE_DETECTOR_STATUS_MASK = 0b10010000111111110000000011111111;
-
-const uint32_t SFE_XM125_PRESENCE_DETECTED_MASK = 0x00000001;
-const uint32_t SFE_XM125_PRESENCE_DETECTED_STICKY_MASK = 0x00000002;
-const uint32_t SFE_XM125_PRESENCE_DETECTOR_ERROR_MASK = 0x00008000;
-const uint32_t SFE_XM125_PRESENCE_TEMPERATURE_MASK = 0xffff0000;
-const uint32_t SFE_XM125_PRESENCE_MAJOR_VERSION_MASK = 0xffff0000;
-const uint32_t SFE_XM125_PRESENCE_MINOR_VERSION_MASK = 0x0000ff00;
-const uint32_t SFE_XM125_PRESENCE_PATCH_VERSION_MASK = 0x000000ff;
-
-const uint32_t SFE_XM125_PRESENCE_RSS_REGISTER_OK_MASK = 0x00000001;
-const uint32_t SFE_XM125_PRESENCE_CONFIG_CREATE_OK_MASK = 0x00000002;
-const uint32_t SFE_XM125_PRESENCE_SENSOR_CREATE_OK_MASK = 0x00000004;
-const uint32_t SFE_XM125_PRESENCE_SENSOR_CALIBRATE_OK_MASK = 0x00000008;
-const uint32_t SFE_XM125_PRESENCE_DETECTOR_CREATE_OK_MASK = 0x00000010;
-const uint32_t SFE_XM125_PRESENCE_DETECTOR_BUFFER_OK_MASK = 0x00000020;
-const uint32_t SFE_XM125_PRESENCE_SENSOR_BUFFER_OK_MASK = 0x00000040;
-const uint32_t SFE_XM125_PRESENCE_CONFIG_APPLY_OK_MASK = 0x00000080;
-const uint32_t SFE_XM125_PRESENCE_RSS_REGISTER_ERROR_MASK = 0x00010000;
-const uint32_t SFE_XM125_PRESENCE_CONFIG_CREATE_ERROR_MASK = 0x00020000;
-const uint32_t SFE_XM125_PRESENCE_SENSOR_CREATE_ERROR_MASK = 0x00040000;
-const uint32_t SFE_XM125_PRESENCE_SENSOR_CALIBRATE_ERROR_MASK = 0x00080000;
-const uint32_t SFE_XM125_PRESENCE_DETECTOR_CREATE_ERROR_MASK = 0x00100000;
-const uint32_t SFE_XM125_PRESENCE_DETECTOR_BUFFER_ERROR_MASK = 0x00200000;
-const uint32_t SFE_XM125_PRESENCE_SENSOR_BUFFER_ERROR_MASK = 0x00400000;
-const uint32_t SFE_XM125_PRESENCE_CONFIG_APPLY_ERROR_MASK = 0x00800000;
-const uint32_t SFE_XM125_PRESENCE_DETECTOR_REG_ERROR_MASK = 0x10000000;
-const uint32_t SFE_XM125_PRESENCE_BUSY_MASK = 0x80000000;
-
-const uint32_t SFE_XM125_PRESENCE_MAJOR_VERSION_MASK_SHIFT = 16;
-const uint32_t SFE_XM125_PRESENCE_MINOR_VERSION_MASK_SHIFT = 8;
-const uint32_t SFE_XM125_PRESENCE_RSS_REGISTER_ERROR_MASK_SHIFT = 15;
-const uint32_t SFE_XM125_PRESENCE_CONFIG_CREATE_ERROR_MASK_SHIFT = 16;
-const uint32_t SFE_XM125_PRESENCE_SENSOR_CREATE_ERROR_MASK_SHIFT = 17;
-const uint32_t SFE_XM125_PRESENCE_SENSOR_CALIBRATE_ERROR_MASK_SHIFT = 18;
-const uint32_t SFE_XM125_PRESENCE_DETECTOR_CREATE_ERROR_MASK_SHIFT = 19;
-const uint32_t SFE_XM125_PRESENCE_DETECTOR_BUFFER_ERROR_MASK_SHIFT = 20;
-const uint32_t SFE_XM125_PRESENCE_SENSOR_BUFFER_ERROR_MASK_SHIFT = 21;
-const uint32_t SFE_XM125_PRESENCE_CONFIG_APPLY_ERROR_MASK_SHIFT = 22;
-const uint32_t SFE_XM125_PRESENCE_DETECTOR_REG_ERROR_MASK_SHIFT = 27;
-const uint32_t SFE_XM125_PRESENCE_DETECTOR_ERROR_MASK_SHIFT = 14;
-const uint32_t SFE_XM125_PRESENCE_TEMPERATURE_MASK_SHIFT = 16;
-const uint32_t SFE_XM125_PRESENCE_BUSY_MASK_SHIFT = 30;
-
-const uint16_t SFE_XM125_PRESENCE_VERSION = 0x00;
-typedef struct
-{
- uint32_t presence_major : 16;
- uint32_t presence_minor : 8;
- uint32_t presence_patch : 8;
-} sfe_xm125_presence_version_t;
-
-const uint16_t SFE_XM125_PRESENCE_PROTOCOL_STATUS = 0x01;
-typedef struct
-{
- uint32_t presence_protocol_state_error : 1;
- uint32_t presence_packet_length_error : 1;
- uint32_t presence_address_error : 1;
- uint32_t presence_write_failed : 1;
- uint32_t presence_write_to_read_only : 1;
- uint32_t reserved1 : 27;
-} sfe_xm125_presence_protocol_status_t;
-
-const uint16_t SFE_XM125_PRESENCE_MEASURE_COUNTER = 0x02;
-
-const uint16_t SFE_XM125_PRESENCE_DETECTOR_STATUS = 0x03;
-typedef struct
-{
- uint32_t presence_rss_register_ok : 1;
- uint32_t presence_config_create_ok : 1;
- uint32_t presence_sensor_create_ok : 1;
- uint32_t presence_sensor_calibrate_ok : 1;
- uint32_t presence_detector_create_ok : 1;
- uint32_t presence_detector_buffer_ok : 1;
- uint32_t presence_sensor_buffer_ok : 1;
- uint32_t presence_config_apply_ok : 1;
- uint32_t reserved1 : 8;
- uint32_t presence_rss_register_error : 1;
- uint32_t presence_config_create_error : 1;
- uint32_t presence_sensor_create_error : 1;
- uint32_t presence_sensor_calibrate_error : 1;
- uint32_t presence_detector_create_error : 1;
- uint32_t presence_detector_buffer_error : 1;
- uint32_t presence_sensor_buffer_error : 1;
- uint32_t presence_config_apply_error : 1;
- uint32_t reserved2 : 4;
- uint32_t presence_detector_error : 1;
- uint32_t reserved3 : 2;
- uint32_t presence_busy : 1;
-
-} sfe_xm125_presence_detector_status_t;
-
-const uint16_t SFE_XM125_PRESENCE_RESULT = 0x10;
-typedef struct
-{
- uint32_t presence_detected : 1;
- uint32_t presence_detected_sticky : 1;
- uint32_t reserved1 : 13;
- uint32_t presence_detector_error : 1;
- uint32_t presence_temperature : 16;
-} sfe_xm125_presence_result_t;
-
-const uint16_t SFE_XM125_PRESENCE_DISTANCE = 0x11;
-const uint16_t SFE_XM125_INTRA_PRESENCE_SCORE = 0x12;
-const uint16_t SFE_XM125_INTER_PRESENCE = 0x13;
-
-const uint16_t SFE_XM125_PRESENCE_SWEEPS_PER_FRAME = 0x40;
-const uint16_t sfe_xm125_presence_sweeps_per_frame_default = 16;
-
-const uint16_t SFE_XM125_PRESENCE_INTER_FRAME_TIMEOUT = 0x41;
-const uint16_t sfe_xm125_presence_inter_frame_timeout_default = 3;
-
-const uint16_t SFE_XM125_PRESENCE_INTER_PHASE_BOOST_ENABLED = 0x42;
-const bool sfe_xm125_presence_inter_phase_boost_enabled_default = false;
-
-const uint16_t SFE_XM125_PRESENCE_INTRA_DETECTION_ENABLED = 0x43;
-const bool sfe_xm125_presence_intra_detection_enabled_default = true;
-
-const uint16_t SFE_XM125_PRESENCE_INTER_DETECTION_ENABLED = 0x44;
-const bool sfe_xm125_presence_inter_detection_enabled_default = true;
-
-const uint16_t SFE_XM125_PRESENCE_FRAME_RATE = 0x45;
-const uint16_t sfe_xm125_presence_frame_rate_default = 12000;
-
-const uint16_t SFE_XM125_PRESENCE_INTRA_DETECTION_THRESHOLD = 0x46;
-const uint16_t sfe_xm125_presence_intra_detection_threshold_default = 1300;
-
-const uint16_t SFE_XM125_PRESENCE_INTER_DETECTION_THRESHOLD = 0x47;
-const uint16_t sfe_xm125_presence_inter_detection_threshold_default = 1000;
-
-const uint16_t SFE_XM125_PRESENCE_INTER_FRAME_DEVIATION = 0x48;
-const uint16_t sfe_xm125_presence_inter_frame_deviation_default = 500;
-
-const uint16_t SFE_XM125_PRESENCE_INTER_FRAME_FAST_CUTOFF = 0x49;
-const uint16_t sfe_xm125_presence_inter_frame_fast_cutoff_default = 6000;
-
-const uint16_t SFE_XM125_PRESENCE_INTER_FRAME_SLOW_CUTOFF = 0x4a;
-const uint16_t sfe_xm125_presence_inter_frame_slow_cutoff_default = 200;
-
-const uint16_t SFE_XM125_PRESENCE_INTRA_FRAME_TIME_CONST = 0x4b;
-const uint16_t sfe_xm125_presence_intra_frame_time_const_default = 150;
-
-const uint16_t SFE_XM125_PRESENCE_INTRA_OUTPUT_TIME_CONST = 0x4c;
-const uint16_t sfe_xm125_presence_intra_output_time_const_default = 300;
-
-const uint16_t SFE_XM125_PRESENCE_INTER_OUTPUT_TIME_CONST = 0x4d;
-const uint16_t sfe_xm125_presence_inter_output_time_const_default = 2000;
-
-const uint16_t SFE_XM125_PRESENCE_AUTO_PROFILE_ENABLED = 0x4e;
-const bool sfe_xm125_presence_auto_profile_enabled_default = true;
-
-const uint16_t SFE_XM125_PRESENCE_AUTO_STEP_LENGTH_ENABLED = 0x4f;
-const bool sfe_xm125_presence_auto_step_length_enabled_default = true;
-
-const uint16_t SFE_XM125_PRESENCE_MANUAL_PROFILE = 0x50;
-typedef enum
-{
- XM125_PRESENCE_PROFILE1 = 1,
- XM125_PRESENCE_PROFILE2 = 2,
- XM125_PRESENCE_PROFILE3 = 3,
- XM125_PRESENCE_PROFILE4 = 4,
- XM125_PRESENCE_PROFILE5 = 5,
-} sfe_xm125_presence_manual_profile_t;
-
-const uint16_t SFE_XM125_PRESENCE_MANUAL_STEP_LENGTH = 0x51;
-const uint16_t sfe_xm125_presence_manual_step_length_default = 72;
-
-const uint16_t SFE_XM125_PRESENCE_START = 0x52;
-const uint16_t sfe_xm125_presence_start_default = 250;
-
-const uint16_t SFE_XM125_PRESENCE_END = 0x53;
-const uint16_t sfe_xm125_presence_end_default = 2500;
-
-const uint16_t SFE_XM125_PRESENCE_RESET_FILTERS_ON_PREPARE = 0x54;
-const bool sfe_xm125_presence_reset_filters_on_prepare_default = true;
-
-const uint16_t SFE_XM125_PRESENCE_HWAAS = 0x55;
-const uint16_t sfe_xm125_presence_hwaas_default = 32;
-
-const uint16_t SFE_XM125_PRESENCE_DETECTION_ON_GPIO = 0x80;
-const bool sfe_xm125_presence_detection_on_gpio_default = false;
-
-const uint16_t SFE_XM125_PRESENCE_COMMAND = 0x100;
-typedef enum
-{
- XM125_PRESENCE_APPLY_CONFIGURATION = 1,
- XM125_PRESENCE_START_DETECTOR = 2,
- XM125_PRESENCE_STOP_DETECTOR = 3,
- XM125_PRESENCE_ENABLE_UART_LOGS = 32,
- XM125_PRESENCE_DISABLE_UART_LOGS = 33,
- XM125_PRESENCE_LOG_CONFIGURATION = 34,
- XM125_PRESENCE_RESET_MODULE = 138119737,
-} sfe_xm125_presence_command_t;
-
-const uint32_t SFE_XM125_PRESENCE_APPLY_CONFIGURATION = 1;
-const uint32_t SFE_XM125_PRESENCE_START_DETECTOR = 2;
-const uint32_t SFE_XM125_PRESENCE_STOP_DETECTOR = 3;
-const uint32_t SFE_XM125_PRESENCE_ENABLE_UART_LOGS = 32;
-const uint32_t SFE_XM125_PRESENCE_DISABLE_UART_LOGS = 33;
-const uint32_t SFE_XM125_PRESENCE_LOG_CONFIGURATION = 34;
-const uint32_t SFE_XM125_PRESENCE_RESET_MODULE = 1381192737;
\ No newline at end of file