Fixed STMPE1600 writeSYS_CTRL, enabled multi sensors support

Dependencies:   ST_INTERFACES X_NUCLEO_COMMON

Fork of X_NUCLEO_53L0A1 by ST

Files at this revision

API Documentation at this revision

Comitter:
mapellil
Date:
Mon Mar 27 12:37:57 2017 +0000
Parent:
7:35ecf3e060c3
Commit message:
Fixed STMPE1600 writeSYS_CTRL(), enabled multi sensors support

Changed in this revision

Components/STMPE1600/stmpe1600_class.h Show annotated file Show diff for this revision Revisions of this file
Components/VL53L0X/vl53l0x_class.cpp Show annotated file Show diff for this revision Revisions of this file
Components/VL53L0X/vl53l0x_class.h Show annotated file Show diff for this revision Revisions of this file
x_nucleo_53l0a1.cpp Show annotated file Show diff for this revision Revisions of this file
x_nucleo_53l0a1.h Show annotated file Show diff for this revision Revisions of this file
diff -r 35ecf3e060c3 -r 992abcfb7ef5 Components/STMPE1600/stmpe1600_class.h
--- a/Components/STMPE1600/stmpe1600_class.h	Mon Dec 05 11:50:38 2016 +0000
+++ b/Components/STMPE1600/stmpe1600_class.h	Mon Mar 27 12:37:57 2017 +0000
@@ -220,7 +220,8 @@
 	 */		
     void writeSYS_CTRL (uint8_t data)     // data = SOFT_RESET reset the device
     {
-	     dev_i2c.i2c_write((uint8_t*)data, expdevaddr, SYS_CTRL, 1);
+		 uint8_t reg_data = data; 
+	     dev_i2c.i2c_write(&reg_data, expdevaddr, SYS_CTRL, 1);
     }
     
 	/**
diff -r 35ecf3e060c3 -r 992abcfb7ef5 Components/VL53L0X/vl53l0x_class.cpp
--- a/Components/VL53L0X/vl53l0x_class.cpp	Mon Dec 05 11:50:38 2016 +0000
+++ b/Components/VL53L0X/vl53l0x_class.cpp	Mon Mar 27 12:37:57 2017 +0000
@@ -5131,7 +5131,7 @@
          return status;
       }
 
-/*
+
       if(NewAddr!=DEFAULT_DEVICE_ADDRESS)
       {
          status=SetDeviceAddress(NewAddr);
@@ -5146,7 +5146,7 @@
          printf("Invalid new address!\n\r");
          return VL53L0X_ERROR_INVALID_PARAMS;
       }
-*/
+
 //      Device->Ready=1;
    }
    return status; 
diff -r 35ecf3e060c3 -r 992abcfb7ef5 Components/VL53L0X/vl53l0x_class.h
--- a/Components/VL53L0X/vl53l0x_class.h	Mon Dec 05 11:50:38 2016 +0000
+++ b/Components/VL53L0X/vl53l0x_class.h	Mon Mar 27 12:37:57 2017 +0000
@@ -352,6 +352,7 @@
 	          *gpio0 = 1;
         else if (expgpio0) 
             *expgpio0 = 1;
