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:
14:0effa0bbf192
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 10:4954b09b72d8 1 /**
gallonm 10:4954b09b72d8 2 ******************************************************************************
gallonm 10:4954b09b72d8 3 * @file x_nucleo_6180xa1.cpp
gallonm 10:4954b09b72d8 4 * @author AST / EST
gallonm 10:4954b09b72d8 5 * @version V0.0.1
gallonm 10:4954b09b72d8 6 * @date 13-April-2015
gallonm 10:4954b09b72d8 7 * @brief Implementation file for the X_NUCLEO_VL6180XA1 singleton class
gallonm 10:4954b09b72d8 8 ******************************************************************************
gallonm 10:4954b09b72d8 9 * @attention
gallonm 10:4954b09b72d8 10 *
gallonm 10:4954b09b72d8 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
gallonm 10:4954b09b72d8 12 *
gallonm 10:4954b09b72d8 13 * Redistribution and use in source and binary forms, with or without modification,
gallonm 10:4954b09b72d8 14 * are permitted provided that the following conditions are met:
gallonm 10:4954b09b72d8 15 * 1. Redistributions of source code must retain the above copyright notice,
gallonm 10:4954b09b72d8 16 * this list of conditions and the following disclaimer.
gallonm 10:4954b09b72d8 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
gallonm 10:4954b09b72d8 18 * this list of conditions and the following disclaimer in the documentation
gallonm 10:4954b09b72d8 19 * and/or other materials provided with the distribution.
gallonm 10:4954b09b72d8 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
gallonm 10:4954b09b72d8 21 * may be used to endorse or promote products derived from this software
gallonm 10:4954b09b72d8 22 * without specific prior written permission.
gallonm 10:4954b09b72d8 23 *
gallonm 10:4954b09b72d8 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
gallonm 10:4954b09b72d8 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
gallonm 10:4954b09b72d8 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
gallonm 10:4954b09b72d8 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
gallonm 10:4954b09b72d8 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
gallonm 10:4954b09b72d8 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
gallonm 10:4954b09b72d8 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
gallonm 10:4954b09b72d8 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
gallonm 10:4954b09b72d8 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
gallonm 10:4954b09b72d8 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
gallonm 10:4954b09b72d8 34 *
gallonm 10:4954b09b72d8 35 ******************************************************************************
gallonm 10:4954b09b72d8 36 */
gallonm 10:4954b09b72d8 37
gallonm 10:4954b09b72d8 38
gallonm 10:4954b09b72d8 39 /* Includes ------------------------------------------------------------------*/
gallonm 10:4954b09b72d8 40 #include "x_nucleo_6180xa1.h"
gallonm 10:4954b09b72d8 41
gallonm 10:4954b09b72d8 42 /* Static variables ----------------------------------------------------------*/
gallonm 10:4954b09b72d8 43 X_NUCLEO_6180XA1* X_NUCLEO_6180XA1::_instance = NULL;
gallonm 10:4954b09b72d8 44
gallonm 10:4954b09b72d8 45
gallonm 10:4954b09b72d8 46 X_NUCLEO_6180XA1* X_NUCLEO_6180XA1::Instance(DevI2C *ext_i2c)
gallonm 10:4954b09b72d8 47 {
gallonm 10:4954b09b72d8 48 if(_instance==NULL)
gallonm 10:4954b09b72d8 49 _instance=new X_NUCLEO_6180XA1(ext_i2c);
gallonm 10:4954b09b72d8 50 else
gallonm 10:4954b09b72d8 51 error("Failed to init X_NUCLEO_6180XA1 board!\n");
gallonm 10:4954b09b72d8 52 return _instance;
gallonm 10:4954b09b72d8 53 }
gallonm 10:4954b09b72d8 54
gallonm 10:4954b09b72d8 55
gallonm 10:4954b09b72d8 56 int X_NUCLEO_6180XA1::InitBoard()
gallonm 10:4954b09b72d8 57 {
gallonm 10:4954b09b72d8 58 int status;
gallonm 10:4954b09b72d8 59
gallonm 10:4954b09b72d8 60 status=sensor_top->InitSensor(NEW_SENSOR_TOP_ADDRESS);
gallonm 10:4954b09b72d8 61 if(status)
gallonm 10:4954b09b72d8 62 {
gallonm 12:71d589e6fd2c 63 delete sensor_top;
gallonm 12:71d589e6fd2c 64 delete gpio0_top;
gallonm 10:4954b09b72d8 65 sensor_top=NULL;
gallonm 10:4954b09b72d8 66 gpio0_top=NULL;
gallonm 10:4954b09b72d8 67 }
gallonm 10:4954b09b72d8 68
gallonm 10:4954b09b72d8 69 //stessa cosa per left, bottom e right
gallonm 10:4954b09b72d8 70 }
gallonm 10:4954b09b72d8 71
gallonm 10:4954b09b72d8 72