Skip to content

Commit 50179d9

Browse files
Begin function completed
Adjusted keywords and associated files for adjusting begin function. General presence and distance detection begin functions have been deleted and there is only one begin function now
1 parent 586d856 commit 50179d9

File tree

4 files changed

+26
-47
lines changed

4 files changed

+26
-47
lines changed

keywords.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ sfe_xm125_presence_command_t KEYWORD1
1717
#########################################################
1818

1919
begin KEYWORD2
20-
distanceBegin KEYWORD2
2120
getDistanceDetectorVersion KEYWORD2
2221
getDistanceDetectorError KEYWORD2
2322
getDistanceMeasureCounter KEYWORD2
@@ -76,7 +75,6 @@ setDistanceFixedStrengthThresholdValue KEYWORD2
7675
getDistanceMeasureOneWakeup KEYWORD2
7776
setDistanceMeasureOneWakeup KEYWORD2
7877
setDistanceCommand KEYWORD2
79-
presenceBegin KEYWORD2
8078
getPresenceDetectorVersion KEYWORD2
8179
getPresenceDetectorError KEYWORD2
8280
getPresenceMeasureCounter KEYWORD2

src/sfeQwiicXM125.cpp

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,38 +22,30 @@ bool QwDevXM125::begin(sfeTkII2C *theBus)
2222
// Sets communication bus
2323
_theBus = theBus;
2424

25-
26-
// TODO: Check if device is connected
27-
28-
// TODO: Initialize hardware
29-
30-
31-
// Turn the sensor on
32-
//acc_hal_integration_sensor_supply_on(SENSOR_ID);
33-
34-
35-
// Create the sensor
36-
//create_sensor(&detector_resources);
37-
38-
39-
40-
// Handle GPIO outputs and commands
41-
42-
// Clear busy bit once the handler is complete
43-
// Set ready pin HIGH when command processing is done
44-
45-
// TODO: Return whether successful
25+
// Check errors from device
26+
uint32_t distanceError = 0;
27+
uint32_t presenceError = 0;
28+
int32_t distFuncErr = getDistanceDetectorError(&distanceError);
29+
int32_t presFuncErr = getDistanceDetectorError(&presenceError);
30+
if(distanceError != 0 )
31+
{
32+
return -1;
33+
}
34+
if(presenceError != 0)
35+
{
36+
return -2;
37+
}
38+
if((distFuncErr != 0)|| (presFuncErr != 0))
39+
{
40+
return -3;
41+
}
4642

43+
// If no errors, return 0
4744
return 0;
4845
}
4946

5047
// --------------------- I2C Disance Detector Functions ---------------------
5148

