ST Expansion SW Team / Vl6180

Dependencies:   VL6180_Board

Dependents:   X_NUCLEO_6180

Embed: (wiki syntax)

« Back to documentation index

Init functions

API init functions. More...

Functions

VL6180_API int VL6180_WaitDeviceBooted (VL6180Dev_t dev)
 Wait for device booted after chip enable (hardware standby)
VL6180_API int VL6180_InitData (VL6180Dev_t dev)
 One time device initialization.
VL6180_API int VL6180_SetupGPIO1 (VL6180Dev_t dev, uint8_t IntFunction, int ActiveHigh)
 Configure GPIO1 function and set polarity.
VL6180_API int VL6180_Prepare (VL6180Dev_t dev)
 Prepare device for operation.

Detailed Description

API init functions.


Function Documentation

VL6180_API int VL6180_InitData ( VL6180Dev_t  dev )

One time device initialization.

To be called once and only once after device is brought out of reset (Chip enable) and booted see VL6180_WaitDeviceBooted()

Function Description
When not used after a fresh device "power up" or reset, it may return CALIBRATION_WARNING meaning wrong calibration data may have been fetched from device that can result in unpredictable and wrong ranging values
Parameters:
devThe device
Returns:
0 on success, CALIBRATION_WARNING if failed

Definition at line 187 of file vl6180_api.c.

VL6180_API int VL6180_Prepare ( VL6180Dev_t  dev )

Prepare device for operation.

Function Description
Does static initialization and reprogram common default settings
Device is prepared for new measure, ready single shot ranging typical polling operation
After prepare user can :
  • Call other API function to set other settings
  • Configure the interrupt pins, etc...
  • Then start ranging operations in single shot or continuous mode
Parameters:
devThe device
Returns:
0 on success

Definition at line 380 of file vl6180_api.c.

VL6180_API int VL6180_SetupGPIO1 ( VL6180Dev_t  dev,
uint8_t  IntFunction,
int  ActiveHigh 
)

Configure GPIO1 function and set polarity.

Function Description
To be used prior to arm single shot measure or start continuous mode.

The function uses VL6180_SetupGPIOx() for setting gpio 1.

Warning:
changing polarity can generate a spurious interrupt on pins. It sets an interrupt flags condition that must be cleared to avoid polling hangs.
It is safe to run VL6180_ClearAllInterrupt() just after.
Parameters:
devThe device
IntFunctionThe interrupt functionality to use one of :
GPIOx_SELECT_OFF
GPIOx_SELECT_GPIO_INTERRUPT_OUTPUT
ActiveHighThe interrupt line polarity see IntrPol_e use INTR_POL_LOW (falling edge) or INTR_POL_HIGH (rising edge)
Returns:
0 on success

Definition at line 1145 of file vl6180_api.c.

VL6180_API int VL6180_WaitDeviceBooted ( VL6180Dev_t  dev )

Wait for device booted after chip enable (hardware standby)

Function Description
After Chip enable Application you can also simply wait at least 1ms to ensure device is ready
Warning:
After device chip enable (gpio0) de-asserted user must wait gpio1 to get asserted (hardware standby). or wait at least 400usec prior to do any low level access or api call .

This function implements polling for standby but you must ensure 400usec from chip enable passed

Warning:
Calling this function if device is not fresh out of reset will result in an indefinite loop
Parameters:
devThe device
Returns:
0 on success

Definition at line 175 of file vl6180_api.c.