Hi,
I try to use the API with a STM32l0 but when i combine the HAL and the API the I2C lines do nothing at all.
When i use the HAL_I2C_IsDeviceReady(&hi2c1, 0x52, 100, 5); i can see the signals on my scope.
but when i start using your sensor and the api there is only a flat 3.24mV line
my code:
> int main( void )
{
VL53L1_Dev_t dev;
VL53L1_DEV Dev = &dev;
/* STM32 HAL library initialization*/
HAL_Init();
/* Configure the system clock*/
SystemClock_Config();
/* Configure the debug mode*/
DBG_Init();
/* Configure the hardware*/
HW_Init();
/* USER CODE BEGIN 1 */
MX_I2C1_Init();
dev.I2cHandle = &hi2c1;
dev.I2cDevAddr = 0x52;
/*** VL53L1X Initialization ***/
VL53L1_WaitDeviceBooted(Dev);
VL53L1_DataInit(Dev);
VL53L1_StaticInit(Dev);
PRINTF("Data init sensor DONE\n");
VL53L1_SetDistanceMode(Dev, VL53L1_DISTANCEMODE_LONG);
VL53L1_SetMeasurementTimingBudgetMicroSeconds(Dev, 50000);
VL53L1_SetInterMeasurementPeriodMilliSeconds(Dev, 500);
VL53L1_StartMeasurement(Dev);
PRINTF("StartMeasuerment TRUE\n");
/* USER CODE END 1 */
/*Disbale Stand-by mode*/
LPM_SetOffMode(LPM_APPLI_Id , LPM_Disable );
PRINTF("VERSION: %X\n\r", VERSION);
/* Configure the Lora Stack*/
LORA_Init( &LoRaMainCallbacks, &LoRaParamInit);
LORA_Join();
LoraStartTx( TX_ON_TIMER);
while( 1 )
{
if (AppProcessRequest==LORA_SET)
{
/*reset notification flag*/
AppProcessRequest=LORA_RESET;
/*Send*/
Send( NULL );
}
if (LoraMacProcessRequest==LORA_SET)
{
/*reset notification flag*/
LoraMacProcessRequest=LORA_RESET;
LoRaMacProcess( );
}
/*If a flag is set at this point, mcu must not enter low power and must loop*/
DISABLE_IRQ( );
/* if an interrupt has occurred after DISABLE_IRQ, it is kept pending
* and cortex will not enter low power anyway */
if ((LoraMacProcessRequest!=LORA_SET) && (AppProcessRequest!=LORA_SET))
{
#ifndef LOW_POWER_DISABLE
LPM_EnterLowPower( );
#endif
}
ENABLE_IRQ();
//HAL_I2C_IsDeviceReady(&hi2c1, 0x52, 100, 5);
VL53L1_WaitMeasurementDataReady( Dev );
VL53L1_GetRangingMeasurementData(Dev, &RangingData);
PRINTF("Distance is: %d",RangingData.RangeMilliMeter);
PRINTF("\n");
/*
switch(RangingData.RangeStatus)
{
case 0:
{
PRINTF("Ranging data is valid\n");
break;
}
case 1:
{
PRINTF("Raised if sigma estimator check is above the internal defined threshold\n");
break;
}
case 2:
{
PRINTF("Raised if signal value is below the internal defined threshold\n");
break;
}
case 4:
{
PRINTF("Raised when phase is out of bounds\n");
break;
}
case 5:
{
PRINTF("Raised in case of HW or VCSEL failure\n");
break;
}
case 7:
{
PRINTF("Wrapped target, not matching phases\n");
break;
}
case 8:
{
PRINTF("Internal algorithm underflow or overflow\n");
break;
}
case 14:
{
PRINTF("The reported range is invalid\n");
break;
}
default:
{
PRINTF("Status is: %d : ", RangingData.RangeStatus);
PRINTF("\n");
}
} */
VL53L1_ClearInterruptAndStartMeasurement( Dev );
/* USER CODE END 2 */
}
}
What am i doing wrong?