52-
int32_t QwDevXM125::distanceBegin()
53-
{
54-
return 0;
55-
}
56-
5749
int32_t QwDevXM125::getDistanceDetectorVersion(uint8_t *major, uint8_t *minor, uint8_t *patch)
5850
{
5951
int32_t retVal;
@@ -70,7 +62,7 @@ int32_t QwDevXM125::getDistanceDetectorVersion(uint8_t *major, uint8_t *minor, u
7062
return retVal;
7163
}
7264

73-
int32_t QwDevXM125::getDistanceDetectorError(sfe_xm125_distance_protocol_status_t *error)
65+
int32_t QwDevXM125::getDistanceDetectorError(uint32_t *error)
7466
{
7567
// Read from 16-Bit Register
7668
return _theBus->read16BitRegisterRegion(SFE_XM125_DISTANCE_PROTOCOL_STATUS, (uint8_t*)error, 4);
@@ -318,12 +310,12 @@ int32_t QwDevXM125::setDistanceMaxProfile(sfe_xm125_distance_profile_t profile)
318310
return _theBus->write16BitRegisterRegion(SFE_XM125_DISTANCE_MAX_PROFILE, (uint8_t*)profile, 4);
319311
}
320312

321-
int32_t QwDevXM125::getDistanceThresholdMethod(sfe_xm125_threshold_method_t *method)
313+
int32_t QwDevXM125::getDistanceThresholdMethod(sfe_xm125_distance_threshold_method_t *method)
322314
{
323315
return _theBus->read16BitRegisterRegion(SFE_XM125_DISTANCE_THRESHOLD_METHOD, (uint8_t*)method, 4);
324316
}
325317

326-
int32_t QwDevXM125::setDistanceThresholdMethod(sfe_xm125_threshold_method_t method)
318+
int32_t QwDevXM125::setDistanceThresholdMethod(sfe_xm125_distance_threshold_method_t method)
327319
{
328320
return _theBus->write16BitRegisterRegion(SFE_XM125_DISTANCE_THRESHOLD_METHOD, (uint8_t*)method, 4);
329321
}
@@ -405,11 +397,6 @@ int32_t QwDevXM125::setDistanceCommand(sfe_xm125_distance_command_t *command)
405397

406398
// --------------------- I2C Presence Detector Functions ---------------------
407399

408-
int32_t QwDevXM125::presenceBegin()
409-
{
410-
return 0;
411-
}
412-
413400
int32_t QwDevXM125::getPresenceDetectorVersion(uint8_t *major, uint8_t *minor, uint8_t *patch)
414401
{
415402
int32_t retVal;

src/sfeQwiicXM125.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ class QwDevXM125
1414
bool begin(sfeTkII2C *theBus = nullptr);
1515

1616
// --------------------- I2C Disance Detector Functions ---------------------
17-
18-
/// @brief This function begins the distance examples/communication.
19-
/// @return Error code (0 no error)
20-
int32_t distanceBegin();
2117

2218
/// @brief This function returns the version number of the device
2319
/// structure: major.minor.patch
@@ -27,7 +23,7 @@ class QwDevXM125
2723
/// @brief This function returns if there was an error from the
2824
/// protocol status register
2925
/// @return Error code (0 no error)
30-
int32_t getDistanceDetectorError(sfe_xm125_distance_protocol_status_t *error);
26+
int32_t getDistanceDetectorError(uint32_t *error);
3127

3228
/// @brief This function returns the measure counter, the number of measurements
3329
/// performed since restart.
@@ -247,12 +243,12 @@ class QwDevXM125
247243

248244
/// @brief This function returns the threshold method
249245
/// @return Error code (0 no error)
250-
int32_t getDistanceThresholdMethod(sfe_xm125_threshold_method_t *method);
246+
int32_t getDistanceThresholdMethod(sfe_xm125_distance_threshold_method_t *method);
251247

252248
/// @brief This function sets the threshold method
253249
/// @param method Threshold method (enum)
254250
/// @return Error code (0 no error)
255-
int32_t setDistanceThresholdMethod(sfe_xm125_threshold_method_t method);
251+
int32_t setDistanceThresholdMethod(sfe_xm125_distance_threshold_method_t method);
256252

257253
/// @brief This function returns the peak sorting method
258254
/// @param peak Peak sorting method
@@ -352,10 +348,6 @@ class QwDevXM125
352348

353349
// --------------------- I2C Presence Detector Functions ---------------------
354350

355-
/// @brief This function begins the presence examples/communication.
356-
/// @return Error code (0 no error)
357-
int32_t presenceBegin();
358-
359351
/// @brief This function returns the RSS version number
360352
/// @param version Version number
361353
/// @param patch Patch version number

src/sfeXM125Regs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
/* ****************************** Distance Values ****************************** */
4545

4646
const uint16_t SFE_XM125_I2C_ADDRESS = 0x52;
47+
const bool SFE_XM125_DISTANCE = false;
48+
const bool SFE_XM125_PRESENCE = true;
4749

4850
const uint16_t SFE_XM125_DISTANCE_VERSION = 0x00;
4951
typedef struct

0 commit comments

Comments
 (0)