Now you can use NC as InterruptIn

Dependencies:   X_NUCLEO_COMMON

Fork of X_NUCLEO_6180XA1 by ST

Committer:
gallonm
Date:
Tue Oct 13 14:22:45 2015 +0200
Revision:
12:71d589e6fd2c
Parent:
10:4954b09b72d8
Child:
13:6736a00a0aa9
Introduced virtual functions GetRange and GetLight of the sensor classes.
Fixed as wrapper functions of VL6180x_RangeGetResult and VL6180x_AlsGetLux.

Fixed a comment of the stmpe1600_class.h

Fixed the function InitSensor.
Introduced the function StartMeasurement to choose the operating mode.
Introduced the funcions RangeMeasPollSingleShot, AlsMeasPollSingleShot,
RangeMeasPollContinuousMode, AlsMeasPollContinuousMode, RangeMeasIntContinuousMode,
AlsMeasIntContinuousMode and InterleavedMode to manage different type of operating
mode.
Introduced the functions GetRangeError and GetAlsError to verify error measurement.
Introduced the functions GetRangeMeasContinuousMode and GetAlsMeasContinuousMode
to get the result of the measure in continuous mode.
Introduced the function StartInterleavedMode to start the interleaved mode.
Introduced the function HandleIRQ to manage the interrupt request.

Introduced MeasureData_t struct that contains the results of range and als measure
and related error (range, als and gpio).
Introduced enum OperatingMode and MeasureType.
Fixed the Vl6180x constructor, introducing the parameter PinName gpio1 needed to
interrupt_measure.
Introduced the wrapper functions.
Introducede InterruptIn interrupt_measure to handle the interrupt request.

Fixed the x_nucleo_6180xa1 constructor.

