1.0
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -51,11 +51,14 @@ VL53L1_Error VL53L1_platform_init(
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
if (pdev == NULL)
|
||||
return VL53L1_ERROR_INVALID_PARAMS;
|
||||
|
||||
/* remember comms settings */
|
||||
|
||||
pdev->i2c_slave_address = i2c_slave_address;
|
||||
pdev->i2c_slave_address = (i2c_slave_address == 0u) ? VL53L1_DEFAULT_ADDR_8BIT : i2c_slave_address;
|
||||
pdev->comms_type = comms_type;
|
||||
pdev->comms_speed_khz = comms_speed_khz;
|
||||
pdev->comms_speed_khz = (comms_speed_khz == 0u) ? 400u : comms_speed_khz;
|
||||
|
||||
if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
|
||||
status =
|
||||
@@ -64,37 +67,13 @@ VL53L1_Error VL53L1_platform_init(
|
||||
pdev->comms_type,
|
||||
pdev->comms_speed_khz);
|
||||
|
||||
/* Ensure device is in reset */
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_GpioXshutdown(0);
|
||||
pdev->io_timeout_ms = (pdev->io_timeout_ms == 0u) ? 100u : pdev->io_timeout_ms;
|
||||
|
||||
/* disable the platform regulators */
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_GpioPowerEnable(0);
|
||||
|
||||
/* set the NCS pin for I2C mode */
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_GpioCommsSelect(0);
|
||||
|
||||
/* 1ms Wait to ensure XSHUTD / NCS are in the right state */
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_WaitUs(pdev, 1000);
|
||||
|
||||
/* enable the platform regulators */
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_GpioPowerEnable(1);
|
||||
|
||||
/* 1ms Wait for power regs to settle */
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_WaitUs(pdev, 1000);
|
||||
|
||||
/* finally, bring the device out of reset */
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_GpioXshutdown(1);
|
||||
|
||||
/* Wait 100us for device to exit reset */
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_WaitUs(pdev, 100);
|
||||
if ((status == VL53L1_ERROR_NONE) && (pdev->xshut_port != NULL)) {
|
||||
status = VL53L1_PlatformBootDevice(pdev, 2u, 2u);
|
||||
} else if (status == VL53L1_ERROR_NONE) {
|
||||
status = VL53L1_WaitMs(pdev, 2);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -110,13 +89,9 @@ VL53L1_Error VL53L1_platform_terminate(
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
/* put device in reset */
|
||||
if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
|
||||
status = VL53L1_GpioXshutdown(0);
|
||||
|
||||
/* disable the platform regulators */
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_GpioPowerEnable(0);
|
||||
/* put device in reset when an XSHUT pin is attached */
|
||||
if ((status == VL53L1_ERROR_NONE) && (pdev != NULL) && (pdev->xshut_port != NULL))
|
||||
status = VL53L1_PlatformSetXShut(pdev, GPIO_PIN_RESET);
|
||||
|
||||
/* close the comms interfaces */
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <stdio.h> // sprintf(), vsnprintf(), printf()
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <malloc.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "vl53l1_platform_log.h"
|
||||
#include "vl53l1_platform_user_config.h"
|
||||
|
||||
Reference in New Issue
Block a user