The VL53L1CB proximity sensor, based on ST’s FlightSense™, Time-of-Flight technology.
Dependencies: X_NUCLEO_COMMON ST_INTERFACES
Dependents: VL53L1CB_noshield_1sensor_polls_auton VL53L1CB_noshield_1sensor_interrupt_auton X_NUCLEO_53L1A2
Based on VL53L1 library, this is a library for the VL53L1CB ToF chip.
src/vl53l1_silicon_core.c@7:1add29d51e72, 2021-06-08 (annotated)
- Committer:
- Charles MacNeill
- Date:
- Tue Jun 08 10:34:47 2021 +0100
- Revision:
- 7:1add29d51e72
- Parent:
- 0:3ac96e360672
Update to v6.6.5 of bare_driver
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
charlesmn | 0:3ac96e360672 | 1 | |
Charles MacNeill |
7:1add29d51e72 | 2 | // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause |
Charles MacNeill |
7:1add29d51e72 | 3 | /****************************************************************************** |
charlesmn | 0:3ac96e360672 | 4 | * Copyright (c) 2020, STMicroelectronics - All Rights Reserved |
charlesmn | 0:3ac96e360672 | 5 | |
Charles MacNeill |
7:1add29d51e72 | 6 | This file is part of VL53L1 and is dual licensed, |
Charles MacNeill |
7:1add29d51e72 | 7 | either GPL-2.0+ |
charlesmn | 0:3ac96e360672 | 8 | or 'BSD 3-clause "New" or "Revised" License' , at your option. |
Charles MacNeill |
7:1add29d51e72 | 9 | ****************************************************************************** |
Charles MacNeill |
7:1add29d51e72 | 10 | */ |
charlesmn | 0:3ac96e360672 | 11 | |
charlesmn | 0:3ac96e360672 | 12 | |
charlesmn | 0:3ac96e360672 | 13 | |
charlesmn | 0:3ac96e360672 | 14 | |
charlesmn | 0:3ac96e360672 | 15 | |
charlesmn | 0:3ac96e360672 | 16 | #include "vl53l1_ll_def.h" |
charlesmn | 0:3ac96e360672 | 17 | #include "vl53l1_platform.h" |
charlesmn | 0:3ac96e360672 | 18 | #include "vl53l1_register_map.h" |
charlesmn | 0:3ac96e360672 | 19 | #include "vl53l1_core.h" |
charlesmn | 0:3ac96e360672 | 20 | #include "vl53l1_silicon_core.h" |
charlesmn | 0:3ac96e360672 | 21 | |
charlesmn | 0:3ac96e360672 | 22 | |
charlesmn | 0:3ac96e360672 | 23 | #define LOG_FUNCTION_START(fmt, ...) \ |
charlesmn | 0:3ac96e360672 | 24 | _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_CORE, fmt, ##__VA_ARGS__) |
charlesmn | 0:3ac96e360672 | 25 | #define LOG_FUNCTION_END(status, ...) \ |
charlesmn | 0:3ac96e360672 | 26 | _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_CORE, status, ##__VA_ARGS__) |
charlesmn | 0:3ac96e360672 | 27 | #define LOG_FUNCTION_END_FMT(status, fmt, ...) \ |
charlesmn | 0:3ac96e360672 | 28 | _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_CORE,\ |
charlesmn | 0:3ac96e360672 | 29 | status, fmt, ##__VA_ARGS__) |
charlesmn | 0:3ac96e360672 | 30 | |
charlesmn | 0:3ac96e360672 | 31 | |
charlesmn | 0:3ac96e360672 | 32 | VL53L1_Error VL53L1_is_firmware_ready_silicon( |
charlesmn | 0:3ac96e360672 | 33 | VL53L1_DEV Dev, |
charlesmn | 0:3ac96e360672 | 34 | uint8_t *pready) |
charlesmn | 0:3ac96e360672 | 35 | { |
charlesmn | 0:3ac96e360672 | 36 | |
charlesmn | 0:3ac96e360672 | 37 | |
charlesmn | 0:3ac96e360672 | 38 | VL53L1_Error status = VL53L1_ERROR_NONE; |
charlesmn | 0:3ac96e360672 | 39 | VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev); |
charlesmn | 0:3ac96e360672 | 40 | |
charlesmn | 0:3ac96e360672 | 41 | uint8_t comms_buffer[5]; |
charlesmn | 0:3ac96e360672 | 42 | |
charlesmn | 0:3ac96e360672 | 43 | LOG_FUNCTION_START(""); |
charlesmn | 0:3ac96e360672 | 44 | |
charlesmn | 0:3ac96e360672 | 45 | |
charlesmn | 0:3ac96e360672 | 46 | |
charlesmn | 0:3ac96e360672 | 47 | status = VL53L1_ReadMulti( |
charlesmn | 0:3ac96e360672 | 48 | Dev, |
charlesmn | 0:3ac96e360672 | 49 | VL53L1_INTERRUPT_MANAGER__ENABLES, |
charlesmn | 0:3ac96e360672 | 50 | comms_buffer, |
charlesmn | 0:3ac96e360672 | 51 | 5); |
charlesmn | 0:3ac96e360672 | 52 | |
charlesmn | 0:3ac96e360672 | 53 | if (status != VL53L1_ERROR_NONE) |
charlesmn | 0:3ac96e360672 | 54 | goto ENDFUNC; |
charlesmn | 0:3ac96e360672 | 55 | |
charlesmn | 0:3ac96e360672 | 56 | pdev->dbg_results.interrupt_manager__enables = |
charlesmn | 0:3ac96e360672 | 57 | comms_buffer[0]; |
charlesmn | 0:3ac96e360672 | 58 | pdev->dbg_results.interrupt_manager__clear = |
charlesmn | 0:3ac96e360672 | 59 | comms_buffer[1]; |
charlesmn | 0:3ac96e360672 | 60 | pdev->dbg_results.interrupt_manager__status = |
charlesmn | 0:3ac96e360672 | 61 | comms_buffer[2]; |
charlesmn | 0:3ac96e360672 | 62 | pdev->dbg_results.mcu_to_host_bank__wr_access_en = |
charlesmn | 0:3ac96e360672 | 63 | comms_buffer[3]; |
charlesmn | 0:3ac96e360672 | 64 | pdev->dbg_results.power_management__go1_reset_status = |
charlesmn | 0:3ac96e360672 | 65 | comms_buffer[4]; |
charlesmn | 0:3ac96e360672 | 66 | |
charlesmn | 0:3ac96e360672 | 67 | if ((pdev->sys_ctrl.power_management__go1_power_force & 0x01) |
charlesmn | 0:3ac96e360672 | 68 | == 0x01) { |
charlesmn | 0:3ac96e360672 | 69 | |
charlesmn | 0:3ac96e360672 | 70 | if (((pdev->dbg_results.interrupt_manager__enables & |
charlesmn | 0:3ac96e360672 | 71 | 0x1F) == 0x1F) && |
charlesmn | 0:3ac96e360672 | 72 | ((pdev->dbg_results.interrupt_manager__clear |
charlesmn | 0:3ac96e360672 | 73 | & 0x1F) == 0x1F)) |
charlesmn | 0:3ac96e360672 | 74 | *pready = 0x01; |
charlesmn | 0:3ac96e360672 | 75 | else |
charlesmn | 0:3ac96e360672 | 76 | *pready = 0x00; |
charlesmn | 0:3ac96e360672 | 77 | |
charlesmn | 0:3ac96e360672 | 78 | } else { |
charlesmn | 0:3ac96e360672 | 79 | |
charlesmn | 0:3ac96e360672 | 80 | |
charlesmn | 0:3ac96e360672 | 81 | if ((pdev->dbg_results.power_management__go1_reset_status |
charlesmn | 0:3ac96e360672 | 82 | & 0x01) == 0x00) |
charlesmn | 0:3ac96e360672 | 83 | *pready = 0x01; |
charlesmn | 0:3ac96e360672 | 84 | else |
charlesmn | 0:3ac96e360672 | 85 | *pready = 0x00; |
charlesmn | 0:3ac96e360672 | 86 | } |
charlesmn | 0:3ac96e360672 | 87 | |
charlesmn | 0:3ac96e360672 | 88 | |
charlesmn | 0:3ac96e360672 | 89 | ENDFUNC: |
charlesmn | 0:3ac96e360672 | 90 | LOG_FUNCTION_END(status); |
charlesmn | 0:3ac96e360672 | 91 | |
charlesmn | 0:3ac96e360672 | 92 | return status; |
charlesmn | 0:3ac96e360672 | 93 | } |
charlesmn | 0:3ac96e360672 | 94 |