Fixed the object sensor_top.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gallonm 0:1fb1f010ac84 1 /**
gallonm 0:1fb1f010ac84 2 ******************************************************************************
gallonm 0:1fb1f010ac84 3 * @file x_nucleo_6180xa1.h
gallonm 0:1fb1f010ac84 4 * @author AST / EST
gallonm 0:1fb1f010ac84 5 * @version V0.0.1
gallonm 0:1fb1f010ac84 6 * @date 13-April-2015
gallonm 0:1fb1f010ac84 7 * @brief Header file for class X_NUCLEO_6180XA1 representing a X-NUCLEO-6180XA1
gallonm 0:1fb1f010ac84 8 * expansion board
gallonm 0:1fb1f010ac84 9 ******************************************************************************
gallonm 0:1fb1f010ac84 10 * @attention
gallonm 0:1fb1f010ac84 11 *
gallonm 0:1fb1f010ac84 12 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
gallonm 0:1fb1f010ac84 13 *
gallonm 0:1fb1f010ac84 14 * Redistribution and use in source and binary forms, with or without modification,
gallonm 0:1fb1f010ac84 15 * are permitted provided that the following conditions are met:
gallonm 0:1fb1f010ac84 16 * 1. Redistributions of source code must retain the above copyright notice,
gallonm 0:1fb1f010ac84 17 * this list of conditions and the following disclaimer.
gallonm 0:1fb1f010ac84 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
gallonm 0:1fb1f010ac84 19 * this list of conditions and the following disclaimer in the documentation
gallonm 0:1fb1f010ac84 20 * and/or other materials provided with the distribution.
gallonm 0:1fb1f010ac84 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
gallonm 0:1fb1f010ac84 22 * may be used to endorse or promote products derived from this software
gallonm 0:1fb1f010ac84 23 * without specific prior written permission.
gallonm 0:1fb1f010ac84 24 *
gallonm 0:1fb1f010ac84 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
gallonm 0:1fb1f010ac84 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
gallonm 0:1fb1f010ac84 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
gallonm 0:1fb1f010ac84 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
gallonm 0:1fb1f010ac84 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
gallonm 0:1fb1f010ac84 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
gallonm 0:1fb1f010ac84 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
gallonm 0:1fb1f010ac84 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
gallonm 0:1fb1f010ac84 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
gallonm 0:1fb1f010ac84 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
gallonm 0:1fb1f010ac84 35 *
gallonm 0:1fb1f010ac84 36 ******************************************************************************
gallonm 0:1fb1f010ac84 37 */
gallonm 0:1fb1f010ac84 38
gallonm 0:1fb1f010ac84 39 /* Define to prevent from recursive inclusion --------------------------------*/
gallonm 0:1fb1f010ac84 40 #ifndef __X_NUCLEO_6180XA1_H
gallonm 0:1fb1f010ac84 41 #define __X_NUCLEO_6180XA1_H
gallonm 0:1fb1f010ac84 42
gallonm 0:1fb1f010ac84 43 /* Includes ------------------------------------------------------------------*/
gallonm 0:1fb1f010ac84 44 #include "mbed.h"
gallonm 0:1fb1f010ac84 45 #include "vl6180x_class.h"
gallonm 0:1fb1f010ac84 46 #include "display_class.h"
gallonm 10:4954b09b72d8 47 #include "STMPE1600_class.h"
gallonm 0:1fb1f010ac84 48 #include "DevI2C.h"
gallonm 0:1fb1f010ac84 49
gallonm 12:71d589e6fd2c 50 /** New device addresses */ //FIXME sistemare i nuovi indirizzi da assegnare ai sensori
gallonm 10:4954b09b72d8 51 #define NEW_SENSOR_TOP_ADDRESS 0x10
gallonm 10:4954b09b72d8 52 //#define NEW_SENSOR_LEFT_ADDRESS 0x33
gallonm 10:4954b09b72d8 53 //#define NEW_SENSOR_BOTTOM_ADDRESS 0x34
gallonm 10:4954b09b72d8 54 //#define NEW_SENSOR_RIGHT_ADDRESS 0x35
gallonm 10:4954b09b72d8 55
gallonm 4:a5abf7757947 56 /* Classes--------------------------------------------------------------------*/
gallonm 0:1fb1f010ac84 57
gallonm 10:4954b09b72d8 58 class X_NUCLEO_6180XA1
gallonm 4:a5abf7757947 59 {
gallonm 4:a5abf7757947 60 public:
gallonm 10:4954b09b72d8 61 X_NUCLEO_6180XA1(DevI2C *ext_i2c) : dev_i2c(ext_i2c)
gallonm 10:4954b09b72d8 62 {
gallonm 10:4954b09b72d8 63 gpio0_top=new STMPE1600DigiOut(*dev_i2c, GPIO_12);
gallonm 12:71d589e6fd2c 64 sensor_top=new VL6180X(*dev_i2c, *gpio0_top, PB_0);
gallonm 10:4954b09b72d8 65 }
gallonm 4:a5abf7757947 66
gallonm 10:4954b09b72d8 67 ~X_NUCLEO_6180XA1()
gallonm 10:4954b09b72d8 68 {
gallonm 10:4954b09b72d8 69 if(gpio0_top!=NULL)
gallonm 10:4954b09b72d8 70 delete[] gpio0_top;
gallonm 10:4954b09b72d8 71 if(sensor_top!=NULL)
gallonm 10:4954b09b72d8 72 delete[] sensor_top;
gallonm 10:4954b09b72d8 73 }
gallonm 10:4954b09b72d8 74
gallonm 10:4954b09b72d8 75 DevI2C *dev_i2c;
gallonm 10:4954b09b72d8 76 STMPE1600DigiOut *gpio0_top;
gallonm 10:4954b09b72d8 77 VL6180X *sensor_top;
gallonm 4:a5abf7757947 78
gallonm 12:71d589e6fd2c 79 //pin gpio1: bottom=PA4, left=D13, right=PA10
gallonm 10:4954b09b72d8 80 //VL6180X *vl6180x_left;
gallonm 10:4954b09b72d8 81 //VL6180X *vl6180x_bottom;
gallonm 10:4954b09b72d8 82 //VL6180X *vl6180x_right;
gallonm 10:4954b09b72d8 83 //Display *display;
gallonm 10:4954b09b72d8 84
gallonm 10:4954b09b72d8 85 static X_NUCLEO_6180XA1 *Instance(DevI2C *ext_i2c);
gallonm 10:4954b09b72d8 86
gallonm 12:71d589e6fd2c 87 int InitBoard(); // FIXME posso ritornare il numero dei dispositivi attivi
gallonm 4:a5abf7757947 88
gallonm 4:a5abf7757947 89 private:
gallonm 7:2dc81120c917 90 static X_NUCLEO_6180XA1 *_instance;
gallonm 10:4954b09b72d8 91 };
gallonm 0:1fb1f010ac84 92
gallonm 7:2dc81120c917 93 #endif /* __X_NUCLEO_6180XA1_H */