‎2022-03-18 09:21 AM
I own a small dev board (LoRa-E5 mini from SeeedStudio) and coding using STM32cube IDE + MX.
I have made project from scratch, using LED, switch, UART (works fine !)
... and now I want to use my VL53L3CX-SATEL board.
The board is defined on I2C2, all looks ok but in project nothing seems to be used ... any sample/tutorial ???
How to read any value from there ?
So annoying to getback to noob state...
Tanks for help.
‎2022-03-18 09:27 AM
STM32CubeIDE Version: 1.8.0
STM32CubeMX : 6.4.0
More about my installed package :
+ STM32CubeWL Firmware Package V1.1.0 / 16-June-2021
+ X-CUBE-TOF1 Release version : 3.0.0
‎2022-03-18 01:12 PM
If you added the X-cube-tof1 to your project, then the drivers have been added to your project.
So teh best course of action would be to download the:
VL53L3CX API (Application Programming Interface)
Because that's where we hide the example code.
You need to make the calls like in this (simplified) example.
But the full code is in the download.
status = VL53LX_WaitDeviceBooted(Dev);
status = VL53LX_DataInit(Dev);
if(status){
printf("VL53LX_StartMeasurement failed: error = %d \n", status);
while(1);
}
status = VL53LX_StartMeasurement(Dev);
if (isInterrupt){
do // HW interrupt mode
{
status = VL53LX_GetMeasurementDataReady(Dev, &NewDataReady);
if((!status)&&(NewDataReady!=0)){
status = VL53LX_GetMultiRangingData(Dev, pMultiRangingData);
printf("status=%d, D=%5dmm, Signal=%2.2f Mcps, Ambient=%2.2f Mcps",
pMultiRangingData->RangeData[j].RangeStatus,
pMultiRangingData->RangeData[j].RangeMilliMeter,
pMultiRangingData->RangeData[j].SignalRateRtnMegaCps/65536.0,
pMultiRangingData->RangeData[j].AmbientRateRtnMegaCps/65536.0);
}
//
if (status==0){
status = VL53LX_ClearInterruptAndStartMeasurement(Dev);
}
}
}
}
while(1);
‎2022-03-21 09:37 AM
Hi, thanks for your answer.
I must be dumb but I cannot make it working ...
(if that help, my cleaned project is in the zip)
How to create the "Dev" used in ????? :
status = VL53LX_WaitDeviceBooted(Dev);
:loudly_crying_face:
Code from "STSW-IMG015" is using i2c object that I don't have since MX have link it to TOF ( and XSHUTDN GPIO too ).
I've tried but nothing works for me, each time = crash ...
I'm pretty sure my TOF device is waiting me somewhere in my project ... arrrgggghhhhhhhh ...
[INTERNAL_SPEAKING_MODE = ON] ok dude, breathe slowlly, you can do that, you see worse ... wake up ! [INTERNAL_SPEAKING_MODE = OFF]
To be more precise : I have added&setup 2 packages in my project.
In my MX 's project >> Software Packs >> STmicroelectronics.X.CUBE.TOF1.3.0.0 Mode and Configuration I have :
☑�? Board Part Ranging
☑�? Board Support STM32Cube Custom BSP Drivers
Thanks for help.
Sebastien.
[INTERNAL_SPEAKING_MODE=ON] you are not stupid ... you are not stupid ... you are not stupid ... [INTERNAL_SPEAKING_MODE=OFF]
Thanks for reading ...
‎2022-03-21 09:40 AM
Here is my main.c :
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART1_UART_Init();
/* USER CODE BEGIN 2 */
printf("*** INIT TOF START ***\r\n");
HAL_Delay(100);
{
printf("I'm sorry Dave ... I'm afraid i can't do that ...\r\n");
}
printf("*** INIT TOF END ***\r\n");
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
printf("Still alive...\r\n");
HAL_Delay(1000);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
‎2022-03-22 01:06 AM
from main.c (full file is too long)
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include <stdio.h>
#include "main.h"
/* USER CODE END Includes */
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/** Configure the main internal regulator output voltage
*/
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2);
/** Initializes the CPU, AHB and APB busses clocks
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/** Configure the SYSCLKSource, HCLK, PCLK1 and PCLK2 clocks dividers
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK3|RCC_CLOCKTYPE_HCLK
|RCC_CLOCKTYPE_SYSCLK|RCC_CLOCKTYPE_PCLK1
|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.AHBCLK3Divider = RCC_SYSCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
{
Error_Handler();
}
}
‎2022-03-22 02:10 AM
I finally get the exampe code to work !!
<< trying to port this into my project now ... >>
c u later ...
Thanks.