Contains Ayoub's Ranging and Custom interfaces for the VL53L3CX
custom_ranging_sensor.h@1:dae4cb24beec, 2021-07-21 (annotated)
- 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?
User | Revision | Line number | New contents of line |
---|---|---|---|
charlesmn | 0:c1910e04fc6c | 1 | /** |
charlesmn | 0:c1910e04fc6c | 2 | ****************************************************************************** |
charlesmn | 0:c1910e04fc6c | 3 | * @file custom_ranging_sensor.h |
charlesmn | 0:c1910e04fc6c | 4 | * @author IMG SW Application Team |
charlesmn | 0:c1910e04fc6c | 5 | * @brief This file contains definitions for the BSP Ranging Sensors |
charlesmn | 0:c1910e04fc6c | 6 | * interface for custom boards |
charlesmn | 0:c1910e04fc6c | 7 | ****************************************************************************** |
charlesmn | 0:c1910e04fc6c | 8 | * @attention |
charlesmn | 0:c1910e04fc6c | 9 | * |
charlesmn | 0:c1910e04fc6c | 10 | * <h2><center>© 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 __CUSTOM_RANGING_SENSOR_H__ |
charlesmn | 0:c1910e04fc6c | 23 | #define __CUSTOM_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 | |
charlesmn | 0:c1910e04fc6c | 31 | #include "custom_tof_conf.h" |
charlesmn | 0:c1910e04fc6c | 32 | #include "ranging_sensor.h" |
charlesmn | 0:c1910e04fc6c | 33 | |
charlesmn | 0:c1910e04fc6c | 34 | |
charlesmn | 0:c1910e04fc6c | 35 | /* Common Error codes */ |
charlesmn | 0:c1910e04fc6c | 36 | #define BSP_ERROR_NONE 0 |
charlesmn | 0:c1910e04fc6c | 37 | #define BSP_ERROR_NO_INIT -1 |
charlesmn | 0:c1910e04fc6c | 38 | #define BSP_ERROR_WRONG_PARAM -2 |
charlesmn | 0:c1910e04fc6c | 39 | #define BSP_ERROR_BUSY -3 |
charlesmn | 0:c1910e04fc6c | 40 | #define BSP_ERROR_PERIPH_FAILURE -4 |
charlesmn | 0:c1910e04fc6c | 41 | #define BSP_ERROR_COMPONENT_FAILURE -5 |
charlesmn | 0:c1910e04fc6c | 42 | #define BSP_ERROR_UNKNOWN_FAILURE -6 |
charlesmn | 0:c1910e04fc6c | 43 | #define BSP_ERROR_UNKNOWN_COMPONENT -7 |
charlesmn | 0:c1910e04fc6c | 44 | #define BSP_ERROR_BUS_FAILURE -8 |
charlesmn | 0:c1910e04fc6c | 45 | #define BSP_ERROR_CLOCK_FAILURE -9 |
charlesmn | 0:c1910e04fc6c | 46 | #define BSP_ERROR_MSP_FAILURE -10 |
charlesmn | 0:c1910e04fc6c | 47 | #define BSP_ERROR_FEATURE_NOT_SUPPORTED -11 |
charlesmn | 0:c1910e04fc6c | 48 | |
charlesmn | 0:c1910e04fc6c | 49 | |
charlesmn | 0:c1910e04fc6c | 50 | #ifndef USE_CUSTOM_RANGING_VL53L3CX |
charlesmn | 0:c1910e04fc6c | 51 | #define USE_CUSTOM_RANGING_VL53L3CX (1U) |
charlesmn | 0:c1910e04fc6c | 52 | #endif |
charlesmn | 0:c1910e04fc6c | 53 | |
charlesmn | 0:c1910e04fc6c | 54 | #if (USE_CUSTOM_RANGING_VL53L3CX == 1U) |
charlesmn | 0:c1910e04fc6c | 55 | #include "vl53l3cx.h" |
charlesmn | 0:c1910e04fc6c | 56 | #endif |
charlesmn | 0:c1910e04fc6c | 57 | |
charlesmn | 0:c1910e04fc6c | 58 | #if (USE_CUSTOM_RANGING_VL53L3CX == 1U) |
charlesmn | 0:c1910e04fc6c | 59 | #define CUSTOM_VL53L3CX (1) |
charlesmn | 0:c1910e04fc6c | 60 | #endif |
charlesmn | 0:c1910e04fc6c | 61 | |
charlesmn | 0:c1910e04fc6c | 62 | #define RANGING_SENSOR_VL53L3CX_ADDRESS (VL53L3CX_DEVICE_ADDRESS) |
charlesmn | 0:c1910e04fc6c | 63 | #define RANGING_SENSOR_NB_TARGET_PER_ZONE (VL53L3CX_NB_TARGET_PER_ZONE) |
charlesmn | 0:c1910e04fc6c | 64 | #define RANGING_SENSOR_MAX_NB_ZONES (VL53L3CX_MAX_NB_ZONES) |
charlesmn | 0:c1910e04fc6c | 65 | |
charlesmn | 0:c1910e04fc6c | 66 | #define RS_MULTI_TARGET_SHORT_RANGE (VL53L3CX_PROFILE_SHORT) |
charlesmn | 0:c1910e04fc6c | 67 | #define RS_MULTI_TARGET_MEDIUM_RANGE (VL53L3CX_PROFILE_MEDIUM) |
charlesmn | 0:c1910e04fc6c | 68 | #define RS_MULTI_TARGET_LONG_RANGE (VL53L3CX_PROFILE_LONG) |
charlesmn | 0:c1910e04fc6c | 69 | |
charlesmn | 0:c1910e04fc6c | 70 | #define RS_MODE_BLOCKING_CONTINUOUS (VL53L3CX_MODE_BLOCKING_CONTINUOUS) |
charlesmn | 0:c1910e04fc6c | 71 | #define RS_MODE_BLOCKING_ONESHOT (VL53L3CX_MODE_BLOCKING_ONESHOT) |
charlesmn | 0:c1910e04fc6c | 72 | #define RS_MODE_ASYNC_CONTINUOUS (VL53L3CX_MODE_ASYNC_CONTINUOUS) |
charlesmn | 0:c1910e04fc6c | 73 | #define RS_MODE_ASYNC_ONESHOT (VL53L3CX_MODE_ASYNC_ONESHOT) |
charlesmn | 0:c1910e04fc6c | 74 | |
charlesmn | 0:c1910e04fc6c | 75 | #define CUSTOM_RANGING_INSTANCES_NBR (3) |
charlesmn | 0:c1910e04fc6c | 76 | |
charlesmn | 0:c1910e04fc6c | 77 | #define CUSTOM_RANGING_POWERMODE_ON (0U) /*!< run */ |
charlesmn | 0:c1910e04fc6c | 78 | #define CUSTOM_RANGING_POWERMODE_OFF (1U) /*!< standby */ |
charlesmn | 0:c1910e04fc6c | 79 | |
charlesmn | 0:c1910e04fc6c | 80 | #if (CUSTOM_RANGING_INSTANCES_NBR == 0U) |
charlesmn | 0:c1910e04fc6c | 81 | #error "No ranging sensor instance has been selected" |
charlesmn | 0:c1910e04fc6c | 82 | #endif |
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 RangingProfile; |
charlesmn | 0:c1910e04fc6c | 95 | uint32_t TimingBudget; /*!< Expressed in milliseconds */ |
charlesmn | 0:c1910e04fc6c | 96 | uint32_t Frequency; /*!< Expressed in Hz */ |
charlesmn | 0:c1910e04fc6c | 97 | uint32_t EnableAmbient; /*<! Enable: 1, Disable: 0 */ |
charlesmn | 0:c1910e04fc6c | 98 | uint32_t EnableSignal; /*<! Enable: 1, Disable: 0 */ |
charlesmn | 0:c1910e04fc6c | 99 | PinName pin_gpio1; // name of interrupt pin |
charlesmn | 0:c1910e04fc6c | 100 | uint32_t EnableInterrupt; /*<! Enable: 1, Disable: 0 */ |
charlesmn | 0:c1910e04fc6c | 101 | VL53L3CX_Interrupt_Func Interrupt_Func; |
charlesmn | 0:c1910e04fc6c | 102 | } RANGING_SENSOR_ProfileConfig_t; |
charlesmn | 0:c1910e04fc6c | 103 | |
charlesmn | 0:c1910e04fc6c | 104 | typedef struct |
charlesmn | 0:c1910e04fc6c | 105 | { |
charlesmn | 0:c1910e04fc6c | 106 | uint8_t TopLeftX; /*!< Top Left x coordinate */ |
charlesmn | 0:c1910e04fc6c | 107 | uint8_t TopLeftY; /*!< Top Left y coordinate */ |
charlesmn | 0:c1910e04fc6c | 108 | uint8_t BotRightX; /*!< Bot Right x coordinate */ |
charlesmn | 0:c1910e04fc6c | 109 | uint8_t BotRightY; /*!< Bot Right y coordinate */ |
charlesmn | 0:c1910e04fc6c | 110 | } RANGING_SENSOR_ROIConfig_t; |
charlesmn | 0:c1910e04fc6c | 111 | |
charlesmn | 0:c1910e04fc6c | 112 | typedef struct |
charlesmn | 0:c1910e04fc6c | 113 | { |
charlesmn | 0:c1910e04fc6c | 114 | uint32_t Criteria; |
charlesmn | 0:c1910e04fc6c | 115 | uint32_t LowThreshold; |
charlesmn | 0:c1910e04fc6c | 116 | uint32_t HighThreshold; |
charlesmn | 0:c1910e04fc6c | 117 | } RANGING_SENSOR_ITConfig_t; |
charlesmn | 0:c1910e04fc6c | 118 | |
charlesmn | 0:c1910e04fc6c | 119 | typedef struct |
charlesmn | 0:c1910e04fc6c | 120 | { |
charlesmn | 0:c1910e04fc6c | 121 | uint32_t NumberOfTargets; |
charlesmn | 0:c1910e04fc6c | 122 | uint32_t Distance[RANGING_SENSOR_NB_TARGET_PER_ZONE]; /*!< millimeters */ |
charlesmn | 0:c1910e04fc6c | 123 | uint32_t Status[RANGING_SENSOR_NB_TARGET_PER_ZONE]; /*!< OK: 0, NOK: !0 */ |
charlesmn | 0:c1910e04fc6c | 124 | float_t Ambient[RANGING_SENSOR_NB_TARGET_PER_ZONE]; /*!< kcps / spad */ |
charlesmn | 0:c1910e04fc6c | 125 | float_t Signal[RANGING_SENSOR_NB_TARGET_PER_ZONE]; /*!< kcps / spad */ |
charlesmn | 0:c1910e04fc6c | 126 | } RANGING_SENSOR_ZoneResult_t; |
charlesmn | 0:c1910e04fc6c | 127 | |
charlesmn | 0:c1910e04fc6c | 128 | typedef struct |
charlesmn | 0:c1910e04fc6c | 129 | { |
charlesmn | 0:c1910e04fc6c | 130 | uint32_t NumberOfZones; |
charlesmn | 0:c1910e04fc6c | 131 | RANGING_SENSOR_ZoneResult_t ZoneResult[RANGING_SENSOR_MAX_NB_ZONES]; |
charlesmn | 0:c1910e04fc6c | 132 | } RANGING_SENSOR_Result_t; |
charlesmn | 0:c1910e04fc6c | 133 | |
charlesmn | 0:c1910e04fc6c | 134 | extern void *CUSTOM_RANGING_CompObj[CUSTOM_RANGING_INSTANCES_NBR]; |
charlesmn | 0:c1910e04fc6c | 135 | |
charlesmn | 0:c1910e04fc6c | 136 | int32_t CUSTOM_RANGING_SENSOR_Init(uint32_t Instance); |
charlesmn | 0:c1910e04fc6c | 137 | int32_t CUSTOM_RANGING_SENSOR_DeInit(uint32_t Instance); |
charlesmn | 0:c1910e04fc6c | 138 | int32_t CUSTOM_RANGING_SENSOR_ReadID(uint32_t Instance, uint32_t *pId); |
charlesmn | 0:c1910e04fc6c | 139 | int32_t CUSTOM_RANGING_SENSOR_GetCapabilities(uint32_t Instance, RANGING_SENSOR_Capabilities_t *pCapabilities); |
charlesmn | 0:c1910e04fc6c | 140 | int32_t CUSTOM_RANGING_SENSOR_ConfigProfile(uint32_t Instance, RANGING_SENSOR_ProfileConfig_t *pConfig); |
charlesmn | 0:c1910e04fc6c | 141 | int32_t CUSTOM_RANGING_SENSOR_ConfigROI(uint32_t Instance, RANGING_SENSOR_ROIConfig_t *pConfig); |
charlesmn | 0:c1910e04fc6c | 142 | int32_t CUSTOM_RANGING_SENSOR_ConfigIT(uint32_t Instance, RANGING_SENSOR_ITConfig_t *pConfig); |
charlesmn | 0:c1910e04fc6c | 143 | int32_t CUSTOM_RANGING_SENSOR_GetDistance(uint32_t Instance, RANGING_SENSOR_Result_t *pResult); |
charlesmn | 0:c1910e04fc6c | 144 | int32_t CUSTOM_RANGING_SENSOR_Start(uint32_t Instance, uint8_t Mode); |
charlesmn | 0:c1910e04fc6c | 145 | int32_t CUSTOM_RANGING_SENSOR_Stop(uint32_t Instance); |
charlesmn | 0:c1910e04fc6c | 146 | int32_t CUSTOM_RANGING_SENSOR_SetAddress(uint32_t Instance, uint16_t Address); |
charlesmn | 0:c1910e04fc6c | 147 | int32_t CUSTOM_RANGING_SENSOR_GetAddress(uint32_t Instance, uint16_t *pAddress); |
charlesmn | 0:c1910e04fc6c | 148 | int32_t CUSTOM_RANGING_SENSOR_SetPowerMode(uint32_t Instance, uint32_t PowerMode); |
charlesmn | 0:c1910e04fc6c | 149 | int32_t CUSTOM_RANGING_SENSOR_GetPowerMode(uint32_t Instance, uint32_t *pPowerMode); |
charlesmn | 0:c1910e04fc6c | 150 | |
charlesmn | 0:c1910e04fc6c | 151 | #ifdef __cplusplus |
charlesmn | 0:c1910e04fc6c | 152 | } |
charlesmn | 0:c1910e04fc6c | 153 | #endif |
charlesmn | 0:c1910e04fc6c | 154 | |
charlesmn | 0:c1910e04fc6c | 155 | #endif /* __CUSTOM_RANGING_SENSOR_H__ */ |
charlesmn | 0:c1910e04fc6c | 156 | |
charlesmn | 0:c1910e04fc6c | 157 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
charlesmn | 0:c1910e04fc6c | 158 |