EwokPlus25 core function definitions. More...
Go to the source code of this file.
Functions | |
void | V53L1_init_zone_dss_configs (VL53L1_DEV Dev) |
Initialise zone dynamic config DSS control values. More... | |
uint32_t | VL53L1_calc_crosstalk_plane_offset_with_margin (uint32_t plane_offset_kcps, int16_t margin_offset_kcps) |
Function to add signed margin to the xtalk plane offset value, dealing with signed and unsigned value mixing. More... | |
uint32_t | VL53L1_calc_decoded_timeout_us (uint16_t timeout_encoded, uint32_t macro_period_us) |
Calculates the decoded timeout in us based on the input encoded timeout register value and the macro period in us. More... | |
uint16_t | VL53L1_calc_encoded_timeout (uint32_t timeout_us, uint32_t macro_period_us) |
Calculates the encoded timeout register value based on the input timeout period in milliseconds and the macro period in us. More... | |
uint32_t | VL53L1_calc_macro_period_us (uint16_t fast_osc_frequency, uint8_t vcsel_period) |
Forces shadow stream count to zero. More... | |
void | VL53L1_calc_mm_effective_spads (uint8_t encoded_mm_roi_centre, uint8_t encoded_mm_roi_size, uint8_t encoded_zone_centre, uint8_t encoded_zone_size, uint8_t *pgood_spads, uint16_t aperture_attenuation, uint16_t *pmm_inner_effective_spads, uint16_t *pmm_outer_effective_spads) |
Calculates the effective SPAD counts for the MM inner and outer regions based on the input MM ROI, Zone info and return good SPAD map. More... | |
uint16_t | VL53L1_calc_range_ignore_threshold (uint32_t central_rate, int16_t x_gradient, int16_t y_gradient, uint8_t rate_mult) |
Calculates the Xtalk Range Ignore Threshold rate per spad in 3.13Mcps. More... | |
uint32_t | VL53L1_calc_timeout_mclks (uint32_t timeout_us, uint32_t macro_period_us) |
Calculates the timeout value in macro period based on the input timeout period in milliseconds and the macro period in us. More... | |
VL53L1_Error | VL53L1_calc_timeout_register_values (uint32_t phasecal_config_timeout_us, uint32_t mm_config_timeout_us, uint32_t range_config_timeout_us, uint16_t fast_osc_frequency, VL53L1_general_config_t *pgeneral, VL53L1_timing_config_t *ptiming) |
Converts the input MM and range timeouts in [us] into the appropriate register values. More... | |
uint32_t | VL53L1_calc_timeout_us (uint32_t timeout_mclks, uint32_t macro_period_us) |
Calculates the timeout in us based on the input timeout im macro periods value and the macro period in us. More... | |
VL53L1_Error | VL53L1_check_ll_driver_rd_state (VL53L1_DEV Dev) |
Checks if the LL Driver Read state and expected stream count matches the state and stream count received from the device. More... | |
VL53L1_Error | VL53L1_clear_interrupt (VL53L1_DEV Dev) |
Clears Ranging Interrupt. More... | |
VL53L1_Error | VL53L1_config_low_power_auto_mode (VL53L1_general_config_t *pgeneral, VL53L1_dynamic_config_t *pdynamic, VL53L1_low_power_auto_data_t *plpadata) |
Initialize the config strcutures when low power auto preset modes are selected. More... | |
void | VL53L1_copy_rtn_good_spads_to_buffer (VL53L1_nvm_copy_data_t *pdata, uint8_t *pbuffer) |
Convenience function to copy return SPAD enables to buffer. More... | |
VL53L1_GPIO_interrupt_config_t | VL53L1_decode_GPIO_interrupt_config (uint8_t system__interrupt_config) |
Decodes FW register to VL53L1_GPIO_interrupt_config_t structure. More... | |
uint32_t | VL53L1_decode_timeout (uint16_t encoded_timeout) |
Decode 16-bit timeout register value. More... | |
uint32_t | VL53L1_decode_unsigned_integer (uint8_t *pbuffer, uint8_t no_of_bytes) |
Decodes an unsigned integer from a uint8_t buffer 16-bit, 24-bit or 32-bit integers. More... | |
void | VL53L1_decode_zone_limits (uint8_t encoded_xy_centre, uint8_t encoded_xy_size, int16_t *px_ll, int16_t *py_ll, int16_t *px_ur, int16_t *py_ur) |
Decodes encoded zone info into min/max limits. More... | |
void | VL53L1_decode_zone_size (uint8_t encoded_xy_size, uint8_t *pwidth, uint8_t *pheight) |
Decodes encoded zone size format into width and height values. More... | |
VL53L1_Error | VL53L1_disable_firmware (VL53L1_DEV Dev) |
Disables MCU firmware. More... | |
VL53L1_Error | VL53L1_disable_powerforce (VL53L1_DEV Dev) |
Disables power force. More... | |
VL53L1_Error | VL53L1_enable_firmware (VL53L1_DEV Dev) |
Enables MCU firmware. More... | |
VL53L1_Error | VL53L1_enable_powerforce (VL53L1_DEV Dev) |
Enables power force. More... | |
uint8_t | VL53L1_encode_GPIO_interrupt_config (VL53L1_GPIO_interrupt_config_t *pintconf) |
Encodes VL53L1_GPIO_interrupt_config_t structure to FW register format. More... | |
void | VL53L1_encode_row_col (uint8_t row, uint8_t col, uint8_t *pspad_number) |
Encodes a (col,row) coord value into ByteIndex.BitIndex format. More... | |
uint16_t | VL53L1_encode_timeout (uint32_t timeout_mclks) |
Encode timeout in (LSByte * 2^MSByte) + 1 register format. More... | |
void | VL53L1_encode_unsigned_integer (uint32_t ip_value, uint8_t no_of_bytes, uint8_t *pbuffer) |
Encodes an unsigned integer into a uint8_t buffer MS byte first. More... | |
uint8_t | VL53L1_encode_vcsel_period (uint8_t vcsel_period_pclks) |
Encodes the real period in PLL clocks into the register value. More... | |
void | VL53L1_encode_zone_size (uint8_t width, uint8_t height, uint8_t *pencoded_xy_size) |
Encodes a zone width & height into encoded size format. More... | |
VL53L1_Error | VL53L1_get_spad_rate_data (VL53L1_DEV Dev, VL53L1_spad_rate_data_t *pspad_rates) |
Gets the 256 return array SSC rates from the Patch RAM. More... | |
int16_t | VL53L1_i2c_decode_int16_t (uint16_t count, uint8_t *pbuffer) |
Decodes a int16_t register value from an I2C read buffer. More... | |
int32_t | VL53L1_i2c_decode_int32_t (uint16_t count, uint8_t *pbuffer) |
Decodes a int32_t register value from an I2C read buffer. More... | |
uint16_t | VL53L1_i2c_decode_uint16_t (uint16_t count, uint8_t *pbuffer) |
Decodes a uint16_t register value from an I2C read buffer. More... | |
uint32_t | VL53L1_i2c_decode_uint32_t (uint16_t count, uint8_t *pbuffer) |
Decodes a uint32_t register value from an I2C read buffer. More... | |
uint32_t | VL53L1_i2c_decode_with_mask (uint16_t count, uint8_t *pbuffer, uint32_t bit_mask, uint32_t down_shift, uint32_t offset) |
Decodes an integer register value from an I2C read buffer. More... | |
void | VL53L1_i2c_encode_int16_t (int16_t ip_value, uint16_t count, uint8_t *pbuffer) |
Encodes a int16_t register value into an I2C write buffer. More... | |
void | VL53L1_i2c_encode_int32_t (int32_t ip_value, uint16_t count, uint8_t *pbuffer) |
Encodes a int32_t register value into an I2C write buffer. More... | |
void | VL53L1_i2c_encode_uint16_t (uint16_t ip_value, uint16_t count, uint8_t *pbuffer) |
Encodes a uint16_t register value into an I2C write buffer. More... | |
void | VL53L1_i2c_encode_uint32_t (uint32_t ip_value, uint16_t count, uint8_t *pbuffer) |
Encodes a uint32_t register value into an I2C write buffer. More... | |
void | VL53L1_init_ll_driver_state (VL53L1_DEV Dev, VL53L1_DeviceState ll_state) |
Initialise LL Driver State. More... | |
void | VL53L1_init_system_results (VL53L1_system_results_t *pdata) |
Initialise system results structure to all ones. More... | |
void | VL53L1_init_version (VL53L1_DEV Dev) |
Initialise version info in pdev. More... | |
uint8_t | VL53L1_is_aperture_location (uint8_t row, uint8_t col) |
Returns > 0 if input (row,col) location is an apertured SPAD. More... | |
VL53L1_Error | VL53L1_low_power_auto_data_init (VL53L1_DEV Dev) |
Initialize the Low Power Auto data structure. More... | |
VL53L1_Error | VL53L1_low_power_auto_data_stop_range (VL53L1_DEV Dev) |
Reset internal state but leave low_power_auto mode intact. More... | |
VL53L1_Error | VL53L1_low_power_auto_setup_manual_calibration (VL53L1_DEV Dev) |
Setup ranges after the first one in low power auto mode by turning off FW calibration steps and programming static values. More... | |
VL53L1_Error | VL53L1_low_power_auto_update_DSS (VL53L1_DEV Dev) |
Do a DSS calculation and update manual config. More... | |
VL53L1_Error | VL53L1_save_cfg_data (VL53L1_DEV Dev) |
Function to save dynamic config data per zone at init and start range. More... | |
VL53L1_Error | VL53L1_set_firmware_enable_register (VL53L1_DEV Dev, uint8_t value) |
Set firmware enable register. More... | |
VL53L1_Error | VL53L1_set_GPIO_distance_threshold (VL53L1_DEV Dev, uint16_t threshold_high, uint16_t threshold_low) |
SET GPIO distance threshold. More... | |
VL53L1_Error | VL53L1_set_GPIO_rate_threshold (VL53L1_DEV Dev, uint16_t threshold_high, uint16_t threshold_low) |
SET GPIO rate threshold. More... | |
VL53L1_Error | VL53L1_set_GPIO_thresholds_from_struct (VL53L1_DEV Dev, VL53L1_GPIO_interrupt_config_t *pintconf) |
SET GPIO thresholds from structure. Sets both rate and distance thresholds. More... | |
VL53L1_Error | VL53L1_set_powerforce_register (VL53L1_DEV Dev, uint8_t value) |
Set power force register. More... | |
VL53L1_Error | VL53L1_set_ref_spad_char_config (VL53L1_DEV Dev, uint8_t vcsel_period_a, uint32_t phasecal_timeout_us, uint16_t total_rate_target_mcps, uint16_t max_count_rate_rtn_limit_mcps, uint16_t min_count_rate_rtn_limit_mcps, uint16_t fast_osc_frequency) |
Set Ref SPAD Characterisation Config. More... | |
VL53L1_Error | VL53L1_set_ssc_config (VL53L1_DEV Dev, VL53L1_ssc_config_t *pssc_cfg, uint16_t fast_osc_frequency) |
Applies SSC (SPAD Self Check) configuration to device. More... | |
void | VL53L1_spad_number_to_byte_bit_index (uint8_t spad_number, uint8_t *pbyte_index, uint8_t *pbit_index, uint8_t *pbit_mask) |
Get the SPAD number, byte index (0-31) and bit index (0-7) for. More... | |
VL53L1_Error | VL53L1_start_test (VL53L1_DEV Dev, uint8_t test_mode__ctrl) |
Triggers the start of the provided test_mode. More... | |
VL53L1_Error | VL53L1_update_ll_driver_cfg_state (VL53L1_DEV Dev) |
Update LL Driver Configuration State. More... | |
VL53L1_Error | VL53L1_update_ll_driver_rd_state (VL53L1_DEV Dev) |
Update LL Driver Read State. More... | |
EwokPlus25 core function definitions.
Definition in file vl53l1_core.h.
void V53L1_init_zone_dss_configs | ( | VL53L1_DEV | Dev | ) |
Initialise zone dynamic config DSS control values.
[in] | Dev | : Device handler |
uint32_t VL53L1_calc_crosstalk_plane_offset_with_margin | ( | uint32_t | plane_offset_kcps, |
int16_t | margin_offset_kcps | ||
) |
Function to add signed margin to the xtalk plane offset value, dealing with signed and unsigned value mixing.
Clips output to 0 if negative Clips to max possible value of 9.9 Kcps if exceeds this limitation
[in] | plane_offset_kcps | : xtalk plane offset (9.9 format) Kcps |
[in] | margin_offset_kcps | : margin offset signed (6.9 format) Kcps |
Definition at line 1172 of file vl53l1_core.c.
Calculates the decoded timeout in us based on the input encoded timeout register value and the macro period in us.
[in] | timeout_encoded | : encoded timeout register value |
[in] | macro_period_us | : macro period in microseconds 12.12 |
Definition at line 1201 of file vl53l1_core.c.
Calculates the encoded timeout register value based on the input timeout period in milliseconds and the macro period in us.
[in] | timeout_us | : timeout period in microseconds |
[in] | macro_period_us | : macro period in microseconds 12.12 |
Definition at line 1094 of file vl53l1_core.c.
Forces shadow stream count to zero.
[in] | Dev | : Device handle |
Calculates the macro period in [us] for the input fast_osc_frequency and VCSEL period register value
Processing steps:
[in] | fast_osc_frequency | : fast oscillator frequency in 4.12 MHz format |
[in] | vcsel_period | : VCSEL period register value |
Definition at line 920 of file vl53l1_core.c.
void VL53L1_calc_mm_effective_spads | ( | uint8_t | encoded_mm_roi_centre, |
uint8_t | encoded_mm_roi_size, | ||
uint8_t | encoded_zone_centre, | ||
uint8_t | encoded_zone_size, | ||
uint8_t * | pgood_spads, | ||
uint16_t | aperture_attenuation, | ||
uint16_t * | pmm_inner_effective_spads, | ||
uint16_t * | pmm_outer_effective_spads | ||
) |
Calculates the effective SPAD counts for the MM inner and outer regions based on the input MM ROI, Zone info and return good SPAD map.
[in] | encoded_mm_roi_centre | : Encoded MM ROI centre - spad number |
[in] | encoded_mm_roi_size | : Encoded MM ROI size |
[in] | encoded_zone_centre | : Encoded Zone centre - spad number |
[in] | encoded_zone_size | : Encoded Zone size |
[in] | pgood_spads | : Return array good SPAD map (32 bytes) |
[in] | aperture_attenuation | : Aperture attenuation value, Format 8.8 |
[out] | pmm_inner_effective_spads | : MM Inner effective SPADs, Format 8.8 |
[out] | pmm_outer_effective_spads | : MM Outer effective SPADs, Format 8.8 |
Definition at line 1583 of file vl53l1_core.c.
uint16_t VL53L1_calc_range_ignore_threshold | ( | uint32_t | central_rate, |
int16_t | x_gradient, | ||
int16_t | y_gradient, | ||
uint8_t | rate_mult | ||
) |
Calculates the Xtalk Range Ignore Threshold rate per spad in 3.13Mcps.
This is done by calculating the worst case xtalk seen on the array and applying a user specified fractional multiplier.
[in] | central_rate | : xtalk central rate in 9.9u Kcps format |
[in] | x_gradient | : xtalk xgradient rate in 4.11s Kcps format |
[in] | y_gradient | : xtalk ygradient rate in 4.11s Kcps format |
[in] | rate_mult | : rate multiplier in 2.5 fractional format |
Definition at line 987 of file vl53l1_core.c.
Calculates the timeout value in macro period based on the input timeout period in milliseconds and the macro period in us.
[in] | timeout_us | : timeout period in microseconds |
[in] | macro_period_us | : macro period in microseconds 12.12 |
Definition at line 1067 of file vl53l1_core.c.
VL53L1_Error VL53L1_calc_timeout_register_values | ( | uint32_t | phasecal_config_timeout_us, |
uint32_t | mm_config_timeout_us, | ||
uint32_t | range_config_timeout_us, | ||
uint16_t | fast_osc_frequency, | ||
VL53L1_general_config_t * | pgeneral, | ||
VL53L1_timing_config_t * | ptiming | ||
) |
Converts the input MM and range timeouts in [us] into the appropriate register values.
Must also be run after the VCSEL period settings are changed
[in] | phasecal_config_timeout_us | : requested Phase Cal Timeout e.g. 1000us |
[in] | mm_config_timeout_us | : requested MM Timeout e.g. 2000us |
[in] | range_config_timeout_us | : requested Ranging Timeout e.g 10000us |
[in] | fast_osc_frequency | : fast oscillator frequency in 4.12 MHz format |
[out] | pgeneral | : general data struct |
[out] | ptiming | : timing data struct with input vcsel period data |
Definition at line 1273 of file vl53l1_core.c.
Calculates the timeout in us based on the input timeout im macro periods value and the macro period in us.
[in] | timeout_mclks | : timeout im macro periods |
[in] | macro_period_us | : macro period in microseconds 12.12 |
Definition at line 1133 of file vl53l1_core.c.
VL53L1_Error VL53L1_check_ll_driver_rd_state | ( | VL53L1_DEV | Dev | ) |
Checks if the LL Driver Read state and expected stream count matches the state and stream count received from the device.
[out] | Dev | : Device handle |
Definition at line 255 of file vl53l1_core.c.
VL53L1_Error VL53L1_clear_interrupt | ( | VL53L1_DEV | Dev | ) |
Clears Ranging Interrupt.
[in] | Dev | : Device handle |
Definition at line 866 of file vl53l1_core.c.
VL53L1_Error VL53L1_config_low_power_auto_mode | ( | VL53L1_general_config_t * | pgeneral, |
VL53L1_dynamic_config_t * | pdynamic, | ||
VL53L1_low_power_auto_data_t * | plpadata | ||
) |
Initialize the config strcutures when low power auto preset modes are selected.
Patch_LowPowerAutoMode
[in] | pgeneral | : pointer to the general config structure |
[in] | pdynamic | : pointer to the dynamic config structure |
[in] | plpadata | : pointer to the low power auto config structure |
Definition at line 2174 of file vl53l1_core.c.
void VL53L1_copy_rtn_good_spads_to_buffer | ( | VL53L1_nvm_copy_data_t * | pdata, |
uint8_t * | pbuffer | ||
) |
Convenience function to copy return SPAD enables to buffer.
[in] | pdata | : pointer to VL53L1_nvm_copy_data_t |
[out] | pbuffer | : pointer to buffer |
Definition at line 437 of file vl53l1_core.c.
VL53L1_GPIO_interrupt_config_t VL53L1_decode_GPIO_interrupt_config | ( | uint8_t | system__interrupt_config | ) |
Decodes FW register to VL53L1_GPIO_interrupt_config_t structure.
[in] | system__interrupt_config | : interrupt config register byte |
Definition at line 1724 of file vl53l1_core.c.
Decode 16-bit timeout register value.
[in] | encoded_timeout | : 16-bit timeout register value |
Definition at line 1257 of file vl53l1_core.c.
Decodes an unsigned integer from a uint8_t buffer 16-bit, 24-bit or 32-bit integers.
Assumes MS Byte first
[in] | pbuffer | : pointer to start of integer uint8_t data |
[in] | no_of_bytes | : size of integer in bytes |
Definition at line 1390 of file vl53l1_core.c.
void VL53L1_decode_zone_limits | ( | uint8_t | encoded_xy_centre, |
uint8_t | encoded_xy_size, | ||
int16_t * | px_ll, | ||
int16_t * | py_ll, | ||
int16_t * | px_ur, | ||
int16_t * | py_ur | ||
) |
Decodes encoded zone info into min/max limits.
Note both the lower left and upper right coordinated lie within the zone (inclusive)
[in] | encoded_xy_centre | : Encoded zone centre (spad number) |
[in] | encoded_xy_size | : Encoded zone size |
[out] | px_ll | : Decoded zone lower left x coord |
[out] | py_ll | : Decoded zone lower left y coord |
[out] | px_ur | : Decoded zone upper right x coord |
[out] | py_ur | : Decoded zone upper right y coord |
Definition at line 1508 of file vl53l1_core.c.
Decodes encoded zone size format into width and height values.
[in] | encoded_xy_size | : Encoded zone size |
[out] | pwidth | : Decoded zone width |
[out] | pheight | : Decoded zone height |
Definition at line 1468 of file vl53l1_core.c.
VL53L1_Error VL53L1_disable_firmware | ( | VL53L1_DEV | Dev | ) |
Disables MCU firmware.
This required to write to MCU G02, G01 registers and access the patch RAM
[in] | Dev | : Device handle |
Definition at line 787 of file vl53l1_core.c.
VL53L1_Error VL53L1_disable_powerforce | ( | VL53L1_DEV | Dev | ) |
Disables power force.
[in] | Dev | : Device handle |
Disable power force
Calls VL53L1_set_powerforce_register()
Definition at line 847 of file vl53l1_core.c.
VL53L1_Error VL53L1_enable_firmware | ( | VL53L1_DEV | Dev | ) |
Enables MCU firmware.
[in] | Dev | : Device handle |
Definition at line 768 of file vl53l1_core.c.
VL53L1_Error VL53L1_enable_powerforce | ( | VL53L1_DEV | Dev | ) |
Enables power force.
This prevents the G01 and patch RAM from powering down between ranges to enable reading of G01 and patch RAM data
Calls VL53L1_set_powerforce_register()
[in] | Dev | : Device handle |
Definition at line 828 of file vl53l1_core.c.
uint8_t VL53L1_encode_GPIO_interrupt_config | ( | VL53L1_GPIO_interrupt_config_t * | pintconf | ) |
Encodes VL53L1_GPIO_interrupt_config_t structure to FW register format.
[in] | pintconf | : pointer to gpio interrupt config structure |
Definition at line 1706 of file vl53l1_core.c.
Encodes a (col,row) coord value into ByteIndex.BitIndex format.
[in] | row | : Row |
[in] | col | : Column |
[out] | pspad_number | : Encoded Coord in Byte.Bit format |
Encodes the input array(row,col) location as SPAD number.
Definition at line 1451 of file vl53l1_core.c.
Encode timeout in (LSByte * 2^MSByte) + 1 register format.
[in] | timeout_mclks | : uint32_t timeout value (macro periods) |
Definition at line 1231 of file vl53l1_core.c.
Encodes an unsigned integer into a uint8_t buffer MS byte first.
[in] | ip_value | : input unsigned integer |
[in] | no_of_bytes | : size of integer storage in bytes |
[out] | pbuffer | : pointer to output buffer |
Definition at line 1409 of file vl53l1_core.c.
Encodes the real period in PLL clocks into the register value.
[in] | vcsel_period_pclks | : 8-bit value |
Definition at line 1375 of file vl53l1_core.c.
Encodes a zone width & height into encoded size format.
[in] | width | : Zone Width |
[in] | height | : Zone height |
[out] | pencoded_xy_size | : Encoded zone size |
Definition at line 1489 of file vl53l1_core.c.
VL53L1_Error VL53L1_get_spad_rate_data | ( | VL53L1_DEV | Dev, |
VL53L1_spad_rate_data_t * | pspad_rates | ||
) |
Gets the 256 return array SSC rates from the Patch RAM.
Each SSC rate is 1.15 or 9.7 dependent on test run. Total of 512 bytes to read!
ssc_rate_mcps buffer format:
Assumes that power force has already been enabled
Function disables firmware at start to allow patch RAM to be read and then enables the firmware before returning
The order of the rates is in SPAD number order (increasing)
[in] | Dev | : Device handle |
[out] | pspad_rates | : pointer to VL53L1_spad_rate_data_t |
Gets the SSC rate map output
Definition at line 2039 of file vl53l1_core.c.
Decodes a int16_t register value from an I2C read buffer.
The I2C read buffer is assumed to be MS byte first i.e. matching the device register map
[in] | count | : register size of in bytes (1, 2, 3 or 4) |
[in] | pbuffer | : uint8_t pointer to the I2C read buffer |
Definition at line 580 of file vl53l1_core.c.
Decodes a int32_t register value from an I2C read buffer.
The I2C read buffer is assumed to be MS byte first i.e. matching the device register map
[in] | count | : register size of in bytes (1, 2, 3 or 4) |
[in] | pbuffer | : uint8_t pointer to the I2C read buffer |
Definition at line 696 of file vl53l1_core.c.
Decodes a uint16_t register value from an I2C read buffer.
The I2C read buffer is assumed to be MS byte first i.e. matching the device register map
[in] | count | : register size of in bytes (1, 2, 3 or 4) |
[in] | pbuffer | : uint8_t pointer to the I2C read buffer |
Definition at line 540 of file vl53l1_core.c.
Decodes a uint32_t register value from an I2C read buffer.
The I2C read buffer is assumed to be MS byte first i.e. matching the device register map
[in] | count | : register size of in bytes (1, 2, 3 or 4) |
[in] | pbuffer | : uint8_t pointer to the I2C read buffer |
Definition at line 624 of file vl53l1_core.c.
uint32_t VL53L1_i2c_decode_with_mask | ( | uint16_t | count, |
uint8_t * | pbuffer, | ||
uint32_t | bit_mask, | ||
uint32_t | down_shift, | ||
uint32_t | offset | ||
) |
Decodes an integer register value from an I2C read buffer.
The I2C read buffer is assumed to be MS byte first i.e. matching the device register map
[in] | count | : integer size of in bytes (1, 2, 3 or 4) |
[in] | pbuffer | : uint8_t pointer to the I2C read buffer |
[in] | bit_mask | : bit mask to apply |
[in] | down_shift | : down shift to apply |
[in] | offset | : offset to apply after the down shift |
Definition at line 643 of file vl53l1_core.c.
Encodes a int16_t register value into an I2C write buffer.
The register is encoded MS byte first is the buffer i.e as per the device register map
[in] | ip_value | : input int16_t value |
[in] | count | : register size of in bytes (1, 2, 3 or 4) |
[out] | pbuffer | : uint8_t pointer to the I2C write buffer |
Definition at line 559 of file vl53l1_core.c.
Encodes a int32_t register value into an I2C write buffer.
The register is encoded MS byte first is the buffer i.e as per the device register map
[in] | ip_value | : input int32_t value |
[in] | count | : register size of in bytes (1, 2, 3 or 4) |
[out] | pbuffer | : uint8_t pointer to the I2C write buffer |
Definition at line 675 of file vl53l1_core.c.
Encodes a uint16_t register value into an I2C write buffer.
The register is encoded MS byte first is the buffer i.e as per the device register map
[in] | ip_value | : input uint16_t value |
[in] | count | : register size of in bytes (1, 2, 3 or 4) |
[out] | pbuffer | : uint8_t pointer to the I2C write buffer |
Definition at line 519 of file vl53l1_core.c.
Encodes a uint32_t register value into an I2C write buffer.
The register is encoded MS byte first is the buffer i.e as per the device register map
[in] | ip_value | : input uint32_t value |
[in] | count | : register size of in bytes (1, 2, 3 or 4) |
[out] | pbuffer | : uint8_t pointer to the I2C write buffer |
Definition at line 603 of file vl53l1_core.c.
void VL53L1_init_ll_driver_state | ( | VL53L1_DEV | Dev, |
VL53L1_DeviceState | ll_state | ||
) |
Initialise LL Driver State.
[out] | Dev | : Device handle |
[in] | ll_state | : Device state |
Initialise LL Driver state variables
Definition at line 114 of file vl53l1_core.c.
void VL53L1_init_system_results | ( | VL53L1_system_results_t * | pdata | ) |
Initialise system results structure to all ones.
This mimics what the device firmware does the the results registers at the start of each range
[out] | pdata | : pointer to VL53L1_system_results_t |
Definition at line 480 of file vl53l1_core.c.
void VL53L1_init_version | ( | VL53L1_DEV | Dev | ) |
Initialise version info in pdev.
[out] | Dev | : Device handle |
Initialise version structure
Definition at line 98 of file vl53l1_core.c.
Returns > 0 if input (row,col) location is an apertured SPAD.
[in] | row | : Row |
[in] | col | : Column |
Definition at line 1561 of file vl53l1_core.c.
VL53L1_Error VL53L1_low_power_auto_data_init | ( | VL53L1_DEV | Dev | ) |
Initialize the Low Power Auto data structure.
Patch_LowPowerAutoMode
[in] | Dev | : Device Handle |
Definition at line 2101 of file vl53l1_core.c.
VL53L1_Error VL53L1_low_power_auto_data_stop_range | ( | VL53L1_DEV | Dev | ) |
Reset internal state but leave low_power_auto mode intact.
Patch_LowPowerAutoMode
[in] | Dev | : Device Handle |
Definition at line 2133 of file vl53l1_core.c.
VL53L1_Error VL53L1_low_power_auto_setup_manual_calibration | ( | VL53L1_DEV | Dev | ) |
Setup ranges after the first one in low power auto mode by turning off FW calibration steps and programming static values.
Patch_LowPowerAutoMode
[out] | Dev | : Device handle |
Definition at line 2216 of file vl53l1_core.c.
VL53L1_Error VL53L1_low_power_auto_update_DSS | ( | VL53L1_DEV | Dev | ) |
Do a DSS calculation and update manual config.
Patch_LowPowerAutoMode
[out] | Dev | : Device handle |
Definition at line 2256 of file vl53l1_core.c.
VL53L1_Error VL53L1_save_cfg_data | ( | VL53L1_DEV | Dev | ) |
Function to save dynamic config data per zone at init and start range.
[in] | Dev | : Pointer to data structure |
VL53L1_Error VL53L1_set_firmware_enable_register | ( | VL53L1_DEV | Dev, |
uint8_t | value | ||
) |
Set firmware enable register.
Wrapper for setting power force register state Also updates pdev->sys_ctrl.firmware__enable
[in] | Dev | : Device handle |
[in] | value | : register value |
Definition at line 747 of file vl53l1_core.c.
VL53L1_Error VL53L1_set_GPIO_distance_threshold | ( | VL53L1_DEV | Dev, |
uint16_t | threshold_high, | ||
uint16_t | threshold_low | ||
) |
SET GPIO distance threshold.
[in] | Dev | : Device Handle |
[in] | threshold_high | : High distance threshold in mm |
[in] | threshold_low | : Low distance threshold in mm |
Definition at line 1748 of file vl53l1_core.c.
VL53L1_Error VL53L1_set_GPIO_rate_threshold | ( | VL53L1_DEV | Dev, |
uint16_t | threshold_high, | ||
uint16_t | threshold_low | ||
) |
SET GPIO rate threshold.
[in] | Dev | : Device Handle |
[in] | threshold_high | : High rate threshold in 9.7 Mcps |
[in] | threshold_low | : Low rate threshold in 9.7 Mcps |
Definition at line 1770 of file vl53l1_core.c.
VL53L1_Error VL53L1_set_GPIO_thresholds_from_struct | ( | VL53L1_DEV | Dev, |
VL53L1_GPIO_interrupt_config_t * | pintconf | ||
) |
SET GPIO thresholds from structure. Sets both rate and distance thresholds.
[in] | Dev | : Device Handle |
[in] | pintconf | : Pointer to structure |
Definition at line 1792 of file vl53l1_core.c.
VL53L1_Error VL53L1_set_powerforce_register | ( | VL53L1_DEV | Dev, |
uint8_t | value | ||
) |
Set power force register.
Wrapper for setting power force register state Also updates pdev->sys_ctrl.power_management__go1_power_force
[in] | Dev | : Device handle |
[in] | value | : register value |
Definition at line 806 of file vl53l1_core.c.
VL53L1_Error VL53L1_set_ref_spad_char_config | ( | VL53L1_DEV | Dev, |
uint8_t | vcsel_period_a, | ||
uint32_t | phasecal_timeout_us, | ||
uint16_t | total_rate_target_mcps, | ||
uint16_t | max_count_rate_rtn_limit_mcps, | ||
uint16_t | min_count_rate_rtn_limit_mcps, | ||
uint16_t | fast_osc_frequency | ||
) |
Set Ref SPAD Characterisation Config.
Initialises the timeout and VCSEL period for the Reference SPAD Characterisation test mode.
Register Mapping:
[in] | Dev | : Device handle |
[in] | vcsel_period_a | : VCSEL period A register value |
[in] | phasecal_timeout_us | : requested PhaseCal Timeout in [us] e.g 1000us |
[in] | total_rate_target_mcps | : Target reference rate [Mcps] 9.7 format |
[in] | max_count_rate_rtn_limit_mcps | : Max rate final check limit [Mcps] 9.7 format |
[in] | min_count_rate_rtn_limit_mcps | : Min rate final check limit [Mcps] 9.7 format |
[in] | fast_osc_frequency | : Fast Osc Frequency (4.12) format |
Definition at line 1819 of file vl53l1_core.c.
VL53L1_Error VL53L1_set_ssc_config | ( | VL53L1_DEV | Dev, |
VL53L1_ssc_config_t * | pssc_cfg, | ||
uint16_t | fast_osc_frequency | ||
) |
Applies SSC (SPAD Self Check) configuration to device.
Prior to calling this function it is assumed both the Fast Osc and VCSEL have already been trimmed and the register values set.
Internally the required timeout in macro periods is calculated from the input VCSEL period, fast_osc_frequency and requested timeout in microseconds.
Register Mapping:
ssc_rate_limit_mcps format:
The configuration is set to the device via a 5-byte multi byte write.
[in] | Dev | : Device handle |
[in] | pssc_cfg | : pointer to VL53L1_ssc_config_t |
[in] | fast_osc_frequency | : Fast Osc Frequency (4.12) format |
Builds and sends a single I2C multiple byte transaction to initialize the device for SSC.
The function also sets the WOI registers based on the input vcsel period register value.
Definition at line 1935 of file vl53l1_core.c.
void VL53L1_spad_number_to_byte_bit_index | ( | uint8_t | spad_number, |
uint8_t * | pbyte_index, | ||
uint8_t * | pbit_index, | ||
uint8_t * | pbit_mask | ||
) |
Get the SPAD number, byte index (0-31) and bit index (0-7) for.
Takes the map index (0 - 255) and calculated the SPAD number, byte index within the SPAD enable byte array and but position within the SPAD enable byte
[in] | spad_number | : spad number |
[out] | pbyte_index | : pointer to output 0-31 byte index for SPAD enables |
[out] | pbit_index | : pointer to output 0-7 bit index |
[out] | pbit_mask | : pointer to output bit mask for the byte |
Converts the input SPAD number into the SPAD Enable byte index, bit index and bit mask
byte_index = (spad_no >> 3) bit_index = spad_no & 0x07 bit_mask = 0x01 << bit_index
Definition at line 1429 of file vl53l1_core.c.
VL53L1_Error VL53L1_start_test | ( | VL53L1_DEV | Dev, |
uint8_t | test_mode__ctrl | ||
) |
Triggers the start of the provided test_mode.
[in] | Dev | : Device handle |
[in] | test_mode__ctrl | : VL53L1_TEST_MODE__CTRL register value |
Definition at line 721 of file vl53l1_core.c.
VL53L1_Error VL53L1_update_ll_driver_cfg_state | ( | VL53L1_DEV | Dev | ) |
Update LL Driver Configuration State.
[out] | Dev | : Device handle |
State machine for configuration device state
Definition at line 349 of file vl53l1_core.c.
VL53L1_Error VL53L1_update_ll_driver_rd_state | ( | VL53L1_DEV | Dev | ) |
Update LL Driver Read State.
[out] | Dev | : Device handle |
State machine for read device state
VL53L1_DEVICESTATE_SW_STANDBY VL53L1_DEVICESTATE_RANGING_WAIT_GPH_SYNC VL53L1_DEVICESTATE_RANGING_GATHER_DATA VL53L1_DEVICESTATE_RANGING_OUTPUT_DATA
Definition at line 138 of file vl53l1_core.c.