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.
Fork of X_NUCLEO_6180XA1 by
x_nucleo_6180xa1.cpp
00001 /** 00002 ****************************************************************************** 00003 * @file x_nucleo_6180xa1.cpp 00004 * @author AST / EST 00005 * @version V0.0.1 00006 * @date 13-April-2015 00007 * @brief Implementation file for the X_NUCLEO_VL6180XA1 singleton class 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * <h2><center>© COPYRIGHT(c) 2015 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_6180xa1.h" 00041 00042 /* Static variables ----------------------------------------------------------*/ 00043 X_NUCLEO_6180XA1* X_NUCLEO_6180XA1::_instance = NULL; 00044 00045 X_NUCLEO_6180XA1* X_NUCLEO_6180XA1::Instance(DevI2C *ext_i2c) 00046 { 00047 if(_instance==NULL) 00048 _instance=new X_NUCLEO_6180XA1(ext_i2c); 00049 else 00050 VL6180x_ErrLog("Failed to create X_NUCLEO_6180XA1 instance\n\r"); 00051 return _instance; 00052 } 00053 00054 X_NUCLEO_6180XA1* X_NUCLEO_6180XA1::Instance(DevI2C *ext_i2c, 00055 PinName gpio1_top, PinName gpio1_bottom, 00056 PinName gpio1_left, PinName gpio1_right) 00057 { 00058 if(_instance==NULL) 00059 //_instance=new X_NUCLEO_6180XA1(ext_i2c); 00060 _instance=new X_NUCLEO_6180XA1(ext_i2c, gpio1_top, gpio1_bottom, gpio1_left, gpio1_right); 00061 else 00062 VL6180x_ErrLog("Failed to create X_NUCLEO_6180XA1 instance\n\r"); 00063 return _instance; 00064 } 00065 00066 00067 int X_NUCLEO_6180XA1::InitBoard() 00068 { 00069 int status, n_dev=0; 00070 00071 sensor_top->VL6180x_Off(); 00072 sensor_bottom->VL6180x_Off(); 00073 sensor_left->VL6180x_Off(); 00074 sensor_right->VL6180x_Off(); 00075 status=sensor_top->InitSensor(NEW_SENSOR_TOP_ADDRESS); 00076 if(status) 00077 { 00078 delete sensor_top; 00079 delete gpio0_top; 00080 sensor_top=NULL; 00081 gpio0_top=NULL; 00082 printf("Sensor top not present\n\r"); 00083 } 00084 else 00085 { 00086 printf("Sensor top present\n\r"); 00087 n_dev++; 00088 } 00089 status=sensor_bottom->InitSensor(NEW_SENSOR_BOTTOM_ADDRESS); 00090 if(status) 00091 { 00092 delete sensor_bottom; 00093 delete gpio0_bottom; 00094 sensor_bottom=NULL; 00095 gpio0_bottom=NULL; 00096 printf("Sensor bottom not present\n\r"); 00097 } 00098 else 00099 { 00100 printf("Sensor bottom present\n\r"); 00101 n_dev++; 00102 } 00103 status=sensor_left->InitSensor(NEW_SENSOR_LEFT_ADDRESS); 00104 if(status) 00105 { 00106 delete sensor_left; 00107 delete gpio0_left; 00108 sensor_left=NULL; 00109 gpio0_left=NULL; 00110 printf("Sensor left not present\n\r"); 00111 } 00112 else 00113 { 00114 printf("Sensor left present\n\r"); 00115 n_dev++; 00116 } 00117 status=sensor_right->InitSensor(NEW_SENSOR_RIGHT_ADDRESS); 00118 if(status) 00119 { 00120 delete sensor_right; 00121 delete gpio0_right; 00122 sensor_right=NULL; 00123 gpio0_right=NULL; 00124 printf("Sensor right not present\n\r"); 00125 } 00126 else 00127 { 00128 printf("Sensor right present\n\r"); 00129 n_dev++; 00130 } 00131 if(n_dev==0) 00132 return 1; 00133 else 00134 return 0; 00135 } 00136 00137
Generated on Wed Jul 13 2022 03:00:33 by
 1.7.2
 1.7.2 
    