+        wait_ms (10);    
     } 
 
 	/**
@@ -365,6 +366,7 @@
 	          *gpio0 = 0;
         else if (expgpio0) 
             *expgpio0 = 0;
+        wait_ms (10);    
     }
     
 	/**
@@ -536,20 +538,20 @@
 
         if(Status == VL53L0X_ERROR_NONE)
         {
-            printf ("Call of VL53L0X_StaticInit\n");
+//            printf ("Call of VL53L0X_StaticInit\n");
             Status = VL53L0X_StaticInit(Device); // Device Initialization
         }
     
         if(Status == VL53L0X_ERROR_NONE)
         {
-            printf ("Call of VL53L0X_PerformRefCalibration\n");
+//            printf ("Call of VL53L0X_PerformRefCalibration\n");
            Status = VL53L0X_PerformRefCalibration(Device,
                         		&VhvSettings, &PhaseCal); // Device Initialization
         }
 
         if(Status == VL53L0X_ERROR_NONE)
         {
-            printf ("Call of VL53L0X_PerformRefSpadManagement\n");
+//            printf ("Call of VL53L0X_PerformRefSpadManagement\n");
             Status = VL53L0X_PerformRefSpadManagement(Device,
                              &refSpadCount, &isApertureSpads); // Device Initialization
 //            printf ("refSpadCount = %d, isApertureSpads = %d\n", refSpadCount, isApertureSpads);
diff -r 35ecf3e060c3 -r 992abcfb7ef5 x_nucleo_53l0a1.cpp
--- a/x_nucleo_53l0a1.cpp	Mon Dec 05 11:50:38 2016 +0000
+++ b/x_nucleo_53l0a1.cpp	Mon Mar 27 12:37:57 2017 +0000
@@ -81,10 +81,11 @@
    }
    else
    {
-      printf("Sensor centre present\n\r");
+      printf("\n\rSensor centre present\n\r");
       n_dev++;
    }
-/*   status=sensor_left->InitSensor(NEW_SENSOR_LEFT_ADDRESS);
+   
+   status=sensor_left->InitSensor(NEW_SENSOR_LEFT_ADDRESS);
    if(status)
    {
       delete sensor_left;
@@ -98,8 +99,8 @@
       printf("Sensor left present\n\r");
       n_dev++;
    }
-*/
-/*   status=sensor_right->InitSensor(NEW_SENSOR_RIGHT_ADDRESS);
+
+   status=sensor_right->InitSensor(NEW_SENSOR_RIGHT_ADDRESS);
    if(status)
    {
       delete sensor_right;
@@ -113,7 +114,7 @@
       printf("Sensor right present\n\r");
       n_dev++;
    }
-*/
+
    if(n_dev==0)
       return 1;
    else
diff -r 35ecf3e060c3 -r 992abcfb7ef5 x_nucleo_53l0a1.h
--- a/x_nucleo_53l0a1.h	Mon Dec 05 11:50:38 2016 +0000
+++ b/x_nucleo_53l0a1.h	Mon Mar 27 12:37:57 2017 +0000
@@ -47,8 +47,8 @@
 #include "DevI2C.h"
 
 /** New device addresses */
-//#define NEW_SENSOR_CENTRE_ADDRESS		0x54
-#define NEW_SENSOR_CENTRE_ADDRESS		0x52
+#define NEW_SENSOR_CENTRE_ADDRESS		0x54
+//#define NEW_SENSOR_CENTRE_ADDRESS		0x52
 #define NEW_SENSOR_LEFT_ADDRESS			0x56
 #define NEW_SENSOR_RIGHT_ADDRESS		0x58
 
@@ -66,10 +66,8 @@
     X_NUCLEO_53L0A1(DevI2C *ext_i2c) : dev_i2c(ext_i2c)
     {
         stmpe1600_exp0 = new STMPE1600(*ext_i2c, (0x43 * 2)); // U21
-        stmpe1600_exp0->writeSYS_CTRL (SOFT_RESET);
 
         stmpe1600_exp1 = new STMPE1600(*ext_i2c, (0x42 * 2)); // U19
-        stmpe1600_exp1->writeSYS_CTRL (SOFT_RESET);
 
         display = new Display(*stmpe1600_exp0, *stmpe1600_exp1);
 			
@@ -93,10 +91,8 @@
     X_NUCLEO_53L0A1(DevI2C *ext_i2c, PinName gpio1_centre,
     		 						  PinName gpio1_left, PinName gpio1_right) : dev_i2c(ext_i2c) {
         stmpe1600_exp0 = new STMPE1600(*ext_i2c, (0x43 * 2)); // U21
-        stmpe1600_exp0->writeSYS_CTRL(SOFT_RESET);
 
         stmpe1600_exp1 = new STMPE1600(*ext_i2c, (0x42 * 2)); // U19
-        stmpe1600_exp1->writeSYS_CTRL(SOFT_RESET);
 
         display = new Display(*stmpe1600_exp0, *stmpe1600_exp1);