commit bf8ca9aae1c1e1ac22201e87735499dff5a00d6a
Author: Andre Raming <araming@techfak.uni-bielefeld.de>
Date:   Mon Apr 29 15:29:19 2019 +0200

    driver vl53l0x is ready

diff --git a/unittests/periphery-lld/src/ut_alld_VL53L0X_v1.c b/unittests/periphery-lld/src/ut_alld_VL53L0X_v1.c
index d35163c..f6ed778 100644
--- a/unittests/periphery-lld/src/ut_alld_VL53L0X_v1.c
+++ b/unittests/periphery-lld/src/ut_alld_VL53L0X_v1.c
@@ -98,43 +98,49 @@ aos_utresult_t utAlldVL53L0XFunc(BaseSequentialStream* stream, aos_unittest_t* u
   //validate I2C bus on 0xC0 0xEE
   status = VL53L0X_read_multi((((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.i2cd, (apalI2Caddr_t)(((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.I2cDevAddr , 0xc0, &reg_8[0], 1, (((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.timeout );
   if ((status == APAL_STATUS_OK || status == APAL_STATUS_WARNING) && reg_8[0]==0xEE) {
-    aosUtPassed(stream, &result);
-  } else {
-    aosUtFailedMsg(stream, &result, "0x%08X; 0x%08X\n", status, reg_8[0]);
-  }
 
+      //validate I2C bus on 0xC1 0xAA
+      status = VL53L0X_read_multi((((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.i2cd, (apalI2Caddr_t)(((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.I2cDevAddr , 0xc1, &reg_8[0], 1, (((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.timeout );
+      if ((status == APAL_STATUS_OK || status == APAL_STATUS_WARNING) && reg_8[0]==0xAA) {
+
+          //validate I2C bus on 0xC2 0x10
+          status = VL53L0X_read_multi((((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.i2cd, (apalI2Caddr_t)(((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.I2cDevAddr , 0xc2, &reg_8[0], 1, (((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.timeout );
+          if ((status == APAL_STATUS_OK || status == APAL_STATUS_WARNING) && reg_8[0]==0x10) {
+
+              //validate I2C bus on  0x51 0x0099
+              status = VL53L0X_read_multi((((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.i2cd, (apalI2Caddr_t)(((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.I2cDevAddr , 0x51, &reg_8[0], 2, (((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.timeout );
+              if ((status == APAL_STATUS_OK || status == APAL_STATUS_WARNING) && reg_8[0]==0x00 && reg_8[1]==0x99) {
+                  //validate I2C bus on  0x61 0x0000
+                  status = VL53L0X_read_multi((((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.i2cd, (apalI2Caddr_t)(((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.I2cDevAddr , 0x61, &reg_8[0], 2, (((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.timeout );
+                  if ((status == APAL_STATUS_OK || status == APAL_STATUS_WARNING) && reg_8[0]==0x00 && reg_8[1]==0x00) {
+                    aosUtPassed(stream, &result);
+                  } else {
+                    aosUtFailedMsg(stream, &result, "0x%08X; 0x%08X\n", status, reg_8[0]);
+                  }
+              } else {
+                aosUtFailedMsg(stream, &result, "0x%08X; 0x%08X\n", status, reg_8[0]);
+              }
+
+          } else {
+            aosUtFailedMsg(stream, &result, "0x%08X; 0x%08X\n", status, reg_8[0]);
+          }
+
+      } else {
+        aosUtFailedMsg(stream, &result, "0x%08X; 0x%08X\n", status, reg_8[0]);
+      }
 
-  //validate I2C bus on 0xC1 0xAA
-  status = VL53L0X_read_multi((((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.i2cd, (apalI2Caddr_t)(((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.I2cDevAddr , 0xc1, &reg_8[0], 1, (((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.timeout );
-  if ((status == APAL_STATUS_OK || status == APAL_STATUS_WARNING) && reg_8[0]==0xAA) {
-    aosUtPassed(stream, &result);
   } else {
     aosUtFailedMsg(stream, &result, "0x%08X; 0x%08X\n", status, reg_8[0]);
   }
 
-  //validate I2C bus on 0xC2 0x10
-  status = VL53L0X_read_multi((((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.i2cd, (apalI2Caddr_t)(((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.I2cDevAddr , 0xc2, &reg_8[0], 1, (((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.timeout );
-  if ((status == APAL_STATUS_OK || status == APAL_STATUS_WARNING) && reg_8[0]==0x10) {
-    aosUtPassed(stream, &result);
-  } else {
-    aosUtFailedMsg(stream, &result, "0x%08X; 0x%08X\n", status, reg_8[0]);
-  }
 
-  //validate I2C bus on  0x51 0x0099
-  status = VL53L0X_read_multi((((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.i2cd, (apalI2Caddr_t)(((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.I2cDevAddr , 0x51, &reg_8[0], 2, (((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.timeout );
-  if ((status == APAL_STATUS_OK || status == APAL_STATUS_WARNING) && reg_8[0]==0x00 && reg_8[1]==0x99) {
-    aosUtPassed(stream, &result);
-  } else {
-    aosUtFailedMsg(stream, &result, "0x%08X; 0x%08X\n", status, reg_8[0]);
-  }
 
-  //validate I2C bus on  0x61 0x0000
-  status = VL53L0X_read_multi((((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.i2cd, (apalI2Caddr_t)(((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.I2cDevAddr , 0x61, &reg_8[0], 2, (((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.timeout );
-  if ((status == APAL_STATUS_OK || status == APAL_STATUS_WARNING) && reg_8[0]==0x00 && reg_8[1]==0x00) {
-    aosUtPassed(stream, &result);
-  } else {
-    aosUtFailedMsg(stream, &result, "0x%08X; 0x%08X\n", status, reg_8[0]);
-  }
+
+
+
+
+
+
 
 
 
@@ -151,7 +157,7 @@ aos_utresult_t utAlldVL53L0XFunc(BaseSequentialStream* stream, aos_unittest_t* u
   }
 
 
-  chprintf(stream, "writing register...\n");
+  chprintf(stream, "writing register (Byte)...\n");
 
   //VL53L0X_WrByte(Dev, 0x88, 0x00);
   uint8_t tx_buf = 0x00;
@@ -167,6 +173,7 @@ aos_utresult_t utAlldVL53L0XFunc(BaseSequentialStream* stream, aos_unittest_t* u
   }
 
 
+  chprintf(stream, "writing register (multi)...\n");
 
   //read register 0x88
   status = VL53L0X_read_multi((((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.i2cd, (apalI2Caddr_t)(((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.I2cDevAddr , 0x88, &reg_8[0], 1, (((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.timeout );
@@ -209,12 +216,12 @@ aos_utresult_t utAlldVL53L0XFunc(BaseSequentialStream* stream, aos_unittest_t* u
   chprintf(stream, "reading results...\n");
 
   status = vl53l0x_lld_perform_mesaurement(((ut_vl53l0xdata_t*)(ut->data))->vl53d, &reg_16[0]);
-  chprintf(stream, "\t\tdistance : %u\n", reg_16[0]);
+  chprintf(stream, "\t\tdistance : %u mm\n", reg_16[0]);
   int i = 0;
   for (i = 0; i<4; i++){
       status |= vl53l0x_lld_perform_mesaurement(((ut_vl53l0xdata_t*)(ut->data))->vl53d, &reg_16[0]);
 
-      chprintf(stream, "\t\tdistance : %u\n", reg_16[0]);
+      chprintf(stream, "\t\tdistance : %u mm\n", reg_16[0]);
   }
 
   if ((status == APAL_STATUS_OK || status == APAL_STATUS_WARNING)) {
@@ -252,20 +259,13 @@ aos_utresult_t utAlldVL53L0XFunc(BaseSequentialStream* stream, aos_unittest_t* u
 
   status = vl53l0x_lld_set_mode(((ut_vl53l0xdata_t*)(ut->data))->vl53d, VL53L0X_DEVICEMODE_SINGLE_RANGING,
                                 VL53L0X_REG_SYSTEM_INTERRUPT_GPIO_NEW_SAMPLE_READY,0,0);
-  /*
-  same as
-
-  status |= VL53L0X_SetDeviceMode(&(((ut_vl53l0xdata_t*)(ut->data))->vl53d->vl53l0x_dev), VL53L0X_DEVICEMODE_SINGLE_RANGING);
-  status |= VL53L0X_SetGpioConfig(&(((ut_vl53l0xdata_t*)(ut->data))->vl53d->vl53l0x_dev), 0, VL53L0X_DEVICEMODE_SINGLE_RANGING,
-                                 VL53L0X_REG_SYSTEM_INTERRUPT_GPIO_NEW_SAMPLE_READY, VL53L0X_INTERRUPTPOLARITY_LOW);
-*/
 
 
 
   status |= VL53L0X_GetGpioConfig(&(((ut_vl53l0xdata_t*)(ut->data))->vl53d->vl53l0x_dev), 0, &deviceMode, &pFunctionality, &pPolarity);
 
   if ((status == APAL_STATUS_OK || status == APAL_STATUS_WARNING) && deviceMode == VL53L0X_DEVICEMODE_SINGLE_RANGING &&
-          pFunctionality == VL53L0X_REG_SYSTEM_INTERRUPT_GPIO_NEW_SAMPLE_READY && pPolarity == VL53L0X_INTERRUPTPOLARITY_LOW) {
+          pFunctionality == VL53L0X_REG_SYSTEM_INTERRUPT_GPIO_NEW_SAMPLE_READY && pPolarity == VL53L0X_INTERRUPTPOLARITY_HIGH) {
     aosUtPassed(stream, &result);
   } else {
     aosUtFailedMsg(stream, &result, "0x%08X; mode:%u; Interrupt:%u; InterruptPolarity: %u\n", status, deviceMode, pFunctionality, pPolarity);
@@ -276,6 +276,27 @@ aos_utresult_t utAlldVL53L0XFunc(BaseSequentialStream* stream, aos_unittest_t* u
 
   status = vl53l0x_lld_CheckRangingDataReady(((ut_vl53l0xdata_t*)(ut->data))->vl53d, &pMeasurementDataReady);
 
+  status |= pcal6524_lld_read_group(((ut_vl53l0xdata_t*)ut->data)->gpio, PCAL6524_LLD_CMD_INPUT_P0, buffer,
+                                  ((ut_vl53l0xdata_t*)ut->data)->timeout);
+  switch (pcal6524_lld_cmd_groupsize(PCAL6524_LLD_CMD_INPUT_P0)) {
+  case 1:
+
+      break;
+  case 2:
+      break;
+  case 3:
+      chprintf(stream, "\t\tRead input: 0x%02X 0x%02X 0x%02X\t", buffer[0], buffer[1], buffer[2]);
+      break;
+  case 6:
+      chprintf(stream, "\t\tRead input: 0x%04X 0x%04X 0x%04X\t",
+               (((uint16_t)buffer[0]) << 8) | buffer[1],
+               (((uint16_t)buffer[2]) << 8) | buffer[3],
+               (((uint16_t)buffer[4]) << 8) | buffer[5]);
+      break;
+  default:
+      break;
+  }
+
 
   if ((status == APAL_STATUS_OK || status == APAL_STATUS_WARNING) && pMeasurementDataReady == 0) {
     aosUtPassed(stream, &result);
@@ -297,7 +318,6 @@ aos_utresult_t utAlldVL53L0XFunc(BaseSequentialStream* stream, aos_unittest_t* u
 
   chprintf(stream, "start maeasurement ... \n");
 
-
   //set everything for eventshandler
   chEvtRegister(((ut_vl53l0xdata_t*)(ut->data))->evtsource, &event_listener, INTERRUPT_EVENT_ID);
   aosSysGetUptime(&tend);
@@ -312,47 +332,46 @@ aos_utresult_t utAlldVL53L0XFunc(BaseSequentialStream* stream, aos_unittest_t* u
 
   }
 
-
+chprintf(stream, "Check for interrupts ... \n");
   do {
     // read proximity data, interrupt event information and interrupt status
-    const eventmask_t emask = chEvtWaitOneTimeout(EVENT_MASK(INTERRUPT_EVENT_ID), chTimeUS2I(10*MICROSECONDS_PER_MILLISECOND));
+    const eventmask_t emask = chEvtWaitOneTimeout(EVENT_MASK(INTERRUPT_EVENT_ID), chTimeUS2I(MICROSECONDS_PER_SECOND));
     const eventflags_t eflags = chEvtGetAndClearFlags(&event_listener);
 
 
     if (emask == EVENT_MASK(INTERRUPT_EVENT_ID) &&
         eflags == ((ut_vl53l0xdata_t*)(ut->data))->evtflags) {
       // true positive (correct case)
-      chprintf(stream, "EVENT\n");
-      status |= VL53L0X_GetRangingMeasurementData(&(((ut_vl53l0xdata_t*)(ut->data))->vl53d->vl53l0x_dev), pRangingMeasurementData);
-      chprintf(stream, "\t\tinterrupt detected: prox = %i\n", RangingMeasurementData.RangeMilliMeter);
-      status |= VL53L0X_ClearInterruptMask(&(((ut_vl53l0xdata_t*)(ut->data))->vl53d->vl53l0x_dev),
-                                           VL53L0X_REG_SYSTEM_INTERRUPT_GPIO_LEVEL_HIGH);
-    }else if (eflags == ((ut_vl53l0xdata_t*)(ut->data))->evtflags){
-        chprintf(stream, "mask: %lu\n", emask);
-        chprintf(stream, "flag: %lu\n", eflags);
-    }else if (emask == EVENT_MASK(INTERRUPT_EVENT_ID)){
-        chprintf(stream, "first::mask: %lu and flag: %lu\n", emask, eflags);
-
-        // read from GPIO
-        status |= pcal6524_lld_read_group(((ut_vl53l0xdata_t*)ut->data)->gpio, PCAL6524_LLD_CMD_INPUT_P0, buffer,
-                                        ((ut_vl53l0xdata_t*)ut->data)->timeout);
+      chprintf(stream, "\t\tEVENT");
+      status |= pcal6524_lld_read_group(((ut_vl53l0xdata_t*)ut->data)->gpio, PCAL6524_LLD_CMD_INPUT_P0, buffer,
+                                      ((ut_vl53l0xdata_t*)ut->data)->timeout);
+      status |= vl53l0x_lld_getRangingData(((ut_vl53l0xdata_t*)(ut->data))->vl53d, pRangingMeasurementData);
 
-        status |= vl53l0x_lld_CheckRangingDataReady(((ut_vl53l0xdata_t*)(ut->data))->vl53d, &pMeasurementDataReady);
 
-        if ((pMeasurementDataReady == 0x01)) {
+      switch (pcal6524_lld_cmd_groupsize(PCAL6524_LLD_CMD_INPUT_P0)) {
+      case 1:
 
-            chprintf(stream, "\t\tRead input: 0x%04X 0x%04X 0x%04X\t",
-                     (((uint16_t)buffer[0]) << 8) | buffer[1],
-                     (((uint16_t)buffer[2]) << 8) | buffer[3],
-                     (((uint16_t)buffer[4]) << 8) | buffer[5]);
+          break;
+      case 2:
+          break;
+      case 3:
+          chprintf(stream, "\tRead input: 0x%02X 0x%02X 0x%02X", buffer[0], buffer[1], buffer[2]);
+          break;
+      case 6:
+          chprintf(stream, "\t\tRead input: 0x%04X 0x%04X 0x%04X",
+                   (((uint16_t)buffer[0]) << 8) | buffer[1],
+                   (((uint16_t)buffer[2]) << 8) | buffer[3],
+                   (((uint16_t)buffer[4]) << 8) | buffer[5]);
+          break;
+      default:
+          break;
+      }
+      chprintf(stream, "\tdistance = %i mm\n", RangingMeasurementData.RangeMilliMeter);
 
 
-            //get the measurement from VL53L0X
-            status |= vl53l0x_lld_getRangingData(((ut_vl53l0xdata_t*)(ut->data))->vl53d, pRangingMeasurementData);
-            chprintf(stream, "distance: %i\n", RangingMeasurementData.RangeMilliMeter);
-
-        }
 
+    }else{
+        chprintf(stream, "\tNo Interrupt, last measurement = %i mm\n", (((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.Data.LastRangeMeasure.RangeMilliMeter);
 
     }
 
@@ -403,7 +422,7 @@ aos_utresult_t utAlldVL53L0XFunc(BaseSequentialStream* stream, aos_unittest_t* u
       &ThresholdLow, &ThresholdHigh);
 
   if ((status == APAL_STATUS_OK || status == APAL_STATUS_WARNING) && deviceMode == VL53L0X_DEVICEMODE_CONTINUOUS_RANGING &&
-          pFunctionality == VL53L0X_REG_SYSTEM_INTERRUPT_GPIO_OUT_OF_WINDOW && pPolarity == VL53L0X_INTERRUPTPOLARITY_LOW){
+          pFunctionality == VL53L0X_REG_SYSTEM_INTERRUPT_GPIO_OUT_OF_WINDOW && pPolarity == VL53L0X_INTERRUPTPOLARITY_HIGH){
           //&& ThresholdLow == 80 * 65536 && ThresholdHigh == 150 * 65536) { not possible, only strange wrong values, e.g. Threshold low:1431655765;Threshold high:0
     aosUtPassed(stream, &result);
   } else {
@@ -415,6 +434,26 @@ aos_utresult_t utAlldVL53L0XFunc(BaseSequentialStream* stream, aos_unittest_t* u
 
   status = vl53l0x_lld_CheckRangingDataReady(((ut_vl53l0xdata_t*)(ut->data))->vl53d, &pMeasurementDataReady);
 
+  status |= pcal6524_lld_read_group(((ut_vl53l0xdata_t*)ut->data)->gpio, PCAL6524_LLD_CMD_INPUT_P0, buffer,
+                                  ((ut_vl53l0xdata_t*)ut->data)->timeout);
+  switch (pcal6524_lld_cmd_groupsize(PCAL6524_LLD_CMD_INPUT_P0)) {
+  case 1:
+
+      break;
+  case 2:
+      break;
+  case 3:
+      chprintf(stream, "\t\tRead input: 0x%02X 0x%02X 0x%02X\t", buffer[0], buffer[1], buffer[2]);
+      break;
+  case 6:
+      chprintf(stream, "\t\tRead input: 0x%04X 0x%04X 0x%04X\t",
+               (((uint16_t)buffer[0]) << 8) | buffer[1],
+               (((uint16_t)buffer[2]) << 8) | buffer[3],
+               (((uint16_t)buffer[4]) << 8) | buffer[5]);
+      break;
+  default:
+      break;
+  }
 
   if ((status == APAL_STATUS_OK || status == APAL_STATUS_WARNING) && pMeasurementDataReady == 0) {
     aosUtPassed(stream, &result);
@@ -422,6 +461,7 @@ aos_utresult_t utAlldVL53L0XFunc(BaseSequentialStream* stream, aos_unittest_t* u
     aosUtFailedMsg(stream, &result, "0x%08X, there are blocking interrupts :%u\n", status, pMeasurementDataReady);
     chprintf(stream, "clear blocking interrupts...\n");
 
+
     status = vl53l0x_lld_getRangingData(((ut_vl53l0xdata_t*)(ut->data))->vl53d, pRangingMeasurementData);
 
     if ((status == APAL_STATUS_OK || status == APAL_STATUS_WARNING)) {
@@ -433,9 +473,6 @@ aos_utresult_t utAlldVL53L0XFunc(BaseSequentialStream* stream, aos_unittest_t* u
 
   }
 
-
-
-
   chprintf(stream, "start maeasurement ... \n");
 
 
@@ -446,57 +483,45 @@ aos_utresult_t utAlldVL53L0XFunc(BaseSequentialStream* stream, aos_unittest_t* u
 
   status = vl53l0x_lld_start_measurement(((ut_vl53l0xdata_t*)(ut->data))->vl53d);
 
-  if ((status == APAL_STATUS_OK || status == APAL_STATUS_WARNING)) {
-    aosUtPassed(stream, &result);
-  } else {
-    aosUtFailedMsg(stream, &result, "0x%08X;\n", status);
-
-  }
-
-
   do {
     // read proximity data, interrupt event information and interrupt status
-    const eventmask_t emask = chEvtWaitOneTimeout(EVENT_MASK(INTERRUPT_EVENT_ID), chTimeUS2I(10*MICROSECONDS_PER_MILLISECOND));
+    const eventmask_t emask = chEvtWaitOneTimeout(EVENT_MASK(INTERRUPT_EVENT_ID), chTimeUS2I(MICROSECONDS_PER_SECOND));
     const eventflags_t eflags = chEvtGetAndClearFlags(&event_listener);
 
     if (emask == EVENT_MASK(INTERRUPT_EVENT_ID) &&
         eflags == ((ut_vl53l0xdata_t*)(ut->data))->evtflags) {
       // true positive (correct case)
-      chprintf(stream, "EVENT\n");
-      status |= VL53L0X_GetRangingMeasurementData(&(((ut_vl53l0xdata_t*)(ut->data))->vl53d->vl53l0x_dev), pRangingMeasurementData);
-
-
-      chprintf(stream, "\t\tinterrupt detected: prox = %i\n", RangingMeasurementData.RangeMilliMeter);
+      chprintf(stream, "\t\tEVENT");
+      // read from GPIO
+      status |= pcal6524_lld_read_group(((ut_vl53l0xdata_t*)ut->data)->gpio, PCAL6524_LLD_CMD_INPUT_P0, buffer,
+                                      ((ut_vl53l0xdata_t*)ut->data)->timeout);
+      switch (pcal6524_lld_cmd_groupsize(PCAL6524_LLD_CMD_INPUT_P0)) {
+      case 1:
+
+          break;
+      case 2:
+          break;
+      case 3:
+          chprintf(stream, "\tRead input: 0x%02X 0x%02X 0x%02X\t", buffer[0], buffer[1], buffer[2]);
+          break;
+      case 6:
+          chprintf(stream, "\t\tRead input: 0x%04X 0x%04X 0x%04X\t",
+                   (((uint16_t)buffer[0]) << 8) | buffer[1],
+                   (((uint16_t)buffer[2]) << 8) | buffer[3],
+                   (((uint16_t)buffer[4]) << 8) | buffer[5]);
+          break;
+      default:
+          break;
+      }
+      status |= vl53l0x_lld_getRangingData(((ut_vl53l0xdata_t*)(ut->data))->vl53d, pRangingMeasurementData);
+
+
+      chprintf(stream, "distance = %i mm\n", RangingMeasurementData.RangeMilliMeter);
       status |= VL53L0X_ClearInterruptMask(&(((ut_vl53l0xdata_t*)(ut->data))->vl53d->vl53l0x_dev),0);
-    }else if (eflags == ((ut_vl53l0xdata_t*)(ut->data))->evtflags){
-        chprintf(stream, "mask: %lu\n", emask);
-        chprintf(stream, "flag: %lu\n", eflags);
-    }else if (emask == EVENT_MASK(INTERRUPT_EVENT_ID)){
-        chprintf(stream, "last::mask: %lu and flag: %lu\n", emask, eflags);
-
-        // read from GPIO
-        status |= pcal6524_lld_read_group(((ut_vl53l0xdata_t*)ut->data)->gpio, PCAL6524_LLD_CMD_INPUT_P0, buffer,
-                                        ((ut_vl53l0xdata_t*)ut->data)->timeout);
-
-        status |= vl53l0x_lld_CheckRangingDataReady(((ut_vl53l0xdata_t*)(ut->data))->vl53d, &pMeasurementDataReady);
-
-        if ((pMeasurementDataReady == 0x01)) {
-
-            chprintf(stream, "\t\tRead input: 0x%04X 0x%04X 0x%04X\t",
-                     (((uint16_t)buffer[0]) << 8) | buffer[1],
-                     (((uint16_t)buffer[2]) << 8) | buffer[3],
-                     (((uint16_t)buffer[4]) << 8) | buffer[5]);
-
-
-            //get the measurement from VL53L0X
-            status |= vl53l0x_lld_getRangingData(((ut_vl53l0xdata_t*)(ut->data))->vl53d, pRangingMeasurementData);
-            chprintf(stream, "distance: %i\n", RangingMeasurementData.RangeMilliMeter);
-        }
-
-
+    }else{
+      chprintf(stream, "\tNo Interrupt, last measurement = %i mm\n", (((ut_vl53l0xdata_t*)(ut->data))->vl53d)->vl53l0x_dev.Data.LastRangeMeasure.RangeMilliMeter);
     }
 
-
     aosSysGetUptime(&tcurrent);
   } while (tcurrent < tend);
 
@@ -523,7 +548,6 @@ aos_utresult_t utAlldVL53L0XFunc(BaseSequentialStream* stream, aos_unittest_t* u
 
 
 
-
   chprintf(stream, "setting default address...\n");
 
   status = vl53l0x_lld_set_address(((ut_vl53l0xdata_t*)(ut->data))->vl53d, 0x29);
