VL53L1X sensor class, for ARM Mbed platform. Based on Ultra-lite, Mass-market C Driver.
Dependencies: X_NUCLEO_COMMON ST_INTERFACES
Dependents: X_NUCLEO_53L1A1_mbed
Diff: vl53l1x_class.h
- Revision:
- 6:aa13392d16bb
- Parent:
- 5:f16727052990
- Child:
- 9:dcaa95b7b374
diff -r f16727052990 -r aa13392d16bb vl53l1x_class.h --- a/vl53l1x_class.h Mon Jan 28 10:14:03 2019 +0000 +++ b/vl53l1x_class.h Fri May 17 09:07:55 2019 +0000 @@ -5,7 +5,7 @@ * @date 15-January-2019 * @brief Header file for VL53L1 sensor component ****************************************************************************** - Copyright © 2019, STMicroelectronics International N.V. + Copyright © 2019, STMicroelectronics International N.V. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -50,7 +50,6 @@ #include "PinNames.h" #include "RangeSensor.h" #include "vl53l1x_error_codes.h" -//#include "DevI2C.h" #include "vl53L1x_I2c.h" #include "Stmpe1600.h" @@ -62,7 +61,6 @@ typedef int8_t VL53L1X_ERROR; -//#define SOFT_RESET 0x0000 #define VL53L1_I2C_SLAVE__DEVICE_ADDRESS 0x0001 #define VL53L1_VHV_CONFIG__TIMEOUT_MACROP_LOOP_BOUND 0x0008 #define ALGO__CROSSTALK_COMPENSATION_PLANE_OFFSET_KCPS 0x0016 @@ -271,18 +269,18 @@ -/** - * - * @brief One time device initialization - * @param void - * @return 0 on success, @a #CALIBRATION_WARNING if failed - */ + /** + * + * @brief One time device initialization + * @param void + * @return 0 on success, @a #CALIBRATION_WARNING if failed + */ virtual int init(void *init) { return VL53L1X_SensorInit(); + } - /** * @brief Initialize the sensor with default values * @return "0" on success @@ -318,13 +316,64 @@ return -1; } - + /** + * @brief Interrupt handling func to be called by user after an INT is occurred + * @param[out] Data pointer to the distance to read data in to + * @return 0 on Success + */ + int handle_irq(uint16_t *distance); -/** - * @brief Get ranging result and only that - * @param pRange_mm Pointer to range distance - * @return 0 on success - */ + /** + * @brief Start the measure indicated by operating mode + * @param[in] fptr specifies call back function must be !NULL in case of interrupt measure + * @return 0 on Success + */ + int start_measurement(void (*fptr)(void)); + /** + * @brief Stop the currently running measure indicate by operating_mode + * @return 0 on Success + */ + int stop_measurement(); + /** + * @brief Get results for the measure + * @param[out] Data pointer to the distance_data to read data in to + * @return 0 on Success + */ + int get_measurement(uint16_t *distance); + /** + * @brief Enable interrupt measure IRQ + * @return 0 on Success + */ + void enable_interrupt_measure_detection_irq(void) + { + if (_gpio1Int != NULL) + _gpio1Int->enable_irq(); + } + + /** + * @brief Disable interrupt measure IRQ + * @return 0 on Success + */ + void disable_interrupt_measure_detection_irq(void) + { + if (_gpio1Int != NULL) + _gpio1Int->disable_irq(); + } + /** + * @brief Attach a function to call when an interrupt is detected, i.e. measurement is ready + * @param[in] fptr pointer to call back function to be called whenever an interrupt occours + * @return 0 on Success + */ + void attach_interrupt_measure_detection_irq(void (*fptr)(void)) + { + if (_gpio1Int != NULL) + _gpio1Int->rise(fptr); + } + /** + * @brief Get ranging result and only that + * @param pRange_mm Pointer to range distance + * @return 0 on success + */ virtual int get_distance(uint32_t *piData) { int status; @@ -335,9 +384,7 @@ } -/* VL53L1X_api.h functions */ - - + /* VL53L1X_api.h functions */ /** * @brief This function returns the SW driver version @@ -628,13 +675,10 @@ /* Measure detection IRQ */ InterruptIn *_gpio1Int; - ///* Digital out pin */ - //int gpio0; - //int gpio1Int; /* Device data */ VL53L1_Dev_t MyDevice; VL53L1_DEV Device; }; -#endif /* _VL53L1X_CLASS_H_ */ \ No newline at end of file +#endif /* _VL53L1X_CLASS_H_ */