You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/02/15 16:50:37 UTC

[GitHub] vrahane commented on a change in pull request #718: MYNEWT-881: SensorAPI: Add sensor_unset_thresh() API and LIS2DH12 set threshold cb fix

vrahane commented on a change in pull request #718: MYNEWT-881: SensorAPI: Add sensor_unset_thresh() API and LIS2DH12 set threshold cb fix
URL: https://github.com/apache/mynewt-core/pull/718#discussion_r168537739
 
 

 ##########
 File path: hw/drivers/sensors/lis2dh12/src/lis2dh12.c
 ##########
 @@ -1308,44 +1298,62 @@ lis2dh12_sensor_set_trigger_thresh(struct sensor *sensor,
     memcpy(&low_thresh, &stt->stt_low_thresh, sizeof(low_thresh));
     memcpy(&high_thresh, &stt->stt_high_thresh, sizeof(high_thresh));
 
-    rc = lis2dh12_get_full_scale(itf, &tmp);
-    if (rc) {
-        goto err;
+    if (!low_thresh.sad->sad_x_is_valid &&
+        !low_thresh.sad->sad_y_is_valid &&
+        !low_thresh.sad->sad_z_is_valid) {
+        /* if all thresholds are not valid, release gpio irq */
+        hal_gpio_irq_release(itf->si_low_pin);
+    } else {
+        /* if one or more thresholds are valid, set trigger */
 
 Review comment:
   For lis2dh12, there are multiple interrupts that you can setup. Each axis has its associated interrupt. Unsetting one of the interrupts does not mean the IRQ is disabled. It means one of the interrupts from the sensor is disabled. By doing this, user can unset specific interrupt or all interrupts. I know unsetting an interrupt is actually just clearing registers of the particular interrupt but it also means we need to keep other interrupts active. Almost all the steps in the set thresh function would have to be repeated here which seems more repetitive code. Hence, calling the set thresh function here.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services