Contains Ayoub's Ranging and Custom interfaces for the VL53L3CX

Committer:
charlesmn
Date:
Wed Jul 21 14:47:53 2021 +0000
Revision:
1:dae4cb24beec
Parent:
0:c1910e04fc6c
strip out commented out code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
charlesmn 0:c1910e04fc6c 1 /**
charlesmn 0:c1910e04fc6c 2 ******************************************************************************
charlesmn 0:c1910e04fc6c 3 * @file 53l3a2_ranging_sensor.h
charlesmn 0:c1910e04fc6c 4 * @author IMG SW Application Team
charlesmn 0:c1910e04fc6c 5 * @brief This file contains the common defines and functions prototypes for
charlesmn 0:c1910e04fc6c 6 * the 53l3a2_ranging_sensor.c driver.
charlesmn 0:c1910e04fc6c 7 ******************************************************************************
charlesmn 0:c1910e04fc6c 8 * @attention
charlesmn 0:c1910e04fc6c 9 *
charlesmn 0:c1910e04fc6c 10 * <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
charlesmn 0:c1910e04fc6c 11 * All rights reserved.</center></h2>
charlesmn 0:c1910e04fc6c 12 *
charlesmn 0:c1910e04fc6c 13 * This software component is licensed by ST under BSD 3-Clause license,
charlesmn 0:c1910e04fc6c 14 * the "License"; You may not use this file except in compliance with the
charlesmn 0:c1910e04fc6c 15 * License. You may obtain a copy of the License at:
charlesmn 0:c1910e04fc6c 16 * opensource.org/licenses/BSD-3-Clause
charlesmn 0:c1910e04fc6c 17 *
charlesmn 0:c1910e04fc6c 18 ******************************************************************************
charlesmn 0:c1910e04fc6c 19 */
charlesmn 0:c1910e04fc6c 20
charlesmn 0:c1910e04fc6c 21 /* Define to prevent recursive inclusion -------------------------------------*/
charlesmn 0:c1910e04fc6c 22 #ifndef XNUCLEO_53L3A2_RANGING_SENSOR_H
charlesmn 0:c1910e04fc6c 23 #define XNUCLEO_53L3A2_RANGING_SENSOR_H
charlesmn 0:c1910e04fc6c 24
charlesmn 0:c1910e04fc6c 25 #ifdef __cplusplus
charlesmn 0:c1910e04fc6c 26 extern "C" {
charlesmn 0:c1910e04fc6c 27 #endif
charlesmn 0:c1910e04fc6c 28
charlesmn 0:c1910e04fc6c 29 /* Includes ------------------------------------------------------------------*/
charlesmn 0:c1910e04fc6c 30 #include "53l3a2.h"
charlesmn 0:c1910e04fc6c 31 #include "ranging_sensor.h"
charlesmn 0:c1910e04fc6c 32
charlesmn 0:c1910e04fc6c 33 #include "vl53l3cx.h"
charlesmn 0:c1910e04fc6c 34
charlesmn 0:c1910e04fc6c 35 /** @addtogroup BSP
charlesmn 0:c1910e04fc6c 36 * @{
charlesmn 0:c1910e04fc6c 37 */
charlesmn 0:c1910e04fc6c 38
charlesmn 0:c1910e04fc6c 39 /** @addtogroup XNUCLEO_53L3A2
charlesmn 0:c1910e04fc6c 40 * @{
charlesmn 0:c1910e04fc6c 41 */
charlesmn 0:c1910e04fc6c 42
charlesmn 0:c1910e04fc6c 43 /** @defgroup XNUCLEO_53L3A2_RANGING_SENSOR RANGING SENSOR
charlesmn 0:c1910e04fc6c 44 * @{
charlesmn 0:c1910e04fc6c 45 */
charlesmn 0:c1910e04fc6c 46
charlesmn 0:c1910e04fc6c 47 /** @defgroup XNUCLEO_53L3A2_RANGING_SENSOR_Exported_Constants Exported Constants
charlesmn 0:c1910e04fc6c 48 * @{
charlesmn 0:c1910e04fc6c 49 */
charlesmn 0:c1910e04fc6c 50 #define RANGING_SENSOR_VL53L3CX_ADDRESS (VL53L3CX_DEVICE_ADDRESS)
charlesmn 0:c1910e04fc6c 51 #define RANGING_SENSOR_NB_TARGET_PER_ZONE (VL53L3CX_NB_TARGET_PER_ZONE)
charlesmn 0:c1910e04fc6c 52 #define RANGING_SENSOR_MAX_NB_ZONES (VL53L3CX_MAX_NB_ZONES)
charlesmn 0:c1910e04fc6c 53
charlesmn 0:c1910e04fc6c 54 #define RANGING_SENSOR_POWERMODE_ON (0U) /*!< Run */
charlesmn 0:c1910e04fc6c 55 #define RANGING_SENSOR_POWERMODE_OFF (1U) /*!< Standby */
charlesmn 0:c1910e04fc6c 56
charlesmn 0:c1910e04fc6c 57 #define RS_MODE_BLOCKING_CONTINUOUS (VL53L3CX_MODE_BLOCKING_CONTINUOUS)
charlesmn 0:c1910e04fc6c 58 #define RS_MODE_BLOCKING_ONESHOT (VL53L3CX_MODE_BLOCKING_ONESHOT)
charlesmn 0:c1910e04fc6c 59 #define RS_MODE_ASYNC_CONTINUOUS (VL53L3CX_MODE_ASYNC_CONTINUOUS)
charlesmn 0:c1910e04fc6c 60 #define RS_MODE_ASYNC_ONESHOT (VL53L3CX_MODE_ASYNC_ONESHOT)
charlesmn 0:c1910e04fc6c 61
charlesmn 0:c1910e04fc6c 62 #define RS_MULTI_TARGET_SHORT_RANGE (VL53L3CX_PROFILE_SHORT)
charlesmn 0:c1910e04fc6c 63 #define RS_MULTI_TARGET_MEDIUM_RANGE (VL53L3CX_PROFILE_MEDIUM)
charlesmn 0:c1910e04fc6c 64 #define RS_MULTI_TARGET_LONG_RANGE (VL53L3CX_PROFILE_LONG)
charlesmn 0:c1910e04fc6c 65 /**
charlesmn 0:c1910e04fc6c 66 * @}
charlesmn 0:c1910e04fc6c 67 */
charlesmn 0:c1910e04fc6c 68
charlesmn 0:c1910e04fc6c 69 /** @defgroup XNUCLEO_53L3A2_RANGING_SENSOR_Exported_Types Exported Types
charlesmn 0:c1910e04fc6c 70 * @{
charlesmn 0:c1910e04fc6c 71 */
charlesmn 0:c1910e04fc6c 72 typedef struct
charlesmn 0:c1910e04fc6c 73 {
charlesmn 0:c1910e04fc6c 74 uint32_t RangingProfile;
charlesmn 0:c1910e04fc6c 75 uint32_t TimingBudget; /*!< Expressed in milliseconds */
charlesmn 0:c1910e04fc6c 76 uint32_t Frequency; /*!< Expressed in Hz */
charlesmn 0:c1910e04fc6c 77 uint32_t EnableAmbient; /*<! Enable: 1, Disable: 0 */
charlesmn 0:c1910e04fc6c 78 uint32_t EnableSignal; /*<! Enable: 1, Disable: 0 */
charlesmn 0:c1910e04fc6c 79 PinName pin_gpio1; // name of interrupt pin
charlesmn 0:c1910e04fc6c 80 uint32_t EnableInterrupt; /*<! Enable: 1, Disable: 0 */
charlesmn 0:c1910e04fc6c 81 VL53L3CX_Interrupt_Func Interrupt_Func;
charlesmn 0:c1910e04fc6c 82 } RANGING_SENSOR_ProfileConfig_t;
charlesmn 0:c1910e04fc6c 83
charlesmn 0:c1910e04fc6c 84 typedef struct
charlesmn 0:c1910e04fc6c 85 {
charlesmn 0:c1910e04fc6c 86 uint32_t NumberOfZones;
charlesmn 0:c1910e04fc6c 87 uint32_t MaxNumberOfTargetsPerZone;
charlesmn 0:c1910e04fc6c 88 uint32_t CustomROI; /*!< Not available: 0, Available: 1 */
charlesmn 0:c1910e04fc6c 89 uint32_t ThresholdDetection; /*!< Not available: 0, Available: 1 */
charlesmn 0:c1910e04fc6c 90 } RANGING_SENSOR_Capabilities_t;
charlesmn 0:c1910e04fc6c 91
charlesmn 0:c1910e04fc6c 92 typedef struct
charlesmn 0:c1910e04fc6c 93 {
charlesmn 0:c1910e04fc6c 94 uint32_t NumberOfTargets;
charlesmn 0:c1910e04fc6c 95 uint32_t Distance[RANGING_SENSOR_NB_TARGET_PER_ZONE]; /*!< millimeters */
charlesmn 0:c1910e04fc6c 96 uint32_t Status[RANGING_SENSOR_NB_TARGET_PER_ZONE]; /*!< OK: 0, NOK: !0 */
charlesmn 0:c1910e04fc6c 97 float_t Ambient[RANGING_SENSOR_NB_TARGET_PER_ZONE]; /*!< kcps / spad */
charlesmn 0:c1910e04fc6c 98 float_t Signal[RANGING_SENSOR_NB_TARGET_PER_ZONE]; /*!< kcps / spad */
charlesmn 0:c1910e04fc6c 99 } RANGING_SENSOR_ZoneResult_t;
charlesmn 0:c1910e04fc6c 100
charlesmn 0:c1910e04fc6c 101 typedef struct
charlesmn 0:c1910e04fc6c 102 {
charlesmn 0:c1910e04fc6c 103 uint32_t NumberOfZones;
charlesmn 0:c1910e04fc6c 104 RANGING_SENSOR_ZoneResult_t ZoneResult[RANGING_SENSOR_MAX_NB_ZONES];
charlesmn 0:c1910e04fc6c 105 } RANGING_SENSOR_Result_t;
charlesmn 0:c1910e04fc6c 106
charlesmn 0:c1910e04fc6c 107 typedef struct
charlesmn 0:c1910e04fc6c 108 {
charlesmn 0:c1910e04fc6c 109 uint32_t Criteria;
charlesmn 0:c1910e04fc6c 110 uint32_t LowThreshold;
charlesmn 0:c1910e04fc6c 111 uint32_t HighThreshold;
charlesmn 0:c1910e04fc6c 112 } RANGING_SENSOR_ITConfig_t;
charlesmn 0:c1910e04fc6c 113
charlesmn 0:c1910e04fc6c 114 typedef struct
charlesmn 0:c1910e04fc6c 115 {
charlesmn 0:c1910e04fc6c 116 uint8_t TopLeftX; /*!< Top Left x coordinate: 0-15 range */
charlesmn 0:c1910e04fc6c 117 uint8_t TopLeftY; /*!< Top Left y coordinate: 0-15 range */
charlesmn 0:c1910e04fc6c 118 uint8_t BotRightX; /*!< Bot Right x coordinate: 0-15 range */
charlesmn 0:c1910e04fc6c 119 uint8_t BotRightY; /*!< Bot Right y coordinate: 0-15 range */
charlesmn 0:c1910e04fc6c 120 } RANGING_SENSOR_ROIConfig_t;
charlesmn 0:c1910e04fc6c 121 /**
charlesmn 0:c1910e04fc6c 122 * @}
charlesmn 0:c1910e04fc6c 123 */
charlesmn 0:c1910e04fc6c 124
charlesmn 0:c1910e04fc6c 125 /** @defgroup XNUCLEO_53L3A2_RANGING_SENSOR_Exported_Variables Exported Variables
charlesmn 0:c1910e04fc6c 126 * @{
charlesmn 0:c1910e04fc6c 127 */
charlesmn 0:c1910e04fc6c 128 extern void *VL53L3A2_RANGING_SENSOR_CompObj[RANGING_SENSOR_INSTANCES_NBR];
charlesmn 0:c1910e04fc6c 129 /**
charlesmn 0:c1910e04fc6c 130 * @}
charlesmn 0:c1910e04fc6c 131 */
charlesmn 0:c1910e04fc6c 132
charlesmn 0:c1910e04fc6c 133 /** @defgroup XNUCLEO_53L3A2_RANGING_SENSOR_Exported_Functions Exported Functions
charlesmn 0:c1910e04fc6c 134 * @{
charlesmn 0:c1910e04fc6c 135 */
charlesmn 0:c1910e04fc6c 136 int32_t VL53L3A2_RANGING_SENSOR_Init(uint32_t Instance);
charlesmn 0:c1910e04fc6c 137 int32_t VL53L3A2_RANGING_SENSOR_DeInit(uint32_t Instance);
charlesmn 0:c1910e04fc6c 138 int32_t VL53L3A2_RANGING_SENSOR_ReadID(uint32_t Instance, uint32_t *pId);
charlesmn 0:c1910e04fc6c 139 int32_t VL53L3A2_RANGING_SENSOR_GetCapabilities(uint32_t Instance, RANGING_SENSOR_Capabilities_t *pCapabilities);
charlesmn 0:c1910e04fc6c 140 int32_t VL53L3A2_RANGING_SENSOR_ConfigProfile(uint32_t Instance, RANGING_SENSOR_ProfileConfig_t *pConfig);
charlesmn 0:c1910e04fc6c 141 int32_t VL53L3A2_RANGING_SENSOR_ConfigROI(uint32_t Instance, RANGING_SENSOR_ROIConfig_t *pConfig);
charlesmn 0:c1910e04fc6c 142 int32_t VL53L3A2_RANGING_SENSOR_ConfigIT(uint32_t Instance, RANGING_SENSOR_ITConfig_t *pConfig);
charlesmn 0:c1910e04fc6c 143 int32_t VL53L3A2_RANGING_SENSOR_GetDistance(uint32_t Instance, RANGING_SENSOR_Result_t *pResult);
charlesmn 0:c1910e04fc6c 144 int32_t VL53L3A2_RANGING_SENSOR_Start(uint32_t Instance, uint32_t Mode);
charlesmn 0:c1910e04fc6c 145 int32_t VL53L3A2_RANGING_SENSOR_Stop(uint32_t Instance);
charlesmn 0:c1910e04fc6c 146 int32_t VL53L3A2_RANGING_SENSOR_SetAddress(uint32_t Instance, uint32_t Address);
charlesmn 0:c1910e04fc6c 147 int32_t VL53L3A2_RANGING_SENSOR_GetAddress(uint32_t Instance, uint32_t *pAddress);
charlesmn 0:c1910e04fc6c 148 int32_t VL53L3A2_RANGING_SENSOR_SetPowerMode(uint32_t Instance, uint32_t PowerMode);
charlesmn 0:c1910e04fc6c 149 int32_t VL53L3A2_RANGING_SENSOR_GetPowerMode(uint32_t Instance, uint32_t *pPowerMode);
charlesmn 0:c1910e04fc6c 150
charlesmn 0:c1910e04fc6c 151 int32_t VL53L3A2_RANGING_SENSOR_OffsetCalibration(uint32_t Instance, uint32_t CalDistance);
charlesmn 0:c1910e04fc6c 152 int32_t VL53L3A2_RANGING_SENSOR_XTalkCalibration(uint32_t Instance);
charlesmn 0:c1910e04fc6c 153 /**
charlesmn 0:c1910e04fc6c 154 * @}
charlesmn 0:c1910e04fc6c 155 */
charlesmn 0:c1910e04fc6c 156
charlesmn 0:c1910e04fc6c 157 /**
charlesmn 0:c1910e04fc6c 158 * @}
charlesmn 0:c1910e04fc6c 159 */
charlesmn 0:c1910e04fc6c 160
charlesmn 0:c1910e04fc6c 161 /**
charlesmn 0:c1910e04fc6c 162 * @}
charlesmn 0:c1910e04fc6c 163 */
charlesmn 0:c1910e04fc6c 164
charlesmn 0:c1910e04fc6c 165 /**
charlesmn 0:c1910e04fc6c 166 * @}
charlesmn 0:c1910e04fc6c 167 */
charlesmn 0:c1910e04fc6c 168
charlesmn 0:c1910e04fc6c 169 #ifdef __cplusplus
charlesmn 0:c1910e04fc6c 170 }
charlesmn 0:c1910e04fc6c 171 #endif
charlesmn 0:c1910e04fc6c 172
charlesmn 0:c1910e04fc6c 173 #endif /* XNUCLEO_53L3A2_RANGING_SENSOR_H */
charlesmn 0:c1910e04fc6c 174
charlesmn 0:c1910e04fc6c 175 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
charlesmn 0:c1910e04fc6c 176