mynewt-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] vrahane commented on a change in pull request #1024: lis2dw12: Support sleep change event for notifications
Date Mon, 16 Apr 2018 20:04:09 GMT
vrahane commented on a change in pull request #1024: lis2dw12: Support sleep change event for
notifications
URL: https://github.com/apache/mynewt-core/pull/1024#discussion_r181867561
 
 

 ##########
 File path: hw/drivers/sensors/lis2dw12/src/lis2dw12.c
 ##########
 @@ -1946,89 +1943,106 @@ init_intpin(struct lis2dw12 * lis2dw12, hal_gpio_irq_handler_t handler,
     if (rc != 0) {
         LIS2DW12_ERR("Failed to initialise interrupt pin %d\n", pin);
         return rc;
-    } 
+    }
 
     return 0;
 }
 
 static int
-enable_interrupt(struct sensor * sensor, uint8_t int_to_enable)
+enable_interrupt(struct sensor *sensor, uint8_t int_to_enable, uint8_t int_num)
 {
     struct lis2dw12 *lis2dw12;
-    struct lis2dw12_private_driver_data *pdd;
+    struct lis2dw12_pdd *pdd;
     struct sensor_itf *itf;
     uint8_t reg;
     int rc;
 
+    if (!int_to_enable) {
+        rc = SYS_EINVAL;
+        goto err;
+    }
+
     lis2dw12 = (struct lis2dw12 *)SENSOR_GET_DEVICE(sensor);
     itf = SENSOR_GET_ITF(sensor);
     pdd = &lis2dw12->pdd;
 
     rc = lis2dw12_clear_int(itf, &reg);
     if (rc) {
-        return rc;
+        goto err;
     }
-    
+
     /* if no interrupts are currently in use enable int pin */
-    if (pdd->int_enable == 0) {
-        hal_gpio_irq_enable(itf->si_ints[pdd->int_num].host_pin);
+    if (!pdd->int_enable) {
+        hal_gpio_irq_enable(itf->si_ints[int_num].host_pin);
 
         rc = lis2dw12_set_int_enable(itf, 1);
         if (rc) {
-            return rc;
+            goto err;
         }
     }
 
-    /*update which interrupts are enabled */
-    pdd->int_enable |= int_to_enable;
-    
+    pdd->int_enable++;
+
     /* enable interrupt in device */
-    rc = lis2dw12_set_int1_pin_cfg(itf, pdd->int_enable);
+    if (int_num == 0) {
+        rc = lis2dw12_set_int1_pin_cfg(itf, int_to_enable);
 
 Review comment:
   I see what you mean here, `lis2dw12_set_int1_pin_cfg()` probably should just OR it then
if we were to support multiple APIs from enabling interrupts and we can add a interrupt clear
API to clear the int cfg. The initial thought was, notification/config would just override
each other but that sounds like might be too limiting.

----------------------------------------------------------------
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

Mime
View raw message