ST Expansion SW Team / VL53L1

Dependencies:   X_NUCLEO_COMMON ST_INTERFACES

Dependents:   X_NUCLEO_53L1CB

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers vl53l1_silicon_core.c Source File

vl53l1_silicon_core.c

00001 
00002 // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
00003 /******************************************************************************
00004  * Copyright (c) 2020, STMicroelectronics - All Rights Reserved
00005 
00006  This file is part of VL53L1 and is dual licensed,
00007  either GPL-2.0+
00008  or 'BSD 3-clause "New" or "Revised" License' , at your option.
00009  ******************************************************************************
00010  */
00011 
00012 
00013 
00014 
00015 
00016 #include "vl53l1_ll_def.h"
00017 #include "vl53l1_platform.h"
00018 #include "vl53l1_register_map.h"
00019 #include "vl53l1_core.h"
00020 #include "vl53l1_silicon_core.h"
00021 
00022 
00023 #define LOG_FUNCTION_START(fmt, ...) \
00024     _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_CORE, fmt, ##__VA_ARGS__)
00025 #define LOG_FUNCTION_END(status, ...) \
00026     _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_CORE, status, ##__VA_ARGS__)
00027 #define LOG_FUNCTION_END_FMT(status, fmt, ...) \
00028     _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_CORE,\
00029             status, fmt, ##__VA_ARGS__)
00030 
00031 
00032 VL53L1_Error VL53L1_is_firmware_ready_silicon(
00033     VL53L1_DEV     Dev,
00034     uint8_t       *pready)
00035 {
00036 
00037 
00038     VL53L1_Error status = VL53L1_ERROR_NONE;
00039     VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
00040 
00041     uint8_t  comms_buffer[5];
00042 
00043     LOG_FUNCTION_START("");
00044 
00045 
00046 
00047     status = VL53L1_ReadMulti(
00048                 Dev,
00049                 VL53L1_INTERRUPT_MANAGER__ENABLES,
00050                 comms_buffer,
00051                 5);
00052 
00053     if (status != VL53L1_ERROR_NONE)
00054         goto ENDFUNC;
00055 
00056     pdev->dbg_results.interrupt_manager__enables =
00057             comms_buffer[0];
00058     pdev->dbg_results.interrupt_manager__clear =
00059             comms_buffer[1];
00060     pdev->dbg_results.interrupt_manager__status =
00061             comms_buffer[2];
00062     pdev->dbg_results.mcu_to_host_bank__wr_access_en =
00063             comms_buffer[3];
00064     pdev->dbg_results.power_management__go1_reset_status =
00065             comms_buffer[4];
00066 
00067     if ((pdev->sys_ctrl.power_management__go1_power_force & 0x01)
00068             == 0x01) {
00069 
00070         if (((pdev->dbg_results.interrupt_manager__enables &
00071                 0x1F) == 0x1F) &&
00072             ((pdev->dbg_results.interrupt_manager__clear
00073                     & 0x1F) == 0x1F))
00074             *pready = 0x01;
00075         else
00076             *pready = 0x00;
00077 
00078     } else {
00079 
00080 
00081         if ((pdev->dbg_results.power_management__go1_reset_status
00082                 & 0x01) == 0x00)
00083             *pready = 0x01;
00084         else
00085             *pready = 0x00;
00086     }
00087 
00088 
00089 ENDFUNC:
00090     LOG_FUNCTION_END(status);
00091 
00092     return status;
00093 }
00094