vrahane closed pull request #1007: LIS2DW12: Interrupt Line Remapping
URL: https://github.com/apache/mynewt-core/pull/1007
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/hw/drivers/sensors/lis2dw12/include/lis2dw12/lis2dw12.h 
b/hw/drivers/sensors/lis2dw12/include/lis2dw12/lis2dw12.h
index 6d6362f03..d6241f8d9 100644
--- a/hw/drivers/sensors/lis2dw12/include/lis2dw12/lis2dw12.h
+++ b/hw/drivers/sensors/lis2dw12/include/lis2dw12/lis2dw12.h
@@ -185,6 +185,7 @@ struct lis2dw12_cfg {
     
     uint8_t int1_pin_cfg;
     uint8_t int2_pin_cfg;
+    bool map_int2_to_int1;
     uint8_t int_enable;
 
     enum lis2dw12_fifo_mode fifo_mode;
@@ -654,7 +655,25 @@ int lis2dw12_set_stationary_en(struct sensor_itf *itf, 
uint8_t en);
  * @return 0 on success, non-zero on failure
  */
 int lis2dw12_get_stationary_en(struct sensor_itf *itf, uint8_t *en);
-    
+
+/**
+ * Set whether interrupts are enabled
+ *
+ * @param the sensor interface
+ * @param value to set (0 = disabled, 1 = enabled)
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_set_int1_on_int2_map(struct sensor_itf *itf, bool enable);
+
+/**
+ * Get whether interrupt 1 signals is mapped onto interrupt 2 pin
+ *
+ * @param the sensor interface
+ * @param value to set (0 = disabled, 1 = enabled)
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_get_int1_on_int2_map(struct sensor_itf *itf, uint8_t *val);
+
 /**
  * Run Self test on sensor
  *
diff --git a/hw/drivers/sensors/lis2dw12/src/lis2dw12.c 
b/hw/drivers/sensors/lis2dw12/src/lis2dw12.c
index 41f482468..85d253cbb 100644
--- a/hw/drivers/sensors/lis2dw12/src/lis2dw12.c
+++ b/hw/drivers/sensors/lis2dw12/src/lis2dw12.c
@@ -1456,6 +1456,53 @@ int lis2dw12_set_int_enable(struct sensor_itf *itf, 
uint8_t enabled)
     return lis2dw12_write8(itf, LIS2DW12_REG_CTRL_REG7, reg);
 }
 
+/**
+ * Set whether interrupt 1 signals is mapped onto interrupt 2 pin
+ *
+ * @param the sensor interface
+ * @param value to set (false = disabled, true = enabled)
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_set_int1_on_int2_map(struct sensor_itf *itf, bool enable)
+{
+    uint8_t reg;
+    int rc;
+
+    rc = lis2dw12_read8(itf, LIS2DW12_REG_CTRL_REG7, &reg);
+    if (rc) {
+        return rc;
+    }
+
+    if (enable) {
+        reg |= LIS2DW12_CTRL_REG7_INT2_ON_INT1;
+    } else {
+        reg &= ~LIS2DW12_CTRL_REG7_INT2_ON_INT1;
+    }
+
+    return lis2dw12_write8(itf, LIS2DW12_REG_CTRL_REG7, reg);
+}
+
+/**
+ * Get whether interrupt 1 signals is mapped onto interrupt 2 pin
+ *
+ * @param the sensor interface
+ * @param value to set (0 = disabled, 1 = enabled)
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_get_int1_on_int2_map(struct sensor_itf *itf, uint8_t *val)
+{
+    uint8_t reg;
+    int rc;
+
+    rc = lis2dw12_read8(itf, LIS2DW12_REG_CTRL_REG7, &reg);
+    if (rc) {
+        return rc;
+    }
+
+    *val = (reg & LIS2DW12_CTRL_REG7_INT2_ON_INT1) >> 5;
+    return 0;
+}
+
 /**
  * Run Self test on sensor
  *
@@ -1608,7 +1655,7 @@ lis2dw12_int_irq_handler(void *arg)
     if(lis2dw12->pdd.interrupt) {
         wake_interrupt(lis2dw12->pdd.interrupt);
     }
-    
+
     sensor_mgr_put_interrupt_evt(sensor);
 }
 
@@ -2418,7 +2465,13 @@ lis2dw12_config(struct lis2dw12 *lis2dw12, struct 
lis2dw12_cfg *cfg)
         goto err;
     }
     lis2dw12->cfg.tap_cfg = cfg->tap_cfg;
-    
+
+    rc = lis2dw12_set_int1_on_int2_map(itf, cfg->map_int2_to_int1);
+    if(rc) {
+        goto err;
+    }
+    lis2dw12->cfg.map_int2_to_int1 = cfg->map_int2_to_int1;
+
     rc = sensor_set_type_mask(&(lis2dw12->sensor), cfg->mask);
     if (rc) {
         goto err;


 

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to