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.
Dependencies: VL53L1
Dependents: VL53L1CB_shield_sensor_polling VL53L1CB_MB2_NoShield_3sensors_interrupt_ranging VL53L1CB_MB5_NoShield_3sensors_interrupt_ranging VL53L1CB_MB5_NoShield_3sensors_interrupt_ranging
XNucleo53L1A2.h
00001 /** 00002 ****************************************************************************** 00003 * @file XNucleo53L1A2.h 00004 * @author JS 00005 * @version V0.0.1 00006 * @date 15-January-2021 00007 * @brief Header file for component XNucleo53L1A2 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * <h2><center>© COPYRIGHT(c) 2019 STMicroelectronics</center></h2> 00012 * 00013 * Redistribution and use in source and binary forms, with or without modification, 00014 * are permitted provided that the following conditions are met: 00015 * 1. Redistributions of source code must retain the above copyright notice, 00016 * this list of conditions and the following disclaimer. 00017 * 2. Redistributions in binary form must reproduce the above copyright notice, 00018 * this list of conditions and the following disclaimer in the documentation 00019 * and/or other materials provided with the distribution. 00020 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00021 * may be used to endorse or promote products derived from this software 00022 * without specific prior written permission. 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00025 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00026 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00027 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00028 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00029 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00030 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00032 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 ****************************************************************************** 00036 * 00037 * *** NOTE : By default hardlinks U10, U11, U15 & U18, on the underside of 00038 * the X-NUCELO-53L1A1 expansion board are not made/OFF. 00039 * These links must be made to allow interrupts from the Satellite boards 00040 * to be received. 00041 * U11 and U18 must be made/ON to allow interrupts to be received from the 00042 * INT_L & INT_R positions; or 00043 * U10 and U15 must be made/ON to allow interrupts to be received from the 00044 * Alternate INT_L & INT_R positions. 00045 * The X_NUCLEO_53L1A2 library defaults to use the INT_L/INT_R positions. 00046 * INT_L is available on expansion board Arduino Connector CN5, pin 1 as D8. 00047 * Alternate INT_L is on CN5 Connector pin 2 as D9. 00048 * INT_R is available on expansion board Arduino Connector CN9, pin 3 as D2. 00049 * Alternate INT_R is on CN9 Connector pin 5 as D4. 00050 * The pinouts are shown here : https://developer.mbed.org/components/X-NUCLEO-53L1A2/ 00051 */ 00052 00053 #ifndef __VL53L1_A2_NUCLEO_CLASS_H 00054 #define __VL53L1_A2_NUCLEO_CLASS_H 00055 00056 00057 /* Includes ------------------------------------------------------------------*/ 00058 #include "VL53L1CB.h" 00059 #include "Stmpe1600.h" 00060 //#include "DevI2C.h" 00061 #include "ToF_I2C.h" 00062 00063 00064 /** New device addresses */ 00065 #define NEW_SENSOR_CENTRE_ADDRESS 0x56 00066 00067 #define NEW_SENSOR_LEFT_ADDRESS 0x58 00068 #define NEW_SENSOR_RIGHT_ADDRESS 0x5a 00069 00070 00071 /* Classes--------------------------------------------------------------------*/ 00072 00073 /* Classes -------------------------------------------------------------------*/ 00074 /** Class representing the X-NUCLEO-VL53L1A2 expansion board 00075 */ 00076 class XNucleo53L1A2 00077 { 00078 public: 00079 /** Constructor 1 00080 * @param[in] &i2c device I2C to be used for communication 00081 */ 00082 XNucleo53L1A2(ToF_DevI2C *ext_i2c) : dev_i2c(ext_i2c) 00083 { 00084 00085 printf("XNucleo53L1A2 %d z\n",ext_i2c); 00086 stmpe1600_exp0 = new Stmpe1600((DevI2C*)ext_i2c, (0x43 * 2)); // U21 00087 00088 stmpe1600_exp1 = new Stmpe1600((DevI2C*)ext_i2c, (0x42 * 2)); // U19 00089 00090 xshutdown_centre = new Stmpe1600DigiOut((DevI2C*)dev_i2c, GPIO_15, (0x42 * 2)); // U19 on schematic 00091 sensor_centre = new VL53L1CB(dev_i2c, xshutdown_centre, A2); 00092 00093 xshutdown_left = new Stmpe1600DigiOut((DevI2C*)dev_i2c, GPIO_14, (0x43 * 2)); // U21 on schematic 00094 sensor_left = new VL53L1CB(dev_i2c, xshutdown_left, D8); 00095 00096 xshutdown_right = new Stmpe1600DigiOut((DevI2C*)dev_i2c, GPIO_15, (0x43 * 2)); // U21 on schematic 00097 sensor_right = new VL53L1CB(dev_i2c, xshutdown_right, D2); 00098 } 00099 00100 /** Constructor 2 00101 * @param[in] &i2c device I2C to be used for communication 00102 * @param[in] PinName gpio1_centre Mbed DigitalOut pin name to be used as a centre sensor GPIO_1 INT 00103 * @param[in] PinName gpio1_left Mbed DigitalOut pin name to be used as a left sensor GPIO_1 INT 00104 * @param[in] PinName gpio1_right Mbed DigitalOut pin name to be used as a right sensor GPIO_1 INT 00105 */ 00106 XNucleo53L1A2(ToF_DevI2C *ext_i2c, PinName gpio1_centre, 00107 PinName gpio1_left, PinName gpio1_right) : dev_i2c(ext_i2c) 00108 { 00109 stmpe1600_exp0 = new Stmpe1600((DevI2C*)ext_i2c, (0x43 * 2)); // U21 00110 00111 stmpe1600_exp1 = new Stmpe1600((DevI2C*)ext_i2c, (0x42 * 2)); // U19 00112 // printf("ToF_DevI2C constructor %d %d %d %d\n",ext_i2c,gpio1_centre,gpio1_left,gpio1_right); 00113 00114 xshutdown_centre = new Stmpe1600DigiOut((DevI2C*)dev_i2c, GPIO_15, (0x42 * 2)); // U19 on schematic 00115 sensor_centre = new VL53L1CB(dev_i2c, xshutdown_centre, gpio1_centre); 00116 00117 xshutdown_left = new Stmpe1600DigiOut((DevI2C*)dev_i2c, GPIO_14, (0x43 * 2)); // U21 on schematic 00118 sensor_left = new VL53L1CB(dev_i2c, xshutdown_left, gpio1_left); 00119 00120 xshutdown_right = new Stmpe1600DigiOut((DevI2C*)dev_i2c, GPIO_15, (0x43 * 2)); // U21 on schematic 00121 sensor_right = new VL53L1CB(dev_i2c, xshutdown_right, gpio1_right); 00122 } 00123 00124 00125 /** Destructor 00126 */ 00127 ~XNucleo53L1A2() 00128 { 00129 printf("XNucleo53L1A2 destructor \n"); 00130 if (xshutdown_centre != NULL) { 00131 delete xshutdown_centre; 00132 xshutdown_centre = NULL; 00133 } 00134 if (sensor_centre != NULL) { 00135 delete sensor_centre; 00136 sensor_centre = NULL; 00137 } 00138 if (xshutdown_left != NULL) { 00139 delete xshutdown_left; 00140 xshutdown_left = NULL; 00141 } 00142 if (sensor_left != NULL) { 00143 delete sensor_left; 00144 sensor_left = NULL; 00145 } 00146 if (xshutdown_right != NULL) { 00147 delete xshutdown_right; 00148 xshutdown_right = NULL; 00149 } 00150 if (sensor_right != NULL) { 00151 delete sensor_right; 00152 sensor_right = NULL; 00153 } 00154 00155 delete stmpe1600_exp0; 00156 stmpe1600_exp0 = NULL; 00157 delete stmpe1600_exp1; 00158 stmpe1600_exp1 = NULL; 00159 _instance = NULL; 00160 } 00161 00162 00163 /** 00164 * @brief Creates a singleton object instance 00165 * @param[in] &i2c device I2C to be used for communication 00166 * @return Pointer to the object instance 00167 */ 00168 static XNucleo53L1A2 *instance(ToF_DevI2C *ext_i2c); 00169 00170 /** 00171 * @brief Creates a singleton object instance 00172 * @param[in] &i2c device I2C to be used for communication 00173 * @param[in] PinName gpio1_centre the pin connected to centre sensor INT 00174 * @param[in] PinName gpio1_left the pin connected to left sensor INT 00175 * @param[in] PinName gpio1_right the pin connected to right sensor INT 00176 * @return Pointer to the object instance 00177 */ 00178 static XNucleo53L1A2 *instance(ToF_DevI2C *ext_i2c, PinName gpio1_centre, 00179 PinName gpio1_left, PinName gpio1_right); 00180 00181 /** 00182 * @brief Initialize the board and sensors with deft values 00183 * @return 0 on success 00184 */ 00185 int init_board(); 00186 00187 ToF_DevI2C *dev_i2c; 00188 00189 VL53L1CB *sensor_centre; 00190 VL53L1CB *sensor_left; 00191 VL53L1CB *sensor_right; 00192 00193 Stmpe1600 *stmpe1600_exp0; 00194 Stmpe1600 *stmpe1600_exp1; 00195 00196 Stmpe1600DigiOut *xshutdown_centre; 00197 Stmpe1600DigiOut *xshutdown_left; 00198 Stmpe1600DigiOut *xshutdown_right; 00199 00200 private: 00201 static XNucleo53L1A2 *_instance; 00202 }; 00203 00204 00205 #endif /* __VL53L1_A2_NUCLEO_CLASS_H */
Generated on Sat Jul 30 2022 13:20:03 by
