hello world LIDAR
Dependencies: ST_INTERFACES X_NUCLEO_COMMON
Fork of X_NUCLEO_53L0A1 by
x_nucleo_53l0a1.cpp
00001 /** 00002 ****************************************************************************** 00003 * @file x_nucleo_53L0A1.cpp 00004 * @author IMG 00005 * @version V1.0.0 00006 * @date 28-November-2016 00007 * @brief Implementation file for the X_NUCLEO_VL53L0A1 singleton class 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * <h2><center>© COPYRIGHT(c) 2016 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 00038 00039 /* Includes ------------------------------------------------------------------*/ 00040 #include "x_nucleo_53l0a1.h" 00041 00042 /* Static variables ----------------------------------------------------------*/ 00043 X_NUCLEO_53L0A1* X_NUCLEO_53L0A1::_instance = NULL; 00044 00045 X_NUCLEO_53L0A1* X_NUCLEO_53L0A1::Instance(DevI2C *ext_i2c) 00046 { 00047 if(_instance==NULL) 00048 _instance=new X_NUCLEO_53L0A1(ext_i2c); 00049 else 00050 VL53L0X_ErrLog("Failed to create X_NUCLEO_53L0A1 instance\n\r"); 00051 return _instance; 00052 } 00053 00054 00055 00056 X_NUCLEO_53L0A1* X_NUCLEO_53L0A1::Instance(DevI2C *ext_i2c, 00057 PinName gpio1_centre, 00058 PinName gpio1_left, PinName gpio1_right) 00059 { 00060 if(_instance==NULL) 00061 _instance=new X_NUCLEO_53L0A1(ext_i2c, gpio1_centre, gpio1_left, gpio1_right); 00062 else 00063 VL53L0X_ErrLog("Failed to create X_NUCLEO_53L0A1 instance\n\r"); 00064 return _instance; 00065 } 00066 00067 00068 int X_NUCLEO_53L0A1::InitBoard() 00069 { 00070 int status, n_dev=0; 00071 00072 sensor_centre->VL53L0X_Off(); 00073 sensor_left->VL53L0X_Off(); 00074 sensor_right->VL53L0X_Off(); 00075 status=sensor_centre->InitSensor(NEW_SENSOR_CENTRE_ADDRESS); 00076 if(status) 00077 { 00078 delete sensor_centre; 00079 delete xshutdown_centre; 00080 sensor_centre=NULL; 00081 xshutdown_centre=NULL; 00082 printf("Sensor centre not present\n\r"); 00083 } 00084 else 00085 { 00086 printf("Sensor centre present\n\r"); 00087 n_dev++; 00088 } 00089 /* status=sensor_left->InitSensor(NEW_SENSOR_LEFT_ADDRESS); 00090 if(status) 00091 { 00092 delete sensor_left; 00093 delete xshutdown_left; 00094 sensor_left=NULL; 00095 xshutdown_left=NULL; 00096 printf("Sensor left not present\n\r"); 00097 } 00098 else 00099 { 00100 printf("Sensor left present\n\r"); 00101 n_dev++; 00102 } 00103 */ 00104 /* status=sensor_right->InitSensor(NEW_SENSOR_RIGHT_ADDRESS); 00105 if(status) 00106 { 00107 delete sensor_right; 00108 delete xshutdown_right; 00109 sensor_right=NULL; 00110 xshutdown_right=NULL; 00111 printf("Sensor right not present\n\r"); 00112 } 00113 else 00114 { 00115 printf("Sensor right present\n\r"); 00116 n_dev++; 00117 } 00118 */ 00119 if(n_dev==0) 00120 return 1; 00121 else 00122 return 0; 00123 } 00124
Generated on Sat Jul 16 2022 20:50:45 by
1.7.2
