initial release
Embed:
(wiki syntax)
Show/hide line numbers
XNucleo53L1A1.cpp
00001 #include "XNucleo53L1A1.h" 00002 00003 XNucleo53L1A1 *XNucleo53L1A1::_instance = NULL; 00004 00005 00006 XNucleo53L1A1 *XNucleo53L1A1::instance(VL53L1X_DevI2C *ext_i2c) 00007 { 00008 if (_instance == NULL) { 00009 _instance = new XNucleo53L1A1(ext_i2c); 00010 } else { 00011 printf("Failed to create XNucleo53L1A1 instance\n\r\r\n"); 00012 } 00013 return _instance; 00014 } 00015 00016 XNucleo53L1A1 *XNucleo53L1A1::instance(VL53L1X_DevI2C *ext_i2c, 00017 PinName gpio1_centre, 00018 PinName gpio1_left, PinName gpio1_right) 00019 { 00020 if (_instance == NULL) { 00021 _instance = new XNucleo53L1A1(ext_i2c, gpio1_centre, gpio1_left, gpio1_right); 00022 } else { 00023 printf("Failed to create XNucleo53L0A1 instance\n\r"); 00024 } 00025 return _instance; 00026 } 00027 00028 00029 int XNucleo53L1A1::init_board() 00030 { 00031 int status, n_dev = 0; 00032 00033 sensor_centre->vl53l1_off(); 00034 sensor_left->vl53l1_off(); 00035 sensor_right->vl53l1_off(); 00036 status = sensor_centre->init_sensor(NEW_SENSOR_CENTRE_ADDRESS); 00037 if (status) { 00038 delete sensor_centre; 00039 delete xshutdown_centre; 00040 sensor_centre = NULL; 00041 xshutdown_centre = NULL; 00042 printf("Sensor centre not present\n\r"); 00043 } else { 00044 printf("Sensor centre present\n\r"); 00045 n_dev++; 00046 } 00047 00048 status = sensor_left->init_sensor(NEW_SENSOR_LEFT_ADDRESS); 00049 if (status) { 00050 delete sensor_left; 00051 delete xshutdown_left; 00052 sensor_left = NULL; 00053 xshutdown_left = NULL; 00054 printf("Sensor left not present\n\r"); 00055 } else { 00056 printf("Sensor left present\n\r"); 00057 n_dev++; 00058 } 00059 00060 status = sensor_right->init_sensor(NEW_SENSOR_RIGHT_ADDRESS); 00061 if (status) { 00062 delete sensor_right; 00063 delete xshutdown_right; 00064 sensor_right = NULL; 00065 xshutdown_right = NULL; 00066 printf("Sensor right not present\n\r"); 00067 } else { 00068 printf("Sensor right present\n\r"); 00069 n_dev++; 00070 } 00071 00072 if (n_dev == 0) { 00073 return 1; 00074 } else { 00075 return 0; 00076 } 00077 } 00078
Generated on Thu Jul 14 2022 03:53:35 by 1.7.2