Changes to the library related to interrupt mode.

Dependencies:   ST_INTERFACES X_NUCLEO_COMMON

Dependents:   Display_53L0A1_IntSatelites Display_53L0A1_InterruptMode

Fork of X_NUCLEO_53L0A1 by ST

Committer:
JerrySzczurak
Date:
Wed Jun 14 14:10:45 2017 +0000
Revision:
12:820afb1af4ef
Parent:
9:367d1f390cb2
Library change to work in interrupt continuous ranging mode

Who changed what in which revision?

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