test
Dependencies: ST_INTERFACES X_NUCLEO_COMMON
x_nucleo_53l0a1.h
00001 /** 00002 ****************************************************************************** 00003 * @file x_nucleo_53L0A1.h 00004 * @author IMG 00005 * @version V1.0.0 00006 * @date 28-November-2016 00007 * @brief Header file for class X_NUCLEO_53L0A1 representing a X-NUCLEO-53L0A1 00008 * expansion board 00009 ****************************************************************************** 00010 * @attention 00011 * 00012 * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> 00013 * 00014 * Redistribution and use in source and binary forms, with or without modification, 00015 * are permitted provided that the following conditions are met: 00016 * 1. Redistributions of source code must retain the above copyright notice, 00017 * this list of conditions and the following disclaimer. 00018 * 2. Redistributions in binary form must reproduce the above copyright notice, 00019 * this list of conditions and the following disclaimer in the documentation 00020 * and/or other materials provided with the distribution. 00021 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00022 * may be used to endorse or promote products derived from this software 00023 * without specific prior written permission. 00024 * 00025 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00026 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00028 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00029 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00030 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00031 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00032 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00033 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00034 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 ****************************************************************************** 00037 */ 00038 00039 /* Define to prevent from recursive inclusion --------------------------------*/ 00040 #ifndef __X_NUCLEO_53L0A1_H 00041 #define __X_NUCLEO_53L0A1_H 00042 00043 /* Includes ------------------------------------------------------------------*/ 00044 #include "vl53l0x_class.h" 00045 #include "Display_class.h" 00046 #include "stmpe1600_class.h" 00047 #include "DevI2C.h" 00048 00049 /** New device addresses */ 00050 //#define NEW_SENSOR_CENTRE_ADDRESS 0x54 00051 #define NEW_SENSOR_CENTRE_ADDRESS 0x52 00052 #define NEW_SENSOR_LEFT_ADDRESS 0x56 00053 #define NEW_SENSOR_RIGHT_ADDRESS 0x58 00054 00055 /* Classes--------------------------------------------------------------------*/ 00056 00057 /* Classes -------------------------------------------------------------------*/ 00058 /** Class representing the X-NUCLEO-VL53L0A1 expansion board 00059 */ 00060 class X_NUCLEO_53L0A1 00061 { 00062 public: 00063 /** Constructor 1 00064 * @param[in] &i2c device I2C to be used for communication 00065 */ 00066 X_NUCLEO_53L0A1(DevI2C *ext_i2c) : dev_i2c(ext_i2c) 00067 { 00068 stmpe1600_exp0 = new STMPE1600(*ext_i2c, (0x43 * 2)); // U21 00069 stmpe1600_exp0->writeSYS_CTRL (SOFT_RESET); 00070 00071 stmpe1600_exp1 = new STMPE1600(*ext_i2c, (0x42 * 2)); // U19 00072 stmpe1600_exp1->writeSYS_CTRL (SOFT_RESET); 00073 00074 display = new Display(*stmpe1600_exp0, *stmpe1600_exp1); 00075 00076 xshutdown_centre=new STMPE1600DigiOut(*dev_i2c, GPIO_15, (0x42 * 2)); // U19 on schematic 00077 sensor_centre=new VL53L0X(*dev_i2c, *xshutdown_centre, A2); 00078 00079 xshutdown_left=new STMPE1600DigiOut(*dev_i2c, GPIO_14, (0x43 * 2)); // U21 on schematic 00080 sensor_left=new VL53L0X(*dev_i2c, *xshutdown_left, D8); 00081 00082 xshutdown_right=new STMPE1600DigiOut(*dev_i2c, GPIO_15, (0x43 * 2)); // U21 on schematic 00083 sensor_right=new VL53L0X(*dev_i2c, *xshutdown_right, D2); 00084 } 00085 00086 /** Constructor 2 00087 * @param[in] &i2c device I2C to be used for communication 00088 * @param[in] PinName gpio1_top Mbed DigitalOut pin name to be used as a top sensor GPIO_1 INT 00089 * @param[in] PinName gpio1_bottom Mbed DigitalOut pin name to be used as a bottom sensor GPIO_1 INT 00090 * @param[in] PinName gpio1_left Mbed DigitalOut pin name to be used as a left sensor GPIO_1 INT 00091 * @param[in] PinName gpio1_right Mbed DigitalOut pin name to be used as a right sensor GPIO_1 INT 00092 */ 00093 X_NUCLEO_53L0A1(DevI2C *ext_i2c, PinName gpio1_centre, 00094 PinName gpio1_left, PinName gpio1_right) : dev_i2c(ext_i2c) { 00095 stmpe1600_exp0 = new STMPE1600(*ext_i2c, (0x43 * 2)); // U21 00096 stmpe1600_exp0->writeSYS_CTRL(SOFT_RESET); 00097 00098 stmpe1600_exp1 = new STMPE1600(*ext_i2c, (0x42 * 2)); // U19 00099 stmpe1600_exp1->writeSYS_CTRL(SOFT_RESET); 00100 00101 display = new Display(*stmpe1600_exp0, *stmpe1600_exp1); 00102 00103 xshutdown_centre=new STMPE1600DigiOut(*dev_i2c, GPIO_15, (0x42 * 2)); // U19 on schematic 00104 sensor_centre=new VL53L0X(*dev_i2c, *xshutdown_centre, gpio1_centre); 00105 00106 xshutdown_left=new STMPE1600DigiOut(*dev_i2c, GPIO_14, (0x43 * 2)); // U21 on schematic 00107 sensor_left=new VL53L0X(*dev_i2c, *xshutdown_left, gpio1_left); 00108 00109 xshutdown_right=new STMPE1600DigiOut(*dev_i2c, GPIO_15, (0x43 * 2)); // U21 on schematic 00110 sensor_right=new VL53L0X(*dev_i2c, *xshutdown_right, gpio1_right); 00111 } 00112 00113 /** Destructor 00114 */ 00115 ~X_NUCLEO_53L0A1() 00116 { 00117 if(xshutdown_centre!=NULL) 00118 { 00119 delete xshutdown_centre; 00120 xshutdown_centre=NULL; 00121 } 00122 if(sensor_centre!=NULL) 00123 { 00124 delete sensor_centre; 00125 sensor_centre=NULL; 00126 } 00127 if(xshutdown_left!=NULL) 00128 { 00129 delete xshutdown_left; 00130 xshutdown_left=NULL; 00131 } 00132 if(sensor_left!=NULL) 00133 { 00134 delete sensor_left; 00135 sensor_left=NULL; 00136 } 00137 if(xshutdown_right!=NULL) 00138 { 00139 delete xshutdown_right; 00140 xshutdown_right=NULL; 00141 } 00142 if(sensor_right!=NULL) 00143 { 00144 delete sensor_right; 00145 sensor_right=NULL; 00146 } 00147 00148 delete stmpe1600_exp0; 00149 stmpe1600_exp0 = NULL; 00150 delete stmpe1600_exp1; 00151 stmpe1600_exp1 = NULL; 00152 delete display; 00153 display = NULL; 00154 _instance=NULL; 00155 } 00156 00157 /** 00158 * @brief Creates a singleton object instance 00159 * @param[in] &i2c device I2C to be used for communication 00160 * @return Pointer to the object instance 00161 */ 00162 static X_NUCLEO_53L0A1 *Instance(DevI2C *ext_i2c); 00163 00164 /** 00165 * @brief Creates a singleton object instance 00166 * @param[in] &i2c device I2C to be used for communication 00167 * @param[in] PinName gpio1_centre the pin connected to top sensor INT 00168 * @param[in] PinName gpio1_left the pin connected to left sensor INT 00169 * @param[in] PinName gpio1_right the pin connected to right sensor INT 00170 * @return Pointer to the object instance 00171 */ 00172 static X_NUCLEO_53L0A1 *Instance(DevI2C *ext_i2c, PinName gpio1_centre, 00173 PinName gpio1_left, PinName gpio1_right); 00174 00175 /** 00176 * @brief Initialize the board and sensors with deft values 00177 * @return 0 on success 00178 */ 00179 int InitBoard(); 00180 00181 DevI2C *dev_i2c; 00182 VL53L0X *sensor_centre; 00183 VL53L0X *sensor_left; 00184 VL53L0X *sensor_right; 00185 STMPE1600 *stmpe1600_exp0; 00186 STMPE1600 *stmpe1600_exp1; 00187 STMPE1600DigiOut *xshutdown_centre; 00188 STMPE1600DigiOut *xshutdown_left; 00189 STMPE1600DigiOut *xshutdown_right; 00190 Display *display; 00191 00192 private: 00193 static X_NUCLEO_53L0A1 *_instance; 00194 }; 00195 00196 #endif /* __X_NUCLEO_53L0A1_H */ 00197 00198
Generated on Wed Jul 13 2022 06:23:43 by
1.7.2