Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of X_NUCLEO_6180XA1 by
Diff: Components/VL6180X/vl6180x_class.h
- Revision:
- 1:1de1ea2994d9
- Child:
- 3:454541a079f4
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Components/VL6180X/vl6180x_class.h Wed Sep 09 16:00:39 2015 +0000 @@ -0,0 +1,125 @@ +/** + ****************************************************************************** + * @file vl6180x_class.h + * @author AST / EST + * @version V0.0.1 + * @date 14-April-2015 + * @brief Header file for component VL6180X + ****************************************************************************** + * @attention + * + * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** +*/ + +#ifndef __VL6180X_CLASS_H +#define __VL6180X_CLASS_H + +/* Includes ------------------------------------------------------------------*/ +#include "RangeSensor.h" +#include "LightSensor.h" +#include "vl6180x_api.h" +#include "vl6180x_cfg.h" +#include "vl6180x_def.h" +#include "vl6180x_i2c.h" +#include "vl6180x_types.h" +#include "vl6180x_platform.h" +#include "vl6180x_appcfg.h" + +/* Classes -------------------------------------------------------------------*/ +/** Class representing a VL6180X sensor component + */ +class VL6180X : public RangeSensor, public LightSensor { + public: + /** Constructor + * @param[in] i2c device I2C to be used for communication + */ + VL6180X(DevI2C &i2c) : RangeSensor(), LightSensor(), dev_i2c(i2c) {} + + /** Destructor + */ + virtual ~VL6180X() {} + + /*** Interface Methods ***/ + virtual int Init(void *init_struct) { + return VL6180X_Init(); + } + + virtual int ReadID(uint8_t *ht_id) { + return VL6180X_ReadID(ht_id); + } + + /** + * @brief Reset sensor + * @return 0 in case of success, an error code otherwise + */ + virtual int Reset(void) { + return VL6180X_RebootCmd(); + } + + virtual int GetRange(float *pfData) { + return VL6180X_GetRange(pfData); + } + + virtual int GetLight(float *pfData) { + return VL6180X_GetLight(pfData); + } + + protected: + /*** Methods ***/ + RANGE_LIGHT_StatusTypeDef VL6180X_Init(RANGE_LIGHT_InitTypeDef *VL6180X_Init); + RANGE_LIGHT_StatusTypeDef VL6180X_ReadID(uint8_t *ht_id); + RANGE_LIGHT_StatusTypeDef VL6180X_SetID(uint8_t *ht_id); + RANGE_LIGHT_StatusTypeDef VL6180X_RebootCmd(void); + RANGE_LIGHT_StatusTypeDef VL6180X_GetRange(float* pfData); + RANGE_LIGHT_StatusTypeDef VL6180X_GetLight(float* pfData); + + /** + * @brief Configures VL6180X interrupt lines for NUCLEO boards + */ + void VL6180X_IO_ITConfig(void) + { + /* To be implemented */ + } + + /** + * @brief Configures VL6180X I2C interface + * @return RANGE_LIGHT_OK in case of success, an error code otherwise + */ + RANGE_LIGHT_StatusTypeDef VL6180X_IO_Init(void) + { + return RANGE_LIGHT_OK; /* done in constructor */ + } + + + /*** Instance Variables ***/ + /* IO Device */ + DevI2C &dev_i2c; + + +}; + +#endif // __VL6180X_CLASS_H \ No newline at end of file