
Step 10. Place the previous source code inside the main() function.
#include “components.h”
#include “AEK_SNS_VL53L1X1.h”
int main(void) {
VL53L1X_Result_t result;
volatile uint8_t irq_state;
/* Initialization of all the imported components in the order specified in the
application wizard. The function is generated automatically. */
componentsInit();
irqIsrEnable();
AEK_TOF_CONFIG();
/*Sensor set-up*/
AEK_TOF_METHODS.SensorInit(AEK_TOF_DEV0);
AEK_TOF_METHODS.SetDistanceMode(AEK_TOF_DEV0,2);
AEK_TOF_METHODS.SetTimingBudgetInMs(AEK_TOF_DEV0,20);
AEK_TOF_METHODS.SetInterMeasurementInMs(AEK_TOF_DEV0,54);
AEK_TOF_METHODS.SetDistanceThreshold(AEK_TOF_DEV0,50,150,3,1);
AEK_TOF_METHODS.StartRanging(AEK_TOF_DEV0);
/* Application main loop. */
for( ; ; )
{
AEK_TOF_METHODS.GetIRQSensorState(AEK_TOF_DEV0,&irq_state);
if(irq_state == 1)
{
AEK_TOF_METHODS.SetIRQSensorState(AEK_TOF_DEV0);
AEK_TOF_METHODS.GetResult(AEK_TOF_DEV0,&result);
AEK_TOF_METHODS.ClearInterrupt(AEK_TOF_DEV0);
}
}
}
Step 11. Save, generate, and compile the application.
Step 12. Open the [Board View Editor] provided by the AutoDevKit.
This editor provides a graphical point-to-point guide on how to wire the boards.
Step 13. Connect the AEK-MCU-C4MLIT1 to a USB port on your PC using a mini-USB to USB cable.
Step 14. Launch SPC5-UDESTK, open the debug folder, and select the debug.wsx file in the "AEK-MCU
C4MLIT1– Application/UDE" folder.
Step 15. Run and debug your code.
Note: The AEK-MCU-C4MLIT1 has several jumpers to activate specific peripherals. These jumpers
influence the behavior of the connected pins. AutoDevKit automatic allocation is not able to
understand if a specific pin has been allocated through a jumper configuration. In case of conflicts,
force a different pin from the PinMap editor. Ensure naming the pin with the same name defined
through the AutoDevKit automatic allocation.
3.6 Available demos for AEK-SNS-VL53L1X1
There are four different demos with specific features provided with the AEK-SNS-VL53L1X1 component:
1. SPC584Bxx_RLA AEK_SNS_VL53L1X1 - ULD Threshold Demo - Test Application
2. SPC58ECxx_RLA AEK_SNS_VL53L1X1 - FULL Demo I2C SW - Test Application
3. SPC58ECxx_RLA AEK_SNS_VL53L1X1 - FULL Demo Double Sensor Ranging - Test Application
4. SPC58ECxx_RLA AEK_SNS_VL53L1X1 – ULD Demo Set Threshold - Test Application
3.6.1 SPC584Bxx_RLA AEK_SNS_VL53L1X1 - ULD Threshold Demo - Test Application
In this demo, we use the ULD API.
We set the threshold in a range between 50 and 150 millimeters, so the sensor can detect all the objects in this
range.
The main APIs used are:
•AEK_TOF_CONFIG(): this function must be called first. It configures one or more XSHUT pins, turns the
sensors on, and configures the sensors I²C slave address.
UM3006
Available demos for AEK-SNS-VL53L1X1
UM3006 - Rev 1 page 18/38