Now you can use NC as InterruptIn

Dependencies:   X_NUCLEO_COMMON

Fork of X_NUCLEO_6180XA1 by ST

Files at this revision

API Documentation at this revision

Comitter:
fabiombed
Date:
Fri Mar 11 09:47:43 2016 +0000
Parent:
41:2e00362bdb8e
Commit message:
Now you can use NC as InterruptIn

Changed in this revision

Components/VL6180X/vl6180x_class.h Show annotated file Show diff for this revision Revisions of this file
x_nucleo_6180xa1.h Show annotated file Show diff for this revision Revisions of this file
--- a/Components/VL6180X/vl6180x_class.h	Thu Mar 03 10:43:01 2016 +0000
+++ b/Components/VL6180X/vl6180x_class.h	Fri Mar 11 09:47:43 2016 +0000
@@ -96,35 +96,37 @@
 class VL6180X : public RangeSensor, public LightSensor
 {
  public:
-    /** Constructor 1
+    /** Constructor 1 (DigitalOut)
      * @param[in] &i2c device I2C to be used for communication
      * @param[in] &pin Mbed DigitalOut pin to be used as component GPIO_0 CE
-     * @param[in] pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT
+     * @param[in] &pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT
      * @param[in] DevAddr device address, 0x29 by default  
      */
-    VL6180X(DevI2C &i2c, DigitalOut &pin, PinName pin_gpio1, uint8_t DevAddr=DEFAULT_DEVICE_ADDRESS) : RangeSensor(), LightSensor(), dev_i2c(i2c), gpio0(&pin), gpio1Int(pin_gpio1)
+    VL6180X(DevI2C &i2c, DigitalOut &pin, PinName pin_gpio1, uint8_t DevAddr=DEFAULT_DEVICE_ADDRESS) : RangeSensor(), LightSensor(), dev_i2c(i2c), gpio0(&pin)
     {
        MyDevice.I2cAddr=DevAddr;		 
        MyDevice.Present=0;
        MyDevice.Ready=0;
        Device=&MyDevice;;
        expgpio0=NULL;
-       gpio1Pin=pin_gpio1;
+       if (pin_gpio1 != NC) { gpio1Int = new InterruptIn(pin_gpio1); }
+       	else { gpio1Int = NULL; }
     }  
-    /** Constructor 2
+    /** Constructor 2 (STMPE1600DigiOut)
      * @param[in] i2c device I2C to be used for communication
      * @param[in] &pin Gpio Expander STMPE1600DigiOut pin to be used as component GPIO_0 CE
      * @param[in] pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT
      * @param[in] device address, 0x29 by default  
      */		
-    VL6180X(DevI2C &i2c, STMPE1600DigiOut &pin, PinName pin_gpio1, uint8_t DevAddr=DEFAULT_DEVICE_ADDRESS) : RangeSensor(), LightSensor(), dev_i2c(i2c), expgpio0(&pin), gpio1Int(pin_gpio1)
+    VL6180X(DevI2C &i2c, STMPE1600DigiOut &pin, PinName pin_gpio1, uint8_t DevAddr=DEFAULT_DEVICE_ADDRESS) : RangeSensor(), LightSensor(), dev_i2c(i2c), expgpio0(&pin)
     {
        MyDevice.I2cAddr=DevAddr;		 
        MyDevice.Present=0;
        MyDevice.Ready=0;
        Device=&MyDevice;
        gpio0=NULL;		
-       gpio1Pin=pin_gpio1;	 		 
+       if (pin_gpio1 != NC) { gpio1Int = new InterruptIn(pin_gpio1); }
+       	else { gpio1Int = NULL; } 		 
     }  	 
     
    /** Destructor
@@ -206,7 +208,7 @@
 	 */					     
     void EnableInterruptMeasureDetectionIRQ(void) 
     {
-       if (gpio1Pin != NC) gpio1Int.enable_irq();
+       if (gpio1Pin != NC) gpio1Int->enable_irq();
     }
 
 	/**
@@ -215,7 +217,7 @@
 	 */					          
     void DisableInterruptMeasureDetectionIRQ(void) 
     {
-       if (gpio1Pin != NC) gpio1Int.disable_irq();
+       if (gpio1Pin != NC) gpio1Int->disable_irq();
     }
 	/*** End High level API ***/	          
 	
@@ -226,7 +228,7 @@
 	 */					                  
     void AttachInterruptMeasureDetectionIRQ(void (*fptr)(void))
     {
-       if (gpio1Pin != NC) gpio1Int.rise(fptr);
+       if (gpio1Pin != NC) gpio1Int->rise(fptr);
     }
     
 	/**
@@ -1187,7 +1189,7 @@
     /* GPIO expander */
     STMPE1600DigiOut *expgpio0;
     /* Measure detection IRQ */
-    InterruptIn gpio1Int;
+    InterruptIn *gpio1Int;
 	PinName     gpio1Pin;    
     /* Device data */
     MyVL6180Dev_t MyDevice;
--- a/x_nucleo_6180xa1.h	Thu Mar 03 10:43:01 2016 +0000
+++ b/x_nucleo_6180xa1.h	Fri Mar 11 09:47:43 2016 +0000
@@ -95,6 +95,7 @@
     X_NUCLEO_6180XA1(DevI2C *ext_i2c, PinName gpio1_top, PinName gpio1_bottom,
     		 						  PinName gpio1_left, PinName gpio1_right) : dev_i2c(ext_i2c) {
        stmpe1600 = new STMPE1600(*ext_i2c);		    		 						  	
+       stmpe1600->writeSYS_CTRL (SOFT_RESET);	
        Switch = new SWITCH (*stmpe1600, GPIO_11);	
        display = new Display(*stmpe1600);