Initial release to ST Sw Expansion Team Repo.

Dependencies:   VL53L3CX_mbed

Dependents:   VL53L3CX_Shield_Polling VL53L3CX_Shield_Polling VL53L3CX_Shield_Polling_v5_15 VL53L3_shield_1sensor_polling_Mb515 ... more

Committer:
johnAlexander
Date:
Thu May 06 14:11:13 2021 +0000
Revision:
12:3596d0435199
Parent:
11:cccb5f470785
Update header file comments for constructor 2.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
johnAlexander 3:4ed68a07058d 1 /**
johnAlexander 3:4ed68a07058d 2 ******************************************************************************
johnAlexander 7:c0e18dd78c42 3 * @file XNucleo53L3A2.h
johnAlexander 3:4ed68a07058d 4 * @author JS
johnAlexander 3:4ed68a07058d 5 * @version V0.0.1
johnAlexander 3:4ed68a07058d 6 * @date 15-January-2019
johnAlexander 7:c0e18dd78c42 7 * @brief Header file for component XNucleo53L3A2
johnAlexander 3:4ed68a07058d 8 ******************************************************************************
johnAlexander 3:4ed68a07058d 9 * @attention
johnAlexander 3:4ed68a07058d 10 *
johnAlexander 3:4ed68a07058d 11 * <h2><center>&copy; COPYRIGHT(c) 2019 STMicroelectronics</center></h2>
johnAlexander 3:4ed68a07058d 12 *
johnAlexander 3:4ed68a07058d 13 * Redistribution and use in source and binary forms, with or without modification,
johnAlexander 3:4ed68a07058d 14 * are permitted provided that the following conditions are met:
johnAlexander 3:4ed68a07058d 15 * 1. Redistributions of source code must retain the above copyright notice,
johnAlexander 3:4ed68a07058d 16 * this list of conditions and the following disclaimer.
johnAlexander 3:4ed68a07058d 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
johnAlexander 3:4ed68a07058d 18 * this list of conditions and the following disclaimer in the documentation
johnAlexander 3:4ed68a07058d 19 * and/or other materials provided with the distribution.
johnAlexander 3:4ed68a07058d 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
johnAlexander 3:4ed68a07058d 21 * may be used to endorse or promote products derived from this software
johnAlexander 3:4ed68a07058d 22 * without specific prior written permission.
johnAlexander 3:4ed68a07058d 23 *
johnAlexander 3:4ed68a07058d 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
johnAlexander 3:4ed68a07058d 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
johnAlexander 3:4ed68a07058d 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
johnAlexander 3:4ed68a07058d 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
johnAlexander 3:4ed68a07058d 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
johnAlexander 3:4ed68a07058d 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
johnAlexander 3:4ed68a07058d 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
johnAlexander 3:4ed68a07058d 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
johnAlexander 3:4ed68a07058d 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
johnAlexander 3:4ed68a07058d 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
johnAlexander 3:4ed68a07058d 34 *
johnAlexander 3:4ed68a07058d 35 ******************************************************************************
johnAlexander 3:4ed68a07058d 36 */
johnAlexander 3:4ed68a07058d 37
johnAlexander 7:c0e18dd78c42 38 #ifndef __VL53L3_NUCLEO_CLASS_H
johnAlexander 7:c0e18dd78c42 39 #define __VL53L3_NUCLEO_CLASS_H
johnAlexander 3:4ed68a07058d 40
johnAlexander 3:4ed68a07058d 41
johnAlexander 3:4ed68a07058d 42 /* Includes ------------------------------------------------------------------*/
johnAlexander 3:4ed68a07058d 43 #include "mbed.h"
johnAlexander 3:4ed68a07058d 44 #include "PinNames.h"
johnAlexander 10:12c0dd3cba9b 45
johnAlexander 10:12c0dd3cba9b 46 #include "vl53l3_class.h"
johnAlexander 3:4ed68a07058d 47 #include "Stmpe1600.h"
johnAlexander 3:4ed68a07058d 48 #include "vl53L3_I2c.h"
johnAlexander 3:4ed68a07058d 49
johnAlexander 3:4ed68a07058d 50
johnAlexander 3:4ed68a07058d 51 /** New device addresses */
johnAlexander 3:4ed68a07058d 52 #define NEW_SENSOR_CENTRE_ADDRESS 0x56
johnAlexander 11:cccb5f470785 53 #define NEW_SENSOR_LEFT_ADDRESS 0x58
johnAlexander 11:cccb5f470785 54 #define NEW_SENSOR_RIGHT_ADDRESS 0x5A
johnAlexander 3:4ed68a07058d 55
johnAlexander 3:4ed68a07058d 56
johnAlexander 3:4ed68a07058d 57 /* Classes--------------------------------------------------------------------*/
johnAlexander 3:4ed68a07058d 58
johnAlexander 3:4ed68a07058d 59 /* Classes -------------------------------------------------------------------*/
johnAlexander 3:4ed68a07058d 60 /** Class representing the X-NUCLEO-VL53L1A1 expansion board
johnAlexander 3:4ed68a07058d 61 */
johnAlexander 7:c0e18dd78c42 62 class XNucleo53L3A2
johnAlexander 3:4ed68a07058d 63 {
johnAlexander 3:4ed68a07058d 64 public:
johnAlexander 3:4ed68a07058d 65 /** Constructor 1
johnAlexander 3:4ed68a07058d 66 * @param[in] &i2c device I2C to be used for communication
johnAlexander 3:4ed68a07058d 67 */
johnAlexander 7:c0e18dd78c42 68 XNucleo53L3A2(vl53L3_DevI2C *ext_i2c) : dev_i2c(ext_i2c)
johnAlexander 3:4ed68a07058d 69 {
johnAlexander 3:4ed68a07058d 70
johnAlexander 11:cccb5f470785 71 printf("XNucleo53L3A2 %d z\n",ext_i2c);
johnAlexander 3:4ed68a07058d 72 stmpe1600_exp0 = new Stmpe1600((DevI2C*)ext_i2c, (0x43 * 2)); // U21
johnAlexander 3:4ed68a07058d 73
johnAlexander 3:4ed68a07058d 74 stmpe1600_exp1 = new Stmpe1600((DevI2C*)ext_i2c, (0x42 * 2)); // U19
johnAlexander 3:4ed68a07058d 75
johnAlexander 3:4ed68a07058d 76 xshutdown_centre = new Stmpe1600DigiOut((DevI2C*)dev_i2c, GPIO_15, (0x42 * 2)); // U19 on schematic
johnAlexander 10:12c0dd3cba9b 77 sensor_centre = new VL53L3(ext_i2c, xshutdown_centre, A2);
johnAlexander 3:4ed68a07058d 78
johnAlexander 3:4ed68a07058d 79 xshutdown_left = new Stmpe1600DigiOut((DevI2C*)dev_i2c, GPIO_14, (0x43 * 2)); // U21 on schematic
johnAlexander 10:12c0dd3cba9b 80 sensor_left = new VL53L3(dev_i2c, xshutdown_left, D8);
johnAlexander 3:4ed68a07058d 81
johnAlexander 3:4ed68a07058d 82 xshutdown_right = new Stmpe1600DigiOut((DevI2C*)dev_i2c, GPIO_15, (0x43 * 2)); // U21 on schematic
johnAlexander 10:12c0dd3cba9b 83 sensor_right = new VL53L3(dev_i2c, xshutdown_right, D2);
johnAlexander 3:4ed68a07058d 84 }
johnAlexander 3:4ed68a07058d 85
johnAlexander 3:4ed68a07058d 86 /** Constructor 2
johnAlexander 3:4ed68a07058d 87 * @param[in] &i2c device I2C to be used for communication
johnAlexander 12:3596d0435199 88 * @param[in] PinName gpio1_centre Mbed DigitalOut pin name to be used as a centre sensor GPIO_1 INT
johnAlexander 3:4ed68a07058d 89 * @param[in] PinName gpio1_left Mbed DigitalOut pin name to be used as a left sensor GPIO_1 INT
johnAlexander 3:4ed68a07058d 90 * @param[in] PinName gpio1_right Mbed DigitalOut pin name to be used as a right sensor GPIO_1 INT
johnAlexander 3:4ed68a07058d 91 */
johnAlexander 7:c0e18dd78c42 92 XNucleo53L3A2(vl53L3_DevI2C *ext_i2c, PinName gpio1_centre,
johnAlexander 3:4ed68a07058d 93 PinName gpio1_left, PinName gpio1_right) : dev_i2c(ext_i2c)
johnAlexander 3:4ed68a07058d 94 {
johnAlexander 3:4ed68a07058d 95 stmpe1600_exp0 = new Stmpe1600((DevI2C*)ext_i2c, (0x43 * 2)); // U21
johnAlexander 3:4ed68a07058d 96
johnAlexander 3:4ed68a07058d 97 stmpe1600_exp1 = new Stmpe1600((DevI2C*)ext_i2c, (0x42 * 2)); // U19
johnAlexander 3:4ed68a07058d 98 printf("vl53L1X_DevI2C constructor %d %d %d %d\n",ext_i2c,gpio1_centre,gpio1_left,gpio1_right);
johnAlexander 3:4ed68a07058d 99
johnAlexander 3:4ed68a07058d 100 xshutdown_centre = new Stmpe1600DigiOut((DevI2C*)dev_i2c, GPIO_15, (0x42 * 2)); // U19 on schematic
johnAlexander 10:12c0dd3cba9b 101 sensor_centre = new VL53L3(dev_i2c, xshutdown_centre, gpio1_centre);
johnAlexander 3:4ed68a07058d 102
johnAlexander 3:4ed68a07058d 103 xshutdown_left = new Stmpe1600DigiOut((DevI2C*)dev_i2c, GPIO_14, (0x43 * 2)); // U21 on schematic
johnAlexander 10:12c0dd3cba9b 104 sensor_left = new VL53L3(dev_i2c, xshutdown_left, gpio1_left);
johnAlexander 3:4ed68a07058d 105
johnAlexander 3:4ed68a07058d 106 xshutdown_right = new Stmpe1600DigiOut((DevI2C*)dev_i2c, GPIO_15, (0x43 * 2)); // U21 on schematic
johnAlexander 10:12c0dd3cba9b 107 sensor_right = new VL53L3(dev_i2c, xshutdown_right, gpio1_right);
johnAlexander 3:4ed68a07058d 108 }
johnAlexander 3:4ed68a07058d 109
johnAlexander 3:4ed68a07058d 110
johnAlexander 3:4ed68a07058d 111 /** Destructor
johnAlexander 3:4ed68a07058d 112 */
johnAlexander 7:c0e18dd78c42 113 ~XNucleo53L3A2()
johnAlexander 3:4ed68a07058d 114 {
johnAlexander 7:c0e18dd78c42 115 printf("XNucleo53L3A2 destructor \n");
johnAlexander 3:4ed68a07058d 116 if (xshutdown_centre != NULL) {
johnAlexander 3:4ed68a07058d 117 delete xshutdown_centre;
johnAlexander 3:4ed68a07058d 118 xshutdown_centre = NULL;
johnAlexander 3:4ed68a07058d 119 }
johnAlexander 3:4ed68a07058d 120 if (sensor_centre != NULL) {
johnAlexander 3:4ed68a07058d 121 delete sensor_centre;
johnAlexander 3:4ed68a07058d 122 sensor_centre = NULL;
johnAlexander 3:4ed68a07058d 123 }
johnAlexander 3:4ed68a07058d 124 if (xshutdown_left != NULL) {
johnAlexander 3:4ed68a07058d 125 delete xshutdown_left;
johnAlexander 3:4ed68a07058d 126 xshutdown_left = NULL;
johnAlexander 3:4ed68a07058d 127 }
johnAlexander 3:4ed68a07058d 128 if (sensor_left != NULL) {
johnAlexander 3:4ed68a07058d 129 delete sensor_left;
johnAlexander 3:4ed68a07058d 130 sensor_left = NULL;
johnAlexander 3:4ed68a07058d 131 }
johnAlexander 3:4ed68a07058d 132 if (xshutdown_right != NULL) {
johnAlexander 3:4ed68a07058d 133 delete xshutdown_right;
johnAlexander 3:4ed68a07058d 134 xshutdown_right = NULL;
johnAlexander 3:4ed68a07058d 135 }
johnAlexander 3:4ed68a07058d 136 if (sensor_right != NULL) {
johnAlexander 3:4ed68a07058d 137 delete sensor_right;
johnAlexander 3:4ed68a07058d 138 sensor_right = NULL;
johnAlexander 3:4ed68a07058d 139 }
johnAlexander 3:4ed68a07058d 140
johnAlexander 3:4ed68a07058d 141 delete stmpe1600_exp0;
johnAlexander 3:4ed68a07058d 142 stmpe1600_exp0 = NULL;
johnAlexander 3:4ed68a07058d 143 delete stmpe1600_exp1;
johnAlexander 3:4ed68a07058d 144 stmpe1600_exp1 = NULL;
johnAlexander 3:4ed68a07058d 145 _instance = NULL;
johnAlexander 3:4ed68a07058d 146 }
johnAlexander 3:4ed68a07058d 147
johnAlexander 3:4ed68a07058d 148
johnAlexander 3:4ed68a07058d 149 /**
johnAlexander 3:4ed68a07058d 150 * @brief Creates a singleton object instance
johnAlexander 3:4ed68a07058d 151 * @param[in] &i2c device I2C to be used for communication
johnAlexander 3:4ed68a07058d 152 * @return Pointer to the object instance
johnAlexander 3:4ed68a07058d 153 */
johnAlexander 7:c0e18dd78c42 154 static XNucleo53L3A2 *instance(vl53L3_DevI2C *ext_i2c);
johnAlexander 3:4ed68a07058d 155
johnAlexander 3:4ed68a07058d 156 /**
johnAlexander 3:4ed68a07058d 157 * @brief Creates a singleton object instance
johnAlexander 3:4ed68a07058d 158 * @param[in] &i2c device I2C to be used for communication
johnAlexander 12:3596d0435199 159 * @param[in] PinName gpio1_centre the pin connected to centre sensor INT
johnAlexander 3:4ed68a07058d 160 * @param[in] PinName gpio1_left the pin connected to left sensor INT
johnAlexander 3:4ed68a07058d 161 * @param[in] PinName gpio1_right the pin connected to right sensor INT
johnAlexander 3:4ed68a07058d 162 * @return Pointer to the object instance
johnAlexander 3:4ed68a07058d 163 */
johnAlexander 7:c0e18dd78c42 164 static XNucleo53L3A2 *instance(vl53L3_DevI2C *ext_i2c, PinName gpio1_centre,
johnAlexander 3:4ed68a07058d 165 PinName gpio1_left, PinName gpio1_right);
johnAlexander 3:4ed68a07058d 166
johnAlexander 3:4ed68a07058d 167 /**
johnAlexander 3:4ed68a07058d 168 * @brief Initialize the board and sensors with deft values
johnAlexander 3:4ed68a07058d 169 * @return 0 on success
johnAlexander 3:4ed68a07058d 170 */
johnAlexander 3:4ed68a07058d 171 int init_board();
johnAlexander 3:4ed68a07058d 172
johnAlexander 11:cccb5f470785 173
johnAlexander 3:4ed68a07058d 174 vl53L3_DevI2C *dev_i2c;
johnAlexander 11:cccb5f470785 175
johnAlexander 10:12c0dd3cba9b 176 VL53L3 *sensor_centre;
johnAlexander 10:12c0dd3cba9b 177 VL53L3 *sensor_left;
johnAlexander 10:12c0dd3cba9b 178 VL53L3 *sensor_right;
johnAlexander 11:cccb5f470785 179
johnAlexander 3:4ed68a07058d 180 Stmpe1600 *stmpe1600_exp0;
johnAlexander 3:4ed68a07058d 181 Stmpe1600 *stmpe1600_exp1;
johnAlexander 11:cccb5f470785 182
johnAlexander 3:4ed68a07058d 183 Stmpe1600DigiOut *xshutdown_centre;
johnAlexander 3:4ed68a07058d 184 Stmpe1600DigiOut *xshutdown_left;
johnAlexander 3:4ed68a07058d 185 Stmpe1600DigiOut *xshutdown_right;
johnAlexander 3:4ed68a07058d 186
johnAlexander 3:4ed68a07058d 187 private:
johnAlexander 7:c0e18dd78c42 188 static XNucleo53L3A2 *_instance;
johnAlexander 3:4ed68a07058d 189 };
johnAlexander 3:4ed68a07058d 190
johnAlexander 3:4ed68a07058d 191
johnAlexander 7:c0e18dd78c42 192 #endif /* __VL53L3_NUCLEO_CLASS_H */