From a66071365aa8fbaf5c43ca82837d49261b7b3d8c Mon Sep 17 00:00:00 2001 From: YunHorn Technology Date: Wed, 18 Dec 2024 14:05:49 +0800 Subject: [PATCH] revised folder structure --- STM32CubeIDE/.project | 10 +- .../Application/User/TOF/App/subdir.mk | 7 +- .../Release/Drivers/BSP/vl53l1x_uld/subdir.mk | 7 +- STM32CubeIDE/Release/objects.list | 2 +- TOF/App/Example_1_basic_ranging.c | 223 -------------- .../Example_2_tune_sensor_with_debug_data.c | 217 ------------- TOF/App/Example_3_long_ranging.c | 185 ----------- TOF/App/Example_4_ultra_low_power.c | 180 ----------- TOF/App/app_tof.c | 289 ++++++++++++------ TOF/App/app_tof.h | 5 + TOF/Target/53l1a2_conf.h | 2 +- TOF/Target/app_tof_pin_conf.c | 4 +- TOF/Target/app_tof_pin_conf.h | 2 +- 13 files changed, 222 insertions(+), 911 deletions(-) delete mode 100644 TOF/App/Example_1_basic_ranging.c delete mode 100644 TOF/App/Example_2_tune_sensor_with_debug_data.c delete mode 100644 TOF/App/Example_3_long_ranging.c delete mode 100644 TOF/App/Example_4_ultra_low_power.c diff --git a/STM32CubeIDE/.project b/STM32CubeIDE/.project index 9e1eded..b619b67 100644 --- a/STM32CubeIDE/.project +++ b/STM32CubeIDE/.project @@ -502,6 +502,11 @@ 1 copy_PARENT/vl53lx_uld/VL53L1X_calibration.c + + Drivers/BSP/vl53l1x_uld/X-NUCLEO-53L1A1.c + 1 + copy_PARENT/vl53lx_uld/X-NUCLEO-53L1A1.c + Drivers/BSP/vl53l1x_uld/vl53l1_platform.c 1 @@ -532,11 +537,6 @@ 1 copy_PARENT/LoRaWAN/Target/radio_board_if.c - - Application/User/TOF/App/X-NUCLEO-53L1A1.c - 1 - copy_PARENT/vl53lx_uld/X-NUCLEO-53L1A1.c - Application/User/TOF/App/app_tof_peoplecount.c 1 diff --git a/STM32CubeIDE/Release/Application/User/TOF/App/subdir.mk b/STM32CubeIDE/Release/Application/User/TOF/App/subdir.mk index 36716b0..d11bed8 100644 --- a/STM32CubeIDE/Release/Application/User/TOF/App/subdir.mk +++ b/STM32CubeIDE/Release/Application/User/TOF/App/subdir.mk @@ -5,24 +5,19 @@ # Add inputs and outputs from these tool invocations to the build variables C_SRCS += \ -D:/ONEDRIVE/STM32WLV13/Projects/NUCLEO-WL55JC/Applications/LoRaWAN/STS_P2_VL53L1/vl53lx_uld/X-NUCLEO-53L1A1.c \ ../Application/User/TOF/App/app_tof.c \ D:/ONEDRIVE/STM32WLV13/Projects/NUCLEO-WL55JC/Applications/LoRaWAN/STS_P2_VL53L1/TOF/App/app_tof_peoplecount.c OBJS += \ -./Application/User/TOF/App/X-NUCLEO-53L1A1.o \ ./Application/User/TOF/App/app_tof.o \ ./Application/User/TOF/App/app_tof_peoplecount.o C_DEPS += \ -./Application/User/TOF/App/X-NUCLEO-53L1A1.d \ ./Application/User/TOF/App/app_tof.d \ ./Application/User/TOF/App/app_tof_peoplecount.d # Each subdirectory must supply rules for building sources it contributes -Application/User/TOF/App/X-NUCLEO-53L1A1.o: D:/ONEDRIVE/STM32WLV13/Projects/NUCLEO-WL55JC/Applications/LoRaWAN/STS_P2_VL53L1/vl53lx_uld/X-NUCLEO-53L1A1.c Application/User/TOF/App/subdir.mk - arm-none-eabi-gcc "$<" -mcpu=cortex-m4 -std=gnu11 -DCORE_CM4 -DYUNHORN_STS_RANDOM -DUSE_HAL_DRIVER -DSTM32WLE5xx -c -I../../Core/Inc -I../../LoRaWAN/App -I../../LoRaWAN/Target -I../../../../../../../Drivers/CMSIS/Include -I../../vl53lx_uld -I../../TOF/Target -I../../TOF/App -I../../../../../../../Drivers/CMSIS/Core/Include -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc/Legacy -I../../../../../../../Utilities/trace/adv_trace -I../../../../../../../Utilities/misc -I../../../../../../../Utilities/sequencer -I../../../../../../../Utilities/timer -I../../../../../../../Utilities/lpm/tiny_lpm -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler/Packages -I../../../../../../../Drivers/CMSIS/Device/ST/STM32WLxx/Include -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Crypto -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac/Region -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Utilities -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver -I../../../../../../../Drivers/BSP/STM32WLxx_Nucleo -Os -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@" Application/User/TOF/App/%.o Application/User/TOF/App/%.su Application/User/TOF/App/%.cyclo: ../Application/User/TOF/App/%.c Application/User/TOF/App/subdir.mk arm-none-eabi-gcc "$<" -mcpu=cortex-m4 -std=gnu11 -DCORE_CM4 -DYUNHORN_STS_RANDOM -DUSE_HAL_DRIVER -DSTM32WLE5xx -c -I../../Core/Inc -I../../LoRaWAN/App -I../../LoRaWAN/Target -I../../../../../../../Drivers/CMSIS/Include -I../../vl53lx_uld -I../../TOF/Target -I../../TOF/App -I../../../../../../../Drivers/CMSIS/Core/Include -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc/Legacy -I../../../../../../../Utilities/trace/adv_trace -I../../../../../../../Utilities/misc -I../../../../../../../Utilities/sequencer -I../../../../../../../Utilities/timer -I../../../../../../../Utilities/lpm/tiny_lpm -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler/Packages -I../../../../../../../Drivers/CMSIS/Device/ST/STM32WLxx/Include -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Crypto -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac/Region -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Utilities -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver -I../../../../../../../Drivers/BSP/STM32WLxx_Nucleo -Os -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@" Application/User/TOF/App/app_tof_peoplecount.o: D:/ONEDRIVE/STM32WLV13/Projects/NUCLEO-WL55JC/Applications/LoRaWAN/STS_P2_VL53L1/TOF/App/app_tof_peoplecount.c Application/User/TOF/App/subdir.mk @@ -31,7 +26,7 @@ Application/User/TOF/App/app_tof_peoplecount.o: D:/ONEDRIVE/STM32WLV13/Projects/ clean: clean-Application-2f-User-2f-TOF-2f-App clean-Application-2f-User-2f-TOF-2f-App: - -$(RM) ./Application/User/TOF/App/X-NUCLEO-53L1A1.cyclo ./Application/User/TOF/App/X-NUCLEO-53L1A1.d ./Application/User/TOF/App/X-NUCLEO-53L1A1.o ./Application/User/TOF/App/X-NUCLEO-53L1A1.su ./Application/User/TOF/App/app_tof.cyclo ./Application/User/TOF/App/app_tof.d ./Application/User/TOF/App/app_tof.o ./Application/User/TOF/App/app_tof.su ./Application/User/TOF/App/app_tof_peoplecount.cyclo ./Application/User/TOF/App/app_tof_peoplecount.d ./Application/User/TOF/App/app_tof_peoplecount.o ./Application/User/TOF/App/app_tof_peoplecount.su + -$(RM) ./Application/User/TOF/App/app_tof.cyclo ./Application/User/TOF/App/app_tof.d ./Application/User/TOF/App/app_tof.o ./Application/User/TOF/App/app_tof.su ./Application/User/TOF/App/app_tof_peoplecount.cyclo ./Application/User/TOF/App/app_tof_peoplecount.d ./Application/User/TOF/App/app_tof_peoplecount.o ./Application/User/TOF/App/app_tof_peoplecount.su .PHONY: clean-Application-2f-User-2f-TOF-2f-App diff --git a/STM32CubeIDE/Release/Drivers/BSP/vl53l1x_uld/subdir.mk b/STM32CubeIDE/Release/Drivers/BSP/vl53l1x_uld/subdir.mk index 2db6773..043dd7f 100644 --- a/STM32CubeIDE/Release/Drivers/BSP/vl53l1x_uld/subdir.mk +++ b/STM32CubeIDE/Release/Drivers/BSP/vl53l1x_uld/subdir.mk @@ -7,16 +7,19 @@ C_SRCS += \ D:/ONEDRIVE/STM32WLV13/Projects/NUCLEO-WL55JC/Applications/LoRaWAN/STS_P2_VL53L1/vl53lx_uld/VL53L1X_api.c \ D:/ONEDRIVE/STM32WLV13/Projects/NUCLEO-WL55JC/Applications/LoRaWAN/STS_P2_VL53L1/vl53lx_uld/VL53L1X_calibration.c \ +D:/ONEDRIVE/STM32WLV13/Projects/NUCLEO-WL55JC/Applications/LoRaWAN/STS_P2_VL53L1/vl53lx_uld/X-NUCLEO-53L1A1.c \ D:/ONEDRIVE/STM32WLV13/Projects/NUCLEO-WL55JC/Applications/LoRaWAN/STS_P2_VL53L1/vl53lx_uld/vl53l1_platform.c OBJS += \ ./Drivers/BSP/vl53l1x_uld/VL53L1X_api.o \ ./Drivers/BSP/vl53l1x_uld/VL53L1X_calibration.o \ +./Drivers/BSP/vl53l1x_uld/X-NUCLEO-53L1A1.o \ ./Drivers/BSP/vl53l1x_uld/vl53l1_platform.o C_DEPS += \ ./Drivers/BSP/vl53l1x_uld/VL53L1X_api.d \ ./Drivers/BSP/vl53l1x_uld/VL53L1X_calibration.d \ +./Drivers/BSP/vl53l1x_uld/X-NUCLEO-53L1A1.d \ ./Drivers/BSP/vl53l1x_uld/vl53l1_platform.d @@ -25,13 +28,15 @@ Drivers/BSP/vl53l1x_uld/VL53L1X_api.o: D:/ONEDRIVE/STM32WLV13/Projects/NUCLEO-WL arm-none-eabi-gcc "$<" -mcpu=cortex-m4 -std=gnu11 -DCORE_CM4 -DYUNHORN_STS_RANDOM -DUSE_HAL_DRIVER -DSTM32WLE5xx -c -I../../Core/Inc -I../../LoRaWAN/App -I../../LoRaWAN/Target -I../../../../../../../Drivers/CMSIS/Include -I../../vl53lx_uld -I../../TOF/Target -I../../TOF/App -I../../../../../../../Drivers/CMSIS/Core/Include -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc/Legacy -I../../../../../../../Utilities/trace/adv_trace -I../../../../../../../Utilities/misc -I../../../../../../../Utilities/sequencer -I../../../../../../../Utilities/timer -I../../../../../../../Utilities/lpm/tiny_lpm -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler/Packages -I../../../../../../../Drivers/CMSIS/Device/ST/STM32WLxx/Include -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Crypto -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac/Region -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Utilities -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver -I../../../../../../../Drivers/BSP/STM32WLxx_Nucleo -Os -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@" Drivers/BSP/vl53l1x_uld/VL53L1X_calibration.o: D:/ONEDRIVE/STM32WLV13/Projects/NUCLEO-WL55JC/Applications/LoRaWAN/STS_P2_VL53L1/vl53lx_uld/VL53L1X_calibration.c Drivers/BSP/vl53l1x_uld/subdir.mk arm-none-eabi-gcc "$<" -mcpu=cortex-m4 -std=gnu11 -DCORE_CM4 -DYUNHORN_STS_RANDOM -DUSE_HAL_DRIVER -DSTM32WLE5xx -c -I../../Core/Inc -I../../LoRaWAN/App -I../../LoRaWAN/Target -I../../../../../../../Drivers/CMSIS/Include -I../../vl53lx_uld -I../../TOF/Target -I../../TOF/App -I../../../../../../../Drivers/CMSIS/Core/Include -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc/Legacy -I../../../../../../../Utilities/trace/adv_trace -I../../../../../../../Utilities/misc -I../../../../../../../Utilities/sequencer -I../../../../../../../Utilities/timer -I../../../../../../../Utilities/lpm/tiny_lpm -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler/Packages -I../../../../../../../Drivers/CMSIS/Device/ST/STM32WLxx/Include -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Crypto -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac/Region -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Utilities -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver -I../../../../../../../Drivers/BSP/STM32WLxx_Nucleo -Os -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@" +Drivers/BSP/vl53l1x_uld/X-NUCLEO-53L1A1.o: D:/ONEDRIVE/STM32WLV13/Projects/NUCLEO-WL55JC/Applications/LoRaWAN/STS_P2_VL53L1/vl53lx_uld/X-NUCLEO-53L1A1.c Drivers/BSP/vl53l1x_uld/subdir.mk + arm-none-eabi-gcc "$<" -mcpu=cortex-m4 -std=gnu11 -DCORE_CM4 -DYUNHORN_STS_RANDOM -DUSE_HAL_DRIVER -DSTM32WLE5xx -c -I../../Core/Inc -I../../LoRaWAN/App -I../../LoRaWAN/Target -I../../../../../../../Drivers/CMSIS/Include -I../../vl53lx_uld -I../../TOF/Target -I../../TOF/App -I../../../../../../../Drivers/CMSIS/Core/Include -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc/Legacy -I../../../../../../../Utilities/trace/adv_trace -I../../../../../../../Utilities/misc -I../../../../../../../Utilities/sequencer -I../../../../../../../Utilities/timer -I../../../../../../../Utilities/lpm/tiny_lpm -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler/Packages -I../../../../../../../Drivers/CMSIS/Device/ST/STM32WLxx/Include -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Crypto -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac/Region -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Utilities -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver -I../../../../../../../Drivers/BSP/STM32WLxx_Nucleo -Os -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@" Drivers/BSP/vl53l1x_uld/vl53l1_platform.o: D:/ONEDRIVE/STM32WLV13/Projects/NUCLEO-WL55JC/Applications/LoRaWAN/STS_P2_VL53L1/vl53lx_uld/vl53l1_platform.c Drivers/BSP/vl53l1x_uld/subdir.mk arm-none-eabi-gcc "$<" -mcpu=cortex-m4 -std=gnu11 -DCORE_CM4 -DYUNHORN_STS_RANDOM -DUSE_HAL_DRIVER -DSTM32WLE5xx -c -I../../Core/Inc -I../../LoRaWAN/App -I../../LoRaWAN/Target -I../../../../../../../Drivers/CMSIS/Include -I../../vl53lx_uld -I../../TOF/Target -I../../TOF/App -I../../../../../../../Drivers/CMSIS/Core/Include -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc/Legacy -I../../../../../../../Utilities/trace/adv_trace -I../../../../../../../Utilities/misc -I../../../../../../../Utilities/sequencer -I../../../../../../../Utilities/timer -I../../../../../../../Utilities/lpm/tiny_lpm -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler/Packages -I../../../../../../../Drivers/CMSIS/Device/ST/STM32WLxx/Include -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Crypto -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac/Region -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Utilities -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver -I../../../../../../../Drivers/BSP/STM32WLxx_Nucleo -Os -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@" clean: clean-Drivers-2f-BSP-2f-vl53l1x_uld clean-Drivers-2f-BSP-2f-vl53l1x_uld: - -$(RM) ./Drivers/BSP/vl53l1x_uld/VL53L1X_api.cyclo ./Drivers/BSP/vl53l1x_uld/VL53L1X_api.d ./Drivers/BSP/vl53l1x_uld/VL53L1X_api.o ./Drivers/BSP/vl53l1x_uld/VL53L1X_api.su ./Drivers/BSP/vl53l1x_uld/VL53L1X_calibration.cyclo ./Drivers/BSP/vl53l1x_uld/VL53L1X_calibration.d ./Drivers/BSP/vl53l1x_uld/VL53L1X_calibration.o ./Drivers/BSP/vl53l1x_uld/VL53L1X_calibration.su ./Drivers/BSP/vl53l1x_uld/vl53l1_platform.cyclo ./Drivers/BSP/vl53l1x_uld/vl53l1_platform.d ./Drivers/BSP/vl53l1x_uld/vl53l1_platform.o ./Drivers/BSP/vl53l1x_uld/vl53l1_platform.su + -$(RM) ./Drivers/BSP/vl53l1x_uld/VL53L1X_api.cyclo ./Drivers/BSP/vl53l1x_uld/VL53L1X_api.d ./Drivers/BSP/vl53l1x_uld/VL53L1X_api.o ./Drivers/BSP/vl53l1x_uld/VL53L1X_api.su ./Drivers/BSP/vl53l1x_uld/VL53L1X_calibration.cyclo ./Drivers/BSP/vl53l1x_uld/VL53L1X_calibration.d ./Drivers/BSP/vl53l1x_uld/VL53L1X_calibration.o ./Drivers/BSP/vl53l1x_uld/VL53L1X_calibration.su ./Drivers/BSP/vl53l1x_uld/X-NUCLEO-53L1A1.cyclo ./Drivers/BSP/vl53l1x_uld/X-NUCLEO-53L1A1.d ./Drivers/BSP/vl53l1x_uld/X-NUCLEO-53L1A1.o ./Drivers/BSP/vl53l1x_uld/X-NUCLEO-53L1A1.su ./Drivers/BSP/vl53l1x_uld/vl53l1_platform.cyclo ./Drivers/BSP/vl53l1x_uld/vl53l1_platform.d ./Drivers/BSP/vl53l1x_uld/vl53l1_platform.o ./Drivers/BSP/vl53l1x_uld/vl53l1_platform.su .PHONY: clean-Drivers-2f-BSP-2f-vl53l1x_uld diff --git a/STM32CubeIDE/Release/objects.list b/STM32CubeIDE/Release/objects.list index aedb857..beb3a35 100644 --- a/STM32CubeIDE/Release/objects.list +++ b/STM32CubeIDE/Release/objects.list @@ -24,7 +24,6 @@ "./Application/User/LoRaWAN/App/lora_info.o" "./Application/User/LoRaWAN/Target/radio_board_if.o" "./Application/User/Startup/startup_stm32wle5ccux.o" -"./Application/User/TOF/App/X-NUCLEO-53L1A1.o" "./Application/User/TOF/App/app_tof.o" "./Application/User/TOF/App/app_tof_peoplecount.o" "./Application/User/TOF/Target/app_tof_pin_conf.o" @@ -32,6 +31,7 @@ "./Drivers/BSP/STM32WLxx_Nucleo/stm32wlxx_nucleo_radio.o" "./Drivers/BSP/vl53l1x_uld/VL53L1X_api.o" "./Drivers/BSP/vl53l1x_uld/VL53L1X_calibration.o" +"./Drivers/BSP/vl53l1x_uld/X-NUCLEO-53L1A1.o" "./Drivers/BSP/vl53l1x_uld/vl53l1_platform.o" "./Drivers/CMSIS/system_stm32wlxx.o" "./Drivers/STM32WLxx_HAL_Driver/stm32wlxx_hal.o" diff --git a/TOF/App/Example_1_basic_ranging.c b/TOF/App/Example_1_basic_ranging.c deleted file mode 100644 index b8b19e2..0000000 --- a/TOF/App/Example_1_basic_ranging.c +++ /dev/null @@ -1,223 +0,0 @@ -/* - Copyright (c) 2021, STMicroelectronics - All Rights Reserved - - This file : part of VL53L1X ULP and : dual licensed, - either 'STMicroelectronics - Proprietary license' - or 'BSD 3-clause "New" or "Revised" License' , at your option. - -******************************************************************************* - - 'STMicroelectronics Proprietary license' - -******************************************************************************* - - License terms: STMicroelectronics Proprietary in accordance with licensing - terms at www.st.com/sla0081 - - STMicroelectronics confidential - Reproduction and Communication of this document : strictly prohibited unless - specifically authorized in writing by STMicroelectronics. - - -******************************************************************************* - - Alternatively, VL53L1X ULP may be distributed under the terms of - 'BSD 3-clause "New" or "Revised" License', in which case the following - provisions apply instead of the ones mentioned above : - -******************************************************************************* - - License terms: BSD 3-clause "New" or "Revised" License. - - 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 the copyright holder 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. -******************************************************************************* -*/ - -/****************************************/ -/* VL53L1X Low Power basic ranging */ -/****************************************/ - -/* -* This example shows how to use the VL53L1X Ultra Low Power driver in a very -* simple example. It initializes the VL53L1X driver, configure the sensor and -* starts a ranging to capture 200 frames. -*/ - -#include -#include -#include -#include "sys_app.h" - -#include "VL53L1X_ULP_api.h" -extern uint8_t ToF_EventDetected; -/* -uint8_t IsInterruptDetected(uint16_t dev) -{ - // To be filled with customer HW. This function should - // return 1 when an interrupt is raised by the ToF on GPIO1 pin (pin7) - if (ToF_EventDetected ) - { - APP_LOG(TS_OFF, VLEVEL_L,"############### TOF EVENT DETECTED \r\n"); - ToF_EventDetected =0; - return 1; - } else { - return 0; - } -} -*/ -int Example_1_basic_ranging(void) -{ /* - int sts_vl53lx_ranging(uint8_t vl_model, uint8_t range_mode, - uint16_t distance_threshold_mm, uint16_t inter_measurement_ms, uint16_t macro_timing, - uint16_t roi_width, uint16_t sigma_mm, uint16_t signal_kcps, uint16_t i_ambient_kcps); - */ - - /*********************************/ - /* VL53L1X ranging variables */ - /*********************************/ - - uint8_t status, loop; - uint8_t dev; - uint16_t sensor_id; - - uint8_t measurement_status; - uint16_t estimated_distance_mm, signal_kcps, sigma_mm, ambient_kcps; - - /*********************************/ - /* Customer platform */ - /*********************************/ - - /* Default VL53L1X Ultra Low Power I2C address */ - dev = 0x52; - - /* (Optional) Change I2C address */ - // status = VL53L1X_ULP_SetI2CAddress(dev, 0x52); //0x20 - - // dev = 0x20; - - - /*********************************/ - /* Power on sensor and init */ - /*********************************/ - - /* (Optional) Check if there is a VL53L1X sensor connected */ - status = VL53L1X_ULP_GetSensorId(dev, &sensor_id); - APP_LOG(TS_OFF,VLEVEL_L,"VL53L1X address =%X\r\n",sensor_id ); - if(status || (sensor_id != 0xEACC)) - { - APP_LOG(TS_OFF,VLEVEL_L,"VL53L1X not detected at requested address\n"); - return status; - } - - /* (Mandatory) Init VL53L1X sensor */ - status = VL53L1X_ULP_SensorInit(dev); - if(status) - { - APP_LOG(TS_OFF,VLEVEL_L,"VL53L1X ultra low power Loading failed\n"); - //HAL_Delay(100); - return status; - } - - APP_LOG(TS_OFF,VLEVEL_L,"VL53L1X ultra low power ready ! \r\n"); - - /*********************************/ - /* Sensor configuration */ - /*********************************/ - - /* (Optional) Program sensor to raise an interrupt ONLY below 300mm */ - status = VL53L1X_ULP_SetInterruptConfiguration(dev, 800, 1); //i_distance_threshold_mm - - /* (Optional) Program a 10Hz ranging frequency */ - status = VL53L1X_ULP_SetInterMeasurementInMs(dev, 100); // range_interval_ms - - { - /* Increase the macro timing. This is equivalent as increasing the integration time */ - status = VL53L1X_ULP_SetMacroTiming(dev, 100); // micro_timing_ms - - /* Enable all the SPADS */ - status = VL53L1X_ULP_SetROI(dev, 16); // SPADS { 1 -- 16 } - - - // STS---001 for ultra low power - /* Reduce the macro timing to minimum. This is equivalent as reducing the integration time */ - //status = VL53L1X_ULP_SetMacroTiming(dev, 1); - /* Reduce at maximum the SPADS */ - //status = VL53L1X_ULP_SetROI(dev, 4); - - - // STS ---002 for short distance - /* Example for robust and short distance measurements. Max distance reduced - * but very low number of false-positives */ - status |= VL53L1X_ULP_SetSigmaThreshold(dev, 30); - status |= VL53L1X_ULP_SetSignalThreshold(dev, 2000); - - // STS --- 003 for long range - /* Relax some limits. Be careful, it can create false-positives !*/ - //status |= VL53L1X_ULP_SetSigmaThreshold(dev, 60); - //status |= VL53L1X_ULP_SetSignalThreshold(dev, 1200); - } - - - /*********************************/ - /* Ranging loop */ - /*********************************/ - - status = VL53L1X_ULP_StartRanging(dev); - if(status) - { - APP_LOG(TS_OFF,VLEVEL_L,"VL53L1X_ULP_StartRanging failed with status %u\n", status); - return status; - } - - APP_LOG(TS_OFF,VLEVEL_L,"Ranging started. Put your hand close to the sensor to generate an interrupt...\n"); - - loop = 0; - while(loop < 20) - { - /* Use this external function to detect when a hardware interrupt is - * generated on PIN 7 (GPIO1). It means that a new measurement is ready. - */ - - //if(IsInterruptDetected(dev)) - { - /* (Mandatory) Clear HW interrupt to restart measurements */ - VL53L1X_ULP_ClearInterrupt(dev); - - /* Dump debug data */ - status = VL53L1X_ULP_DumpDebugData(dev, &measurement_status, - &estimated_distance_mm, &sigma_mm, &signal_kcps, &ambient_kcps); - - APP_LOG(TS_OFF,VLEVEL_L,"Target detected! Interrupt raised by sensor, Distance =%d mm \r\n", estimated_distance_mm ); - - loop++; - } - } - - status = VL53L1X_ULP_StopRanging(dev); - APP_LOG(TS_OFF,VLEVEL_L,"End of VL53L1X ultra low power demo\n"); - return status; -} diff --git a/TOF/App/Example_2_tune_sensor_with_debug_data.c b/TOF/App/Example_2_tune_sensor_with_debug_data.c deleted file mode 100644 index e8b5b25..0000000 --- a/TOF/App/Example_2_tune_sensor_with_debug_data.c +++ /dev/null @@ -1,217 +0,0 @@ -/* - Copyright (c) 2021, STMicroelectronics - All Rights Reserved - - This file : part of VL53L1X ULP and : dual licensed, - either 'STMicroelectronics - Proprietary license' - or 'BSD 3-clause "New" or "Revised" License' , at your option. - -******************************************************************************* - - 'STMicroelectronics Proprietary license' - -******************************************************************************* - - License terms: STMicroelectronics Proprietary in accordance with licensing - terms at www.st.com/sla0081 - - STMicroelectronics confidential - Reproduction and Communication of this document : strictly prohibited unless - specifically authorized in writing by STMicroelectronics. - - -******************************************************************************* - - Alternatively, VL53L1X ULP may be distributed under the terms of - 'BSD 3-clause "New" or "Revised" License', in which case the following - provisions apply instead of the ones mentioned above : - -******************************************************************************* - - License terms: BSD 3-clause "New" or "Revised" License. - - 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 the copyright holder 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. -******************************************************************************* -*/ - -/****************************************/ -/* VL53L1X Low Power tune sensor */ -/****************************************/ - -/* -* This example shows how to tune the VL53L1X Low power for a specific -* application, playing with sigma and signal threshold. -* It initializes the VL53L1X driver, configure the sensor and -* starts a ranging to capture 200 frames. -*/ - -#include -#include -#include - -#include "../../STM32CubeIDE/Drivers/BSP/vl53l1x_uld/VL53L1X_ULP_api.h" - -uint8_t IsInterruptDetected(uint16_t dev) -{ - // To be filled with customer HW. This function should - // return 1 when an interrupt is raised by the ToF on GPIO1 pin (pin7) -} - -uint8_t Example_2_tune_sensor_with_debug_data(void) -{ - - /*********************************/ - /* VL53L1X ranging variables */ - /*********************************/ - - uint8_t status, loop; - uint8_t dev; - uint16_t sensor_id; - - uint8_t measurement_status; - uint16_t estimated_distance_mm, signal_kcps, sigma_mm, ambient_kcps; - - - /*********************************/ - /* Customer platform */ - /*********************************/ - - /* Default VL53L1X Ultra Low Power I2C address */ - dev = 0x52; - - /* (Optional) Change I2C address */ - // status = VL53L1X_ULP_SetI2CAddress(dev, 0x20); - // dev = 0x20; - - - /*********************************/ - /* Power on sensor and init */ - /*********************************/ - - /* (Optional) Check if there is a VL53L1X sensor connected */ - status = VL53L1X_ULP_GetSensorId(dev, &sensor_id); - if(status || (sensor_id != 0xEACC)) - { - printf("VL53L1X not detected at requested address\n"); - return status; - } - - /* (Mandatory) Init VL53L1X sensor */ - status = VL53L1X_ULP_SensorInit(dev); - if(status) - { - printf("VL53L1X ultra low power Loading failed\n"); - return status; - } - - printf("VL53L1X ultra low power ready !\n"); - - /*********************************/ - /* Sensor tuning */ - /*********************************/ - - /* Here we will change some settings to tune the sensor valid measurements. - * The sensor can output 2 thresholds used to define a valid distance : - * - Sigma threshold. This is the estimated standard deviation of the - * measurement. A low value means that the accuracy is good. Reducing - * this threshold reduces the max ranging distance, but it reduces the - * number of false-positives. - * - * - Signal threshold. This is the quantity of photons measured by the - * sensor. A high value means that the accuracy is good. Increasing - * this threshold reduces the max ranging distance, but it reduces the - * number of false-positives. - */ - - /* Example for robust and short distance measurements. Max distance reduced - * but very low number of false-positives */ - status |= VL53L1X_ULP_SetSigmaThreshold(dev, 30); - status |= VL53L1X_ULP_SetSignalThreshold(dev, 2000); - - - /* Example for longer distance measurements. Max distance increased - * but false-positives may appear */ - // status |= VL53L1X_ULP_SetSigmaThreshold(dev, 60); - // status |= VL53L1X_ULP_SetSignalThreshold(dev, 1200); - - - /*********************************/ - /* Sensor configuration */ - /*********************************/ - - /* (Optional) Program sensor to output interrupt when a new measurement is - * ready, even if the distance is not valid */ - status = VL53L1X_ULP_SetInterruptConfiguration(dev, 0, 0); - - /* (Optional) Program a 10Hz ranging frequency */ - status = VL53L1X_ULP_SetInterMeasurementInMs(dev, 100); - - - /*********************************/ - /* Ranging loop */ - /*********************************/ - - status = VL53L1X_ULP_StartRanging(dev); - if(status) - { - printf("VL53L1X_ULP_StartRanging failed with status %u\n", status); - return status; - } - - printf("Ranging started. Put your hand close to the sensor to generate an interrupt...\n"); - - loop = 0; - while(loop < 200) - { - /* Use this external function to detect when a hardware interrupt is - * generated on PIN 7 (GPIO1). It means that a new measurement is ready. - */ - - if(IsInterruptDetected(dev)) - { - /* (Mandatory) Clear HW interrupt to restart measurements */ - VL53L1X_ULP_ClearInterrupt(dev); - - /* Dump debug data */ - status = VL53L1X_ULP_DumpDebugData(dev, &measurement_status, - &estimated_distance_mm, &sigma_mm, &signal_kcps, &ambient_kcps); - - /* Print debug data. Measurement status 0 means that a valid target - * has been detected */ - printf("DEBUG DATA : Status = %2u, Estimated distance = %4u mm, Signal = %6u kcps, Sigma = %3u mm\n", - measurement_status, - estimated_distance_mm, - signal_kcps, - sigma_mm); - - loop++; - } - } - - status = VL53L1X_ULP_StopRanging(dev); - printf("End of VL53L1X ultra low power demo\n"); - return status; -} diff --git a/TOF/App/Example_3_long_ranging.c b/TOF/App/Example_3_long_ranging.c deleted file mode 100644 index 571f941..0000000 --- a/TOF/App/Example_3_long_ranging.c +++ /dev/null @@ -1,185 +0,0 @@ -/* - Copyright (c) 2021, STMicroelectronics - All Rights Reserved - - This file : part of VL53L1X ULP and : dual licensed, - either 'STMicroelectronics - Proprietary license' - or 'BSD 3-clause "New" or "Revised" License' , at your option. - -******************************************************************************* - - 'STMicroelectronics Proprietary license' - -******************************************************************************* - - License terms: STMicroelectronics Proprietary in accordance with licensing - terms at www.st.com/sla0081 - - STMicroelectronics confidential - Reproduction and Communication of this document : strictly prohibited unless - specifically authorized in writing by STMicroelectronics. - - -******************************************************************************* - - Alternatively, VL53L1X ULP may be distributed under the terms of - 'BSD 3-clause "New" or "Revised" License', in which case the following - provisions apply instead of the ones mentioned above : - -******************************************************************************* - - License terms: BSD 3-clause "New" or "Revised" License. - - 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 the copyright holder 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. -******************************************************************************* -*/ - -/****************************************/ -/* VL53L1X Low Power basic ranging */ -/****************************************/ - -/* -* This example shows how to use the VL53L1X Ultra Low Power driver for -* detecting a user at long distance (>60cm). Please note that the proposed -* configuration also increase the power consumption. -* The example initializes the VL53L1X driver, configure the sensor and -* starts a ranging to capture 200 frames. -*/ - -#include -#include -#include - -#include "../../STM32CubeIDE/Drivers/BSP/vl53l1x_uld/VL53L1X_ULP_api.h" - -uint8_t IsInterruptDetected(uint16_t dev) -{ - // To be filled with customer HW. This function should - // return 1 when an interrupt is raised by the ToF on GPIO1 pin (pin7) -} - -uint8_t Example_3_long_ranging(void) -{ - - /*********************************/ - /* VL53L1X ranging variables */ - /*********************************/ - - uint8_t status, loop; - uint8_t dev; - uint16_t sensor_id; - - - /*********************************/ - /* Customer platform */ - /*********************************/ - - /* Default VL53L1X Ultra Low Power I2C address */ - dev = 0x52; - - /* (Optional) Change I2C address */ - // status = VL53L1X_ULP_SetI2CAddress(dev, 0x20); - // dev = 0x20; - - - /*********************************/ - /* Power on sensor and init */ - /*********************************/ - - /* (Optional) Check if there is a VL53L1X sensor connected */ - status = VL53L1X_ULP_GetSensorId(dev, &sensor_id); - if(status || (sensor_id != 0xEACC)) - { - printf("VL53L1X not detected at requested address\n"); - return status; - } - - /* (Mandatory) Init VL53L1X sensor */ - status = VL53L1X_ULP_SensorInit(dev); - if(status) - { - printf("VL53L1X ultra low power Loading failed\n"); - return status; - } - - printf("VL53L1X ultra low power ready !\n"); - - /*********************************/ - /* Sensor configuration */ - /*********************************/ - - /* (Optional) Program sensor to raise an interrupt ONLY below 600mm */ - status = VL53L1X_ULP_SetInterruptConfiguration(dev, 600, 1); - - /* (Optional) Program a 10Hz ranging frequency */ - status = VL53L1X_ULP_SetInterMeasurementInMs(dev, 100); - - /* Increase the macro timing. This is equivalent as increasing the integration time */ - status = VL53L1X_ULP_SetMacroTiming(dev, 100); - - /* Enable all the SPADS */ - status = VL53L1X_ULP_SetROI(dev, 16); - - /* Relax some limits. Be careful, it can create false-positives !*/ - status |= VL53L1X_ULP_SetSigmaThreshold(dev, 60); - status |= VL53L1X_ULP_SetSignalThreshold(dev, 1200); - - - /*********************************/ - /* Ranging loop */ - /*********************************/ - - status = VL53L1X_ULP_StartRanging(dev); - if(status) - { - printf("VL53L1X_ULP_StartRanging failed with status %u\n", status); - return status; - } - - printf("Ranging started. Put your hand close to the sensor to generate an interrupt...\n"); - - loop = 0; - while(loop < 200) - { - /* Use this external function to detect when a hardware interrupt is - * generated on PIN 7 (GPIO1). It means that a new measurement is ready. - */ - - if(IsInterruptDetected(dev)) - { - /* (Mandatory) Clear HW interrupt to restart measurements */ - VL53L1X_ULP_ClearInterrupt(dev); - - printf("Target detected! Interrupt raised by sensor\n"); - - loop++; - } - } - - status = VL53L1X_ULP_StopRanging(dev); - printf("End of VL53L1X ultra low power demo\n"); - return status; -} diff --git a/TOF/App/Example_4_ultra_low_power.c b/TOF/App/Example_4_ultra_low_power.c deleted file mode 100644 index 436b602..0000000 --- a/TOF/App/Example_4_ultra_low_power.c +++ /dev/null @@ -1,180 +0,0 @@ -/* - Copyright (c) 2021, STMicroelectronics - All Rights Reserved - - This file : part of VL53L1X ULP and : dual licensed, - either 'STMicroelectronics - Proprietary license' - or 'BSD 3-clause "New" or "Revised" License' , at your option. - -******************************************************************************* - - 'STMicroelectronics Proprietary license' - -******************************************************************************* - - License terms: STMicroelectronics Proprietary in accordance with licensing - terms at www.st.com/sla0081 - - STMicroelectronics confidential - Reproduction and Communication of this document : strictly prohibited unless - specifically authorized in writing by STMicroelectronics. - - -******************************************************************************* - - Alternatively, VL53L1X ULP may be distributed under the terms of - 'BSD 3-clause "New" or "Revised" License', in which case the following - provisions apply instead of the ones mentioned above : - -******************************************************************************* - - License terms: BSD 3-clause "New" or "Revised" License. - - 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 the copyright holder 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. -******************************************************************************* -*/ - -/****************************************/ -/* VL53L1X Low Power basic ranging */ -/****************************************/ - -/* -* This example shows how to use the VL53L1X Ultra Low Power driver with the -* lowest possible power consumption. -* The example initializes the VL53L1X driver, configure the sensor and -* starts a ranging to capture 200 frames. -*/ - -#include -#include -#include - -#include "../../STM32CubeIDE/Drivers/BSP/vl53l1x_uld/VL53L1X_ULP_api.h" - -uint8_t IsInterruptDetected(uint16_t dev) -{ - // To be filled with customer HW. This function should - // return 1 when an interrupt is raised by the ToF on GPIO1 pin (pin7) -} - -uint8_t Example_4_ultra_low_power(void) -{ - - /*********************************/ - /* VL53L1X ranging variables */ - /*********************************/ - - uint8_t status, loop; - uint8_t dev; - uint16_t sensor_id; - - - /*********************************/ - /* Customer platform */ - /*********************************/ - - /* Default VL53L1X Ultra Low Power I2C address */ - dev = 0x52; - - /* (Optional) Change I2C address */ - // status = VL53L1X_ULP_SetI2CAddress(dev, 0x20); - // dev = 0x20; - - - /*********************************/ - /* Power on sensor and init */ - /*********************************/ - - /* (Optional) Check if there is a VL53L1X sensor connected */ - status = VL53L1X_ULP_GetSensorId(dev, &sensor_id); - if(status || (sensor_id != 0xEACC)) - { - printf("VL53L1X not detected at requested address\n"); - return status; - } - - /* (Mandatory) Init VL53L1X sensor */ - status = VL53L1X_ULP_SensorInit(dev); - if(status) - { - printf("VL53L1X ultra low power Loading failed\n"); - return status; - } - - printf("VL53L1X ultra low power ready !\n"); - - /*********************************/ - /* Sensor configuration */ - /*********************************/ - - /* (Optional) Program sensor to raise an interrupt ONLY below 300mm */ - status = VL53L1X_ULP_SetInterruptConfiguration(dev, 300, 1); - - /* (Optional) Program a 10Hz ranging frequency */ - status = VL53L1X_ULP_SetInterMeasurementInMs(dev, 100); - - /* Reduce the macro timing to minimum. This is equivalent as reducing the integration time */ - status = VL53L1X_ULP_SetMacroTiming(dev, 1); - - /* Reduce at maximum the SPADS */ - status = VL53L1X_ULP_SetROI(dev, 4); - - - /*********************************/ - /* Ranging loop */ - /*********************************/ - - status = VL53L1X_ULP_StartRanging(dev); - if(status) - { - printf("VL53L1X_ULP_StartRanging failed with status %u\n", status); - return status; - } - - printf("Ranging started. Put your hand close to the sensor to generate an interrupt...\n"); - - loop = 0; - while(loop < 200) - { - /* Use this external function to detect when a hardware interrupt is - * generated on PIN 7 (GPIO1). It means that a new measurement is ready. - */ - - if(IsInterruptDetected(dev)) - { - /* (Mandatory) Clear HW interrupt to restart measurements */ - VL53L1X_ULP_ClearInterrupt(dev); - - printf("Target detected! Interrupt raised by sensor\n"); - - loop++; - } - } - - status = VL53L1X_ULP_StopRanging(dev); - printf("End of VL53L1X ultra low power demo\n"); - return status; -} diff --git a/TOF/App/app_tof.c b/TOF/App/app_tof.c index 2ebb44e..d8457b0 100644 --- a/TOF/App/app_tof.c +++ b/TOF/App/app_tof.c @@ -25,9 +25,11 @@ extern "C" { /* Includes ------------------------------------------------------------------*/ #include "app_tof.h" #include "main.h" +#include "sys_app.h" #include -#include "53l1a2_ranging_sensor.h" +#include "VL53L1X_ULP_api.h" +//#include "53l1a2_ranging_sensor.h" #include "stm32wlxx_nucleo.h" /* Private typedef -----------------------------------------------------------*/ @@ -37,17 +39,17 @@ extern "C" { #define POLLING_PERIOD (250U) /* refresh rate for polling mode (milliseconds, shall be consistent with TimingBudget value) */ /* Private variables ---------------------------------------------------------*/ -static RANGING_SENSOR_Capabilities_t Cap; -static RANGING_SENSOR_ProfileConfig_t Profile; -static int32_t status = 0; -static volatile uint8_t PushButtonDetected = 0; +//static RANGING_SENSOR_Capabilities_t Cap; +//static RANGING_SENSOR_ProfileConfig_t Profile; +//static int32_t status = 0; + volatile uint8_t ToF_EventDetected = 0; + /* Private function prototypes -----------------------------------------------*/ -static void MX_53L1A2_SimpleRanging_Init(void); -static void MX_53L1A2_SimpleRanging_Process(void); -static void print_result(RANGING_SENSOR_Result_t *Result); -static int32_t decimal_part(float_t x); + +int sts_vl53lx_ranging(uint8_t vl_model, uint8_t range_mode, uint16_t distance_threshold_mm, uint16_t inter_measurement_ms, uint16_t macro_timing,uint16_t roi_width, uint16_t sigma_mm, uint16_t signal_kcps); +uint8_t IsInterruptDetected(uint16_t dev); void MX_TOF_Init(void) { @@ -60,9 +62,10 @@ void MX_TOF_Init(void) /* USER CODE END TOF_Init_PreTreatment */ /* Initialize the peripherals and the TOF components */ + APP_LOG(TS_OFF,VLEVEL_L,"\r\n###################### MX TOF Init... \r\n"); - MX_53L1A2_SimpleRanging_Init(); - + //MX_53L1A2_SimpleRanging_Init(); + STS_TOF_VL53LX_PeopleCounting_Process(); /* USER CODE BEGIN TOF_Init_PostTreatment */ /* USER CODE END TOF_Init_PostTreatment */ @@ -77,112 +80,218 @@ void MX_TOF_Process(void) /* USER CODE END TOF_Process_PreTreatment */ - MX_53L1A2_SimpleRanging_Process(); + + //APP_LOG(TS_OFF,VLEVEL_L,"\r\n###################### MX TOF Process... \r\n"); + //STS_TOF_VL53LX_Range_Process(); + //STS_TOF_VL53LX_PeopleCounting_Process(); + + sts_tof_vl53lx_peoplecount_subprocess(); /* USER CODE BEGIN TOF_Process_PostTreatment */ /* USER CODE END TOF_Process_PostTreatment */ } +typedef enum { + STS_TOF_SHORT_RANGE=0, + STS_TOF_LONG_RANGE, + STS_TOF_LOW_POWER_RANGE, + STS_TOF_PP_RANGE +} range_mode_t; +typedef enum { + STS_TOF_VL53L0X=0, + STS_TOF_VL53L1X, + STS_TOF_VL53L2X, + STS_TOF_VL53L3X, + STS_TOF_VL53L4X, + STS_TOF_VL53L5X, + STS_TOF_VL53L6X, + STS_TOF_VL53L7X +} vl53lx_model; -static void MX_53L1A2_SimpleRanging_Init(void) +uint8_t IsInterruptDetected(uint16_t dev) { - /* Initialize Virtual COM Port */ - BSP_COM_Init(COM1); - - /* Initialize button */ - BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI); - - printf("53L1A2 Simple Ranging demo application\n"); - status = VL53L1A2_RANGING_SENSOR_Init(VL53L1A2_DEV_CENTER); - - if (status != BSP_ERROR_NONE) - { - printf("VL53L1A2_RANGING_SENSOR_Init failed\n"); - while(1); - } + // To be filled with customer HW. This function should + // return 1 when an interrupt is raised by the ToF on GPIO1 pin (pin7) + if (ToF_EventDetected ) + { + APP_LOG(TS_OFF, VLEVEL_L,"############### TOF EVENT DETECTED \r\n"); + ToF_EventDetected =0; + return 1; + } else { + return 0; + } } -static void MX_53L1A2_SimpleRanging_Process(void) +void STS_TOF_VL53LX_Range_Process(void) { - uint32_t Id; + uint8_t vl53lx_model = STS_TOF_VL53L1X; + uint8_t range_mode = STS_TOF_SHORT_RANGE; - RANGING_SENSOR_Result_t Result; + uint16_t i_distance_threshold_mm = 800; + uint16_t i_inter_measurement_ms, i_macro_timing; + uint16_t i_roi_width=16, i_sigma_mm=30, i_signal_kcps=2000; + while (1) + { - VL53L1A2_RANGING_SENSOR_ReadID(VL53L1A2_DEV_CENTER, &Id); - VL53L1A2_RANGING_SENSOR_GetCapabilities(VL53L1A2_DEV_CENTER, &Cap); - Profile.RangingProfile = RS_MULTI_TARGET_MEDIUM_RANGE; - Profile.TimingBudget = TIMING_BUDGET; /* 16 ms < TimingBudget < 500 ms */ - Profile.Frequency = 0; /* Induces intermeasurement period, set to ZERO for normal ranging */ - Profile.EnableAmbient = 1; /* Enable: 1, Disable: 0 */ - Profile.EnableSignal = 1; /* Enable: 1, Disable: 0 */ + switch (range_mode) + { + case STS_TOF_SHORT_RANGE: + // STS ---002 for short distance + /* Example for robust and short distance measurements. Max distance reduced + * but very low number of false-positives */ + //status |= VL53L1X_ULP_SetSigmaThreshold(dev, 30); + //status |= VL53L1X_ULP_SetSignalThreshold(dev, 2000); + i_sigma_mm = 30; //increase this for longer distance, reduce for shorter distance + i_signal_kcps = 2000; // 1000- 6000 kcps + i_distance_threshold_mm = 900; + i_inter_measurement_ms = 100; // 100 - 1000 ms + i_macro_timing = 100; + //i_roi_width = 16; - /* set the profile if different from default one */ - VL53L1A2_RANGING_SENSOR_ConfigProfile(VL53L1A2_DEV_CENTER, &Profile); + break; - status = VL53L1A2_RANGING_SENSOR_Start(VL53L1A2_DEV_CENTER, RS_MODE_BLOCKING_CONTINUOUS); + case STS_TOF_LONG_RANGE: + // STS --- 003 for long range + /* Relax some limits. Be careful, it can create false-positives !*/ + //status |= VL53L1X_ULP_SetSigmaThreshold(dev, 60); + //status |= VL53L1X_ULP_SetSignalThreshold(dev, 1200); + i_sigma_mm = 85; // increase this for longer distance, reduce for short distance + i_signal_kcps = 1000; // 1000- 6000 kcps + i_distance_threshold_mm = 4000; //4000; + i_inter_measurement_ms = 200; // 100 - 1000 ms + i_macro_timing = 30; // 1 - 100 ms + i_roi_width = 8; - if (status != BSP_ERROR_NONE) - { - printf("VL53L1A2_RANGING_SENSOR_Start failed\n"); - while(1); - } - while (1) - { - /* polling mode */ - status = VL53L1A2_RANGING_SENSOR_GetDistance(VL53L1A2_DEV_CENTER, &Result); + break; - if (status == BSP_ERROR_NONE) - { - print_result(&Result); - } + case STS_TOF_LOW_POWER_RANGE: + // STS---001 for ultra low power + /* Reduce the macro timing to minimum. This is equivalent as reducing the integration time */ + //status = VL53L1X_ULP_SetMacroTiming(dev, 1); + i_distance_threshold_mm = 4000; + i_inter_measurement_ms = 100; // 100 - 1000 ms + i_macro_timing = 1; + /* Reduce at maximum the SPADS */ + //status = VL53L1X_ULP_SetROI(dev, 4); + i_roi_width = 4; - HAL_Delay(POLLING_PERIOD); - } -} + break; + default: + break; + } -static void print_result(RANGING_SENSOR_Result_t *Result) -{ - uint8_t i, j; + sts_vl53lx_ranging(vl53lx_model, range_mode, i_distance_threshold_mm, i_inter_measurement_ms,i_macro_timing, i_roi_width, i_sigma_mm, i_signal_kcps); - for (i = 0; i < RANGING_SENSOR_MAX_NB_ZONES; i++) - { - printf("\nTargets = %lu", (unsigned long)Result->ZoneResult[i].NumberOfTargets); - - for (j = 0; j < Result->ZoneResult[i].NumberOfTargets; j++) - { - printf("\n |---> "); - - printf("Status = %ld, Distance = %5ld mm ", - (long)Result->ZoneResult[i].Status[j], - (long)Result->ZoneResult[i].Distance[j]); - - if (Profile.EnableAmbient) - printf(", Ambient = %ld.%02ld kcps/spad", - (long)Result->ZoneResult[i].Ambient[j], - (long)decimal_part(Result->ZoneResult[i].Ambient[j])); - - if (Profile.EnableSignal) - printf(", Signal = %ld.%02ld kcps/spad", - (long)Result->ZoneResult[i].Signal[j], - (long)decimal_part(Result->ZoneResult[i].Signal[j])); - } - } - printf ("\n"); -} - -static int32_t decimal_part(float_t x) -{ - int32_t int_part = (int32_t) x; - return (int32_t)((x - int_part) * 100); + range_mode ++; + range_mode %= 3 ; + } } void BSP_PB_Callback(Button_TypeDef Button) { - PushButtonDetected = 1; + //PushButtonDetected = 1; } + +int sts_vl53lx_ranging(uint8_t vl_model, uint8_t range_mode, uint16_t distance_threshold_mm, uint16_t inter_measurement_ms, uint16_t macro_timing, +uint16_t roi_width, uint16_t sigma_mm, uint16_t signal_kcps) +{ + /*********************************/ + /* VL53L1X ranging variables */ + /*********************************/ + uint8_t status, loop; + uint8_t dev; + uint16_t sensor_id; + uint8_t measurement_status; + uint16_t estimated_distance_mm, r_signal_kcps, r_sigma_mm, r_ambient_kcps; + /*********************************/ + /* Customer platform */ + /*********************************/ + /* Default VL53L1X Ultra Low Power I2C address */ + dev = 0x52; + + /* (Optional) Change I2C address */ + // status = VL53L1X_ULP_SetI2CAddress(dev, 0x52); + // dev = 0x20; + + /*********************************/ + /* Power on sensor and init */ + /*********************************/ + APP_LOG(TS_OFF,VLEVEL_L,"Range Mode =%d \r\n",range_mode); + /* (Optional) Check if there is a VL53L1X sensor connected */ + status = VL53L1X_ULP_GetSensorId(dev, &sensor_id); + APP_LOG(TS_OFF,VLEVEL_L,"VL53L1X address =%X\r\n",sensor_id ); + if(status || (sensor_id != 0xEACC)) + { + APP_LOG(TS_OFF,VLEVEL_L,"VL53L1X not detected at requested address\n"); + return status; + } + /* (Mandatory) Init VL53L1X sensor */ + status = VL53L1X_ULP_SensorInit(dev); + if(status) + { + APP_LOG(TS_OFF,VLEVEL_L,"VL53L1X ultra low power Loading failed\n"); + //HAL_Delay(100); + return status; + } + APP_LOG(TS_OFF,VLEVEL_L,"VL53L1X ultra low power ready ! \r\n"); + /*********************************/ + /* Sensor configuration */ + /*********************************/ + /* (Optional) Program sensor to raise an interrupt ONLY below 300mm */ + status = VL53L1X_ULP_SetInterruptConfiguration(dev, distance_threshold_mm, 1); //i_distance_threshold_mm + /* (Optional) Program a 10Hz ranging frequency */ + status = VL53L1X_ULP_SetInterMeasurementInMs(dev, inter_measurement_ms); // range_interval_ms + /* Increase the macro timing. This is equivalent as increasing the integration time */ + status = VL53L1X_ULP_SetMacroTiming(dev, macro_timing); // micro_timing_ms + /* Enable all the SPADS */ + status = VL53L1X_ULP_SetROI(dev, roi_width); // SPADS { 1 -- 16 } + + if(range_mode != STS_TOF_LOW_POWER_RANGE) + { + /* Example for robust and short distance measurements. Max distance reduced + * but very low number of false-positives */ + status |= VL53L1X_ULP_SetSigmaThreshold(dev, sigma_mm); + status |= VL53L1X_ULP_SetSignalThreshold(dev, signal_kcps); + } + + /*********************************/ + /* Ranging loop */ + /*********************************/ + status = VL53L1X_ULP_StartRanging(dev); + if(status) + { + APP_LOG(TS_OFF,VLEVEL_L,"VL53L1X_ULP_StartRanging failed with status %u\n", status); + return status; + } + APP_LOG(TS_OFF,VLEVEL_L,"Ranging started. Put your hand close to the sensor to generate an interrupt...\n"); + loop = 0; + while(loop < 20) + { + /* Use this external function to detect when a hardware interrupt is generated on PIN 7 (GPIO1). It means that a new measurement is ready. + */ + + if(IsInterruptDetected(dev)) + { + /* (Mandatory) Clear HW interrupt to restart measurements */ + VL53L1X_ULP_ClearInterrupt(dev); + /* Dump debug data */ + status = VL53L1X_ULP_DumpDebugData(dev, &measurement_status, + &estimated_distance_mm, &r_sigma_mm, &r_signal_kcps, &r_ambient_kcps); + + APP_LOG(TS_OFF,VLEVEL_L,"Target detected! Interrupt raised by sensor, Distance =%d mm \r\n", estimated_distance_mm ); + loop++; + } + } + + status = VL53L1X_ULP_StopRanging(dev); + APP_LOG(TS_OFF,VLEVEL_L,"End of VL53L1X ultra low power demo\n"); + return status; +} + + #ifdef __cplusplus } #endif diff --git a/TOF/App/app_tof.h b/TOF/App/app_tof.h index 328c4ff..d86b6c7 100644 --- a/TOF/App/app_tof.h +++ b/TOF/App/app_tof.h @@ -33,6 +33,11 @@ /* Exported functions --------------------------------------------------------*/ void MX_TOF_Init(void); void MX_TOF_Process(void); +void STS_TOF_VL53LX_Range_Process(void); +void STS_TOF_VL53LX_PeopleCounting_Process(void); +int sts_tof_vl53lx_peoplecount_subprocess(void); + + #ifdef __cplusplus } diff --git a/TOF/Target/53l1a2_conf.h b/TOF/Target/53l1a2_conf.h index 9467008..986b36f 100644 --- a/TOF/Target/53l1a2_conf.h +++ b/TOF/Target/53l1a2_conf.h @@ -39,7 +39,7 @@ extern "C" { * if you are only using the on-board sensor without break-out boards * change its to (1U) in order to save space in RAM memory */ -#define RANGING_SENSOR_INSTANCES_NBR (3U) +#define RANGING_SENSOR_INSTANCES_NBR (1U) #define VL53L1A2_hi2c (hi2c2) diff --git a/TOF/Target/app_tof_pin_conf.c b/TOF/Target/app_tof_pin_conf.c index 73e1c29..32c062a 100644 --- a/TOF/Target/app_tof_pin_conf.c +++ b/TOF/Target/app_tof_pin_conf.c @@ -20,7 +20,7 @@ #include "app_tof_pin_conf.h" extern volatile uint8_t ToF_EventDetected; - +#if 0 void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { if (GPIO_Pin == TOF_INT_EXTI_PIN) @@ -28,3 +28,5 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) ToF_EventDetected = 1; } } + +#endif diff --git a/TOF/Target/app_tof_pin_conf.h b/TOF/Target/app_tof_pin_conf.h index 5cd9b10..59708ec 100644 --- a/TOF/Target/app_tof_pin_conf.h +++ b/TOF/Target/app_tof_pin_conf.h @@ -28,7 +28,7 @@ extern "C" { #include "stm32wlxx_hal.h" /* Exported symbols ----------------------------------------------------------*/ -#define TOF_INT_EXTI_PIN (GPIO_PIN_3) // (GPIO_PIN_4) +#define TOF_INT_EXTI_PIN (GPIO_PIN_3) // WL55JC GPIO_PIN_10, F401xE ==>(GPIO_PIN_4) #define TOF_INT_EXTI_PORT (GPIOB) #ifdef __cplusplus