@@ -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-
5749int32_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-
413400int32_t QwDevXM125::getPresenceDetectorVersion (uint8_t *major, uint8_t *minor, uint8_t *patch)
414401{
415402 int32_t retVal;
0 commit comments