Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Check_VL6180XA1_ToF
Fork of X_NUCLEO_6180XA1 by
Diff: x_nucleo_6180xa1.h
- Revision:
- 36:f6278b3e7c82
- Parent:
- 33:1573db91352c
- Child:
- 37:837cffa6b530
diff -r 407b0b127eb8 -r f6278b3e7c82 x_nucleo_6180xa1.h
--- a/x_nucleo_6180xa1.h Wed Nov 18 16:35:04 2015 +0000
+++ b/x_nucleo_6180xa1.h Tue Nov 24 16:04:41 2015 +0000
@@ -56,31 +56,22 @@
/* Classes--------------------------------------------------------------------*/
+/* Classes -------------------------------------------------------------------*/
+/** Class representing the X-NUCLEO-VL6180XA1 expansion board
+ */
class X_NUCLEO_6180XA1
{
public:
+ /** Constructor 1
+ * @param[in] &i2c device I2C to be used for communication
+ */
X_NUCLEO_6180XA1(DevI2C *ext_i2c) : dev_i2c(ext_i2c)
{
- stmpe1600 = new STMPE1600(*ext_i2c);
- stmpe1600->writeSYS_CTRL (SOFT_RESET);
+ stmpe1600 = new STMPE1600(*ext_i2c);
+ stmpe1600->writeSYS_CTRL (SOFT_RESET);
Switch = new SWITCH (*stmpe1600, GPIO_11);
- display = new Display(*stmpe1600);
-
- /*digit1=new STMPE1600DigiOut(*dev_i2c, GPIO_7);
- digit2=new STMPE1600DigiOut(*dev_i2c, GPIO_8);
- digit3=new STMPE1600DigiOut(*dev_i2c, GPIO_9);
- digit4=new STMPE1600DigiOut(*dev_i2c, GPIO_10);
+ display = new Display(*stmpe1600);
- dispA=new STMPE1600DigiOut(*dev_i2c, GPIO_0);
- dispB=new STMPE1600DigiOut(*dev_i2c, GPIO_1);
- dispC=new STMPE1600DigiOut(*dev_i2c, GPIO_2);
- dispD=new STMPE1600DigiOut(*dev_i2c, GPIO_3);
- dispE=new STMPE1600DigiOut(*dev_i2c, GPIO_4);
- dispF=new STMPE1600DigiOut(*dev_i2c, GPIO_5);
- dispG=new STMPE1600DigiOut(*dev_i2c, GPIO_6);*/
- //display=new Display(*digit1,*digit2,*digit3,*digit4,*dispA,*dispB,*dispC,*dispD,*dispE,*dispF,*dispG);
- //display=new Display(*ext_i2c);
-
gpio0_top=new STMPE1600DigiOut(*dev_i2c, GPIO_12);
sensor_top=new VL6180X(*dev_i2c, *gpio0_top, PB_0);
@@ -93,7 +84,35 @@
gpio0_right=new STMPE1600DigiOut(*dev_i2c, GPIO_15);
sensor_right=new VL6180X(*dev_i2c, *gpio0_right, PA_10);
}
-
+
+ /** Constructor 2
+ * @param[in] &i2c device I2C to be used for communication
+ * @param[in] PinName gpio1_top Mbed DigitalOut pin name to be used as a top sensor GPIO_1 INT
+ * @param[in] PinName gpio1_bottom Mbed DigitalOut pin name to be used as a bottom sensor GPIO_1 INT
+ * @param[in] PinName gpio1_left Mbed DigitalOut pin name to be used as a left sensor GPIO_1 INT
+ * @param[in] PinName gpio1_right Mbed DigitalOut pin name to be used as a right sensor GPIO_1 INT
+ */
+ 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);
+ Switch = new SWITCH (*stmpe1600, GPIO_11);
+ display = new Display(*stmpe1600);
+
+ gpio0_top=new STMPE1600DigiOut(*dev_i2c, GPIO_12);
+ sensor_top=new VL6180X(*dev_i2c, *gpio0_top, gpio1_top);
+
+ gpio0_bottom=new STMPE1600DigiOut(*dev_i2c, GPIO_13);
+ sensor_bottom=new VL6180X(*dev_i2c, *gpio0_bottom, gpio1_bottom);
+
+ gpio0_left=new STMPE1600DigiOut(*dev_i2c, GPIO_14);
+ sensor_left=new VL6180X(*dev_i2c, *gpio0_left, gpio1_left);
+
+ gpio0_right=new STMPE1600DigiOut(*dev_i2c, GPIO_15);
+ sensor_right=new VL6180X(*dev_i2c, *gpio0_right, gpio1_right);
+ }
+
+ /** Destructor
+ */
~X_NUCLEO_6180XA1()
{
if(gpio0_top!=NULL)
@@ -136,62 +155,62 @@
delete sensor_right;
sensor_right=NULL;
}
- /*delete digit1;
- delete digit2;
- delete digit3;
- delete digit4;
- delete dispA;
- delete dispB;
- delete dispC;
- delete dispD;
- delete dispE;
- delete dispF;
- delete dispG;*/
- delete stmpe1600;
- delete Switch;
- delete display;
+ delete stmpe1600;
+ stmpe1600 = NULL;
+ delete Switch;
+ Switch = NULL;
+ delete display;
+ display = NULL;
_instance=NULL;
}
+ /**
+ * @brief Creates a singleton object instance
+ * @param[in] &i2c device I2C to be used for communication
+ * @return Pointer to the object instance
+ */
+ static X_NUCLEO_6180XA1 *Instance(DevI2C *ext_i2c);
+
+ /**
+ * @brief Creates a singleton object instance
+ * @param[in] &i2c device I2C to be used for communication
+ * @param[in] PinName gpio1_top the pin connected to top sensor INT
+ * @param[in] PinName gpio1_bottem the pin connected to bottom sensor INT
+ * @param[in] PinName gpio1_left the pin connected to left sensor INT
+ * @param[in] PinName gpio1_right the pin connected to right sensor INT
+ * @return Pointer to the object instance
+ */
+ static X_NUCLEO_6180XA1 *Instance(DevI2C *ext_i2c, PinName gpio1_top, PinName gpio1_bottom,
+ PinName gpio1_left, PinName gpio1_right);
+
+ /**
+ * @brief Initialize the board and sensors with deft values
+ * @return 0 on success
+ */
+ int InitBoard();
+
+ /**
+ * @brief Read the on board red slider switch
+ * @return 0 or 1 according to switch position
+ */
bool RdSwitch () {
return Switch->RdSwitch();
}
-
+
DevI2C *dev_i2c;
-
VL6180X *sensor_top;
VL6180X *sensor_bottom;
VL6180X *sensor_left;
VL6180X *sensor_right;
-
- STMPE1600 * stmpe1600;
- SWITCH * Switch;
-
+ STMPE1600 * stmpe1600;
+ SWITCH * Switch;
STMPE1600DigiOut *gpio0_top;
STMPE1600DigiOut *gpio0_bottom;
STMPE1600DigiOut *gpio0_left;
- STMPE1600DigiOut *gpio0_right;
+ STMPE1600DigiOut *gpio0_right;
+ Display *display;
- STMPE1600DigiOut *digit1;
- STMPE1600DigiOut *digit2;
- STMPE1600DigiOut *digit3;
- STMPE1600DigiOut *digit4;
-
- STMPE1600DigiOut *dispA;
- STMPE1600DigiOut *dispB;
- STMPE1600DigiOut *dispC;
- STMPE1600DigiOut *dispD;
- STMPE1600DigiOut *dispE;
- STMPE1600DigiOut *dispF;
- STMPE1600DigiOut *dispG;
-
- Display *display;
-
- static X_NUCLEO_6180XA1 *Instance(DevI2C *ext_i2c);
-
- int InitBoard();
-
- private:
+ private:
static X_NUCLEO_6180XA1 *_instance;
};
