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.
XNucleo53L0A1.h
00001 /** 00002 ****************************************************************************** 00003 * @file XNucleo53L0A1.h 00004 * @author IMG 00005 * @version V1.0.0 00006 * @date 28-November-2016 00007 * @brief Header file for class XNucleo53L0A1 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 __XNucleo53L0A1_H 00041 #define __XNucleo53L0A1_H 00042 00043 /* Includes ------------------------------------------------------------------*/ 00044 #include "VL53L0X.h" 00045 #include "Display.h" 00046 #include "Stmpe1600.h" 00047 #include "DevI2C.h" 00048 00049 /** New device addresses */ 00050 #define NEW_SENSOR_CENTRE_ADDRESS 0x54 00051 #define NEW_SENSOR_LEFT_ADDRESS 0x56 00052 #define NEW_SENSOR_RIGHT_ADDRESS 0x58 00053 00054 /* Classes--------------------------------------------------------------------*/ 00055 00056 /* Classes -------------------------------------------------------------------*/ 00057 /** Class representing the X-NUCLEO-VL53L0A1 expansion board 00058 */ 00059 class XNucleo53L0A1 00060 { 00061 public: 00062 /** Constructor 1 00063 * @param[in] &i2c device I2C to be used for communication 00064 */ 00065 XNucleo53L0A1(DevI2C *ext_i2c) : dev_i2c(ext_i2c) 00066 { 00067 stmpe1600_exp0 = new Stmpe1600(ext_i2c, (0x43 * 2)); // U21 00068 00069 stmpe1600_exp1 = new Stmpe1600(ext_i2c, (0x42 * 2)); // U19 00070 00071 display = new Display(stmpe1600_exp0, stmpe1600_exp1); 00072 00073 xshutdown_centre = new Stmpe1600DigiOut(dev_i2c, GPIO_15, (0x42 * 2)); // U19 on schematic 00074 sensor_centre = new VL53L0X(dev_i2c, xshutdown_centre, A2); 00075 00076 xshutdown_left = new Stmpe1600DigiOut(dev_i2c, GPIO_14, (0x43 * 2)); // U21 on schematic 00077 sensor_left = new VL53L0X(dev_i2c, xshutdown_left, D8); 00078 00079 xshutdown_right = new Stmpe1600DigiOut(dev_i2c, GPIO_15, (0x43 * 2)); // U21 on schematic 00080 sensor_right = new VL53L0X(dev_i2c, xshutdown_right, D2); 00081 } 00082 00083 /** Constructor 2 00084 * @param[in] &i2c device I2C to be used for communication 00085 * @param[in] PinName gpio1_top Mbed DigitalOut pin name to be used as a top sensor GPIO_1 INT 00086 * @param[in] PinName gpio1_bottom Mbed DigitalOut pin name to be used as a bottom sensor GPIO_1 INT 00087 * @param[in] PinName gpio1_left Mbed DigitalOut pin name to be used as a left sensor GPIO_1 INT 00088 * @param[in] PinName gpio1_right Mbed DigitalOut pin name to be used as a right sensor GPIO_1 INT 00089 */ 00090 XNucleo53L0A1(DevI2C *ext_i2c, PinName gpio1_centre, 00091 PinName gpio1_left, PinName gpio1_right) : dev_i2c(ext_i2c) 00092 { 00093 stmpe1600_exp0 = new Stmpe1600(ext_i2c, (0x43 * 2)); // U21 00094 00095 stmpe1600_exp1 = new Stmpe1600(ext_i2c, (0x42 * 2)); // U19 00096 00097 display = new Display(stmpe1600_exp0, stmpe1600_exp1); 00098 00099 xshutdown_centre = new Stmpe1600DigiOut(dev_i2c, GPIO_15, (0x42 * 2)); // U19 on schematic 00100 sensor_centre = new VL53L0X(dev_i2c, xshutdown_centre, gpio1_centre); 00101 00102 xshutdown_left = new Stmpe1600DigiOut(dev_i2c, GPIO_14, (0x43 * 2)); // U21 on schematic 00103 sensor_left = new VL53L0X(dev_i2c, xshutdown_left, gpio1_left); 00104 00105 xshutdown_right = new Stmpe1600DigiOut(dev_i2c, GPIO_15, (0x43 * 2)); // U21 on schematic 00106 sensor_right = new VL53L0X(dev_i2c, xshutdown_right, gpio1_right); 00107 } 00108 00109 /** Destructor 00110 */ 00111 ~XNucleo53L0A1() 00112 { 00113 if (xshutdown_centre != NULL) { 00114 delete xshutdown_centre; 00115 xshutdown_centre = NULL; 00116 } 00117 if (sensor_centre != NULL) { 00118 delete sensor_centre; 00119 sensor_centre = NULL; 00120 } 00121 if (xshutdown_left != NULL) { 00122 delete xshutdown_left; 00123 xshutdown_left = NULL; 00124 } 00125 if (sensor_left != NULL) { 00126 delete sensor_left; 00127 sensor_left = NULL; 00128 } 00129 if (xshutdown_right != NULL) { 00130 delete xshutdown_right; 00131 xshutdown_right = NULL; 00132 } 00133 if (sensor_right != NULL) { 00134 delete sensor_right; 00135 sensor_right = NULL; 00136 } 00137 00138 delete stmpe1600_exp0; 00139 stmpe1600_exp0 = NULL; 00140 delete stmpe1600_exp1; 00141 stmpe1600_exp1 = NULL; 00142 delete display; 00143 display = NULL; 00144 _instance = NULL; 00145 } 00146 00147 /** 00148 * @brief Creates a singleton object instance 00149 * @param[in] &i2c device I2C to be used for communication 00150 * @return Pointer to the object instance 00151 */ 00152 static XNucleo53L0A1 *instance(DevI2C *ext_i2c); 00153 00154 /** 00155 * @brief Creates a singleton object instance 00156 * @param[in] &i2c device I2C to be used for communication 00157 * @param[in] PinName gpio1_centre the pin connected to top sensor INT 00158 * @param[in] PinName gpio1_left the pin connected to left sensor INT 00159 * @param[in] PinName gpio1_right the pin connected to right sensor INT 00160 * @return Pointer to the object instance 00161 */ 00162 static XNucleo53L0A1 *instance(DevI2C *ext_i2c, PinName gpio1_centre, 00163 PinName gpio1_left, PinName gpio1_right); 00164 00165 /** 00166 * @brief Initialize the board and sensors with deft values 00167 * @return 0 on success 00168 */ 00169 int init_board(); 00170 00171 DevI2C *dev_i2c; 00172 VL53L0X *sensor_centre; 00173 VL53L0X *sensor_left; 00174 VL53L0X *sensor_right; 00175 Stmpe1600 *stmpe1600_exp0; 00176 Stmpe1600 *stmpe1600_exp1; 00177 Stmpe1600DigiOut *xshutdown_centre; 00178 Stmpe1600DigiOut *xshutdown_left; 00179 Stmpe1600DigiOut *xshutdown_right; 00180 Display *display; 00181 00182 private: 00183 static XNucleo53L0A1 *_instance; 00184 }; 00185 00186 #endif /* __XNucleo53L0A1_H */ 00187 00188
Generated on Fri Jul 15 2022 15:26:22 by
1.7.2