├── CMakeLists.txt
├── README
├── audio
└── microphone
│ ├── OpenPDMFilter.c
│ ├── OpenPDMFilter.h
│ └── README
├── sensor
├── stmemsc
│ ├── CMakeLists.txt
│ ├── LICENSE
│ ├── README
│ ├── a3g4250d_STdC
│ │ └── driver
│ │ │ ├── a3g4250d_reg.c
│ │ │ └── a3g4250d_reg.h
│ ├── ais25ba_STdC
│ │ └── driver
│ │ │ ├── ais25ba_reg.c
│ │ │ └── ais25ba_reg.h
│ ├── ais2dw12_STdC
│ │ └── driver
│ │ │ ├── ais2dw12_reg.c
│ │ │ └── ais2dw12_reg.h
│ ├── ais2ih_STdC
│ │ └── driver
│ │ │ ├── ais2ih_reg.c
│ │ │ └── ais2ih_reg.h
│ ├── ais328dq_STdC
│ │ └── driver
│ │ │ ├── ais328dq_reg.c
│ │ │ └── ais328dq_reg.h
│ ├── ais3624dq_STdC
│ │ └── driver
│ │ │ ├── ais3624dq_reg.c
│ │ │ └── ais3624dq_reg.h
│ ├── asm330lhb_STdC
│ │ └── driver
│ │ │ ├── asm330lhb_reg.c
│ │ │ └── asm330lhb_reg.h
│ ├── asm330lhbg1_STdC
│ │ └── driver
│ │ │ ├── asm330lhbg1_reg.c
│ │ │ └── asm330lhbg1_reg.h
│ ├── asm330lhh_STdC
│ │ └── driver
│ │ │ ├── asm330lhh_reg.c
│ │ │ └── asm330lhh_reg.h
│ ├── asm330lhhx_STdC
│ │ └── driver
│ │ │ ├── asm330lhhx_reg.c
│ │ │ └── asm330lhhx_reg.h
│ ├── asm330lhhxg1_STdC
│ │ └── driver
│ │ │ ├── asm330lhhxg1_reg.c
│ │ │ └── asm330lhhxg1_reg.h
│ ├── h3lis100dl_STdC
│ │ └── driver
│ │ │ ├── h3lis100dl_reg.c
│ │ │ └── h3lis100dl_reg.h
│ ├── h3lis331dl_STdC
│ │ └── driver
│ │ │ ├── h3lis331dl_reg.c
│ │ │ └── h3lis331dl_reg.h
│ ├── hts221_STdC
│ │ └── driver
│ │ │ ├── hts221_reg.c
│ │ │ └── hts221_reg.h
│ ├── i3g4250d_STdC
│ │ └── driver
│ │ │ ├── i3g4250d_reg.c
│ │ │ └── i3g4250d_reg.h
│ ├── iis2dh_STdC
│ │ └── driver
│ │ │ ├── iis2dh_reg.c
│ │ │ └── iis2dh_reg.h
│ ├── iis2dlpc_STdC
│ │ └── driver
│ │ │ ├── iis2dlpc_reg.c
│ │ │ └── iis2dlpc_reg.h
│ ├── iis2dulpx_STdC
│ │ └── driver
│ │ │ ├── iis2dulpx_reg.c
│ │ │ └── iis2dulpx_reg.h
│ ├── iis2iclx_STdC
│ │ └── driver
│ │ │ ├── iis2iclx_reg.c
│ │ │ └── iis2iclx_reg.h
│ ├── iis2mdc_STdC
│ │ └── driver
│ │ │ ├── iis2mdc_reg.c
│ │ │ └── iis2mdc_reg.h
│ ├── iis328dq_STdC
│ │ └── driver
│ │ │ ├── iis328dq_reg.c
│ │ │ └── iis328dq_reg.h
│ ├── iis3dhhc_STdC
│ │ └── driver
│ │ │ ├── iis3dhhc_reg.c
│ │ │ └── iis3dhhc_reg.h
│ ├── iis3dwb_STdC
│ │ └── driver
│ │ │ ├── iis3dwb_reg.c
│ │ │ └── iis3dwb_reg.h
│ ├── ilps22qs_STdC
│ │ └── driver
│ │ │ ├── ilps22qs_reg.c
│ │ │ └── ilps22qs_reg.h
│ ├── ilps28qsw_STdC
│ │ └── driver
│ │ │ ├── ilps28qsw_reg.c
│ │ │ └── ilps28qsw_reg.h
│ ├── ism303dac_STdC
│ │ └── driver
│ │ │ ├── ism303dac_reg.c
│ │ │ └── ism303dac_reg.h
│ ├── ism330bx_STdC
│ │ └── driver
│ │ │ ├── ism330bx_reg.c
│ │ │ └── ism330bx_reg.h
│ ├── ism330dhcx_STdC
│ │ └── driver
│ │ │ ├── ism330dhcx_reg.c
│ │ │ └── ism330dhcx_reg.h
│ ├── ism330dlc_STdC
│ │ └── driver
│ │ │ ├── ism330dlc_reg.c
│ │ │ └── ism330dlc_reg.h
│ ├── ism330is_STdC
│ │ └── driver
│ │ │ ├── ism330is_reg.c
│ │ │ └── ism330is_reg.h
│ ├── l3gd20h_STdC
│ │ └── driver
│ │ │ ├── l3gd20h_reg.c
│ │ │ └── l3gd20h_reg.h
│ ├── lis25ba_STdC
│ │ └── driver
│ │ │ ├── lis25ba_reg.c
│ │ │ └── lis25ba_reg.h
│ ├── lis2de12_STdC
│ │ └── driver
│ │ │ ├── lis2de12_reg.c
│ │ │ └── lis2de12_reg.h
│ ├── lis2dh12_STdC
│ │ └── driver
│ │ │ ├── lis2dh12_reg.c
│ │ │ └── lis2dh12_reg.h
│ ├── lis2ds12_STdC
│ │ └── driver
│ │ │ ├── lis2ds12_reg.c
│ │ │ └── lis2ds12_reg.h
│ ├── lis2dtw12_STdC
│ │ └── driver
│ │ │ ├── lis2dtw12_reg.c
│ │ │ └── lis2dtw12_reg.h
│ ├── lis2du12_STdC
│ │ └── driver
│ │ │ ├── lis2du12_reg.c
│ │ │ └── lis2du12_reg.h
│ ├── lis2dux12_STdC
│ │ └── driver
│ │ │ ├── lis2dux12_reg.c
│ │ │ └── lis2dux12_reg.h
│ ├── lis2duxs12_STdC
│ │ └── driver
│ │ │ ├── lis2duxs12_reg.c
│ │ │ └── lis2duxs12_reg.h
│ ├── lis2dw12_STdC
│ │ └── driver
│ │ │ ├── lis2dw12_reg.c
│ │ │ └── lis2dw12_reg.h
│ ├── lis2hh12_STdC
│ │ └── driver
│ │ │ ├── lis2hh12_reg.c
│ │ │ └── lis2hh12_reg.h
│ ├── lis2mdl_STdC
│ │ └── driver
│ │ │ ├── lis2mdl_reg.c
│ │ │ └── lis2mdl_reg.h
│ ├── lis331dlh_STdC
│ │ └── driver
│ │ │ ├── lis331dlh_reg.c
│ │ │ └── lis331dlh_reg.h
│ ├── lis3de_STdC
│ │ └── driver
│ │ │ ├── lis3de_reg.c
│ │ │ └── lis3de_reg.h
│ ├── lis3dh_STdC
│ │ └── driver
│ │ │ ├── lis3dh_reg.c
│ │ │ └── lis3dh_reg.h
│ ├── lis3dhh_STdC
│ │ └── driver
│ │ │ ├── lis3dhh_reg.c
│ │ │ └── lis3dhh_reg.h
│ ├── lis3mdl_STdC
│ │ └── driver
│ │ │ ├── lis3mdl_reg.c
│ │ │ └── lis3mdl_reg.h
│ ├── lps22ch_STdC
│ │ └── driver
│ │ │ ├── lps22ch_reg.c
│ │ │ └── lps22ch_reg.h
│ ├── lps22df_STdC
│ │ └── driver
│ │ │ ├── lps22df_reg.c
│ │ │ └── lps22df_reg.h
│ ├── lps22hb_STdC
│ │ └── driver
│ │ │ ├── lps22hb_reg.c
│ │ │ └── lps22hb_reg.h
│ ├── lps22hh_STdC
│ │ └── driver
│ │ │ ├── lps22hh_reg.c
│ │ │ └── lps22hh_reg.h
│ ├── lps25hb_STdC
│ │ └── driver
│ │ │ ├── lps25hb_reg.c
│ │ │ └── lps25hb_reg.h
│ ├── lps27hhtw_STdC
│ │ └── driver
│ │ │ ├── lps27hhtw_reg.c
│ │ │ └── lps27hhtw_reg.h
│ ├── lps27hhw_STdC
│ │ └── driver
│ │ │ ├── lps27hhw_reg.c
│ │ │ └── lps27hhw_reg.h
│ ├── lps28dfw_STdC
│ │ └── driver
│ │ │ ├── lps28dfw_reg.c
│ │ │ └── lps28dfw_reg.h
│ ├── lps33k_STdC
│ │ └── driver
│ │ │ ├── lps33k_reg.c
│ │ │ └── lps33k_reg.h
│ ├── lsm303agr_STdC
│ │ └── driver
│ │ │ ├── lsm303agr_reg.c
│ │ │ └── lsm303agr_reg.h
│ ├── lsm303ah_STdC
│ │ └── driver
│ │ │ ├── lsm303ah_reg.c
│ │ │ └── lsm303ah_reg.h
│ ├── lsm6ds3tr-c_STdC
│ │ └── driver
│ │ │ ├── lsm6ds3tr-c_reg.c
│ │ │ └── lsm6ds3tr-c_reg.h
│ ├── lsm6dsl_STdC
│ │ └── driver
│ │ │ ├── lsm6dsl_reg.c
│ │ │ └── lsm6dsl_reg.h
│ ├── lsm6dsm_STdC
│ │ └── driver
│ │ │ ├── lsm6dsm_reg.c
│ │ │ └── lsm6dsm_reg.h
│ ├── lsm6dso16is_STdC
│ │ └── driver
│ │ │ ├── lsm6dso16is_reg.c
│ │ │ └── lsm6dso16is_reg.h
│ ├── lsm6dso32_STdC
│ │ └── driver
│ │ │ ├── lsm6dso32_reg.c
│ │ │ └── lsm6dso32_reg.h
│ ├── lsm6dso32x_STdC
│ │ └── driver
│ │ │ ├── lsm6dso32x_reg.c
│ │ │ └── lsm6dso32x_reg.h
│ ├── lsm6dso_STdC
│ │ └── driver
│ │ │ ├── lsm6dso_reg.c
│ │ │ └── lsm6dso_reg.h
│ ├── lsm6dsox_STdC
│ │ └── driver
│ │ │ ├── lsm6dsox_reg.c
│ │ │ └── lsm6dsox_reg.h
│ ├── lsm6dsr_STdC
│ │ └── driver
│ │ │ ├── lsm6dsr_reg.c
│ │ │ └── lsm6dsr_reg.h
│ ├── lsm6dsrx_STdC
│ │ └── driver
│ │ │ ├── lsm6dsrx_reg.c
│ │ │ └── lsm6dsrx_reg.h
│ ├── lsm6dsv16b_STdC
│ │ └── driver
│ │ │ ├── lsm6dsv16b_reg.c
│ │ │ └── lsm6dsv16b_reg.h
│ ├── lsm6dsv16bx_STdC
│ │ └── driver
│ │ │ ├── lsm6dsv16bx_reg.c
│ │ │ └── lsm6dsv16bx_reg.h
│ ├── lsm6dsv16x_STdC
│ │ └── driver
│ │ │ ├── lsm6dsv16x_reg.c
│ │ │ └── lsm6dsv16x_reg.h
│ ├── lsm6dsv320x_STdC
│ │ └── driver
│ │ │ ├── lsm6dsv320x_reg.c
│ │ │ └── lsm6dsv320x_reg.h
│ ├── lsm6dsv32x_STdC
│ │ └── driver
│ │ │ ├── lsm6dsv32x_reg.c
│ │ │ └── lsm6dsv32x_reg.h
│ ├── lsm6dsv80x_STdC
│ │ └── driver
│ │ │ ├── lsm6dsv80x_reg.c
│ │ │ └── lsm6dsv80x_reg.h
│ ├── lsm6dsv_STdC
│ │ └── driver
│ │ │ ├── lsm6dsv_reg.c
│ │ │ └── lsm6dsv_reg.h
│ ├── lsm9ds1_STdC
│ │ └── driver
│ │ │ ├── lsm9ds1_reg.c
│ │ │ └── lsm9ds1_reg.h
│ ├── st1vafe3bx_STdC
│ │ └── driver
│ │ │ ├── st1vafe3bx_reg.c
│ │ │ └── st1vafe3bx_reg.h
│ ├── st1vafe6ax_STdC
│ │ └── driver
│ │ │ ├── st1vafe6ax_reg.c
│ │ │ └── st1vafe6ax_reg.h
│ ├── sths34pf80_STdC
│ │ └── driver
│ │ │ ├── sths34pf80_reg.c
│ │ │ └── sths34pf80_reg.h
│ ├── stts22h_STdC
│ │ └── driver
│ │ │ ├── stts22h_reg.c
│ │ │ └── stts22h_reg.h
│ └── stts751_STdC
│ │ └── driver
│ │ ├── stts751_reg.c
│ │ └── stts751_reg.h
├── vl53l0x
│ ├── README
│ └── api
│ │ └── core
│ │ ├── inc
│ │ ├── vl53l0x_api.h
│ │ ├── vl53l0x_api_calibration.h
│ │ ├── vl53l0x_api_core.h
│ │ ├── vl53l0x_api_ranging.h
│ │ ├── vl53l0x_api_strings.h
│ │ ├── vl53l0x_def.h
│ │ ├── vl53l0x_device.h
│ │ ├── vl53l0x_interrupt_threshold_settings.h
│ │ └── vl53l0x_tuning.h
│ │ └── src
│ │ ├── vl53l0x_api.c
│ │ ├── vl53l0x_api_calibration.c
│ │ ├── vl53l0x_api_core.c
│ │ ├── vl53l0x_api_ranging.c
│ │ └── vl53l0x_api_strings.c
└── vl53l1x
│ ├── README
│ └── api
│ └── core
│ ├── inc
│ ├── vl53l1_api.h
│ ├── vl53l1_api_calibration.h
│ ├── vl53l1_api_core.h
│ ├── vl53l1_api_debug.h
│ ├── vl53l1_api_preset_modes.h
│ ├── vl53l1_api_strings.h
│ ├── vl53l1_core.h
│ ├── vl53l1_core_support.h
│ ├── vl53l1_def.h
│ ├── vl53l1_error_codes.h
│ ├── vl53l1_error_exceptions.h
│ ├── vl53l1_error_strings.h
│ ├── vl53l1_ll_def.h
│ ├── vl53l1_ll_device.h
│ ├── vl53l1_nvm_map.h
│ ├── vl53l1_preset_setup.h
│ ├── vl53l1_register_funcs.h
│ ├── vl53l1_register_map.h
│ ├── vl53l1_register_settings.h
│ ├── vl53l1_register_structs.h
│ ├── vl53l1_silicon_core.h
│ ├── vl53l1_tuning_parm_defaults.h
│ └── vl53l1_wait.h
│ └── src
│ ├── vl53l1_api.c
│ ├── vl53l1_api_calibration.c
│ ├── vl53l1_api_core.c
│ ├── vl53l1_api_debug.c
│ ├── vl53l1_api_preset_modes.c
│ ├── vl53l1_api_strings.c
│ ├── vl53l1_core.c
│ ├── vl53l1_core_support.c
│ ├── vl53l1_error_strings.c
│ ├── vl53l1_register_funcs.c
│ ├── vl53l1_silicon_core.c
│ └── vl53l1_wait.c
└── zephyr
└── module.yml
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Makefile - STLIB SDK
2 | #
3 | # Copyright (c) 2016 Linaro Limited
4 | #
5 | # SPDX-License-Identifier: Apache-2.0
6 |
7 | if(CONFIG_HAS_STLIB)
8 |
9 | zephyr_library()
10 |
11 | if(CONFIG_VL53L0X)
12 | zephyr_include_directories(sensor/vl53l0x/api/core/inc
13 | ${PROJECT_SOURCE_DIR}/drivers/sensor/st/vl53l0x)
14 | zephyr_library_sources(sensor/vl53l0x/api/core/src/vl53l0x_api.c)
15 | zephyr_library_sources(sensor/vl53l0x/api/core/src/vl53l0x_api_ranging.c)
16 | zephyr_library_sources(sensor/vl53l0x/api/core/src/vl53l0x_api_calibration.c)
17 | zephyr_library_sources(sensor/vl53l0x/api/core/src/vl53l0x_api_core.c)
18 | zephyr_library_sources(sensor/vl53l0x/api/core/src/vl53l0x_api_strings.c)
19 | endif()
20 |
21 | if(CONFIG_VL53L1X)
22 | zephyr_include_directories(sensor/vl53l1x/api/core/inc
23 | ${PROJECT_SOURCE_DIR}/drivers/sensor/st/vl53l1x)
24 | zephyr_library_sources(sensor/vl53l1x/api/core/src/vl53l1_api.c)
25 | zephyr_library_sources(sensor/vl53l1x/api/core/src/vl53l1_api_calibration.c)
26 | zephyr_library_sources(sensor/vl53l1x/api/core/src/vl53l1_wait.c)
27 | zephyr_library_sources(sensor/vl53l1x/api/core/src/vl53l1_core.c)
28 | zephyr_library_sources(sensor/vl53l1x/api/core/src/vl53l1_api_core.c)
29 | zephyr_library_sources(sensor/vl53l1x/api/core/src/vl53l1_api_preset_modes.c)
30 | zephyr_library_sources(sensor/vl53l1x/api/core/src/vl53l1_core_support.c)
31 | zephyr_library_sources(sensor/vl53l1x/api/core/src/vl53l1_register_funcs.c)
32 | endif()
33 |
34 | if(CONFIG_AUDIO_MPXXDTYY)
35 | zephyr_include_directories(audio/microphone)
36 | zephyr_library_sources(audio/microphone/OpenPDMFilter.c)
37 | endif()
38 |
39 | endif()
40 |
41 | # STMEMSC - Hardware Abstraction Layer for ST sensor
42 | add_subdirectory_ifdef(CONFIG_HAS_STMEMSC sensor/stmemsc)
43 |
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
1 |
2 | Directory contains all the official libraries provided by STMicroelectronics.
3 |
4 | Available libs:
5 | * sensor/vl53l0x:
6 | allows to drive the vl53l0x sensor
7 | full information can be found here : http://www.st.com/en/embedded-software/stsw-img005.html
8 | *...
9 |
10 | Patch List:
11 |
12 | *Fix double-promotion warnings
13 | -audio/microphone/OpenPDMFilter.c modified
14 |
--------------------------------------------------------------------------------
/audio/microphone/OpenPDMFilter.c:
--------------------------------------------------------------------------------
1 | /**
2 | *******************************************************************************
3 | * @file OpenPDMFilter.c
4 | * @author CL
5 | * @version V1.0.0
6 | * @date 9-September-2015
7 | * @brief Open PDM audio software decoding Library.
8 | * This Library is used to decode and reconstruct the audio signal
9 | * produced by ST MEMS microphone (MP45Dxxx, MP34Dxxx).
10 | *******************************************************************************
11 | * @attention
12 | *
13 | *
© COPYRIGHT 2018 STMicroelectronics
14 | *
15 | * Licensed under the Apache License, Version 2.0 (the "License");
16 | * you may not use this file except in compliance with the License.
17 | * You may obtain a copy of the License at
18 | *
19 | * http://www.apache.org/licenses/LICENSE-2.0
20 | *
21 | * Unless required by applicable law or agreed to in writing, software
22 | * distributed under the License is distributed on an "AS IS" BASIS,
23 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 | * See the License for the specific language governing permissions and
25 | * limitations under the License.
26 | *******************************************************************************
27 | */
28 |
29 |
30 | /* Includes ------------------------------------------------------------------*/
31 |
32 | #include "OpenPDMFilter.h"
33 |
34 |
35 | /* Variables -----------------------------------------------------------------*/
36 |
37 | uint32_t div_const = 0;
38 | int64_t sub_const = 0;
39 | uint32_t sinc[DECIMATION_MAX * SINCN];
40 | uint32_t sinc1[DECIMATION_MAX];
41 | uint32_t sinc2[DECIMATION_MAX * 2];
42 | uint32_t coef[SINCN][DECIMATION_MAX];
43 | #ifdef USE_LUT
44 | int32_t lut[256][DECIMATION_MAX / 8][SINCN];
45 | #endif
46 |
47 |
48 | /* Functions -----------------------------------------------------------------*/
49 |
50 | #ifdef USE_LUT
51 | int32_t filter_table_mono_64(uint8_t *data, uint8_t sincn)
52 | {
53 | return (int32_t)
54 | lut[data[0]][0][sincn] +
55 | lut[data[1]][1][sincn] +
56 | lut[data[2]][2][sincn] +
57 | lut[data[3]][3][sincn] +
58 | lut[data[4]][4][sincn] +
59 | lut[data[5]][5][sincn] +
60 | lut[data[6]][6][sincn] +
61 | lut[data[7]][7][sincn];
62 | }
63 | int32_t filter_table_stereo_64(uint8_t *data, uint8_t sincn)
64 | {
65 | return (int32_t)
66 | lut[data[0]][0][sincn] +
67 | lut[data[2]][1][sincn] +
68 | lut[data[4]][2][sincn] +
69 | lut[data[6]][3][sincn] +
70 | lut[data[8]][4][sincn] +
71 | lut[data[10]][5][sincn] +
72 | lut[data[12]][6][sincn] +
73 | lut[data[14]][7][sincn];
74 | }
75 | int32_t filter_table_mono_128(uint8_t *data, uint8_t sincn)
76 | {
77 | return (int32_t)
78 | lut[data[0]][0][sincn] +
79 | lut[data[1]][1][sincn] +
80 | lut[data[2]][2][sincn] +
81 | lut[data[3]][3][sincn] +
82 | lut[data[4]][4][sincn] +
83 | lut[data[5]][5][sincn] +
84 | lut[data[6]][6][sincn] +
85 | lut[data[7]][7][sincn] +
86 | lut[data[8]][8][sincn] +
87 | lut[data[9]][9][sincn] +
88 | lut[data[10]][10][sincn] +
89 | lut[data[11]][11][sincn] +
90 | lut[data[12]][12][sincn] +
91 | lut[data[13]][13][sincn] +
92 | lut[data[14]][14][sincn] +
93 | lut[data[15]][15][sincn];
94 | }
95 | int32_t filter_table_stereo_128(uint8_t *data, uint8_t sincn)
96 | {
97 | return (int32_t)
98 | lut[data[0]][0][sincn] +
99 | lut[data[2]][1][sincn] +
100 | lut[data[4]][2][sincn] +
101 | lut[data[6]][3][sincn] +
102 | lut[data[8]][4][sincn] +
103 | lut[data[10]][5][sincn] +
104 | lut[data[12]][6][sincn] +
105 | lut[data[14]][7][sincn] +
106 | lut[data[16]][8][sincn] +
107 | lut[data[18]][9][sincn] +
108 | lut[data[20]][10][sincn] +
109 | lut[data[22]][11][sincn] +
110 | lut[data[24]][12][sincn] +
111 | lut[data[26]][13][sincn] +
112 | lut[data[28]][14][sincn] +
113 | lut[data[30]][15][sincn];
114 | }
115 | int32_t (* filter_tables_64[2]) (uint8_t *data, uint8_t sincn) = {filter_table_mono_64, filter_table_stereo_64};
116 | int32_t (* filter_tables_128[2]) (uint8_t *data, uint8_t sincn) = {filter_table_mono_128, filter_table_stereo_128};
117 | #else
118 | int32_t filter_table(uint8_t *data, uint8_t sincn, TPDMFilter_InitStruct *param)
119 | {
120 | uint8_t c, i;
121 | uint16_t data_index = 0;
122 | uint32_t *coef_p = &coef[sincn][0];
123 | int32_t F = 0;
124 | uint8_t decimation = param->Decimation;
125 | uint8_t channels = param->In_MicChannels;
126 |
127 | for (i = 0; i < decimation; i += 8) {
128 | c = data[data_index];
129 | F += ((c >> 7) ) * coef_p[i ] +
130 | ((c >> 6) & 0x01) * coef_p[i + 1] +
131 | ((c >> 5) & 0x01) * coef_p[i + 2] +
132 | ((c >> 4) & 0x01) * coef_p[i + 3] +
133 | ((c >> 3) & 0x01) * coef_p[i + 4] +
134 | ((c >> 2) & 0x01) * coef_p[i + 5] +
135 | ((c >> 1) & 0x01) * coef_p[i + 6] +
136 | ((c ) & 0x01) * coef_p[i + 7];
137 | data_index += channels;
138 | }
139 | return F;
140 | }
141 | #endif
142 |
143 | void convolve(uint32_t Signal[/* SignalLen */], unsigned short SignalLen,
144 | uint32_t Kernel[/* KernelLen */], unsigned short KernelLen,
145 | uint32_t Result[/* SignalLen + KernelLen - 1 */])
146 | {
147 | uint16_t n;
148 |
149 | for (n = 0; n < SignalLen + KernelLen - 1; n++)
150 | {
151 | unsigned short kmin, kmax, k;
152 |
153 | Result[n] = 0;
154 |
155 | kmin = (n >= KernelLen - 1) ? n - (KernelLen - 1) : 0;
156 | kmax = (n < SignalLen - 1) ? n : SignalLen - 1;
157 |
158 | for (k = kmin; k <= kmax; k++) {
159 | Result[n] += Signal[k] * Kernel[n - k];
160 | }
161 | }
162 | }
163 |
164 | void Open_PDM_Filter_Init(TPDMFilter_InitStruct *Param)
165 | {
166 | uint16_t i, j;
167 | int64_t sum = 0;
168 |
169 | uint8_t decimation = Param->Decimation;
170 |
171 | for (i = 0; i < SINCN; i++) {
172 | Param->Coef[i] = 0;
173 | Param->bit[i] = 0;
174 | }
175 | for (i = 0; i < decimation; i++) {
176 | sinc1[i] = 1;
177 | }
178 |
179 | Param->OldOut = Param->OldIn = Param->OldZ = 0;
180 | Param->LP_ALFA = (Param->LP_HZ != 0 ? (uint16_t) (Param->LP_HZ * 256 / (Param->LP_HZ + Param->Fs / (2 * 3.14159f))) : 0);
181 | Param->HP_ALFA = (Param->HP_HZ != 0 ? (uint16_t) (Param->Fs * 256 / (2 * 3.14159f * Param->HP_HZ + Param->Fs)) : 0);
182 |
183 | Param->FilterLen = decimation * SINCN;
184 | sinc[0] = 0;
185 | sinc[decimation * SINCN - 1] = 0;
186 | convolve(sinc1, decimation, sinc1, decimation, sinc2);
187 | convolve(sinc2, decimation * 2 - 1, sinc1, decimation, &sinc[1]);
188 | for(j = 0; j < SINCN; j++) {
189 | for (i = 0; i < decimation; i++) {
190 | coef[j][i] = sinc[j * decimation + i];
191 | sum += sinc[j * decimation + i];
192 | }
193 | }
194 |
195 | sub_const = sum >> 1;
196 | div_const = sub_const * Param->MaxVolume / 32768 / FILTER_GAIN;
197 | div_const = (div_const == 0 ? 1 : div_const);
198 |
199 | #ifdef USE_LUT
200 | /* Look-Up Table. */
201 | uint16_t c, d, s;
202 | for (s = 0; s < SINCN; s++)
203 | {
204 | uint32_t *coef_p = &coef[s][0];
205 | for (c = 0; c < 256; c++)
206 | for (d = 0; d < decimation / 8; d++)
207 | lut[c][d][s] = ((c >> 7) ) * coef_p[d * 8 ] +
208 | ((c >> 6) & 0x01) * coef_p[d * 8 + 1] +
209 | ((c >> 5) & 0x01) * coef_p[d * 8 + 2] +
210 | ((c >> 4) & 0x01) * coef_p[d * 8 + 3] +
211 | ((c >> 3) & 0x01) * coef_p[d * 8 + 4] +
212 | ((c >> 2) & 0x01) * coef_p[d * 8 + 5] +
213 | ((c >> 1) & 0x01) * coef_p[d * 8 + 6] +
214 | ((c ) & 0x01) * coef_p[d * 8 + 7];
215 | }
216 | #endif
217 | }
218 |
219 | void Open_PDM_Filter_64(uint8_t* data, uint16_t* dataOut, uint16_t volume, TPDMFilter_InitStruct *Param)
220 | {
221 | uint8_t i, data_out_index;
222 | uint8_t channels = Param->In_MicChannels;
223 | uint8_t data_inc = ((DECIMATION_MAX >> 4) * channels);
224 | int64_t Z, Z0, Z1, Z2;
225 | int64_t OldOut, OldIn, OldZ;
226 |
227 | OldOut = Param->OldOut;
228 | OldIn = Param->OldIn;
229 | OldZ = Param->OldZ;
230 |
231 | #ifdef USE_LUT
232 | uint8_t j = channels - 1;
233 | #endif
234 |
235 | for (i = 0, data_out_index = 0; i < Param->Fs / 1000; i++, data_out_index += channels) {
236 | #ifdef USE_LUT
237 | Z0 = filter_tables_64[j](data, 0);
238 | Z1 = filter_tables_64[j](data, 1);
239 | Z2 = filter_tables_64[j](data, 2);
240 | #else
241 | Z0 = filter_table(data, 0, Param);
242 | Z1 = filter_table(data, 1, Param);
243 | Z2 = filter_table(data, 2, Param);
244 | #endif
245 |
246 | Z = Param->Coef[1] + Z2 - sub_const;
247 | Param->Coef[1] = Param->Coef[0] + Z1;
248 | Param->Coef[0] = Z0;
249 |
250 | OldOut = (Param->HP_ALFA * (OldOut + Z - OldIn)) >> 8;
251 | OldIn = Z;
252 | OldZ = ((256 - Param->LP_ALFA) * OldZ + Param->LP_ALFA * OldOut) >> 8;
253 |
254 | Z = OldZ * volume;
255 | Z = RoundDiv(Z, div_const);
256 | Z = SaturaLH(Z, -32700, 32700);
257 |
258 | dataOut[data_out_index] = Z;
259 | data += data_inc;
260 | }
261 |
262 | Param->OldOut = OldOut;
263 | Param->OldIn = OldIn;
264 | Param->OldZ = OldZ;
265 | }
266 |
267 | void Open_PDM_Filter_128(uint8_t* data, uint16_t* dataOut, uint16_t volume, TPDMFilter_InitStruct *Param)
268 | {
269 | uint8_t i, data_out_index;
270 | uint8_t channels = Param->In_MicChannels;
271 | uint8_t data_inc = ((DECIMATION_MAX >> 3) * channels);
272 | int64_t Z, Z0, Z1, Z2;
273 | int64_t OldOut, OldIn, OldZ;
274 |
275 | OldOut = Param->OldOut;
276 | OldIn = Param->OldIn;
277 | OldZ = Param->OldZ;
278 |
279 | #ifdef USE_LUT
280 | uint8_t j = channels - 1;
281 | #endif
282 |
283 | for (i = 0, data_out_index = 0; i < Param->Fs / 1000; i++, data_out_index += channels) {
284 | #ifdef USE_LUT
285 | Z0 = filter_tables_128[j](data, 0);
286 | Z1 = filter_tables_128[j](data, 1);
287 | Z2 = filter_tables_128[j](data, 2);
288 | #else
289 | Z0 = filter_table(data, 0, Param);
290 | Z1 = filter_table(data, 1, Param);
291 | Z2 = filter_table(data, 2, Param);
292 | #endif
293 |
294 | Z = Param->Coef[1] + Z2 - sub_const;
295 | Param->Coef[1] = Param->Coef[0] + Z1;
296 | Param->Coef[0] = Z0;
297 |
298 | OldOut = (Param->HP_ALFA * (OldOut + Z - OldIn)) >> 8;
299 | OldIn = Z;
300 | OldZ = ((256 - Param->LP_ALFA) * OldZ + Param->LP_ALFA * OldOut) >> 8;
301 |
302 | Z = OldZ * volume;
303 | Z = RoundDiv(Z, div_const);
304 | Z = SaturaLH(Z, -32700, 32700);
305 |
306 | dataOut[data_out_index] = Z;
307 | data += data_inc;
308 | }
309 |
310 | Param->OldOut = OldOut;
311 | Param->OldIn = OldIn;
312 | Param->OldZ = OldZ;
313 | }
314 |
--------------------------------------------------------------------------------
/audio/microphone/OpenPDMFilter.h:
--------------------------------------------------------------------------------
1 | /**
2 | *******************************************************************************
3 | * @file OpenPDMFilter.h
4 | * @author CL
5 | * @version V1.0.0
6 | * @date 9-September-2015
7 | * @brief Header file for Open PDM audio software decoding Library.
8 | * This Library is used to decode and reconstruct the audio signal
9 | * produced by ST MEMS microphone (MP45Dxxx, MP34Dxxx).
10 | *******************************************************************************
11 | * @attention
12 | *
13 | * © COPYRIGHT 2018 STMicroelectronics
14 | *
15 | * Licensed under the Apache License, Version 2.0 (the "License");
16 | * you may not use this file except in compliance with the License.
17 | * You may obtain a copy of the License at
18 | *
19 | * http://www.apache.org/licenses/LICENSE-2.0
20 | *
21 | * Unless required by applicable law or agreed to in writing, software
22 | * distributed under the License is distributed on an "AS IS" BASIS,
23 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 | * See the License for the specific language governing permissions and
25 | * limitations under the License.
26 | *******************************************************************************
27 | */
28 |
29 |
30 | /* Define to prevent recursive inclusion -------------------------------------*/
31 |
32 | #ifndef __OPENPDMFILTER_H
33 | #define __OPENPDMFILTER_H
34 |
35 | #ifdef __cplusplus
36 | extern "C" {
37 | #endif
38 |
39 |
40 | /* Includes ------------------------------------------------------------------*/
41 |
42 | #include
43 |
44 |
45 | /* Definitions ---------------------------------------------------------------*/
46 |
47 | /*
48 | * Enable to use a Look-Up Table to improve performances while using more FLASH
49 | * and RAM memory.
50 | * Note: Without Look-Up Table up to stereo@16KHz configuration is supported.
51 | */
52 | #define USE_LUT
53 |
54 | #define SINCN 3
55 | #define DECIMATION_MAX 128
56 | #define FILTER_GAIN 16
57 |
58 | #define HTONS(A) ((((uint16_t)(A) & 0xff00) >> 8) | \
59 | (((uint16_t)(A) & 0x00ff) << 8))
60 | #define RoundDiv(a, b) (((a)>0)?(((a)+(b)/2)/(b)):(((a)-(b)/2)/(b)))
61 | #define SaturaLH(N, L, H) (((N)<(L))?(L):(((N)>(H))?(H):(N)))
62 |
63 |
64 | /* Types ---------------------------------------------------------------------*/
65 |
66 | typedef struct {
67 | /* Public */
68 | float LP_HZ;
69 | float HP_HZ;
70 | uint16_t Fs;
71 | uint8_t In_MicChannels;
72 | uint8_t Out_MicChannels;
73 | uint8_t Decimation;
74 | uint8_t MaxVolume;
75 | /* Private */
76 | uint32_t Coef[SINCN];
77 | uint16_t FilterLen;
78 | int64_t OldOut, OldIn, OldZ;
79 | uint16_t LP_ALFA;
80 | uint16_t HP_ALFA;
81 | uint16_t bit[5];
82 | uint16_t byte;
83 | } TPDMFilter_InitStruct;
84 |
85 |
86 | /* Exported functions ------------------------------------------------------- */
87 |
88 | void Open_PDM_Filter_Init(TPDMFilter_InitStruct *init_struct);
89 | void Open_PDM_Filter_64(uint8_t* data, uint16_t* data_out, uint16_t mic_gain, TPDMFilter_InitStruct *init_struct);
90 | void Open_PDM_Filter_128(uint8_t* data, uint16_t* data_out, uint16_t mic_gain, TPDMFilter_InitStruct *init_struct);
91 |
92 | #ifdef __cplusplus
93 | }
94 | #endif
95 |
96 | #endif // __OPENPDMFILTER_H
97 |
98 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
99 |
--------------------------------------------------------------------------------
/audio/microphone/README:
--------------------------------------------------------------------------------
1 | OpenPDM2PCM
2 | ###########
3 |
4 | Origin:
5 | Arm Mbed OS
6 | https://os.mbed.com/teams/ST/code/X_NUCLEO_CCA02M1/Middlewares/OpenPDM2PCM/
7 |
8 | Status:
9 | version 1.0.0
10 |
11 | Purpose:
12 | This Library is used to decode and reconstruct the audio signal
13 | produced by ST MEMS microphone (MP45Dxxx, MP34Dxxx).
14 |
15 | Description:
16 | This library, written by STMicroelectronics, is used to convert an audio
17 | stream from PDM format to PCM format through a signal filtering and
18 | decimation.
19 |
20 | Library APIs:
21 | - Open_PDM_Filter_Init() /* Init the OpenPDM2PCM library */
22 | - Open_PDM_Filter_64() /* Filter and decimate stream by 64 */
23 | - Open_PDM_Filter_128() /* Filter and decimate stream by 128 */
24 |
25 |
26 | Dependencies:
27 | This library depends by Zephyr mpxxdtyy driver and is linked statically.
28 | This library will be used by a standard Zephyr microphone driver
29 | (./drivers/audio/).
30 |
31 | URL:
32 | https://os.mbed.com/teams/ST/code/X_NUCLEO_CCA02M1/Middlewares/OpenPDM2PCM/
33 |
34 | commit:
35 | 25:f2c04f757003
36 |
37 | Maintained-by:
38 | External
39 |
40 | License:
41 | Apache 2.0
42 |
43 | License Link:
44 | https://www.apache.org/licenses/LICENSE-2.0
45 |
46 |
--------------------------------------------------------------------------------
/sensor/stmemsc/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Makefile - STMems_Standard_C_drivers
2 | #
3 | # Copyright (c) 2019 STMicroelectronics
4 | #
5 | # SPDX-License-Identifier: Apache-2.0
6 |
7 | set(stmems_pids
8 | a3g4250d
9 | ais25ba
10 | ais2dw12
11 | ais2ih
12 | ais328dq
13 | ais3624dq
14 | asm330lhb
15 | asm330lhbg1
16 | asm330lhh
17 | asm330lhhx
18 | asm330lhhxg1
19 | h3lis100dl
20 | h3lis331dl
21 | hts221
22 | i3g4250d
23 | iis2dh
24 | iis2dlpc
25 | iis2dulpx
26 | iis2iclx
27 | iis2mdc
28 | iis328dq
29 | iis3dhhc
30 | iis3dwb
31 | ilps22qs
32 | ilps28qsw
33 | ism303dac
34 | ism330bx
35 | ism330dhcx
36 | ism330dlc
37 | ism330is
38 | l3gd20h
39 | lis25ba
40 | lis2de12
41 | lis2dh12
42 | lis2ds12
43 | lis2dtw12
44 | lis2du12
45 | lis2dux12
46 | lis2duxs12
47 | lis2dw12
48 | lis2hh12
49 | lis2mdl
50 | lis331dlh
51 | lis3de
52 | lis3dh
53 | lis3dhh
54 | lis3mdl
55 | lps22ch
56 | lps22df
57 | lps22hb
58 | lps22hh
59 | lps25hb
60 | lps27hhtw
61 | lps27hhw
62 | lps28dfw
63 | lps33k
64 | lsm303agr
65 | lsm303ah
66 | lsm6ds3tr-c
67 | lsm6dsl
68 | lsm6dsm
69 | lsm6dso
70 | lsm6dso16is
71 | lsm6dso32
72 | lsm6dso32x
73 | lsm6dsox
74 | lsm6dsr
75 | lsm6dsrx
76 | lsm6dsv16b
77 | lsm6dsv16bx
78 | lsm6dsv16x
79 | lsm6dsv320x
80 | lsm6dsv32x
81 | lsm6dsv80x
82 | lsm6dsv
83 | lsm9ds1
84 | st1vafe3bx
85 | st1vafe6ax
86 | sths34pf80
87 | stts22h
88 | stts751
89 | )
90 |
91 | foreach(stmems_pid ${stmems_pids})
92 | string(TOUPPER ${stmems_pid} pid_to_upper)
93 | string(REPLACE "-" "_" pid_replace_dash_underscore ${pid_to_upper})
94 | if(CONFIG_USE_STDC_${pid_replace_dash_underscore})
95 | zephyr_include_directories(
96 | ${stmems_pid}_STdC/driver/
97 | )
98 | zephyr_library_sources(
99 | ${stmems_pid}_STdC/driver/${stmems_pid}_reg.c
100 | )
101 | endif()
102 | endforeach()
103 |
--------------------------------------------------------------------------------
/sensor/stmemsc/LICENSE:
--------------------------------------------------------------------------------
1 | BSD 3-Clause License
2 |
3 | Copyright (c) 2019, STMicroelectronics
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | * Neither the name of the copyright holder nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 |
--------------------------------------------------------------------------------
/sensor/stmemsc/README:
--------------------------------------------------------------------------------
1 | C-Driver-MEMS
2 | #############
3 |
4 | Origin:
5 | ST Microelectronics
6 | https://www.st.com/en/embedded-software/c-driver-mems.html
7 |
8 | Status:
9 | version v2.9.1
10 |
11 | Purpose:
12 | ST Microelectronics standard C platform-independent drivers for MEMS
13 | motion and environmental sensors.
14 |
15 | Description:
16 | This package is an extract (examples have not been retained) of official
17 | C-Driver-MEMS package written by ST Microelectronics.
18 | It contains standard drivers for STMicroelectronics MEMS sensors to
19 | provide a common and stable interface to access sensor registers.
20 | For each supported sensor following files are provided:
21 |
22 | - xyz_reg.c: contains the function to read/write 'xyz' sensor registers
23 | - xyz_reg.h: contains structures and defines to describe in details
24 | the 'xyz' sensor registers.
25 |
26 | The driver is platform-independent, you only need to define the two
27 | functions for read and write transactions from the sensor hardware bus
28 | (i.e. SPI or I2C/I3C). In addition you may define a mdelay (milliseconds)
29 | routine.
30 |
31 | Define in your 'xyz' driver code the read and write functions that use the
32 | I2C or SPI platform driver (plus the optional mdelay function) like the following:
33 |
34 | /** Please note that is MANDATORY: return 0 -> no Error.**/
35 | int platform_wr(void *handle, u8_t reg, const u8_t *bufp, u16_t len);
36 | int platform_rd(void *handle, u8_t reg, u8_t *bufp, u16_t len);
37 |
38 | /** Component optional fields **/
39 | void platform_mdelay(u32_t millisec);
40 |
41 |
42 | stmdev_ctx_t stmdev_ctx = {
43 | .read_reg = (stmdev_read_ptr) platform_rd,
44 | .write_reg = (stmdev_write_ptr) platform_wr,
45 |
46 | /** Component optional fields **/
47 | .mdelay = (stmdev_mdelay_ptr) platform_mdelay,
48 | };
49 |
50 | Driver versions in this package:
51 |
52 | - a3g4250d_STdC v2.0.1
53 | - ais25ba_STdC v2.0.1
54 | - ais2dw12_STdC v2.0.1
55 | - ais2ih_STdC v2.0.1
56 | - ais328dq_STdC v2.0.1
57 | - ais3624dq_STdC v2.0.1
58 | - asm330lhb_STdC v2.1.0
59 | - asm330lhbg1_STdC v1.1.0
60 | - asm330lhh_STdC v3.2.0
61 | - asm330lhhx_STdC v2.1.0
62 | - asm330lhhxg1_STdC v2.0.1
63 | - h3lis100dl_STdC v2.0.1
64 | - h3lis331dl_STdC v2.0.1
65 | - hts221_STdC v2.1.0
66 | - i3g4250d_STdC v2.0.1
67 | - iis2dh_STdC v2.0.1
68 | - iis2dlpc_STdC v2.0.1
69 | - iis2dulpx_STdC v1.0.2
70 | - iis2iclx_STdC v2.0.1
71 | - iis2mdc_STdC v2.0.3
72 | - iis328dq_STdC v2.0.1
73 | - iis3dhhc_STdC v2.0.1
74 | - iis3dwb_STdC v2.0.1
75 | - ilps22qs_STdC v3.1.1
76 | - ilps28qsw_STdC v2.2.0
77 | - ism303dac_STdC v2.0.1
78 | - ism330bx_STdC v3.0.2
79 | - ism330dhcx_STdC v2.1.1
80 | - ism330dlc_STdC v2.0.2
81 | - ism330is_STdC v3.0.1
82 | - l3gd20h_STdC v2.0.1
83 | - lis25ba_STdC v2.0.1
84 | - lis2de12_STdC v2.0.1
85 | - lis2dh12_STdC v2.0.1
86 | - lis2ds12_STdC v2.0.1
87 | - lis2dtw12_STdC v2.0.1
88 | - lis2du12_STdC v2.0.1
89 | - lis2dux12_STdC v2.4.1
90 | - lis2duxs12_STdC v2.4.1
91 | - lis2dw12_STdC v2.0.1
92 | - lis2hh12_STdC v2.0.1
93 | - lis2mdl_STdC v2.0.1
94 | - lis331dlh_STdC v2.0.1
95 | - lis3de_STdC v2.0.1
96 | - lis3dh_STdC v2.0.1
97 | - lis3dhh_STdC v2.0.2
98 | - lis3mdl_STdC v2.0.1
99 | - lps22ch_STdC v2.0.1
100 | - lps22df_STdC v2.2.0
101 | - lps22hb_STdC v2.0.2
102 | - lps22hh_STdC v3.0.2
103 | - lps25hb_STdC v2.0.1
104 | - lps27hhtw_STdC v2.0.1
105 | - lps27hhw_STdC v2.0.1
106 | - lps28dfw_STdC v2.2.0
107 | - lps33k_STdC v2.0.1
108 | - lsm303agr_STdC v2.0.1
109 | - lsm303ah_STdC v2.0.1
110 | - lsm6ds3tr-c_STdC v2.0.1
111 | - lsm6dsl_STdC v2.0.1
112 | - lsm6dsm_STdC v2.0.1
113 | - lsm6dso16is_STdC v3.0.1
114 | - lsm6dso32_STdC v2.1.0
115 | - lsm6dso32x_STdC v2.1.0
116 | - lsm6dso_STdC v3.1.1
117 | - lsm6dsox_STdC v3.1.0
118 | - lsm6dsr_STdC v2.1.0
119 | - lsm6dsrx_STdC v2.1.0
120 | - lsm6dsv16b_STdC v3.0.1
121 | - lsm6dsv16bx_STdC v5.0.2
122 | - lsm6dsv16x_STdC v4.3.0
123 | - lsm6dsv320x_STdC v1.1.0
124 | - lsm6dsv32x_STdC v2.3.0
125 | - lsm6dsv80x_STdC v1.1.0
126 | - lsm6dsv_STdC v3.3.0
127 | - lsm9ds1_STdC v2.0.1
128 | - st1vafe3bx_STdC v2.1.1
129 | - st1vafe6ax_STdC v2.0.2
130 | - sths34pf80_STdC v3.0.1
131 | - stts22h_STdC v2.1.1
132 | - stts751_STdC v2.0.1
133 |
134 | Dependencies:
135 | None.
136 |
137 | URL:
138 | https://www.st.com/en/embedded-software/c-driver-mems.html
139 | https://github.com/STMicroelectronics/STMems_Standard_C_drivers/tree/v2.9.1
140 |
141 | commit:
142 | 0c1759e4 (tag v2.9.1)
143 |
144 | Maintained-by:
145 | ST Microelectronics
146 |
147 | License:
148 | BSD-3-Clause
149 |
150 | License Link:
151 | https://opensource.org/licenses/BSD-3-Clause
152 |
--------------------------------------------------------------------------------
/sensor/stmemsc/ais25ba_STdC/driver/ais25ba_reg.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file ais25ba_reg.c
4 | * @author Sensors Software Solution Team
5 | * @brief AIS25BA driver file
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2022 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | #include "ais25ba_reg.h"
21 |
22 | /**
23 | * @defgroup AIS25BA
24 | * @brief This file provides a set of functions needed to drive the
25 | * ais25ba enhanced inertial module.
26 | * @{
27 | *
28 | */
29 |
30 | /**
31 | * @defgroup AIS25BA_Interfaces_Functions
32 | * @brief This section provide a set of functions used to read and
33 | * write a generic register of the device.
34 | * MANDATORY: return 0 -> no Error.
35 | * @{
36 | *
37 | */
38 |
39 | /**
40 | * @brief Read generic device register
41 | *
42 | * @param ctx communication interface handler.(ptr)
43 | * @param reg first register address to read.
44 | * @param data buffer for data read.(ptr)
45 | * @param len number of consecutive register to read.
46 | * @retval interface status (MANDATORY: return 0 -> no Error).
47 | *
48 | */
49 | int32_t __weak ais25ba_read_reg(const stmdev_ctx_t *ctx, uint8_t reg,
50 | uint8_t *data,
51 | uint16_t len)
52 | {
53 | int32_t ret;
54 |
55 | if (ctx == NULL) return -1;
56 |
57 | ret = ctx->read_reg(ctx->handle, reg, data, len);
58 |
59 | return ret;
60 | }
61 |
62 | /**
63 | * @brief Write generic device register
64 | *
65 | * @param ctx communication interface handler.(ptr)
66 | * @param reg first register address to write.
67 | * @param data the buffer contains data to be written.(ptr)
68 | * @param len number of consecutive register to write.
69 | * @retval interface status (MANDATORY: return 0 -> no Error).
70 | *
71 | */
72 | int32_t __weak ais25ba_write_reg(const stmdev_ctx_t *ctx, uint8_t reg,
73 | uint8_t *data,
74 | uint16_t len)
75 | {
76 | int32_t ret;
77 |
78 | if (ctx == NULL) return -1;
79 |
80 | ret = ctx->write_reg(ctx->handle, reg, data, len);
81 |
82 | return ret;
83 | }
84 |
85 | /**
86 | * @}
87 | *
88 | */
89 |
90 | /**
91 | * @defgroup AIS25BA_Private_functions
92 | * @brief Section collect all the utility functions needed by APIs.
93 | * @{
94 | *
95 | */
96 |
97 | static void bytecpy(uint8_t *target, uint8_t *source)
98 | {
99 | if ((target != NULL) && (source != NULL))
100 | {
101 | *target = *source;
102 | }
103 | }
104 |
105 | /**
106 | * @}
107 | *
108 | */
109 |
110 | /**
111 | * @defgroup AIS25BA_Sensitivity
112 | * @brief These functions convert raw-data into engineering units.
113 | * @{
114 | *
115 | */
116 | float_t ais25ba_from_raw_to_mg(int16_t lsb)
117 | {
118 | return ((float_t)lsb) * 0.122f;
119 | }
120 |
121 | /**
122 | * @}
123 | *
124 | */
125 |
126 | /**
127 | * @defgroup Basic configuration
128 | * @brief This section groups all the functions concerning
129 | * device basic configuration.
130 | * @{
131 | *
132 | */
133 |
134 | /**
135 | * @brief Device "Who am I".[get]
136 | *
137 | * @param ctx communication interface handler.(ptr)
138 | * @param val ID values read from the I2C interface.
139 | *
140 | * @retval interface status (MANDATORY: return 0 -> no Error).
141 | *
142 | */
143 | int32_t ais25ba_id_get(const stmdev_ctx_t *ctx, ais25ba_id_t *val)
144 | {
145 | int32_t ret = 0;
146 |
147 | if (ctx != NULL)
148 | {
149 | ret = ais25ba_read_reg(ctx, AIS25BA_WHO_AM_I, (uint8_t *) & (val->id), 1);
150 | }
151 |
152 | return ret;
153 | }
154 |
155 | /**
156 | * @brief Configures the bus operating mode.[set]
157 | *
158 | * @param ctx communication interface handler.(ptr)
159 | * @param val configures the TDM bus operating mode.(ptr)
160 | *
161 | * @retval interface status (MANDATORY: return 0 -> no Error).
162 | *
163 | */
164 | int32_t ais25ba_bus_mode_set(const stmdev_ctx_t *ctx,
165 | ais25ba_bus_mode_t *val)
166 | {
167 | ais25ba_tdm_ctrl_reg_t tdm_ctrl_reg;
168 | ais25ba_tdm_cmax_h_t tdm_cmax_h;
169 | ais25ba_tdm_cmax_l_t tdm_cmax_l;
170 | uint8_t reg[2];
171 | int32_t ret;
172 |
173 | ret = ais25ba_read_reg(ctx, AIS25BA_TDM_CTRL_REG,
174 | (uint8_t *)&tdm_ctrl_reg, 1);
175 |
176 | if (ret == 0)
177 | {
178 | ret = ais25ba_read_reg(ctx, AIS25BA_TDM_CMAX_H, reg, 2);
179 | bytecpy((uint8_t *)&tdm_cmax_h, ®[0]);
180 | bytecpy((uint8_t *)&tdm_cmax_l, ®[1]);
181 | tdm_ctrl_reg.tdm_pd = ~val->tdm.en;
182 | tdm_ctrl_reg.data_valid = val->tdm.clk_pol;
183 | tdm_ctrl_reg.delayed = val->tdm.clk_edge;
184 | tdm_ctrl_reg.wclk_fq = val->tdm.mapping;
185 | tdm_cmax_h.tdm_cmax = (uint8_t)(val->tdm.cmax / 256U);
186 | tdm_cmax_l.tdm_cmax = (uint8_t)(val->tdm.cmax - tdm_cmax_h.tdm_cmax);
187 | }
188 |
189 | if (ret == 0)
190 | {
191 | ret = ais25ba_write_reg(ctx, AIS25BA_TDM_CTRL_REG,
192 | (uint8_t *)&tdm_ctrl_reg, 1);
193 | }
194 |
195 | if (ret == 0)
196 | {
197 | bytecpy(®[0], (uint8_t *)&tdm_cmax_h);
198 | bytecpy(®[1], (uint8_t *)&tdm_cmax_l);
199 | ret = ais25ba_write_reg(ctx, AIS25BA_TDM_CMAX_H, reg, 2);
200 | }
201 |
202 | return ret;
203 | }
204 |
205 | /**
206 | * @brief Get the bus operating mode.[get]
207 | *
208 | * @param ctx communication interface handler.(ptr)
209 | * @param val configures the TDM bus operating mode.(ptr)
210 | *
211 | * @retval interface status (MANDATORY: return 0 -> no Error).
212 | *
213 | */
214 | int32_t ais25ba_bus_mode_get(const stmdev_ctx_t *ctx,
215 | ais25ba_bus_mode_t *val)
216 | {
217 | ais25ba_tdm_ctrl_reg_t tdm_ctrl_reg;
218 | ais25ba_tdm_cmax_h_t tdm_cmax_h;
219 | ais25ba_tdm_cmax_l_t tdm_cmax_l;
220 | uint8_t reg[2];
221 | int32_t ret;
222 |
223 | ret = ais25ba_read_reg(ctx, AIS25BA_TDM_CTRL_REG,
224 | (uint8_t *)&tdm_ctrl_reg, 1);
225 |
226 | if (ret == 0)
227 | {
228 | ret = ais25ba_read_reg(ctx, AIS25BA_TDM_CMAX_H, reg, 2);
229 | bytecpy((uint8_t *)&tdm_cmax_h, ®[0]);
230 | bytecpy((uint8_t *)&tdm_cmax_l, ®[1]);
231 | }
232 |
233 | val->tdm.en = ~tdm_ctrl_reg.tdm_pd;
234 | val->tdm.clk_pol = tdm_ctrl_reg.data_valid;
235 | val->tdm.clk_edge = tdm_ctrl_reg.delayed;
236 | val->tdm.mapping = tdm_ctrl_reg.wclk_fq;
237 | val->tdm.cmax = tdm_cmax_h.tdm_cmax * 256U;
238 | val->tdm.cmax += tdm_cmax_l.tdm_cmax;
239 |
240 | return ret;
241 | }
242 |
243 | /**
244 | * @brief Sensor conversion parameters selection.[set]
245 | *
246 | * @param ctx communication interface handler.(ptr)
247 | * @param val set the sensor conversion parameters by checking
248 | * the constraints of the device.(ptr)
249 | *
250 | * @retval interface status (MANDATORY: return 0 -> no Error).
251 | *
252 | */
253 | int32_t ais25ba_mode_set(const stmdev_ctx_t *ctx, ais25ba_md_t *val)
254 | {
255 | ais25ba_axes_ctrl_reg_t axes_ctrl_reg;
256 | ais25ba_tdm_ctrl_reg_t tdm_ctrl_reg;
257 | ais25ba_ctrl_reg_t ctrl_reg;
258 | uint8_t reg[2];
259 | int32_t ret;
260 |
261 | ret = ais25ba_read_reg(ctx, AIS25BA_CTRL_REG_1, (uint8_t *)&ctrl_reg, 1);
262 |
263 | if (ret == 0)
264 | {
265 | ret = ais25ba_read_reg(ctx, AIS25BA_TDM_CTRL_REG, reg, 2);
266 | bytecpy((uint8_t *)&tdm_ctrl_reg, ®[0]);
267 | bytecpy((uint8_t *)&axes_ctrl_reg, ®[1]);
268 | }
269 |
270 | ctrl_reg.pd = (uint8_t)val->xl.odr & 0x01U;
271 | tdm_ctrl_reg.wclk_fq = ((uint8_t)val->xl.odr & 0x06U) >> 1;
272 | axes_ctrl_reg.odr_auto_en = ((uint8_t)val->xl.odr & 0x10U) >> 4;
273 |
274 | if (ret == 0)
275 | {
276 | ret = ais25ba_write_reg(ctx, AIS25BA_CTRL_REG_1, (uint8_t *)&ctrl_reg, 1);
277 | }
278 |
279 | /* writing checked configuration */
280 | bytecpy(®[0], (uint8_t *)&tdm_ctrl_reg);
281 | bytecpy(®[1], (uint8_t *)&axes_ctrl_reg);
282 |
283 | if (ret == 0)
284 | {
285 | ret = ais25ba_write_reg(ctx, AIS25BA_TDM_CTRL_REG, (uint8_t *)®,
286 | 2);
287 | }
288 |
289 | return ret;
290 | }
291 |
292 | /**
293 | * @brief Sensor conversion parameters selection.[get]
294 | *
295 | * @param ctx communication interface handler.(ptr)
296 | * @param val get the sensor conversion parameters.(ptr)
297 | *
298 | * @retval interface status (MANDATORY: return 0 -> no Error).
299 | *
300 | */
301 | int32_t ais25ba_mode_get(const stmdev_ctx_t *ctx, ais25ba_md_t *val)
302 | {
303 | ais25ba_axes_ctrl_reg_t axes_ctrl_reg;
304 | ais25ba_tdm_ctrl_reg_t tdm_ctrl_reg;
305 | ais25ba_ctrl_reg_t ctrl_reg;
306 | uint8_t reg[2];
307 | int32_t ret;
308 |
309 | ret = ais25ba_read_reg(ctx, AIS25BA_CTRL_REG_1, (uint8_t *)&ctrl_reg, 1);
310 |
311 | if (ret == 0)
312 | {
313 | ret = ais25ba_read_reg(ctx, AIS25BA_TDM_CTRL_REG, reg, 2);
314 | bytecpy((uint8_t *)&tdm_ctrl_reg, ®[0]);
315 | bytecpy((uint8_t *)&axes_ctrl_reg, ®[1]);
316 | }
317 |
318 | switch ((axes_ctrl_reg.odr_auto_en << 4) | (tdm_ctrl_reg.wclk_fq <<
319 | 1) |
320 | ctrl_reg.pd)
321 | {
322 | case AIS25BA_XL_OFF:
323 | val->xl.odr = AIS25BA_XL_OFF;
324 | break;
325 |
326 | case AIS25BA_XL_8kHz:
327 | val->xl.odr = AIS25BA_XL_8kHz;
328 | break;
329 |
330 | case AIS25BA_XL_16kHz:
331 | val->xl.odr = AIS25BA_XL_16kHz;
332 | break;
333 |
334 | case AIS25BA_XL_24kHz:
335 | val->xl.odr = AIS25BA_XL_24kHz;
336 | break;
337 |
338 | case AIS25BA_XL_HW_SEL:
339 | val->xl.odr = AIS25BA_XL_HW_SEL;
340 | break;
341 |
342 | default:
343 | val->xl.odr = AIS25BA_XL_OFF;
344 | break;
345 | }
346 |
347 | return ret;
348 | }
349 |
350 | /**
351 | * @brief Read data in engineering unit.[get]
352 | *
353 | * @param tdm_stream data stream from TDM interface.(ptr)
354 | * @param md the TDM interface configuration.(ptr)
355 | * @param data data read by the sensor.(ptr)
356 | *
357 | * @retval interface status (MANDATORY: return 0 -> no Error).
358 | *
359 | */
360 | int32_t ais25ba_data_get(uint16_t *tdm_stream, ais25ba_bus_mode_t *md,
361 | ais25ba_data_t *data)
362 | {
363 | uint8_t offset;
364 | uint8_t i;
365 |
366 | if (md->tdm.mapping == PROPERTY_DISABLE)
367 | {
368 | offset = 0; /* slot0-1-2 */
369 | }
370 |
371 | else
372 | {
373 | offset = 4; /* slot4-5-6 */
374 | }
375 |
376 | for (i = 0U; i < 3U; i++)
377 | {
378 | data->xl.raw[i] = (int16_t) tdm_stream[i + offset];
379 | data->xl.mg[i] = ais25ba_from_raw_to_mg(data->xl.raw[i]);
380 | }
381 |
382 | return 0;
383 | }
384 |
385 | /**
386 | * @brief Linear acceleration sensor self-test enable.[set]
387 | *
388 | * @param ctx read / write interface definitions.(ptr)
389 | * @param val enable/ disable selftest
390 | *
391 | * @retval interface status (MANDATORY: return 0 -> no Error).
392 | *
393 | */
394 | int32_t ais25ba_self_test_set(const stmdev_ctx_t *ctx, uint8_t val)
395 | {
396 | ais25ba_test_reg_t test_reg;
397 | int32_t ret;
398 |
399 | ret = ais25ba_read_reg(ctx, AIS25BA_TEST_REG, (uint8_t *)&test_reg, 1);
400 |
401 | if (ret == 0)
402 | {
403 | test_reg.st = val;
404 | ret = ais25ba_write_reg(ctx, AIS25BA_TEST_REG, (uint8_t *)&test_reg, 1);
405 | }
406 |
407 | return ret;
408 | }
409 |
410 | /**
411 | * @brief Linear acceleration sensor self-test enable.[get]
412 | *
413 | * @param ctx read / write interface definitions.(ptr)
414 | * @param val enable/ disable selftest.(ptr)
415 | *
416 | * @retval interface status (MANDATORY: return 0 -> no Error).
417 | *
418 | */
419 | int32_t ais25ba_self_test_get(const stmdev_ctx_t *ctx, uint8_t *val)
420 | {
421 | ais25ba_test_reg_t test_reg;
422 | int32_t ret;
423 |
424 | ret = ais25ba_read_reg(ctx, AIS25BA_TEST_REG, (uint8_t *)&test_reg, 1);
425 | *val = test_reg.st;
426 |
427 | return ret;
428 | }
429 |
430 | /**
431 | * @}
432 | *
433 | */
434 |
435 | /**
436 | * @}
437 | *
438 | */
439 |
440 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
441 |
--------------------------------------------------------------------------------
/sensor/stmemsc/ais25ba_STdC/driver/ais25ba_reg.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file ais25ba_reg.h
4 | * @author Sensors Software Solution Team
5 | * @brief This file contains all the functions prototypes for the
6 | * ais25ba_reg.c driver.
7 | ******************************************************************************
8 | * @attention
9 | *
10 | * © Copyright (c) 2022 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under BSD 3-Clause license,
14 | * the "License"; You may not use this file except in compliance with the
15 | * License. You may obtain a copy of the License at:
16 | * opensource.org/licenses/BSD-3-Clause
17 | *
18 | ******************************************************************************
19 | */
20 |
21 | /* Define to prevent recursive inclusion -------------------------------------*/
22 | #ifndef AIS25BA_REGS_H
23 | #define AIS25BA_REGS_H
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | /* Includes ------------------------------------------------------------------*/
30 | #include
31 | #include
32 | #include
33 |
34 | /** @addtogroup AIS25BA
35 | * @{
36 | *
37 | */
38 |
39 | /** @defgroup Endianness definitions
40 | * @{
41 | *
42 | */
43 |
44 | #ifndef DRV_BYTE_ORDER
45 | #ifndef __BYTE_ORDER__
46 |
47 | #define DRV_LITTLE_ENDIAN 1234
48 | #define DRV_BIG_ENDIAN 4321
49 |
50 | /** if _BYTE_ORDER is not defined, choose the endianness of your architecture
51 | * by uncommenting the define which fits your platform endianness
52 | */
53 | //#define DRV_BYTE_ORDER DRV_BIG_ENDIAN
54 | #define DRV_BYTE_ORDER DRV_LITTLE_ENDIAN
55 |
56 | #else /* defined __BYTE_ORDER__ */
57 |
58 | #define DRV_LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
59 | #define DRV_BIG_ENDIAN __ORDER_BIG_ENDIAN__
60 | #define DRV_BYTE_ORDER __BYTE_ORDER__
61 |
62 | #endif /* __BYTE_ORDER__*/
63 | #endif /* DRV_BYTE_ORDER */
64 |
65 | /**
66 | * @}
67 | *
68 | */
69 |
70 | /** @defgroup STMicroelectronics sensors common types
71 | * @{
72 | *
73 | */
74 |
75 | #ifndef MEMS_SHARED_TYPES
76 | #define MEMS_SHARED_TYPES
77 |
78 | typedef struct
79 | {
80 | #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
81 | uint8_t bit0 : 1;
82 | uint8_t bit1 : 1;
83 | uint8_t bit2 : 1;
84 | uint8_t bit3 : 1;
85 | uint8_t bit4 : 1;
86 | uint8_t bit5 : 1;
87 | uint8_t bit6 : 1;
88 | uint8_t bit7 : 1;
89 | #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
90 | uint8_t bit7 : 1;
91 | uint8_t bit6 : 1;
92 | uint8_t bit5 : 1;
93 | uint8_t bit4 : 1;
94 | uint8_t bit3 : 1;
95 | uint8_t bit2 : 1;
96 | uint8_t bit1 : 1;
97 | uint8_t bit0 : 1;
98 | #endif /* DRV_BYTE_ORDER */
99 | } bitwise_t;
100 |
101 | #define PROPERTY_DISABLE (0U)
102 | #define PROPERTY_ENABLE (1U)
103 |
104 | /** @addtogroup Interfaces_Functions
105 | * @brief This section provide a set of functions used to read and
106 | * write a generic register of the device.
107 | * MANDATORY: return 0 -> no Error.
108 | * @{
109 | *
110 | */
111 |
112 | typedef int32_t (*stmdev_write_ptr)(void *, uint8_t, const uint8_t *, uint16_t);
113 | typedef int32_t (*stmdev_read_ptr)(void *, uint8_t, uint8_t *, uint16_t);
114 | typedef void (*stmdev_mdelay_ptr)(uint32_t millisec);
115 |
116 | typedef struct
117 | {
118 | /** Component mandatory fields **/
119 | stmdev_write_ptr write_reg;
120 | stmdev_read_ptr read_reg;
121 | /** Component optional fields **/
122 | stmdev_mdelay_ptr mdelay;
123 | /** Customizable optional pointer **/
124 | void *handle;
125 | } stmdev_ctx_t;
126 |
127 | /**
128 | * @}
129 | *
130 | */
131 |
132 | #endif /* MEMS_SHARED_TYPES */
133 |
134 | #ifndef MEMS_UCF_SHARED_TYPES
135 | #define MEMS_UCF_SHARED_TYPES
136 |
137 | /** @defgroup Generic address-data structure definition
138 | * @brief This structure is useful to load a predefined configuration
139 | * of a sensor.
140 | * You can create a sensor configuration by your own or using
141 | * Unico / Unicleo tools available on STMicroelectronics
142 | * web site.
143 | *
144 | * @{
145 | *
146 | */
147 |
148 | typedef struct
149 | {
150 | uint8_t address;
151 | uint8_t data;
152 | } ucf_line_t;
153 |
154 | /**
155 | * @}
156 | *
157 | */
158 |
159 | #endif /* MEMS_UCF_SHARED_TYPES */
160 |
161 | /**
162 | * @}
163 | *
164 | */
165 |
166 | /** @defgroup AIS25BA_Infos
167 | * @{
168 | *
169 | */
170 |
171 | /** I2C Device Address 8 bit format. SA0 = not(I2C_A0 pin) **/
172 | #define AIS25BA_I2C_ADD_L 0x33
173 | #define AIS25BA_I2C_ADD_H 0x31
174 |
175 | /** Device Identification (Who am I) **/
176 | #define AIS25BA_ID 0x20
177 |
178 | /**
179 | * @}
180 | *
181 | */
182 |
183 | #define AIS25BA_TEST_REG 0x0BU
184 | typedef struct
185 | {
186 | #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
187 | uint8_t not_used_01 : 3;
188 | uint8_t st : 1;
189 | uint8_t not_used_02 : 4;
190 | #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
191 | uint8_t not_used_02 : 4;
192 | uint8_t st : 1;
193 | uint8_t not_used_01 : 3;
194 | #endif /* DRV_BYTE_ORDER */
195 | } ais25ba_test_reg_t;
196 |
197 | #define AIS25BA_WHO_AM_I 0x0FU
198 |
199 | #define AIS25BA_TDM_CMAX_H 0x24U
200 | typedef struct
201 | {
202 | #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
203 | uint8_t tdm_cmax : 4;
204 | uint8_t not_used_01 : 4;
205 | #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
206 | uint8_t not_used_01 : 4;
207 | uint8_t tdm_cmax : 4;
208 | #endif /* DRV_BYTE_ORDER */
209 | } ais25ba_tdm_cmax_h_t;
210 |
211 | #define AIS25BA_TDM_CMAX_L 0x25U
212 | typedef struct
213 | {
214 | uint8_t tdm_cmax : 8;
215 | } ais25ba_tdm_cmax_l_t;
216 |
217 | #define AIS25BA_CTRL_REG_1 0x26U
218 | typedef struct
219 | {
220 | #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
221 | uint8_t not_used_01 : 5;
222 | uint8_t pd : 1;
223 | uint8_t not_used_02 : 2;
224 | #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
225 | uint8_t not_used_02 : 2;
226 | uint8_t pd : 1;
227 | uint8_t not_used_01 : 5;
228 | #endif /* DRV_BYTE_ORDER */
229 | } ais25ba_ctrl_reg_t;
230 |
231 | #define AIS25BA_TDM_CTRL_REG 0x2EU
232 | typedef struct
233 | {
234 | #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
235 | uint8_t not_used_01 : 1;
236 | uint8_t wclk_fq : 2;
237 | uint8_t not_used_02 : 1;
238 | uint8_t mapping : 1;
239 | uint8_t data_valid : 1;
240 | uint8_t delayed : 1;
241 | uint8_t tdm_pd : 1;
242 | #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
243 | uint8_t tdm_pd : 1;
244 | uint8_t delayed : 1;
245 | uint8_t data_valid : 1;
246 | uint8_t mapping : 1;
247 | uint8_t not_used_02 : 1;
248 | uint8_t wclk_fq : 2;
249 | uint8_t not_used_01 : 1;
250 | #endif /* DRV_BYTE_ORDER */
251 | } ais25ba_tdm_ctrl_reg_t;
252 |
253 | #define AIS25BA_CTRL_REG_2 0x2FU
254 | typedef struct
255 | {
256 | #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
257 | uint8_t odr_auto_en : 1;
258 | uint8_t not_used_01 : 7;
259 | #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
260 | uint8_t not_used_01 : 7;
261 | uint8_t odr_auto_en : 1;
262 | #endif /* DRV_BYTE_ORDER */
263 | } ais25ba_axes_ctrl_reg_t;
264 |
265 | /**
266 | * @defgroup AIS25BA_Register_Union
267 | * @brief This union group all the registers that has a bitfield
268 | * description.
269 | * This union is useful but not need by the driver.
270 | *
271 | * REMOVING this union you are compliant with:
272 | * MISRA-C 2012 [Rule 19.2] -> " Union are not allowed "
273 | *
274 | * @{
275 | *
276 | */
277 | typedef union
278 | {
279 | ais25ba_test_reg_t test_reg;
280 | ais25ba_tdm_cmax_h_t tdm_cmax_h;
281 | ais25ba_tdm_cmax_l_t tdm_cmax_l;
282 | ais25ba_ctrl_reg_t ctrl_reg;
283 | ais25ba_tdm_ctrl_reg_t tdm_ctrl_reg;
284 | ais25ba_axes_ctrl_reg_t axes_ctrl_reg;
285 | bitwise_t bitwise;
286 | uint8_t byte;
287 | } ais25ba_reg_t;
288 |
289 | /**
290 | * @}
291 | *
292 | */
293 |
294 | #ifndef __weak
295 | #define __weak __attribute__((weak))
296 | #endif /* __weak */
297 |
298 | /*
299 | * These are the basic platform dependent I/O routines to read
300 | * and write device registers connected on a standard bus.
301 | * The driver keeps offering a default implementation based on function
302 | * pointers to read/write routines for backward compatibility.
303 | * The __weak directive allows the final application to overwrite
304 | * them with a custom implementation.
305 | */
306 |
307 | int32_t ais25ba_read_reg(const stmdev_ctx_t *ctx, uint8_t reg,
308 | uint8_t *data,
309 | uint16_t len);
310 | int32_t ais25ba_write_reg(const stmdev_ctx_t *ctx, uint8_t reg,
311 | uint8_t *data,
312 | uint16_t len);
313 |
314 | extern float_t ais25ba_from_raw_to_mg(int16_t lsb);
315 |
316 | typedef struct
317 | {
318 | uint8_t id;
319 | } ais25ba_id_t;
320 | int32_t ais25ba_id_get(const stmdev_ctx_t *ctx, ais25ba_id_t *val);
321 |
322 | typedef struct
323 | {
324 | struct
325 | {
326 | uint8_t en : 1; /* TDM interface 1=on / 0=off) */
327 | uint8_t clk_pol : 1; /* data valid on 0=rise/1=falling edge of BCLK */
328 | uint8_t clk_edge : 1; /* data on 0=first / 1=second valid edge of BCLK */
329 | uint8_t mapping : 1; /* xl data in 0=slot0-1-2 / 1=slot4-5-6 */
330 | uint16_t cmax : 1; /* BCLK in a WCLK (unused if odr=_XL_HW_SEL) */
331 | } tdm;
332 | } ais25ba_bus_mode_t;
333 | int32_t ais25ba_bus_mode_set(const stmdev_ctx_t *ctx,
334 | ais25ba_bus_mode_t *val);
335 | int32_t ais25ba_bus_mode_get(const stmdev_ctx_t *ctx,
336 | ais25ba_bus_mode_t *val);
337 |
338 | typedef struct
339 | {
340 | struct
341 | {
342 | enum
343 | {
344 | AIS25BA_XL_OFF = 0x01, /* in power down */
345 | AIS25BA_XL_8kHz = 0x00, /* sampling rate equal to 8 kHz */
346 | AIS25BA_XL_16kHz = 0x02, /* sampling rate equal to 16 kHz */
347 | AIS25BA_XL_24kHz = 0x04, /* sampling rate equal to 24 kHz */
348 | AIS25BA_XL_HW_SEL = 0x10, /* ratio between the MCLK and WCLK */
349 | } odr;
350 | } xl;
351 | } ais25ba_md_t;
352 | int32_t ais25ba_mode_set(const stmdev_ctx_t *ctx, ais25ba_md_t *val);
353 | int32_t ais25ba_mode_get(const stmdev_ctx_t *ctx, ais25ba_md_t *val);
354 |
355 | typedef struct
356 | {
357 | struct
358 | {
359 | float_t mg[3];
360 | int16_t raw[3];
361 | } xl;
362 | } ais25ba_data_t;
363 | int32_t ais25ba_data_get(uint16_t *tdm_stream, ais25ba_bus_mode_t *md,
364 | ais25ba_data_t *data);
365 |
366 | int32_t ais25ba_self_test_set(const stmdev_ctx_t *ctx, uint8_t val);
367 | int32_t ais25ba_self_test_get(const stmdev_ctx_t *ctx, uint8_t *val);
368 |
369 | /**
370 | * @}
371 | *
372 | */
373 |
374 | #ifdef __cplusplus
375 | }
376 | #endif
377 |
378 | #endif /*AIS25BA_DRIVER_H */
379 |
380 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
381 |
--------------------------------------------------------------------------------
/sensor/stmemsc/lis25ba_STdC/driver/lis25ba_reg.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file lis25ba_reg.h
4 | * @author Sensors Software Solution Team
5 | * @brief This file contains all the functions prototypes for the
6 | * lis25ba_reg.c driver.
7 | ******************************************************************************
8 | * @attention
9 | *
10 | * © Copyright (c) 2021 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under BSD 3-Clause license,
14 | * the "License"; You may not use this file except in compliance with the
15 | * License. You may obtain a copy of the License at:
16 | * opensource.org/licenses/BSD-3-Clause
17 | *
18 | ******************************************************************************
19 | */
20 |
21 | /* Define to prevent recursive inclusion -------------------------------------*/
22 | #ifndef LIS25BA_REGS_H
23 | #define LIS25BA_REGS_H
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | /* Includes ------------------------------------------------------------------*/
30 | #include
31 | #include
32 | #include
33 |
34 | /** @addtogroup LIS25BA
35 | * @{
36 | *
37 | */
38 |
39 | /** @defgroup Endianness definitions
40 | * @{
41 | *
42 | */
43 |
44 | #ifndef DRV_BYTE_ORDER
45 | #ifndef __BYTE_ORDER__
46 |
47 | #define DRV_LITTLE_ENDIAN 1234
48 | #define DRV_BIG_ENDIAN 4321
49 |
50 | /** if _BYTE_ORDER is not defined, choose the endianness of your architecture
51 | * by uncommenting the define which fits your platform endianness
52 | */
53 | //#define DRV_BYTE_ORDER DRV_BIG_ENDIAN
54 | #define DRV_BYTE_ORDER DRV_LITTLE_ENDIAN
55 |
56 | #else /* defined __BYTE_ORDER__ */
57 |
58 | #define DRV_LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
59 | #define DRV_BIG_ENDIAN __ORDER_BIG_ENDIAN__
60 | #define DRV_BYTE_ORDER __BYTE_ORDER__
61 |
62 | #endif /* __BYTE_ORDER__*/
63 | #endif /* DRV_BYTE_ORDER */
64 |
65 | /**
66 | * @}
67 | *
68 | */
69 |
70 | /** @defgroup STMicroelectronics sensors common types
71 | * @{
72 | *
73 | */
74 |
75 | #ifndef MEMS_SHARED_TYPES
76 | #define MEMS_SHARED_TYPES
77 |
78 | typedef struct
79 | {
80 | #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
81 | uint8_t bit0 : 1;
82 | uint8_t bit1 : 1;
83 | uint8_t bit2 : 1;
84 | uint8_t bit3 : 1;
85 | uint8_t bit4 : 1;
86 | uint8_t bit5 : 1;
87 | uint8_t bit6 : 1;
88 | uint8_t bit7 : 1;
89 | #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
90 | uint8_t bit7 : 1;
91 | uint8_t bit6 : 1;
92 | uint8_t bit5 : 1;
93 | uint8_t bit4 : 1;
94 | uint8_t bit3 : 1;
95 | uint8_t bit2 : 1;
96 | uint8_t bit1 : 1;
97 | uint8_t bit0 : 1;
98 | #endif /* DRV_BYTE_ORDER */
99 | } bitwise_t;
100 |
101 | #define PROPERTY_DISABLE (0U)
102 | #define PROPERTY_ENABLE (1U)
103 |
104 | /** @addtogroup Interfaces_Functions
105 | * @brief This section provide a set of functions used to read and
106 | * write a generic register of the device.
107 | * MANDATORY: return 0 -> no Error.
108 | * @{
109 | *
110 | */
111 |
112 | typedef int32_t (*stmdev_write_ptr)(void *, uint8_t, const uint8_t *, uint16_t);
113 | typedef int32_t (*stmdev_read_ptr)(void *, uint8_t, uint8_t *, uint16_t);
114 | typedef void (*stmdev_mdelay_ptr)(uint32_t millisec);
115 |
116 | typedef struct
117 | {
118 | /** Component mandatory fields **/
119 | stmdev_write_ptr write_reg;
120 | stmdev_read_ptr read_reg;
121 | /** Component optional fields **/
122 | stmdev_mdelay_ptr mdelay;
123 | /** Customizable optional pointer **/
124 | void *handle;
125 | } stmdev_ctx_t;
126 |
127 | /**
128 | * @}
129 | *
130 | */
131 |
132 | #endif /* MEMS_SHARED_TYPES */
133 |
134 | #ifndef MEMS_UCF_SHARED_TYPES
135 | #define MEMS_UCF_SHARED_TYPES
136 |
137 | /** @defgroup Generic address-data structure definition
138 | * @brief This structure is useful to load a predefined configuration
139 | * of a sensor.
140 | * You can create a sensor configuration by your own or using
141 | * Unico / Unicleo tools available on STMicroelectronics
142 | * web site.
143 | *
144 | * @{
145 | *
146 | */
147 |
148 | typedef struct
149 | {
150 | uint8_t address;
151 | uint8_t data;
152 | } ucf_line_t;
153 |
154 | /**
155 | * @}
156 | *
157 | */
158 |
159 | #endif /* MEMS_UCF_SHARED_TYPES */
160 |
161 | /**
162 | * @}
163 | *
164 | */
165 |
166 | /** @defgroup LIS25BA_Infos
167 | * @{
168 | *
169 | */
170 |
171 | /** I2C Device Address 8 bit format. SA0 = not(I2C_A0 pin) **/
172 | #define LIS25BA_I2C_ADD_L 0x33
173 | #define LIS25BA_I2C_ADD_H 0x31
174 |
175 | /** Device Identification (Who am I) **/
176 | #define LIS25BA_ID 0x20
177 |
178 | /**
179 | * @}
180 | *
181 | */
182 |
183 | #define LIS25BA_TEST_REG 0x0BU
184 | typedef struct
185 | {
186 | #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
187 | uint8_t not_used_01 : 3;
188 | uint8_t st : 1;
189 | uint8_t not_used_02 : 4;
190 | #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
191 | uint8_t not_used_02 : 4;
192 | uint8_t st : 1;
193 | uint8_t not_used_01 : 3;
194 | #endif /* DRV_BYTE_ORDER */
195 | } lis25ba_test_reg_t;
196 |
197 | #define LIS25BA_WHO_AM_I 0x0FU
198 |
199 | #define LIS25BA_TDM_CMAX_H 0x24U
200 | typedef struct
201 | {
202 | #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
203 | uint8_t tdm_cmax : 4;
204 | uint8_t not_used_01 : 4;
205 | #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
206 | uint8_t not_used_01 : 4;
207 | uint8_t tdm_cmax : 4;
208 | #endif /* DRV_BYTE_ORDER */
209 | } lis25ba_tdm_cmax_h_t;
210 |
211 | #define LIS25BA_TDM_CMAX_L 0x25U
212 | typedef struct
213 | {
214 | uint8_t tdm_cmax : 8;
215 | } lis25ba_tdm_cmax_l_t;
216 |
217 | #define LIS25BA_CTRL_REG 0x26U
218 | typedef struct
219 | {
220 | #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
221 | uint8_t not_used_01 : 5;
222 | uint8_t pd : 1;
223 | uint8_t not_used_02 : 2;
224 | #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
225 | uint8_t not_used_02 : 2;
226 | uint8_t pd : 1;
227 | uint8_t not_used_01 : 5;
228 | #endif /* DRV_BYTE_ORDER */
229 | } lis25ba_ctrl_reg_t;
230 |
231 | #define LIS25BA_TDM_CTRL_REG 0x2EU
232 | typedef struct
233 | {
234 | #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
235 | uint8_t not_used_01 : 1;
236 | uint8_t wclk_fq : 2;
237 | uint8_t not_used_02 : 1;
238 | uint8_t mapping : 1;
239 | uint8_t data_valid : 1;
240 | uint8_t delayed : 1;
241 | uint8_t tdm_pd : 1;
242 | #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
243 | uint8_t tdm_pd : 1;
244 | uint8_t delayed : 1;
245 | uint8_t data_valid : 1;
246 | uint8_t mapping : 1;
247 | uint8_t not_used_02 : 1;
248 | uint8_t wclk_fq : 2;
249 | uint8_t not_used_01 : 1;
250 | #endif /* DRV_BYTE_ORDER */
251 | } lis25ba_tdm_ctrl_reg_t;
252 |
253 | #define LIS25BA_AXES_CTRL_REG 0x2FU
254 | typedef struct
255 | {
256 | #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
257 | uint8_t odr_auto_en : 1;
258 | uint8_t not_used_01 : 4;
259 | uint8_t axisx_en : 1;
260 | uint8_t axisy_en : 1;
261 | uint8_t axisz_en : 1;
262 | #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
263 | uint8_t axisz_en : 1;
264 | uint8_t axisy_en : 1;
265 | uint8_t axisx_en : 1;
266 | uint8_t not_used_01 : 4;
267 | uint8_t odr_auto_en : 1;
268 | #endif /* DRV_BYTE_ORDER */
269 | } lis25ba_axes_ctrl_reg_t;
270 |
271 | /**
272 | * @defgroup LIS25BA_Register_Union
273 | * @brief This union group all the registers that has a bitfield
274 | * description.
275 | * This union is useful but not need by the driver.
276 | *
277 | * REMOVING this union you are compliant with:
278 | * MISRA-C 2012 [Rule 19.2] -> " Union are not allowed "
279 | *
280 | * @{
281 | *
282 | */
283 | typedef union
284 | {
285 | lis25ba_test_reg_t test_reg;
286 | lis25ba_tdm_cmax_h_t tdm_cmax_h;
287 | lis25ba_tdm_cmax_l_t tdm_cmax_l;
288 | lis25ba_ctrl_reg_t ctrl_reg;
289 | lis25ba_tdm_ctrl_reg_t tdm_ctrl_reg;
290 | lis25ba_axes_ctrl_reg_t axes_ctrl_reg;
291 | bitwise_t bitwise;
292 | uint8_t byte;
293 | } lis25ba_reg_t;
294 |
295 | /**
296 | * @}
297 | *
298 | */
299 |
300 | #ifndef __weak
301 | #define __weak __attribute__((weak))
302 | #endif /* __weak */
303 |
304 | /*
305 | * These are the basic platform dependent I/O routines to read
306 | * and write device registers connected on a standard bus.
307 | * The driver keeps offering a default implementation based on function
308 | * pointers to read/write routines for backward compatibility.
309 | * The __weak directive allows the final application to overwrite
310 | * them with a custom implementation.
311 | */
312 |
313 | int32_t lis25ba_read_reg(const stmdev_ctx_t *ctx, uint8_t reg,
314 | uint8_t *data,
315 | uint16_t len);
316 | int32_t lis25ba_write_reg(const stmdev_ctx_t *ctx, uint8_t reg,
317 | uint8_t *data,
318 | uint16_t len);
319 |
320 | extern float_t lis25ba_from_raw_to_mg(int16_t lsb);
321 |
322 | typedef struct
323 | {
324 | uint8_t id;
325 | } lis25ba_id_t;
326 | int32_t lis25ba_id_get(const stmdev_ctx_t *ctx, lis25ba_id_t *val);
327 |
328 | typedef struct
329 | {
330 | struct
331 | {
332 | uint8_t en : 1; /* TDM interface 1=on / 0=off) */
333 | uint8_t clk_pol : 1; /* data valid on 0=rise/1=falling edge of BCLK */
334 | uint8_t clk_edge : 1; /* data on 0=first / 1=second valid edge of BCLK */
335 | uint8_t mapping : 1; /* xl data in 0=slot0-1-2 / 1=slot4-5-6 */
336 | uint16_t cmax : 1; /* BCLK in a WCLK (unused if odr=_XL_HW_SEL) */
337 | } tdm;
338 | } lis25ba_bus_mode_t;
339 | int32_t lis25ba_bus_mode_set(const stmdev_ctx_t *ctx,
340 | lis25ba_bus_mode_t *val);
341 | int32_t lis25ba_bus_mode_get(const stmdev_ctx_t *ctx,
342 | lis25ba_bus_mode_t *val);
343 |
344 | typedef struct
345 | {
346 | struct
347 | {
348 | struct
349 | {
350 | uint8_t x : 1; /* X-axis: 0=disabled / 1=enabled */
351 | uint8_t y : 1; /* Y-axis: 0=disabled / 1=enabled */
352 | uint8_t z : 1; /* Z-axis: 0=disabled / 1=enabled */
353 | } axis;
354 | enum
355 | {
356 | LIS25BA_XL_OFF = 0x01, /* in power down */
357 | LIS25BA_XL_8kHz = 0x00, /* sampling rate equal to 8 kHz */
358 | LIS25BA_XL_16kHz = 0x02, /* sampling rate equal to 16 kHz */
359 | LIS25BA_XL_24kHz = 0x04, /* sampling rate equal to 24 kHz */
360 | LIS25BA_XL_HW_SEL = 0x10, /* ratio between the MCLK and WCLK */
361 | } odr;
362 | } xl;
363 | } lis25ba_md_t;
364 | int32_t lis25ba_mode_set(const stmdev_ctx_t *ctx, lis25ba_md_t *val);
365 | int32_t lis25ba_mode_get(const stmdev_ctx_t *ctx, lis25ba_md_t *val);
366 |
367 | typedef struct
368 | {
369 | struct
370 | {
371 | float_t mg[3];
372 | int16_t raw[3];
373 | } xl;
374 | } lis25ba_data_t;
375 | int32_t lis25ba_data_get(uint16_t *tdm_stream, lis25ba_bus_mode_t *md,
376 | lis25ba_data_t *data);
377 |
378 | int32_t lis25ba_self_test_set(const stmdev_ctx_t *ctx, uint8_t val);
379 | int32_t lis25ba_self_test_get(const stmdev_ctx_t *ctx, uint8_t *val);
380 |
381 | /**
382 | * @}
383 | *
384 | */
385 |
386 | #ifdef __cplusplus
387 | }
388 | #endif
389 |
390 | #endif /*LIS25BA_DRIVER_H */
391 |
392 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
393 |
--------------------------------------------------------------------------------
/sensor/stmemsc/lps33k_STdC/driver/lps33k_reg.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file lps33k_reg.h
4 | * @author Sensors Software Solution Team
5 | * @brief This file contains all the functions prototypes for the
6 | * lps33k_reg.c driver.
7 | ******************************************************************************
8 | * @attention
9 | *
10 | * © Copyright (c) 2021 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under BSD 3-Clause license,
14 | * the "License"; You may not use this file except in compliance with the
15 | * License. You may obtain a copy of the License at:
16 | * opensource.org/licenses/BSD-3-Clause
17 | *
18 | ******************************************************************************
19 | */
20 |
21 | /* Define to prevent recursive inclusion -------------------------------------*/
22 | #ifndef LPS33K_REGS_H
23 | #define LPS33K_REGS_H
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | /* Includes ------------------------------------------------------------------*/
30 | #include
31 | #include
32 | #include
33 |
34 | /** @addtogroup LPS33K
35 | * @{
36 | *
37 | */
38 |
39 | /** @defgroup Endianness definitions
40 | * @{
41 | *
42 | */
43 |
44 | #ifndef DRV_BYTE_ORDER
45 | #ifndef __BYTE_ORDER__
46 |
47 | #define DRV_LITTLE_ENDIAN 1234
48 | #define DRV_BIG_ENDIAN 4321
49 |
50 | /** if _BYTE_ORDER is not defined, choose the endianness of your architecture
51 | * by uncommenting the define which fits your platform endianness
52 | */
53 | //#define DRV_BYTE_ORDER DRV_BIG_ENDIAN
54 | #define DRV_BYTE_ORDER DRV_LITTLE_ENDIAN
55 |
56 | #else /* defined __BYTE_ORDER__ */
57 |
58 | #define DRV_LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
59 | #define DRV_BIG_ENDIAN __ORDER_BIG_ENDIAN__
60 | #define DRV_BYTE_ORDER __BYTE_ORDER__
61 |
62 | #endif /* __BYTE_ORDER__*/
63 | #endif /* DRV_BYTE_ORDER */
64 |
65 | /**
66 | * @}
67 | *
68 | */
69 |
70 | /** @defgroup STMicroelectronics sensors common types
71 | * @{
72 | *
73 | */
74 |
75 | #ifndef MEMS_SHARED_TYPES
76 | #define MEMS_SHARED_TYPES
77 |
78 | typedef struct
79 | {
80 | #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
81 | uint8_t bit0 : 1;
82 | uint8_t bit1 : 1;
83 | uint8_t bit2 : 1;
84 | uint8_t bit3 : 1;
85 | uint8_t bit4 : 1;
86 | uint8_t bit5 : 1;
87 | uint8_t bit6 : 1;
88 | uint8_t bit7 : 1;
89 | #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
90 | uint8_t bit7 : 1;
91 | uint8_t bit6 : 1;
92 | uint8_t bit5 : 1;
93 | uint8_t bit4 : 1;
94 | uint8_t bit3 : 1;
95 | uint8_t bit2 : 1;
96 | uint8_t bit1 : 1;
97 | uint8_t bit0 : 1;
98 | #endif /* DRV_BYTE_ORDER */
99 | } bitwise_t;
100 |
101 | #define PROPERTY_DISABLE (0U)
102 | #define PROPERTY_ENABLE (1U)
103 |
104 | /** @addtogroup Interfaces_Functions
105 | * @brief This section provide a set of functions used to read and
106 | * write a generic register of the device.
107 | * MANDATORY: return 0 -> no Error.
108 | * @{
109 | *
110 | */
111 |
112 | typedef int32_t (*stmdev_write_ptr)(void *, uint8_t, const uint8_t *, uint16_t);
113 | typedef int32_t (*stmdev_read_ptr)(void *, uint8_t, uint8_t *, uint16_t);
114 | typedef void (*stmdev_mdelay_ptr)(uint32_t millisec);
115 |
116 | typedef struct
117 | {
118 | /** Component mandatory fields **/
119 | stmdev_write_ptr write_reg;
120 | stmdev_read_ptr read_reg;
121 | /** Component optional fields **/
122 | stmdev_mdelay_ptr mdelay;
123 | /** Customizable optional pointer **/
124 | void *handle;
125 | } stmdev_ctx_t;
126 |
127 | /**
128 | * @}
129 | *
130 | */
131 |
132 | #endif /* MEMS_SHARED_TYPES */
133 |
134 | #ifndef MEMS_UCF_SHARED_TYPES
135 | #define MEMS_UCF_SHARED_TYPES
136 |
137 | /** @defgroup Generic address-data structure definition
138 | * @brief This structure is useful to load a predefined configuration
139 | * of a sensor.
140 | * You can create a sensor configuration by your own or using
141 | * Unico / Unicleo tools available on STMicroelectronics
142 | * web site.
143 | *
144 | * @{
145 | *
146 | */
147 |
148 | typedef struct
149 | {
150 | uint8_t address;
151 | uint8_t data;
152 | } ucf_line_t;
153 |
154 | /**
155 | * @}
156 | *
157 | */
158 |
159 | #endif /* MEMS_UCF_SHARED_TYPES */
160 |
161 | /**
162 | * @}
163 | *
164 | */
165 |
166 |
167 | /** @defgroup LPS22HB_Infos
168 | * @{
169 | *
170 | */
171 |
172 | /** I2C Device Address 8 bit format. **/
173 | #define LPS33K_I2C_ADD 0xBBU
174 |
175 | /** Device Identification (Who am I) **/
176 | #define LPS33K_ID 0xB1U
177 |
178 | /**
179 | * @}
180 | *
181 | */
182 |
183 | #define LPS33K_WHO_AM_I 0x0FU
184 | #define LPS33K_CTRL_REG1 0x10U
185 | typedef struct
186 | {
187 | #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
188 | uint8_t not_used_01 : 1;
189 | uint8_t bdu : 1;
190 | uint8_t lpfp : 2; /* en_lpfp + lpfp_cfg -> lpfp */
191 | uint8_t odr : 3;
192 | uint8_t not_used_02 : 1;
193 | #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
194 | uint8_t not_used_02 : 1;
195 | uint8_t odr : 3;
196 | uint8_t lpfp : 2; /* en_lpfp + lpfp_cfg -> lpfp */
197 | uint8_t bdu : 1;
198 | uint8_t not_used_01 : 1;
199 | #endif /* DRV_BYTE_ORDER */
200 | } lps33k_ctrl_reg1_t;
201 |
202 | #define LPS33K_CTRL_REG2 0x11U
203 | typedef struct
204 | {
205 | #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
206 | uint8_t one_shot : 1;
207 | uint8_t not_used_01 : 1;
208 | uint8_t swreset : 1;
209 | uint8_t not_used_02 : 1;
210 | uint8_t if_add_inc : 1;
211 | uint8_t not_used_03 : 2;
212 | uint8_t boot : 1;
213 | #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
214 | uint8_t boot : 1;
215 | uint8_t not_used_03 : 2;
216 | uint8_t if_add_inc : 1;
217 | uint8_t not_used_02 : 1;
218 | uint8_t swreset : 1;
219 | uint8_t not_used_01 : 1;
220 | uint8_t one_shot : 1;
221 | #endif /* DRV_BYTE_ORDER */
222 | } lps33k_ctrl_reg2_t;
223 |
224 | #define LPS33K_RPDS_L 0x18U
225 | #define LPS33K_RPDS_H 0x19U
226 |
227 | #define LPS33K_RES_CONF 0x1AU
228 | typedef struct
229 | {
230 | #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
231 | uint8_t lc_en : 1;
232 | uint8_t not_used_01 : 7;
233 | #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
234 | uint8_t not_used_01 : 7;
235 | uint8_t lc_en : 1;
236 | #endif /* DRV_BYTE_ORDER */
237 | } lps33k_res_conf_t;
238 |
239 | #define LPS33K_STATUS 0x27U
240 | typedef struct
241 | {
242 | #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
243 | uint8_t p_da : 1;
244 | uint8_t t_da : 1;
245 | uint8_t not_used_02 : 2;
246 | uint8_t p_or : 1;
247 | uint8_t t_or : 1;
248 | uint8_t not_used_01 : 2;
249 | #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
250 | uint8_t not_used_01 : 2;
251 | uint8_t t_or : 1;
252 | uint8_t p_or : 1;
253 | uint8_t not_used_02 : 2;
254 | uint8_t t_da : 1;
255 | uint8_t p_da : 1;
256 | #endif /* DRV_BYTE_ORDER */
257 | } lps33k_status_t;
258 |
259 | #define LPS33K_PRESS_OUT_XL 0x28U
260 | #define LPS33K_PRESS_OUT_L 0x29U
261 | #define LPS33K_PRESS_OUT_H 0x2AU
262 | #define LPS33K_TEMP_OUT_L 0x2BU
263 | #define LPS33K_TEMP_OUT_H 0x2CU
264 | #define LPS33K_LPFP_RES 0x33U
265 |
266 | /**
267 | * @defgroup LPS33K_Register_Union
268 | * @brief This union group all the registers having a bit-field
269 | * description.
270 | * This union is useful but it's not needed by the driver.
271 | *
272 | * REMOVING this union you are compliant with:
273 | * MISRA-C 2012 [Rule 19.2] -> " Union are not allowed "
274 | *
275 | * @{
276 | *
277 | */
278 |
279 | typedef union
280 | {
281 | lps33k_ctrl_reg1_t ctrl_reg1;
282 | lps33k_ctrl_reg2_t ctrl_reg2;
283 | lps33k_res_conf_t res_conf;
284 | lps33k_status_t status;
285 | bitwise_t bitwise;
286 | uint8_t byte;
287 | } lps33k_reg_t;
288 |
289 | /**
290 | * @}
291 | *
292 | */
293 |
294 | #ifndef __weak
295 | #define __weak __attribute__((weak))
296 | #endif /* __weak */
297 |
298 | /*
299 | * These are the basic platform dependent I/O routines to read
300 | * and write device registers connected on a standard bus.
301 | * The driver keeps offering a default implementation based on function
302 | * pointers to read/write routines for backward compatibility.
303 | * The __weak directive allows the final application to overwrite
304 | * them with a custom implementation.
305 | */
306 |
307 | int32_t lps33k_read_reg(const stmdev_ctx_t *ctx, uint8_t reg, uint8_t *data,
308 | uint16_t len);
309 | int32_t lps33k_write_reg(const stmdev_ctx_t *ctx, uint8_t reg,
310 | uint8_t *data,
311 | uint16_t len);
312 |
313 | float_t lps33k_from_lsb_to_hpa(int32_t lsb);
314 |
315 | float_t lps33k_from_lsb_to_degc(int16_t lsb);
316 |
317 | int32_t lps33k_block_data_update_set(const stmdev_ctx_t *ctx, uint8_t val);
318 | int32_t lps33k_block_data_update_get(const stmdev_ctx_t *ctx, uint8_t *val);
319 |
320 | typedef enum
321 | {
322 | LPS33K_LPF_ODR_DIV_2 = 0,
323 | LPS33K_LPF_ODR_DIV_9 = 2,
324 | LPS33K_LPF_ODR_DIV_20 = 3,
325 | } lps33k_lpfp_t;
326 | int32_t lps33k_low_pass_filter_mode_set(const stmdev_ctx_t *ctx,
327 | lps33k_lpfp_t val);
328 | int32_t lps33k_low_pass_filter_mode_get(const stmdev_ctx_t *ctx,
329 | lps33k_lpfp_t *val);
330 |
331 | typedef enum
332 | {
333 | LPS33K_POWER_DOWN = 0,
334 | LPS33K_ODR_1_Hz = 1,
335 | LPS33K_ODR_10_Hz = 2,
336 | LPS33K_ODR_25_Hz = 3,
337 | LPS33K_ODR_50_Hz = 4,
338 | LPS33K_ODR_75_Hz = 5,
339 | } lps33k_odr_t;
340 | int32_t lps33k_data_rate_set(const stmdev_ctx_t *ctx, lps33k_odr_t val);
341 | int32_t lps33k_data_rate_get(const stmdev_ctx_t *ctx, lps33k_odr_t *val);
342 |
343 | int32_t lps33k_one_shoot_trigger_set(const stmdev_ctx_t *ctx, uint8_t val);
344 | int32_t lps33k_one_shoot_trigger_get(const stmdev_ctx_t *ctx, uint8_t *val);
345 |
346 | int32_t lps33k_pressure_offset_set(const stmdev_ctx_t *ctx, int16_t val);
347 | int32_t lps33k_pressure_offset_get(const stmdev_ctx_t *ctx, int16_t *val);
348 |
349 | int32_t lps33k_press_data_ready_get(const stmdev_ctx_t *ctx, uint8_t *val);
350 |
351 | int32_t lps33k_temp_data_ready_get(const stmdev_ctx_t *ctx, uint8_t *val);
352 |
353 | int32_t lps33k_press_data_ovr_get(const stmdev_ctx_t *ctx, uint8_t *val);
354 |
355 | int32_t lps33k_temp_data_ovr_get(const stmdev_ctx_t *ctx, uint8_t *val);
356 |
357 | int32_t lps33k_pressure_raw_get(const stmdev_ctx_t *ctx, uint32_t *buff);
358 |
359 | int32_t lps33k_temperature_raw_get(const stmdev_ctx_t *ctx, int16_t *buff);
360 |
361 | int32_t lps33k_low_pass_rst_get(const stmdev_ctx_t *ctx, uint8_t *buff);
362 |
363 | int32_t lps33k_device_id_get(const stmdev_ctx_t *ctx, uint8_t *buff);
364 |
365 | int32_t lps33k_reset_set(const stmdev_ctx_t *ctx, uint8_t val);
366 | int32_t lps33k_reset_get(const stmdev_ctx_t *ctx, uint8_t *val);
367 |
368 | int32_t lps33k_boot_set(const stmdev_ctx_t *ctx, uint8_t val);
369 | int32_t lps33k_boot_get(const stmdev_ctx_t *ctx, uint8_t *val);
370 |
371 | int32_t lps33k_low_power_set(const stmdev_ctx_t *ctx, uint8_t val);
372 | int32_t lps33k_low_power_get(const stmdev_ctx_t *ctx, uint8_t *val);
373 |
374 | int32_t lps33k_auto_add_inc_set(const stmdev_ctx_t *ctx, uint8_t val);
375 | int32_t lps33k_auto_add_inc_get(const stmdev_ctx_t *ctx, uint8_t *val);
376 |
377 | /**
378 | *@}
379 | *
380 | */
381 |
382 | #ifdef __cplusplus
383 | }
384 | #endif
385 |
386 | #endif /* LPS33K_REGS_H */
387 |
388 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
389 |
--------------------------------------------------------------------------------
/sensor/stmemsc/stts22h_STdC/driver/stts22h_reg.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stts22h_reg.h
4 | * @author Sensors Software Solution Team
5 | * @brief This file contains all the functions prototypes for the
6 | * stts22h_reg.c driver.
7 | ******************************************************************************
8 | * @attention
9 | *
10 | * © Copyright (c) 2021 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under BSD 3-Clause license,
14 | * the "License"; You may not use this file except in compliance with the
15 | * License. You may obtain a copy of the License at:
16 | * opensource.org/licenses/BSD-3-Clause
17 | *
18 | ******************************************************************************
19 | */
20 |
21 | /* Define to prevent recursive inclusion -------------------------------------*/
22 | #ifndef STTS22H_REGS_H
23 | #define STTS22H_REGS_H
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | /* Includes ------------------------------------------------------------------*/
30 | #include
31 | #include
32 | #include
33 |
34 | /** @addtogroup STTS22H
35 | * @{
36 | *
37 | */
38 |
39 | /** @defgroup Endianness definitions
40 | * @{
41 | *
42 | */
43 |
44 | #ifndef DRV_BYTE_ORDER
45 | #ifndef __BYTE_ORDER__
46 |
47 | #define DRV_LITTLE_ENDIAN 1234
48 | #define DRV_BIG_ENDIAN 4321
49 |
50 | /** if _BYTE_ORDER is not defined, choose the endianness of your architecture
51 | * by uncommenting the define which fits your platform endianness
52 | */
53 | //#define DRV_BYTE_ORDER DRV_BIG_ENDIAN
54 | #define DRV_BYTE_ORDER DRV_LITTLE_ENDIAN
55 |
56 | #else /* defined __BYTE_ORDER__ */
57 |
58 | #define DRV_LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
59 | #define DRV_BIG_ENDIAN __ORDER_BIG_ENDIAN__
60 | #define DRV_BYTE_ORDER __BYTE_ORDER__
61 |
62 | #endif /* __BYTE_ORDER__*/
63 | #endif /* DRV_BYTE_ORDER */
64 |
65 | /**
66 | * @}
67 | *
68 | */
69 |
70 | /** @defgroup STMicroelectronics sensors common types
71 | * @{
72 | *
73 | */
74 |
75 | #ifndef MEMS_SHARED_TYPES
76 | #define MEMS_SHARED_TYPES
77 |
78 | typedef struct
79 | {
80 | #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
81 | uint8_t bit0 : 1;
82 | uint8_t bit1 : 1;
83 | uint8_t bit2 : 1;
84 | uint8_t bit3 : 1;
85 | uint8_t bit4 : 1;
86 | uint8_t bit5 : 1;
87 | uint8_t bit6 : 1;
88 | uint8_t bit7 : 1;
89 | #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
90 | uint8_t bit7 : 1;
91 | uint8_t bit6 : 1;
92 | uint8_t bit5 : 1;
93 | uint8_t bit4 : 1;
94 | uint8_t bit3 : 1;
95 | uint8_t bit2 : 1;
96 | uint8_t bit1 : 1;
97 | uint8_t bit0 : 1;
98 | #endif /* DRV_BYTE_ORDER */
99 | } bitwise_t;
100 |
101 | #define PROPERTY_DISABLE (0U)
102 | #define PROPERTY_ENABLE (1U)
103 |
104 | /** @addtogroup Interfaces_Functions
105 | * @brief This section provide a set of functions used to read and
106 | * write a generic register of the device.
107 | * MANDATORY: return 0 -> no Error.
108 | * @{
109 | *
110 | */
111 |
112 | typedef int32_t (*stmdev_write_ptr)(void *, uint8_t, const uint8_t *, uint16_t);
113 | typedef int32_t (*stmdev_read_ptr)(void *, uint8_t, uint8_t *, uint16_t);
114 | typedef void (*stmdev_mdelay_ptr)(uint32_t millisec);
115 |
116 | typedef struct
117 | {
118 | /** Component mandatory fields **/
119 | stmdev_write_ptr write_reg;
120 | stmdev_read_ptr read_reg;
121 | /** Component optional fields **/
122 | stmdev_mdelay_ptr mdelay;
123 | /** Customizable optional pointer **/
124 | void *handle;
125 | } stmdev_ctx_t;
126 |
127 | /**
128 | * @}
129 | *
130 | */
131 |
132 | #endif /* MEMS_SHARED_TYPES */
133 |
134 | /**
135 | * @}
136 | *
137 | */
138 |
139 | /** @defgroup STTS22H_Infos
140 | * @{
141 | *
142 | */
143 |
144 | /** I2C Device Address 8 bit format **/
145 | #define STTS22H_I2C_ADD_H 0x71U
146 | #define STTS22H_I2C_ADD_L 0x7FU
147 |
148 | /** Device Identification (Who am I) **/
149 | #define STTS22H_ID 0xA0U
150 |
151 | /**
152 | * @}
153 | *
154 | */
155 |
156 | #define STTS22H_WHOAMI 0x01U
157 | #define STTS22H_TEMP_H_LIMIT 0x02U
158 | typedef struct
159 | {
160 | uint8_t thl : 8;
161 | } stts22h_temp_h_limit_t;
162 |
163 | #define STTS22H_TEMP_L_LIMIT 0x03U
164 | typedef struct
165 | {
166 | uint8_t tll : 8;
167 | } stts22h_temp_l_limit_t;
168 |
169 | #define STTS22H_CTRL 0x04U
170 | typedef struct
171 | {
172 | #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
173 | uint8_t one_shot : 1;
174 | uint8_t time_out_dis : 1;
175 | uint8_t freerun : 1;
176 | uint8_t if_add_inc : 1;
177 | uint8_t avg : 2;
178 | uint8_t bdu : 1;
179 | uint8_t low_odr_start : 1;
180 | #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
181 | uint8_t low_odr_start : 1;
182 | uint8_t bdu : 1;
183 | uint8_t avg : 2;
184 | uint8_t if_add_inc : 1;
185 | uint8_t freerun : 1;
186 | uint8_t time_out_dis : 1;
187 | uint8_t one_shot : 1;
188 | #endif /* DRV_BYTE_ORDER */
189 | } stts22h_ctrl_t;
190 |
191 | #define STTS22H_STATUS 0x05U
192 | typedef struct
193 | {
194 | #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
195 | uint8_t busy : 1;
196 | uint8_t over_thh : 1;
197 | uint8_t under_thl : 1;
198 | uint8_t not_used_01 : 5;
199 | #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
200 | uint8_t not_used_01 : 5;
201 | uint8_t under_thl : 1;
202 | uint8_t over_thh : 1;
203 | uint8_t busy : 1;
204 | #endif /* DRV_BYTE_ORDER */
205 | } stts22h_status_t;
206 |
207 | #define STTS22H_TEMP_L_OUT 0x06U
208 | #define STTS22H_TEMP_H_OUT 0x07U
209 |
210 | #ifndef __weak
211 | #define __weak __attribute__((weak))
212 | #endif /* __weak */
213 |
214 | /*
215 | * These are the basic platform dependent I/O routines to read
216 | * and write device registers connected on a standard bus.
217 | * The driver keeps offering a default implementation based on function
218 | * pointers to read/write routines for backward compatibility.
219 | * The __weak directive allows the final application to overwrite
220 | * them with a custom implementation.
221 | */
222 |
223 | int32_t stts22h_read_reg(const stmdev_ctx_t *ctx, uint8_t reg,
224 | uint8_t *data,
225 | uint16_t len);
226 | int32_t stts22h_write_reg(const stmdev_ctx_t *ctx, uint8_t reg,
227 | const uint8_t *data,
228 | uint16_t len);
229 |
230 | float_t stts22h_from_lsb_to_celsius(int16_t lsb);
231 |
232 | typedef enum
233 | {
234 | STTS22H_POWER_DOWN = 0x00,
235 | STTS22H_ONE_SHOT = 0x01,
236 | STTS22H_1Hz = 0x04,
237 | STTS22H_25Hz = 0x02,
238 | STTS22H_50Hz = 0x12,
239 | STTS22H_100Hz = 0x22,
240 | STTS22H_200Hz = 0x32,
241 | } stts22h_odr_temp_t;
242 | int32_t stts22h_temp_data_rate_set(const stmdev_ctx_t *ctx,
243 | stts22h_odr_temp_t val);
244 | int32_t stts22h_temp_data_rate_get(const stmdev_ctx_t *ctx,
245 | stts22h_odr_temp_t *val);
246 |
247 | int32_t stts22h_block_data_update_set(const stmdev_ctx_t *ctx, uint8_t val);
248 | int32_t stts22h_block_data_update_get(const stmdev_ctx_t *ctx,
249 | uint8_t *val);
250 |
251 | int32_t stts22h_temp_flag_data_ready_get(const stmdev_ctx_t *ctx,
252 | uint8_t *val);
253 |
254 | int32_t stts22h_temperature_raw_get(const stmdev_ctx_t *ctx, int16_t *val);
255 |
256 | int32_t stts22h_dev_id_get(const stmdev_ctx_t *ctx, uint8_t *buff);
257 |
258 | typedef struct
259 | {
260 | uint8_t busy : 1;
261 | } stts22h_dev_status_t;
262 | int32_t stts22h_dev_status_get(const stmdev_ctx_t *ctx,
263 | stts22h_dev_status_t *val);
264 |
265 | typedef enum
266 | {
267 | STTS22H_SMBUS_TIMEOUT_ENABLE = 0,
268 | STTS22H_SMBUS_TIMEOUT_DISABLE = 1,
269 | } stts22h_smbus_md_t;
270 | int32_t stts22h_smbus_interface_set(const stmdev_ctx_t *ctx,
271 | stts22h_smbus_md_t val);
272 | int32_t stts22h_smbus_interface_get(const stmdev_ctx_t *ctx,
273 | stts22h_smbus_md_t *val);
274 |
275 | int32_t stts22h_auto_increment_set(const stmdev_ctx_t *ctx, uint8_t val);
276 | int32_t stts22h_auto_increment_get(const stmdev_ctx_t *ctx, uint8_t *val);
277 |
278 | int32_t stts22h_temp_trshld_high_set(const stmdev_ctx_t *ctx, uint8_t val);
279 | int32_t stts22h_temp_trshld_high_get(const stmdev_ctx_t *ctx, uint8_t *val);
280 |
281 | int32_t stts22h_temp_trshld_low_set(const stmdev_ctx_t *ctx, uint8_t val);
282 | int32_t stts22h_temp_trshld_low_get(const stmdev_ctx_t *ctx, uint8_t *val);
283 |
284 | typedef struct
285 | {
286 | uint8_t under_thl : 1;
287 | uint8_t over_thh : 1;
288 | } stts22h_temp_trlhd_src_t;
289 | int32_t stts22h_temp_trshld_src_get(const stmdev_ctx_t *ctx,
290 | stts22h_temp_trlhd_src_t *val);
291 |
292 | /**
293 | *@}
294 | *
295 | */
296 |
297 | #ifdef __cplusplus
298 | }
299 | #endif
300 |
301 | #endif /* STTS22H_REGS_H */
302 |
303 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
304 |
--------------------------------------------------------------------------------
/sensor/vl53l0x/README:
--------------------------------------------------------------------------------
1 | VL53L0X
2 | #######
3 |
4 | Origin:
5 | ST Microelectronics
6 | http://www.st.com/en/embedded-software/stsw-img005.html
7 |
8 | Status:
9 | version 1.0.2
10 |
11 | Purpose:
12 | ST Microelectonics official API to use vl53l0x sensor.
13 |
14 | Description:
15 | This library written by STMicroelectronics is dedicated to vl53l0x time of flight sensor.
16 | Instead of providing a full description of the registers, ST decided to provide a C library to drive this sensor.
17 |
18 | This library is called from the vl53l0x driver and is kept transparent for user.
19 | User is calling a standard Zephyr driver and then, the driver makes some calls to this library.
20 |
21 | In order to fit with Zephyr rules and simplify version updates, we have done a minimum of modifications :
22 | - keep only API directory
23 | (remove documentation and samples, see ST website for this)
24 | - rename Api to api
25 | - customize api/platform to fit in Zephyr (mainly for I2C access)
26 | vl53l0x_platform.c has been moved to Zephyr drivers directory.
27 |
28 | In order to use this library, you have to :
29 | * define CONFIG_HAS_STLIB and CONFIG_VL53L0X
30 | * use NEWLIB_LIBC in prj.conf (needed for abs function)
31 | * include vl53l0x_api.h and vl53l0x_platform.h in the driver .h
32 |
33 | Dependencies:
34 | This package depends on Zephyr I2C implementation and is linked statically.
35 | This library will be used by a standard Zephyr driver.
36 |
37 | URL:
38 | http://www.st.com/en/embedded-software/stsw-img005.html
39 |
40 | commit:
41 | version 1.0.2
42 |
43 | Maintained-by:
44 | External
45 |
46 | License:
47 | BSD-3-Clause
48 |
49 | License Link:
50 | http://www.st.com/en/embedded-software/stsw-img005.html
51 |
52 | Patch List:
53 |
54 | *Cast unsigned abs param to signed type
55 | This will prevent a compiler warning when using clang
56 | without -ffreestanding
57 | Impacted files:
58 | api/core/src/vl53l0x_api_core.c
59 |
--------------------------------------------------------------------------------
/sensor/vl53l0x/api/core/inc/vl53l0x_api.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zephyrproject-rtos/hal_st/9f81b4427e955885398805b7bca0da3a8cd9109c/sensor/vl53l0x/api/core/inc/vl53l0x_api.h
--------------------------------------------------------------------------------
/sensor/vl53l0x/api/core/inc/vl53l0x_api_calibration.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zephyrproject-rtos/hal_st/9f81b4427e955885398805b7bca0da3a8cd9109c/sensor/vl53l0x/api/core/inc/vl53l0x_api_calibration.h
--------------------------------------------------------------------------------
/sensor/vl53l0x/api/core/inc/vl53l0x_api_core.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zephyrproject-rtos/hal_st/9f81b4427e955885398805b7bca0da3a8cd9109c/sensor/vl53l0x/api/core/inc/vl53l0x_api_core.h
--------------------------------------------------------------------------------
/sensor/vl53l0x/api/core/inc/vl53l0x_api_ranging.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zephyrproject-rtos/hal_st/9f81b4427e955885398805b7bca0da3a8cd9109c/sensor/vl53l0x/api/core/inc/vl53l0x_api_ranging.h
--------------------------------------------------------------------------------
/sensor/vl53l0x/api/core/inc/vl53l0x_api_strings.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zephyrproject-rtos/hal_st/9f81b4427e955885398805b7bca0da3a8cd9109c/sensor/vl53l0x/api/core/inc/vl53l0x_api_strings.h
--------------------------------------------------------------------------------
/sensor/vl53l0x/api/core/inc/vl53l0x_def.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zephyrproject-rtos/hal_st/9f81b4427e955885398805b7bca0da3a8cd9109c/sensor/vl53l0x/api/core/inc/vl53l0x_def.h
--------------------------------------------------------------------------------
/sensor/vl53l0x/api/core/inc/vl53l0x_device.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zephyrproject-rtos/hal_st/9f81b4427e955885398805b7bca0da3a8cd9109c/sensor/vl53l0x/api/core/inc/vl53l0x_device.h
--------------------------------------------------------------------------------
/sensor/vl53l0x/api/core/inc/vl53l0x_interrupt_threshold_settings.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zephyrproject-rtos/hal_st/9f81b4427e955885398805b7bca0da3a8cd9109c/sensor/vl53l0x/api/core/inc/vl53l0x_interrupt_threshold_settings.h
--------------------------------------------------------------------------------
/sensor/vl53l0x/api/core/inc/vl53l0x_tuning.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zephyrproject-rtos/hal_st/9f81b4427e955885398805b7bca0da3a8cd9109c/sensor/vl53l0x/api/core/inc/vl53l0x_tuning.h
--------------------------------------------------------------------------------
/sensor/vl53l0x/api/core/src/vl53l0x_api.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zephyrproject-rtos/hal_st/9f81b4427e955885398805b7bca0da3a8cd9109c/sensor/vl53l0x/api/core/src/vl53l0x_api.c
--------------------------------------------------------------------------------
/sensor/vl53l0x/api/core/src/vl53l0x_api_calibration.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zephyrproject-rtos/hal_st/9f81b4427e955885398805b7bca0da3a8cd9109c/sensor/vl53l0x/api/core/src/vl53l0x_api_calibration.c
--------------------------------------------------------------------------------
/sensor/vl53l0x/api/core/src/vl53l0x_api_core.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zephyrproject-rtos/hal_st/9f81b4427e955885398805b7bca0da3a8cd9109c/sensor/vl53l0x/api/core/src/vl53l0x_api_core.c
--------------------------------------------------------------------------------
/sensor/vl53l0x/api/core/src/vl53l0x_api_ranging.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zephyrproject-rtos/hal_st/9f81b4427e955885398805b7bca0da3a8cd9109c/sensor/vl53l0x/api/core/src/vl53l0x_api_ranging.c
--------------------------------------------------------------------------------
/sensor/vl53l0x/api/core/src/vl53l0x_api_strings.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zephyrproject-rtos/hal_st/9f81b4427e955885398805b7bca0da3a8cd9109c/sensor/vl53l0x/api/core/src/vl53l0x_api_strings.c
--------------------------------------------------------------------------------
/sensor/vl53l1x/README:
--------------------------------------------------------------------------------
1 | VL53L1X
2 | #######
3 |
4 | Origin:
5 | ST Microelectronics
6 | https://www.st.com/en/embedded-software/stsw-img007.html
7 |
8 | Status:
9 | version 2.4.5
10 |
11 | Purpose:
12 | ST Microelectonics official API to use vl53l1x sensor.
13 |
14 | Description:
15 | This library written by STMicroelectronics is dedicated to vl53l1x time of flight sensor.
16 |
17 | This library is called from the vl53l1x driver and is kept transparent for user.
18 | User is calling a standard Zephyr driver and then the driver makes some calls to this library.
19 |
20 | In order to fit with Zephyr rules and simplify version updates, we have done a minimum of modifications :
21 | - split headers and source to inc/src
22 | - keep only API directory
23 | (remove documentation and samples, see ST website for this)
24 |
25 | In order to use this library, you have to :
26 | * define CONFIG_HAS_STLIB and CONFIG_VL53L1X
27 | * use NEWLIB_LIBC in prj.conf (needed for abs function)
28 | * include vl53l1_api.h and vl53l1_platform.h in the driver .h
29 |
30 | Dependencies:
31 | This package depends on Zephyr I2C implementation and is linked statically.
32 | This library will be used by a standard Zephyr driver.
33 |
34 | URL:
35 | http://www.st.com/en/embedded-software/stsw-img007.html
36 |
37 | commit:
38 | version 2.4.5
39 |
40 | Maintained-by:
41 | External
42 |
43 | License:
44 | BSD-3-Clause
45 |
46 | License Link:
47 | http://www.st.com/en/embedded-software/stsw-img007.html
48 |
--------------------------------------------------------------------------------
/sensor/vl53l1x/api/core/inc/vl53l1_api_calibration.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, STMicroelectronics - All Rights Reserved
3 | *
4 | * This file is part of VL53L1 Core and is dual licensed,
5 | * either 'STMicroelectronics
6 | * Proprietary license'
7 | * or 'BSD 3-clause "New" or "Revised" License' , at your option.
8 | *
9 | ********************************************************************************
10 | *
11 | * 'STMicroelectronics Proprietary license'
12 | *
13 | ********************************************************************************
14 | *
15 | * License terms: STMicroelectronics Proprietary in accordance with licensing
16 | * terms at www.st.com/sla0081
17 | *
18 | * STMicroelectronics confidential
19 | * Reproduction and Communication of this document is strictly prohibited unless
20 | * specifically authorized in writing by STMicroelectronics.
21 | *
22 | *
23 | ********************************************************************************
24 | *
25 | * Alternatively, VL53L1 Core may be distributed under the terms of
26 | * 'BSD 3-clause "New" or "Revised" License', in which case the following
27 | * provisions apply instead of the ones mentioned above :
28 | *
29 | ********************************************************************************
30 | *
31 | * License terms: BSD 3-clause "New" or "Revised" License.
32 | *
33 | * Redistribution and use in source and binary forms, with or without
34 | * modification, are permitted provided that the following conditions are met:
35 | *
36 | * 1. Redistributions of source code must retain the above copyright notice, this
37 | * list of conditions and the following disclaimer.
38 | *
39 | * 2. Redistributions in binary form must reproduce the above copyright notice,
40 | * this list of conditions and the following disclaimer in the documentation
41 | * and/or other materials provided with the distribution.
42 | *
43 | * 3. Neither the name of the copyright holder nor the names of its contributors
44 | * may be used to endorse or promote products derived from this software
45 | * without specific prior written permission.
46 | *
47 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
48 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
51 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
53 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
54 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
55 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
56 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 | *
58 | *
59 | ********************************************************************************
60 | *
61 | */
62 |
63 | /**
64 | * @file vl53l1_api_core.h
65 | *
66 | * @brief EwokPlus25 low level API function definitions
67 | */
68 |
69 | #ifndef _VL53L1_API_CALIBRATION_H_
70 | #define _VL53L1_API_CALIBRATION_H_
71 |
72 | #include "vl53l1_platform.h"
73 |
74 | #ifdef __cplusplus
75 | extern "C" {
76 | #endif
77 |
78 |
79 | /**
80 | * @brief Run Reference Array SPAD Characterisation.
81 | *
82 | * This function finds the required number of reference SPAD
83 | * to meet the input required peak reference rate.
84 | *
85 | * The algorithm first tries the non apertured reference SPAD's,
86 | * if the rate is too high for the minimum allowed SPAD count (5)
87 | * then the algo switches to 5x apertured SPAD's and if the rate
88 | * is still to high then the 10x apertured SPAD are selected.
89 | *
90 | * The function reads the following results from the device and
91 | * both caches the values in the pdev->customer structure and
92 | * writes the data into the G02 customer register group.
93 | *
94 | * - num_ref_spads
95 | * - ref_location
96 | * - DCR SPAD enables for selected reference location
97 | *
98 | * Note power force is enabled as the function needs to read
99 | * data from the Patch RAM.
100 | *
101 | * Should only be called once per part with coverglass attached to
102 | * generate the required num of SPAD, Ref location and DCR SPAD enable
103 | * data
104 | *
105 | * @param[in] Dev : Device Handle
106 | * @param[out] pcal_status : Pointer to unfiltered calibration status
107 | *
108 | * @return VL53L1_ERROR_NONE Success
109 | * @return VL53L1_WARNING_REF_SPAD_CHAR_NOT_ENOUGH_SPADS
110 | * Less than 5 Good SPAD available, output not valid
111 | * @return VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_HIGH
112 | * At end of search reference rate > 40.0 Mcps
113 | * Offset stability may be degraded.
114 | * @return VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_LOW
115 | * At end of search reference rate < 10.0 Mcps
116 | * Offset stability may be degraded.
117 | *
118 | */
119 |
120 | #ifndef VL53L1_NOCALIB
121 | VL53L1_Error VL53L1_run_ref_spad_char(VL53L1_DEV Dev, VL53L1_Error *pcal_status);
122 | #endif
123 |
124 |
125 | /**
126 | * @brief Runs the input Device Test
127 | *
128 | * Calls
129 | *
130 | * - VL53L1_enable_powerforce()
131 | * - VL53L1_start_test()
132 | * - VL53L1_poll_for_range_completion()
133 | *
134 | * @param[in] Dev : Device handle
135 | * @param[in] device_test_mode : Device test mode register value
136 | *
137 | * @return VL53L1_ERROR_NONE Success
138 | * @return "Other error code" See ::VL53L1_Error
139 | */
140 |
141 | #ifndef VL53L1_NOCALIB
142 | VL53L1_Error VL53L1_run_device_test(
143 | VL53L1_DEV Dev,
144 | VL53L1_DeviceTestMode device_test_mode);
145 | #endif
146 |
147 |
148 | /**
149 | * @brief Runs SPAD rate map
150 | *
151 | * Output structure contains SPAD rate data in SPAD number order
152 | *
153 | * @param[in] Dev : Device handle
154 | * @param[in] device_test_mode : Device test mode register value.
155 | * Valid options: \n
156 | * - VL53L1_DEVICETESTMODE_LCR_VCSEL_OFF \n
157 | * - VL53L1_DEVICETESTMODE_LCR_VCSEL_ON
158 | * @param[in] array_select : Device SPAD array select
159 | * Valid options: \n
160 | * - VL53L1_DEVICESSCARRAY_RTN \n
161 | * - VL53L1_DEVICESSCARRAY_REF
162 | * @param[in] ssc_config_timeout_us : SSC timeout in [us] e.g 36000us
163 | * @param[out] pspad_rate_data : pointer to output rates structure
164 | * 1.15 format for LCR_VCSEL_OFF
165 | * 9.7 format for LCR_VCSEL_ON
166 | *
167 | * @return VL53L1_ERROR_NONE Success
168 | * @return "Other error code" See ::VL53L1_Error
169 | */
170 |
171 | #ifndef VL53L1_NOCALIB
172 | VL53L1_Error VL53L1_run_spad_rate_map(
173 | VL53L1_DEV Dev,
174 | VL53L1_DeviceTestMode device_test_mode,
175 | VL53L1_DeviceSscArray array_select,
176 | uint32_t ssc_config_timeout_us,
177 | VL53L1_spad_rate_data_t *pspad_rate_data);
178 | #endif
179 |
180 |
181 | /**
182 | * @brief Run offset calibration
183 | *
184 | * Runs the standard ranging MM1 and MM2 calibration presets
185 | * to generate the MM1 and MM2 range offset data
186 | *
187 | * The range config timeout is used for both MM1 and MM2 so that
188 | * the sigma delta settling is the same as for the 'real' range
189 | *
190 | * Places results into VL53L1_customer_nvm_managed_t within pdev
191 | *
192 | * Use VL53L1_get_part_to_part_data() to get the offset calibration
193 | * results
194 | *
195 | * Current FMT settings:
196 | *
197 | * - offset_calibration_mode = VL53L1_OFFSETCALIBRATIONMODE__STANDARD_RANGING
198 | * - dss_config__target_total_rate_mcps = 0x0A00 (20.0Mcps) to 0x1400 (40.0Mcps)
199 | * - phasecal_config_timeout_us = 1000
200 | * - range_config_timeout_us = 13000
201 | * - pre_num_of_samples = 32
202 | * - mm1_num_of_samples = 100
203 | * - mm2_range_num_of_samples = 64
204 | * - target_distance_mm = 140 mm
205 | * - target reflectance = 5%
206 | *
207 | * Note: function parms simplified as part of Patch_CalFunctionSimplification_11791
208 | *
209 | * @param[in] Dev : Device handle
210 | * @param[in] cal_distance_mm : Distance to target in [mm] - the ground truth
211 | * @param[out] pcal_status : Pointer to unfiltered calibration status
212 | *
213 | * @return VL53L1_ERROR_NONE Success
214 | * @return VL53L1_WARNING_OFFSET_CAL_INSUFFICIENT_MM1_SPADS
215 | * Effective MM1 SPAD count too low (<5.0).
216 | * Out with recommended calibration condition.
217 | * Accuracy of offset calibration may be degraded.
218 | * @return VL53L1_WARNING_OFFSET_CAL_PRE_RANGE_RATE_TOO_HIGH
219 | * Pre range too high (>40.0) in pile up region.
220 | * Out with recommended calibration condition.
221 | * Accuracy of offset calibration may be degraded.
222 | */
223 |
224 | #ifndef VL53L1_NOCALIB
225 | VL53L1_Error VL53L1_run_offset_calibration(
226 | VL53L1_DEV Dev,
227 | int16_t cal_distance_mm,
228 | VL53L1_Error *pcal_status);
229 | #endif
230 |
231 |
232 | #ifdef __cplusplus
233 | }
234 | #endif
235 |
236 | #endif /* _VL53L1_API_CALIBRATION_H_ */
237 |
--------------------------------------------------------------------------------
/sensor/vl53l1x/api/core/inc/vl53l1_api_debug.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, STMicroelectronics - All Rights Reserved
3 | *
4 | * This file is part of VL53L1 Core and is dual licensed,
5 | * either 'STMicroelectronics
6 | * Proprietary license'
7 | * or 'BSD 3-clause "New" or "Revised" License' , at your option.
8 | *
9 | ********************************************************************************
10 | *
11 | * 'STMicroelectronics Proprietary license'
12 | *
13 | ********************************************************************************
14 | *
15 | * License terms: STMicroelectronics Proprietary in accordance with licensing
16 | * terms at www.st.com/sla0081
17 | *
18 | * STMicroelectronics confidential
19 | * Reproduction and Communication of this document is strictly prohibited unless
20 | * specifically authorized in writing by STMicroelectronics.
21 | *
22 | *
23 | ********************************************************************************
24 | *
25 | * Alternatively, VL53L1 Core may be distributed under the terms of
26 | * 'BSD 3-clause "New" or "Revised" License', in which case the following
27 | * provisions apply instead of the ones mentioned above :
28 | *
29 | ********************************************************************************
30 | *
31 | * License terms: BSD 3-clause "New" or "Revised" License.
32 | *
33 | * Redistribution and use in source and binary forms, with or without
34 | * modification, are permitted provided that the following conditions are met:
35 | *
36 | * 1. Redistributions of source code must retain the above copyright notice, this
37 | * list of conditions and the following disclaimer.
38 | *
39 | * 2. Redistributions in binary form must reproduce the above copyright notice,
40 | * this list of conditions and the following disclaimer in the documentation
41 | * and/or other materials provided with the distribution.
42 | *
43 | * 3. Neither the name of the copyright holder nor the names of its contributors
44 | * may be used to endorse or promote products derived from this software
45 | * without specific prior written permission.
46 | *
47 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
48 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
51 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
53 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
54 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
55 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
56 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 | *
58 | *
59 | ********************************************************************************
60 | *
61 | */
62 |
63 | /**
64 | * @file vl53l1_api_debug.h
65 | *
66 | * @brief EwokPlus25 low level API function definitions
67 | */
68 |
69 | #ifndef _VL53L1_API_DEBUG_H_
70 | #define _VL53L1_API_DEBUG_H_
71 |
72 | #include "vl53l1_platform.h"
73 |
74 | #ifdef __cplusplus
75 | extern "C" {
76 | #endif
77 |
78 |
79 |
80 | /* Start Patch_AdditionalDebugData_11823 */
81 |
82 | /**
83 | * @brief Gets the current LL Driver configuration parameters and the last
84 | * set of histogram data for debug
85 | *
86 | * @param[in] Dev : Device Handle
87 | * @param[out] pdata : pointer to VL53L1_additional_data_t data structure
88 | *
89 | * @return VL53L1_ERROR_NONE Success
90 | * @return "Other error code" See ::VL53L1_Error
91 | */
92 |
93 | VL53L1_Error VL53L1_get_additional_data(
94 | VL53L1_DEV Dev,
95 | VL53L1_additional_data_t *pdata);
96 |
97 | /* End Patch_AdditionalDebugData_11823 */
98 |
99 |
100 | #ifdef VL53L1_LOG_ENABLE
101 |
102 | /**
103 | * @brief Implements an sprintf function for signed fixed point numbers
104 | *
105 | * @param[in] fp_value : input signed fixed point number
106 | * @param[in] frac_bits : number of fixed point fractional bits
107 | * @param[in] buf_size : size of supplied text buffer
108 | * @param[out] pbuffer : pointer to text buffer
109 | *
110 | */
111 |
112 | void VL53L1_signed_fixed_point_sprintf(
113 | int32_t fp_value,
114 | uint8_t frac_bits,
115 | uint16_t buf_size,
116 | char *pbuffer);
117 |
118 |
119 | /**
120 | * @brief Convenience function to print out VL53L1_static_nvm_managed_t for debug
121 | *
122 | * @param[in] pdata : pointer to VL53L1_static_nvm_managed_t
123 | * @param[in] pprefix : pointer to name prefix string
124 | * @param[in] trace_flags : logging module enable bit flags
125 | */
126 |
127 | void VL53L1_print_static_nvm_managed(
128 | VL53L1_static_nvm_managed_t *pdata,
129 | char *pprefix,
130 | uint32_t trace_flags);
131 |
132 |
133 | /**
134 | * @brief Convenience function to print out VL53L1_customer_nvm_managed_t for debug
135 | *
136 | * @param[in] pdata : pointer to VL53L1_customer_nvm_managed_t
137 | * @param[in] pprefix : pointer to name prefix string
138 | * @param[in] trace_flags : logging module enable bit flags
139 | */
140 |
141 | void VL53L1_print_customer_nvm_managed(
142 | VL53L1_customer_nvm_managed_t *pdata,
143 | char *pprefix,
144 | uint32_t trace_flags);
145 |
146 |
147 | /**
148 | * @brief Convenience function to print out VL53L1_nvm_copy_data_t for debug
149 | *
150 | * @param[in] pdata : pointer to VL53L1_nvm_copy_data_t
151 | * @param[in] pprefix : pointer to name prefix string
152 | * @param[in] trace_flags : logging module enable bit flags
153 | */
154 |
155 | void VL53L1_print_nvm_copy_data(
156 | VL53L1_nvm_copy_data_t *pdata,
157 | char *pprefix,
158 | uint32_t trace_flags);
159 |
160 |
161 | /**
162 | * @brief Convenience function to print out the contents of
163 | * the Range Results structure for debug
164 | *
165 | * @param[in] pdata : pointer to a VL53L1_range_results_t structure
166 | * @param[in] pprefix : pointer to name prefix string
167 | * @param[in] trace_flags : logging module enable bit flags
168 | */
169 |
170 | void VL53L1_print_range_results(
171 | VL53L1_range_results_t *pdata,
172 | char *pprefix,
173 | uint32_t trace_flags);
174 |
175 | /**
176 | * @brief Convenience function to print out the contents of
177 | * the Range Data structure for debug
178 | *
179 | * @param[in] pdata : pointer to a VL53L1_range_data_t structure
180 | * @param[in] pprefix : pointer to name prefix string
181 | * @param[in] trace_flags : logging module enable bit flags
182 | */
183 |
184 | void VL53L1_print_range_data(
185 | VL53L1_range_data_t *pdata,
186 | char *pprefix,
187 | uint32_t trace_flags);
188 |
189 | /**
190 | * @brief Convenience function to print out the contents of
191 | * the offset range results structure for debug
192 | *
193 | * @param[in] pdata : pointer to a VL53L1_offset_range_results_t structure
194 | * @param[in] pprefix : pointer to name prefix string
195 | * @param[in] trace_flags : logging module enable bit flags
196 | */
197 |
198 | void VL53L1_print_offset_range_results(
199 | VL53L1_offset_range_results_t *pdata,
200 | char *pprefix,
201 | uint32_t trace_flags);
202 |
203 | /**
204 | * @brief Convenience function to print out the contents of
205 | * the offset range data structure for debug
206 | *
207 | * @param[in] pdata : pointer to a VL53L1_offset_range_data_t structure
208 | * @param[in] pprefix : pointer to name prefix string
209 | * @param[in] trace_flags : logging module enable bit flags
210 | */
211 |
212 | void VL53L1_print_offset_range_data(
213 | VL53L1_offset_range_data_t *pdata,
214 | char *pprefix,
215 | uint32_t trace_flags);
216 |
217 |
218 | /**
219 | * @brief Convenience function to print out the contents of
220 | * the peak rate map calibration data structure
221 | *
222 | * @param[in] pdata : pointer to a VL53L1_cal_peak_rate_map_t structure
223 | * @param[in] pprefix : pointer to name prefix string
224 | * @param[in] trace_flags : logging module enable bit flags
225 | */
226 |
227 | void VL53L1_print_cal_peak_rate_map(
228 | VL53L1_cal_peak_rate_map_t *pdata,
229 | char *pprefix,
230 | uint32_t trace_flags);
231 |
232 |
233 | /**
234 | * @brief Convenience function to print out the contents of
235 | * the additional offset calibration data structure
236 | *
237 | * @param[in] pdata : pointer to a VL53L1_additional_offset_cal_data_t structure
238 | * @param[in] pprefix : pointer to name prefix string
239 | * @param[in] trace_flags : logging module enable bit flags
240 | */
241 |
242 | void VL53L1_print_additional_offset_cal_data(
243 | VL53L1_additional_offset_cal_data_t *pdata,
244 | char *pprefix,
245 | uint32_t trace_flags);
246 |
247 | /**
248 | * @brief Convenience function to print out the contents of
249 | * the additional data structure
250 | *
251 | * @param[in] pdata : pointer to a VL53L1_additional_data_t structure
252 | * @param[in] pprefix : pointer to name prefix string
253 | * @param[in] trace_flags : logging module enable bit flags
254 | */
255 |
256 | void VL53L1_print_additional_data(
257 | VL53L1_additional_data_t *pdata,
258 | char *pprefix,
259 | uint32_t trace_flags);
260 |
261 |
262 | /**
263 | * @brief Convenience function to print out the contents of
264 | * the LL driver gain calibration data structure
265 | *
266 | * @param[in] pdata : pointer to a VL53L1_gain_calibration_data_t structure
267 | * @param[in] pprefix : pointer to name prefix string
268 | * @param[in] trace_flags : logging module enable bit flags
269 | */
270 |
271 | void VL53L1_print_gain_calibration_data(
272 | VL53L1_gain_calibration_data_t *pdata,
273 | char *pprefix,
274 | uint32_t trace_flags);
275 |
276 |
277 | /**
278 | * @brief Convenience function to print out the contents of
279 | * the xtalk configuration data for debug
280 | *
281 | * @param[in] pdata : pointer to a VL53L1_xtalk_config_t Structure
282 | * @param[in] pprefix : pointer to name prefix string
283 | * @param[in] trace_flags : logging module enable bit flags
284 | */
285 |
286 | void VL53L1_print_xtalk_config(
287 | VL53L1_xtalk_config_t *pdata,
288 | char *pprefix,
289 | uint32_t trace_flags);
290 |
291 | /**
292 | * @brief Convenience function to print out the contents of
293 | * the Optical Centre structure for debug
294 | *
295 | * @param[in] pdata : pointer to a VL53L1_optical_centre_t structure
296 | * @param[in] pprefix : pointer to name prefix string
297 | * @param[in] trace_flags : logging module enable bit flags
298 | */
299 |
300 | void VL53L1_print_optical_centre(
301 | VL53L1_optical_centre_t *pdata,
302 | char *pprefix,
303 | uint32_t trace_flags);
304 |
305 |
306 | /**
307 | * @brief Convenience function to print out the contents of
308 | * the User Zone (ROI) structure for debug
309 | *
310 | * @param[in] pdata : pointer to a VL53L1_user_zone_t structure
311 | * @param[in] pprefix : pointer to name prefix string
312 | * @param[in] trace_flags : logging module enable bit flags
313 | */
314 |
315 | void VL53L1_print_user_zone(
316 | VL53L1_user_zone_t *pdata,
317 | char *pprefix,
318 | uint32_t trace_flags);
319 |
320 | /**
321 | * @brief Convenience function for printing out VL53L1_spad_rate_data_t
322 | *
323 | * @param[in] pspad_rates : pointer to VL53L1_spad_rate_data_t
324 | * @param[in] pprefix : pointer to name prefix string
325 | * @param[in] trace_flags : logging module enable bit flags
326 | */
327 |
328 | void VL53L1_print_spad_rate_data(
329 | VL53L1_spad_rate_data_t *pspad_rates,
330 | char *pprefix,
331 | uint32_t trace_flags);
332 |
333 |
334 | /**
335 | * @brief Convenience function for printing out VL53L1_spad_rate_map_t
336 | *
337 | * @param[in] pspad_rates : pointer to VL53L1_spad_rate_map_t
338 | * @param[in] pprefix : pointer to name prefix string
339 | * @param[in] trace_flags : logging module enable bit flags
340 | */
341 |
342 | void VL53L1_print_spad_rate_map(
343 | VL53L1_spad_rate_data_t *pspad_rates,
344 | char *pprefix,
345 | uint32_t trace_flags);
346 |
347 |
348 | #endif /* VL53L1_LOG_ENABLE */
349 |
350 | #ifdef __cplusplus
351 | }
352 | #endif
353 |
354 | #endif /* _VL53L1_API_DEBUG_H_ */
355 |
--------------------------------------------------------------------------------
/sensor/vl53l1x/api/core/inc/vl53l1_api_strings.h:
--------------------------------------------------------------------------------
1 |
2 | /* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
3 | /******************************************************************************
4 | * Copyright (c) 2020, STMicroelectronics - All Rights Reserved
5 |
6 | This file is part of VL53L1 and is dual licensed,
7 | either GPL-2.0+
8 | or 'BSD 3-clause "New" or "Revised" License' , at your option.
9 | ******************************************************************************
10 | */
11 |
12 | /**
13 | * @file vl53l1_api_strings.h
14 | * @brief VL53L1 API function declarations for decoding error codes to a
15 | * text strings
16 | */
17 |
18 |
19 | #ifndef VL53L1_API_STRINGS_H_
20 | #define VL53L1_API_STRINGS_H_
21 |
22 | #include "vl53l1_def.h"
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 |
29 |
30 | /**
31 | * @brief Generates a string for the input device range status code
32 | *
33 | * @param[in] RangeStatus : Device Range AStatus Code
34 | * @param[out] pRangeStatusString : pointer to character buffer
35 | *
36 | * @return VL53L1_ERROR_NONE Success
37 | * @return "Other error code" See ::VL53L1_Error
38 | */
39 |
40 | VL53L1_Error VL53L1_get_range_status_string(
41 | uint8_t RangeStatus,
42 | char *pRangeStatusString);
43 |
44 | /**
45 | * @brief Generates an error string for the input PAL error code
46 | *
47 | * @param[in] PalErrorCode : PAL Error Code
48 | * @param[out] pPalErrorString : pointer to character buffer
49 | *
50 | * @return VL53L1_ERROR_NONE Success
51 | * @return "Other error code" See ::VL53L1_Error
52 | */
53 |
54 | VL53L1_Error VL53L1_get_pal_error_string(
55 | VL53L1_Error PalErrorCode,
56 | char *pPalErrorString);
57 |
58 | /**
59 | * @brief Generates a string for the input PAL State code
60 | *
61 | * @param[in] PalStateCode : PAL State Code
62 | * @param[out] pPalStateString : pointer to character buffer
63 | *
64 | * @return VL53L1_ERROR_NONE Success
65 | * @return "Other error code" See ::VL53L1_Error
66 | */
67 |
68 | VL53L1_Error VL53L1_get_pal_state_string(
69 | VL53L1_State PalStateCode,
70 | char *pPalStateString);
71 |
72 |
73 | /**
74 | * @brief Generates a string for the sequence step Id
75 | *
76 | * @param[in] SequenceStepId : Sequence Step Id
77 | * @param[out] pSequenceStepsString : pointer to character buffer
78 | *
79 | * @return VL53L1_ERROR_NONE Success
80 | * @return "Other error code" See ::VL53L1_Error
81 | */
82 | VL53L1_Error VL53L1_get_sequence_steps_info(
83 | VL53L1_SequenceStepId SequenceStepId,
84 | char *pSequenceStepsString);
85 |
86 | /**
87 | * @brief Generates a string for the limit check Id
88 | *
89 | * @param[in] LimitCheckId : Limit check Id
90 | * @param[out] pLimitCheckString : pointer to character buffer
91 | *
92 | * @return VL53L1_ERROR_NONE Success
93 | * @return "Other error code" See ::VL53L1_Error
94 | */
95 | VL53L1_Error VL53L1_get_limit_check_info(uint16_t LimitCheckId,
96 | char *pLimitCheckString);
97 |
98 | #ifndef VL53L1_USE_EMPTY_STRING
99 | #define VL53L1_STRING_DEVICE_INFO_NAME0 "VL53L1 cut1.0"
100 | #define VL53L1_STRING_DEVICE_INFO_NAME1 "VL53L1 cut1.1"
101 | #define VL53L1_STRING_DEVICE_INFO_TYPE "VL53L1"
102 |
103 | /* Range Status */
104 | #define VL53L1_STRING_RANGESTATUS_NONE "No Update"
105 | #define VL53L1_STRING_RANGESTATUS_RANGEVALID "Range Valid"
106 | #define VL53L1_STRING_RANGESTATUS_SIGMA "Sigma Fail"
107 | #define VL53L1_STRING_RANGESTATUS_SIGNAL "Signal Fail"
108 | #define VL53L1_STRING_RANGESTATUS_MINRANGE "Min Range Fail"
109 | #define VL53L1_STRING_RANGESTATUS_PHASE "Phase Fail"
110 | #define VL53L1_STRING_RANGESTATUS_HW "Hardware Fail"
111 |
112 |
113 | /* Range Status */
114 | #define VL53L1_STRING_STATE_POWERDOWN "POWERDOWN State"
115 | #define VL53L1_STRING_STATE_WAIT_STATICINIT \
116 | "Wait for staticinit State"
117 | #define VL53L1_STRING_STATE_STANDBY "STANDBY State"
118 | #define VL53L1_STRING_STATE_IDLE "IDLE State"
119 | #define VL53L1_STRING_STATE_RUNNING "RUNNING State"
120 | #define VL53L1_STRING_STATE_RESET "RESET State"
121 | #define VL53L1_STRING_STATE_UNKNOWN "UNKNOWN State"
122 | #define VL53L1_STRING_STATE_ERROR "ERROR State"
123 |
124 |
125 |
126 | /* Check Enable */
127 | #define VL53L1_STRING_CHECKENABLE_SIGMA_FINAL_RANGE \
128 | "SIGMA FINAL RANGE"
129 | #define VL53L1_STRING_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE \
130 | "SIGNAL RATE FINAL RANGE"
131 | #define VL53L1_STRING_CHECKENABLE_SIGNAL_MIN_CLIP \
132 | "SIGNAL MIN CLIP"
133 | #define VL53L1_STRING_CHECKENABLE_RANGE_IGNORE_THRESHOLD \
134 | "RANGE IGNORE THRESHOLD"
135 | #define VL53L1_STRING_CHECKENABLE_RANGE_PHASE_HIGH \
136 | "RANGE PHASE HIGH"
137 | #define VL53L1_STRING_CHECKENABLE_RANGE_PHASE_LOW \
138 | "RANGE PHASE LOW"
139 | #define VL53L1_STRING_CHECKENABLE_RANGE_PHASE_CONSISTENCY \
140 | "RANGE PHASE CONSISTENCY"
141 |
142 | /* Sequence Step */
143 | #define VL53L1_STRING_SEQUENCESTEP_VHV "VHV"
144 | #define VL53L1_STRING_SEQUENCESTEP_PHASECAL "PHASE CAL"
145 | #define VL53L1_STRING_SEQUENCESTEP_REFPHASE "REF PHASE"
146 | #define VL53L1_STRING_SEQUENCESTEP_DSS1 "DSS1"
147 | #define VL53L1_STRING_SEQUENCESTEP_DSS2 "DSS2"
148 | #define VL53L1_STRING_SEQUENCESTEP_MM1 "MM1"
149 | #define VL53L1_STRING_SEQUENCESTEP_MM2 "MM2"
150 | #define VL53L1_STRING_SEQUENCESTEP_RANGE "RANGE"
151 | #endif /* VL53L1_USE_EMPTY_STRING */
152 |
153 |
154 | #ifdef __cplusplus
155 | }
156 | #endif
157 |
158 | #endif
159 |
160 |
--------------------------------------------------------------------------------
/sensor/vl53l1x/api/core/inc/vl53l1_core_support.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, STMicroelectronics - All Rights Reserved
3 | *
4 | * This file is part of VL53L1 Core and is dual licensed,
5 | * either 'STMicroelectronics
6 | * Proprietary license'
7 | * or 'BSD 3-clause "New" or "Revised" License' , at your option.
8 | *
9 | ********************************************************************************
10 | *
11 | * 'STMicroelectronics Proprietary license'
12 | *
13 | ********************************************************************************
14 | *
15 | * License terms: STMicroelectronics Proprietary in accordance with licensing
16 | * terms at www.st.com/sla0081
17 | *
18 | * STMicroelectronics confidential
19 | * Reproduction and Communication of this document is strictly prohibited unless
20 | * specifically authorized in writing by STMicroelectronics.
21 | *
22 | *
23 | ********************************************************************************
24 | *
25 | * Alternatively, VL53L1 Core may be distributed under the terms of
26 | * 'BSD 3-clause "New" or "Revised" License', in which case the following
27 | * provisions apply instead of the ones mentioned above :
28 | *
29 | ********************************************************************************
30 | *
31 | * License terms: BSD 3-clause "New" or "Revised" License.
32 | *
33 | * Redistribution and use in source and binary forms, with or without
34 | * modification, are permitted provided that the following conditions are met:
35 | *
36 | * 1. Redistributions of source code must retain the above copyright notice, this
37 | * list of conditions and the following disclaimer.
38 | *
39 | * 2. Redistributions in binary form must reproduce the above copyright notice,
40 | * this list of conditions and the following disclaimer in the documentation
41 | * and/or other materials provided with the distribution.
42 | *
43 | * 3. Neither the name of the copyright holder nor the names of its contributors
44 | * may be used to endorse or promote products derived from this software
45 | * without specific prior written permission.
46 | *
47 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
48 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
51 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
53 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
54 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
55 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
56 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 | *
58 | *
59 | ********************************************************************************
60 | *
61 | */
62 |
63 | /**
64 | * @file vl53l1_core_support.h
65 | *
66 | * @brief EwokPlus25 core function definitions
67 | */
68 |
69 | #ifndef _VL53L1_CORE_SUPPORT_H_
70 | #define _VL53L1_CORE_SUPPORT_H_
71 |
72 | #include "vl53l1_types.h"
73 |
74 | #ifdef __cplusplus
75 | extern "C" {
76 | #endif
77 |
78 |
79 | /**
80 | * @brief Calculates the PLL period in [us] from the input
81 | * fast_osc_frequency
82 | *
83 | * @param[in] fast_osc_frequency : fast oscillator frequency in 4.12 MHz format
84 | *
85 | * @return pll_period_us : PLL period in [us] 8.24 format
86 | */
87 |
88 | uint32_t VL53L1_calc_pll_period_us(
89 | uint16_t fast_osc_frequency);
90 |
91 |
92 |
93 | #ifdef PAL_EXTENDED
94 | /**
95 | * @brief Calculates the ranging duration in ns using fixed point maths
96 | * *
97 | * Uses a temporary uint64_t variable internally
98 | *
99 | * @param[in] pll_period_us : PLL Period in [us] 0.25 format
100 | * @param[in] vcsel_parm_pclks : period, width or WOI window in PLL clocks
101 | * in 6.4 format.
102 | * @param[in] window_vclks : ranging or ambient window duration in VCSEL clocks
103 | * @param[in] periods_elapsed_mclks : elapsed time in macro clocks
104 | *
105 | * @return duration_us : uint32_t containing the duration time in us
106 | */
107 |
108 | uint32_t VL53L1_duration_maths(
109 | uint32_t pll_period_us,
110 | uint32_t vcsel_parm_pclks,
111 | uint32_t window_vclks,
112 | uint32_t periods_elapsed_mclks);
113 |
114 |
115 | /**
116 | * @brief Calculates the square root of the input integer
117 | *
118 | * Reference : http://en.wikipedia.org/wiki/Methods_of_computing_square_roots
119 | *
120 | * @param[in] num : input integer
121 | *
122 | * @return res : square root result
123 | */
124 |
125 | uint32_t VL53L1_isqrt(
126 | uint32_t num);
127 |
128 | /**
129 | * @brief Calculates the count rate using fixed point maths
130 | *
131 | * Uses a temporary uint64_t variable internally
132 | * Any negative negative rates are clipped to 0.
133 | *
134 | * @param[in] events : accumulated SPAD events
135 | * @param[in] time_us : elapsed time in us
136 | *
137 | * @return rate_mcps : uint16_t count rate in 9.7 format
138 | */
139 |
140 | uint16_t VL53L1_rate_maths(
141 | int32_t events,
142 | uint32_t time_us);
143 |
144 | /**
145 | * @brief Calculates the Rate per spad
146 | *
147 | * Uses a temporary uint32_t variable internally
148 | * Any output rates larger than 16 bit are clipped to 0xFFFF.
149 | *
150 | * @param[in] frac_bits : required output fractional precision - 7 \
151 | * due to inherent resolution of pk_rate
152 | * @param[in] peak_count_rate : peak signal count rate in mcps
153 | * @param[in] num_spads : actual effective spads in 8.8
154 | * @param[in] max_output_value : User set value to clip output
155 | *
156 | * @return rate_per_spad : uint16_t count rate in variable fractional format
157 | */
158 |
159 | uint16_t VL53L1_rate_per_spad_maths(
160 | uint32_t frac_bits,
161 | uint32_t peak_count_rate,
162 | uint16_t num_spads,
163 | uint32_t max_output_value);
164 |
165 |
166 | /**
167 | * @brief Calculates the range from the phase data
168 | *
169 | * Uses a temporary int64_t variable internally
170 | *
171 | * @param[in] fast_osc_frequency : Fast oscillator freq [MHz] 4.12 format
172 | * @param[in] phase : phase in 5.11 format
173 | * @param[in] zero_distance_phase : zero distance phase in 5.11 format
174 | * @param[in] fractional_bits : valid options : 0, 1, 2
175 | * @param[in] gain_factor : gain correction factor 1.11 format
176 | * @param[in] range_offset_mm : range offset [mm] 14.2 format
177 |
178 | * @return range_mm : signed range in [mm]
179 | * format depends on fractional_bits input
180 | */
181 |
182 | int32_t VL53L1_range_maths(
183 | uint16_t fast_osc_frequency,
184 | uint16_t phase,
185 | uint16_t zero_distance_phase,
186 | uint8_t fractional_bits,
187 | int32_t gain_factor,
188 | int32_t range_offset_mm);
189 | #endif
190 |
191 |
192 | /**
193 | * @brief Decodes VCSEL period register value into the real period in PLL clocks
194 | *
195 | * @param[in] vcsel_period_reg : 8 -bit register value
196 | *
197 | * @return vcsel_period_pclks : 8-bit decoded value
198 | *
199 | */
200 |
201 | uint8_t VL53L1_decode_vcsel_period(
202 | uint8_t vcsel_period_reg);
203 |
204 | /**
205 | * @brief Decodes the Byte.Bit coord encoding into an (x,y) coord value
206 | *
207 | * @param[in] spad_number : Coord location in Byte.Bit format
208 | * @param[out] prow : Decoded row
209 | * @param[out] pcol : Decoded column
210 | *
211 | */
212 |
213 | void VL53L1_decode_row_col(
214 | uint8_t spad_number,
215 | uint8_t *prow,
216 | uint8_t *pcol);
217 |
218 | #ifdef __cplusplus
219 | }
220 | #endif
221 |
222 | #endif /* _VL53L1_CORE_SUPPORT_H_ */
223 |
--------------------------------------------------------------------------------
/sensor/vl53l1x/api/core/inc/vl53l1_error_codes.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, STMicroelectronics - All Rights Reserved
3 | *
4 | * This file is part of VL53L1 Core and is dual licensed,
5 | * either 'STMicroelectronics
6 | * Proprietary license'
7 | * or 'BSD 3-clause "New" or "Revised" License' , at your option.
8 | *
9 | ********************************************************************************
10 | *
11 | * 'STMicroelectronics Proprietary license'
12 | *
13 | ********************************************************************************
14 | *
15 | * License terms: STMicroelectronics Proprietary in accordance with licensing
16 | * terms at www.st.com/sla0081
17 | *
18 | * STMicroelectronics confidential
19 | * Reproduction and Communication of this document is strictly prohibited unless
20 | * specifically authorized in writing by STMicroelectronics.
21 | *
22 | *
23 | ********************************************************************************
24 | *
25 | * Alternatively, VL53L1 Core may be distributed under the terms of
26 | * 'BSD 3-clause "New" or "Revised" License', in which case the following
27 | * provisions apply instead of the ones mentioned above :
28 | *
29 | ********************************************************************************
30 | *
31 | * License terms: BSD 3-clause "New" or "Revised" License.
32 | *
33 | * Redistribution and use in source and binary forms, with or without
34 | * modification, are permitted provided that the following conditions are met:
35 | *
36 | * 1. Redistributions of source code must retain the above copyright notice, this
37 | * list of conditions and the following disclaimer.
38 | *
39 | * 2. Redistributions in binary form must reproduce the above copyright notice,
40 | * this list of conditions and the following disclaimer in the documentation
41 | * and/or other materials provided with the distribution.
42 | *
43 | * 3. Neither the name of the copyright holder nor the names of its contributors
44 | * may be used to endorse or promote products derived from this software
45 | * without specific prior written permission.
46 | *
47 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
48 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
51 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
53 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
54 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
55 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
56 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 | *
58 | *
59 | ********************************************************************************
60 | *
61 | */
62 |
63 | /**
64 | * @file vl53l1_error_codes.h
65 | *
66 | * @brief Error Code definitions for VL53L1 API.
67 | *
68 | */
69 |
70 | #ifndef _VL53L1_ERROR_CODES_H_
71 | #define _VL53L1_ERROR_CODES_H_
72 |
73 | #include "vl53l1_types.h"
74 |
75 | #ifdef __cplusplus
76 | extern "C" {
77 | #endif
78 |
79 |
80 | /****************************************
81 | * PRIVATE define do not edit
82 | ****************************************/
83 |
84 | /** @defgroup VL53L1_define_Error_group Error and Warning code returned by API
85 | * The following DEFINE are used to identify the PAL ERROR
86 | * @{
87 | */
88 |
89 | typedef int8_t VL53L1_Error;
90 |
91 | #define VL53L1_ERROR_NONE ((VL53L1_Error) 0)
92 | #define VL53L1_ERROR_CALIBRATION_WARNING ((VL53L1_Error) - 1)
93 | /*!< Warning invalid calibration data may be in used
94 | \a VL53L1_InitData()
95 | \a VL53L1_GetOffsetCalibrationData
96 | \a VL53L1_SetOffsetCalibrationData */
97 | #define VL53L1_ERROR_MIN_CLIPPED ((VL53L1_Error) - 2)
98 | /*!< Warning parameter passed was clipped to min before to be applied */
99 |
100 | #define VL53L1_ERROR_UNDEFINED ((VL53L1_Error) - 3)
101 | /*!< Unqualified error */
102 | #define VL53L1_ERROR_INVALID_PARAMS ((VL53L1_Error) - 4)
103 | /*!< Parameter passed is invalid or out of range */
104 | #define VL53L1_ERROR_NOT_SUPPORTED ((VL53L1_Error) - 5)
105 | /*!< Function is not supported in current mode or configuration */
106 | #define VL53L1_ERROR_RANGE_ERROR ((VL53L1_Error) - 6)
107 | /*!< Device report a ranging error interrupt status */
108 | #define VL53L1_ERROR_TIME_OUT ((VL53L1_Error) - 7)
109 | /*!< Aborted due to time out */
110 | #define VL53L1_ERROR_MODE_NOT_SUPPORTED ((VL53L1_Error) - 8)
111 | /*!< Asked mode is not supported by the device */
112 | #define VL53L1_ERROR_BUFFER_TOO_SMALL ((VL53L1_Error) - 9)
113 | /*!< ... */
114 | #define VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL ((VL53L1_Error) - 10)
115 | /*!< Supplied buffer is larger than I2C supports */
116 | #define VL53L1_ERROR_GPIO_NOT_EXISTING ((VL53L1_Error) - 11)
117 | /*!< User tried to setup a non-existing GPIO pin */
118 | #define VL53L1_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED ((VL53L1_Error) - 12)
119 | /*!< unsupported GPIO functionality */
120 | #define VL53L1_ERROR_CONTROL_INTERFACE ((VL53L1_Error) - 13)
121 | /*!< error reported from IO functions */
122 | #define VL53L1_ERROR_INVALID_COMMAND ((VL53L1_Error) - 14)
123 | /*!< The command is not allowed in the current device state
124 | * (power down) */
125 | #define VL53L1_ERROR_DIVISION_BY_ZERO ((VL53L1_Error) - 15)
126 | /*!< In the function a division by zero occurs */
127 | #define VL53L1_ERROR_REF_SPAD_INIT ((VL53L1_Error) - 16)
128 | /*!< Error during reference SPAD initialization */
129 | #define VL53L1_ERROR_GPH_SYNC_CHECK_FAIL ((VL53L1_Error) - 17)
130 | /*!< GPH sync interrupt check fail - API out of sync with device*/
131 | #define VL53L1_ERROR_STREAM_COUNT_CHECK_FAIL ((VL53L1_Error) - 18)
132 | /*!< Stream count check fail - API out of sync with device */
133 | #define VL53L1_ERROR_GPH_ID_CHECK_FAIL ((VL53L1_Error) - 19)
134 | /*!< GPH ID check fail - API out of sync with device */
135 | #define VL53L1_ERROR_ZONE_STREAM_COUNT_CHECK_FAIL ((VL53L1_Error) - 20)
136 | /*!< Zone dynamic config stream count check failed - API out of sync */
137 | #define VL53L1_ERROR_ZONE_GPH_ID_CHECK_FAIL ((VL53L1_Error) - 21)
138 | /*!< Zone dynamic config GPH ID check failed - API out of sync */
139 |
140 | #define VL53L1_ERROR_XTALK_EXTRACTION_NO_SAMPLE_FAIL ((VL53L1_Error) - 22)
141 | /*!< Thrown when run_xtalk_extraction fn has 0 succesful samples
142 | * when using the full array to sample the xtalk. In this case there is
143 | * not enough information to generate new Xtalk parm info. The function
144 | * will exit and leave the current xtalk parameters unaltered */
145 | #define VL53L1_ERROR_XTALK_EXTRACTION_SIGMA_LIMIT_FAIL ((VL53L1_Error) - 23)
146 | /*!< Thrown when run_xtalk_extraction fn has found that the
147 | * avg sigma estimate of the full array xtalk sample is > than the
148 | * maximal limit allowed. In this case the xtalk sample is too noisy for
149 | * measurement. The function will exit and leave the current xtalk parameters
150 | * unaltered. */
151 |
152 |
153 | #define VL53L1_ERROR_OFFSET_CAL_NO_SAMPLE_FAIL ((VL53L1_Error) - 24)
154 | /*!< Thrown if there one of stages has no valid offset calibration
155 | * samples. A fatal error calibration not valid */
156 | #define VL53L1_ERROR_OFFSET_CAL_NO_SPADS_ENABLED_FAIL ((VL53L1_Error) - 25)
157 | /*!< Thrown if there one of stages has zero effective SPADS
158 | * Traps the case when MM1 SPADs is zero.
159 | * A fatal error calibration not valid */
160 | #define VL53L1_ERROR_ZONE_CAL_NO_SAMPLE_FAIL ((VL53L1_Error) - 26)
161 | /*!< Thrown if then some of the zones have no valid samples
162 | * A fatal error calibration not valid */
163 |
164 | #define VL53L1_ERROR_TUNING_PARM_KEY_MISMATCH ((VL53L1_Error) - 27)
165 | /*!< Thrown if the tuning file key table version does not match with
166 | * expected value. The driver expects the key table version to match
167 | * the compiled default version number in the define
168 | * #VL53L1_TUNINGPARM_KEY_TABLE_VERSION_DEFAULT
169 | * */
170 |
171 | #define VL53L1_WARNING_REF_SPAD_CHAR_NOT_ENOUGH_SPADS ((VL53L1_Error) - 28)
172 | /*!< Thrown if there are less than 5 good SPADs are available. */
173 | #define VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_HIGH ((VL53L1_Error) - 29)
174 | /*!< Thrown if the final reference rate is greater than
175 | the upper reference rate limit - default is 40 Mcps.
176 | Implies a minimum Q3 (x10) SPAD (5) selected */
177 | #define VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_LOW ((VL53L1_Error) - 30)
178 | /*!< Thrown if the final reference rate is less than
179 | the lower reference rate limit - default is 10 Mcps.
180 | Implies maximum Q1 (x1) SPADs selected */
181 |
182 |
183 | #define VL53L1_WARNING_OFFSET_CAL_MISSING_SAMPLES ((VL53L1_Error) - 31)
184 | /*!< Thrown if there is less than the requested number of
185 | * valid samples. */
186 | #define VL53L1_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH ((VL53L1_Error) - 32)
187 | /*!< Thrown if the offset calibration range sigma estimate is greater
188 | * than 8.0 mm. This is the recommended min value to yield a stable
189 | * offset measurement */
190 | #define VL53L1_WARNING_OFFSET_CAL_RATE_TOO_HIGH ((VL53L1_Error) - 33)
191 | /*!< Thrown when VL53L1_run_offset_calibration() peak rate is greater
192 | than that 50.0Mcps. This is the recommended max rate to avoid
193 | pile-up influencing the offset measurement */
194 | #define VL53L1_WARNING_OFFSET_CAL_SPAD_COUNT_TOO_LOW ((VL53L1_Error) - 34)
195 | /*!< Thrown when VL53L1_run_offset_calibration() when one of stages
196 | range has less that 5.0 effective SPADS. This is the recommended
197 | min value to yield a stable offset */
198 |
199 |
200 | #define VL53L1_WARNING_ZONE_CAL_MISSING_SAMPLES ((VL53L1_Error) - 35)
201 | /*!< Thrown if one of more of the zones have less than
202 | the requested number of valid samples */
203 | #define VL53L1_WARNING_ZONE_CAL_SIGMA_TOO_HIGH ((VL53L1_Error) - 36)
204 | /*!< Thrown if one or more zones have sigma estimate value greater
205 | * than 8.0 mm. This is the recommended min value to yield a stable
206 | * offset measurement */
207 | #define VL53L1_WARNING_ZONE_CAL_RATE_TOO_HIGH ((VL53L1_Error) - 37)
208 | /*!< Thrown if one of more zones have peak rate higher than
209 | that 50.0Mcps. This is the recommended max rate to avoid
210 | pile-up influencing the offset measurement */
211 |
212 |
213 | #define VL53L1_WARNING_XTALK_MISSING_SAMPLES ((VL53L1_Error) - 38)
214 | /*!< Thrown to notify that some of the xtalk samples did not yield
215 | * valid ranging pulse data while attempting to measure
216 | * the xtalk signal in vl53l1_run_xtalk_extract(). This can signify any of
217 | * the zones are missing samples, for further debug information the
218 | * xtalk_results struct should be referred to. This warning is for
219 | * notification only, the xtalk pulse and shape have still been generated
220 | */
221 | #define VL53L1_WARNING_XTALK_NO_SAMPLES_FOR_GRADIENT ((VL53L1_Error) - 39)
222 | /*!< Thrown to notify that some of teh xtalk samples used for gradient
223 | * generation did not yield valid ranging pulse data while attempting to
224 | * measure the xtalk signal in vl53l1_run_xtalk_extract(). This can signify
225 | * that any one of the zones 0-3 yielded no successful samples. The
226 | * xtalk_results struct should be referred to for further debug info.
227 | * This warning is for notification only, the xtalk pulse and shape
228 | * have still been generated.
229 | */
230 | #define VL53L1_WARNING_XTALK_SIGMA_LIMIT_FOR_GRADIENT ((VL53L1_Error) - 40)
231 | /*!< Thrown to notify that some of the xtalk samples used for gradient
232 | * generation did not pass the sigma limit check while attempting to
233 | * measure the xtalk signal in vl53l1_run_xtalk_extract(). This can signify
234 | * that any one of the zones 0-3 yielded an avg sigma_mm value > the limit.
235 | * The xtalk_results struct should be referred to for further debug info.
236 | * This warning is for notification only, the xtalk pulse and shape
237 | * have still been generated.
238 | */
239 |
240 | #define VL53L1_ERROR_NOT_IMPLEMENTED ((VL53L1_Error) - 41)
241 | /*!< Tells requested functionality has not been implemented yet or
242 | * not compatible with the device */
243 | #define VL53L1_ERROR_PLATFORM_SPECIFIC_START ((VL53L1_Error) - 60)
244 | /*!< Tells the starting code for platform */
245 | /** @} VL53L1_define_Error_group */
246 |
247 |
248 | #ifdef __cplusplus
249 | }
250 | #endif
251 |
252 |
253 | #endif /* _VL53L1_ERROR_CODES_H_ */
254 |
--------------------------------------------------------------------------------
/sensor/vl53l1x/api/core/inc/vl53l1_error_exceptions.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, STMicroelectronics - All Rights Reserved
3 | *
4 | * This file is part of VL53L1 Core and is dual licensed,
5 | * either 'STMicroelectronics
6 | * Proprietary license'
7 | * or 'BSD 3-clause "New" or "Revised" License' , at your option.
8 | *
9 | ********************************************************************************
10 | *
11 | * 'STMicroelectronics Proprietary license'
12 | *
13 | ********************************************************************************
14 | *
15 | * License terms: STMicroelectronics Proprietary in accordance with licensing
16 | * terms at www.st.com/sla0081
17 | *
18 | * STMicroelectronics confidential
19 | * Reproduction and Communication of this document is strictly prohibited unless
20 | * specifically authorized in writing by STMicroelectronics.
21 | *
22 | *
23 | ********************************************************************************
24 | *
25 | * Alternatively, VL53L1 Core may be distributed under the terms of
26 | * 'BSD 3-clause "New" or "Revised" License', in which case the following
27 | * provisions apply instead of the ones mentioned above :
28 | *
29 | ********************************************************************************
30 | *
31 | * License terms: BSD 3-clause "New" or "Revised" License.
32 | *
33 | * Redistribution and use in source and binary forms, with or without
34 | * modification, are permitted provided that the following conditions are met:
35 | *
36 | * 1. Redistributions of source code must retain the above copyright notice, this
37 | * list of conditions and the following disclaimer.
38 | *
39 | * 2. Redistributions in binary form must reproduce the above copyright notice,
40 | * this list of conditions and the following disclaimer in the documentation
41 | * and/or other materials provided with the distribution.
42 | *
43 | * 3. Neither the name of the copyright holder nor the names of its contributors
44 | * may be used to endorse or promote products derived from this software
45 | * without specific prior written permission.
46 | *
47 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
48 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
51 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
53 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
54 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
55 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
56 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 | *
58 | *
59 | ********************************************************************************
60 | *
61 | */
62 |
63 | /**
64 | * @file vl53l1_error_exceptions.h
65 | *
66 | * @brief EwokPlus25 LL Driver definitions for control of error handling in LL driver
67 | */
68 |
69 | #ifndef _VL53L1_ERROR_EXCEPTIONS_H_
70 | #define _VL53L1_ERROR_EXCEPTIONS_H_
71 |
72 | #define IGNORE_DIVISION_BY_ZERO 0
73 |
74 | #define IGNORE_XTALK_EXTRACTION_NO_SAMPLE_FAIL 0
75 | #define IGNORE_XTALK_EXTRACTION_SIGMA_LIMIT_FAIL 0
76 | #define IGNORE_XTALK_EXTRACTION_NO_SAMPLE_FOR_GRADIENT_WARN 0
77 | #define IGNORE_XTALK_EXTRACTION_SIGMA_LIMIT_FOR_GRADIENT_WARN 0
78 | #define IGNORE_XTALK_EXTRACTION_MISSING_SAMPLES_WARN 0
79 |
80 | #define IGNORE_REF_SPAD_CHAR_NOT_ENOUGH_SPADS 0
81 | #define IGNORE_REF_SPAD_CHAR_RATE_TOO_HIGH 0
82 | #define IGNORE_REF_SPAD_CHAR_RATE_TOO_LOW 0
83 |
84 | #define IGNORE_OFFSET_CAL_MISSING_SAMPLES 0
85 | #define IGNORE_OFFSET_CAL_SIGMA_TOO_HIGH 0
86 | #define IGNORE_OFFSET_CAL_RATE_TOO_HIGH 0
87 | #define IGNORE_OFFSET_CAL_SPAD_COUNT_TOO_LOW 0
88 |
89 | #define IGNORE_ZONE_CAL_MISSING_SAMPLES 0
90 | #define IGNORE_ZONE_CAL_SIGMA_TOO_HIGH 0
91 | #define IGNORE_ZONE_CAL_RATE_TOO_HIGH 0
92 |
93 | #endif /* _VL53L1_ERROR_EXCEPTIONS_H_ */
94 |
--------------------------------------------------------------------------------
/sensor/vl53l1x/api/core/inc/vl53l1_error_strings.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, STMicroelectronics - All Rights Reserved
3 | *
4 | * This file is part of VL53L1 Core and is dual licensed,
5 | * either 'STMicroelectronics
6 | * Proprietary license'
7 | * or 'BSD 3-clause "New" or "Revised" License' , at your option.
8 | *
9 | ********************************************************************************
10 | *
11 | * 'STMicroelectronics Proprietary license'
12 | *
13 | ********************************************************************************
14 | *
15 | * License terms: STMicroelectronics Proprietary in accordance with licensing
16 | * terms at www.st.com/sla0081
17 | *
18 | * STMicroelectronics confidential
19 | * Reproduction and Communication of this document is strictly prohibited unless
20 | * specifically authorized in writing by STMicroelectronics.
21 | *
22 | *
23 | ********************************************************************************
24 | *
25 | * Alternatively, VL53L1 Core may be distributed under the terms of
26 | * 'BSD 3-clause "New" or "Revised" License', in which case the following
27 | * provisions apply instead of the ones mentioned above :
28 | *
29 | ********************************************************************************
30 | *
31 | * License terms: BSD 3-clause "New" or "Revised" License.
32 | *
33 | * Redistribution and use in source and binary forms, with or without
34 | * modification, are permitted provided that the following conditions are met:
35 | *
36 | * 1. Redistributions of source code must retain the above copyright notice, this
37 | * list of conditions and the following disclaimer.
38 | *
39 | * 2. Redistributions in binary form must reproduce the above copyright notice,
40 | * this list of conditions and the following disclaimer in the documentation
41 | * and/or other materials provided with the distribution.
42 | *
43 | * 3. Neither the name of the copyright holder nor the names of its contributors
44 | * may be used to endorse or promote products derived from this software
45 | * without specific prior written permission.
46 | *
47 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
48 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
51 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
53 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
54 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
55 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
56 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 | *
58 | *
59 | ********************************************************************************
60 | *
61 | */
62 |
63 | /**
64 | * @file vl53l1_error_strings.h
65 | * @brief VL53L1 function declarations for decoding error codes to a
66 | * text strings
67 | */
68 |
69 |
70 | #ifndef VL53L1_ERROR_STRINGS_H_
71 | #define VL53L1_ERROR_STRINGS_H_
72 |
73 | #include "vl53l1_error_codes.h"
74 |
75 | #ifdef __cplusplus
76 | extern "C" {
77 | #endif
78 |
79 |
80 | /**
81 | * @brief Generates an error string for the input PAL error code
82 | *
83 | * @param[in] PalErrorCode : PAL Error Code
84 | * @param[out] pPalErrorString : pointer to character buffer
85 | *
86 | * @return VL53L1_ERROR_NONE Success
87 | * @return "Other error code" See ::VL53L1_Error
88 | */
89 |
90 | VL53L1_Error VL53L1_get_pal_error_string(
91 | VL53L1_Error PalErrorCode,
92 | char *pPalErrorString);
93 |
94 |
95 | #ifndef VL53L1_USE_EMPTY_STRING
96 |
97 | /* PAL ERROR strings */
98 | #define VL53L1_STRING_ERROR_NONE \
99 | "No Error"
100 | #define VL53L1_STRING_ERROR_CALIBRATION_WARNING \
101 | "Calibration Warning Error"
102 | #define VL53L1_STRING_ERROR_MIN_CLIPPED \
103 | "Min clipped error"
104 | #define VL53L1_STRING_ERROR_UNDEFINED \
105 | "Undefined error"
106 | #define VL53L1_STRING_ERROR_INVALID_PARAMS \
107 | "Invalid parameters error"
108 | #define VL53L1_STRING_ERROR_NOT_SUPPORTED \
109 | "Not supported error"
110 | #define VL53L1_STRING_ERROR_RANGE_ERROR \
111 | "Range error"
112 | #define VL53L1_STRING_ERROR_TIME_OUT \
113 | "Time out error"
114 | #define VL53L1_STRING_ERROR_MODE_NOT_SUPPORTED \
115 | "Mode not supported error"
116 | #define VL53L1_STRING_ERROR_BUFFER_TOO_SMALL \
117 | "Buffer too small"
118 | #define VL53L1_STRING_ERROR_COMMS_BUFFER_TOO_SMALL \
119 | "Comms Buffer too small"
120 | #define VL53L1_STRING_ERROR_GPIO_NOT_EXISTING \
121 | "GPIO not existing"
122 | #define VL53L1_STRING_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED \
123 | "GPIO funct not supported"
124 | #define VL53L1_STRING_ERROR_CONTROL_INTERFACE \
125 | "Control Interface Error"
126 | #define VL53L1_STRING_ERROR_INVALID_COMMAND \
127 | "Invalid Command Error"
128 | #define VL53L1_STRING_ERROR_DIVISION_BY_ZERO \
129 | "Division by zero Error"
130 | #define VL53L1_STRING_ERROR_REF_SPAD_INIT \
131 | "Reference Spad Init Error"
132 | #define VL53L1_STRING_ERROR_GPH_SYNC_CHECK_FAIL \
133 | "GPH Sync Check Fail - API out of sync"
134 | #define VL53L1_STRING_ERROR_STREAM_COUNT_CHECK_FAIL \
135 | "Stream Count Check Fail - API out of sync"
136 | #define VL53L1_STRING_ERROR_GPH_ID_CHECK_FAIL \
137 | "GPH ID Check Fail - API out of sync"
138 | #define VL53L1_STRING_ERROR_ZONE_STREAM_COUNT_CHECK_FAIL \
139 | "Zone Stream Count Check Fail - API out of sync"
140 | #define VL53L1_STRING_ERROR_ZONE_GPH_ID_CHECK_FAIL \
141 | "Zone GPH ID Check Fail - API out of sync"
142 |
143 | #define VL53L1_STRING_ERROR_XTALK_EXTRACTION_NO_SAMPLES_FAIL \
144 | "No Xtalk using full array - Xtalk Extract Fail"
145 | #define VL53L1_STRING_ERROR_XTALK_EXTRACTION_SIGMA_LIMIT_FAIL \
146 | "Xtalk does not meet required sigma limit - Xtalk Extract Fail"
147 |
148 | #define VL53L1_STRING_ERROR_OFFSET_CAL_NO_SAMPLE_FAIL \
149 | "Offset Cal - one of more stages with no valid samples - fatal"
150 | #define VL53L1_STRING_ERROR_OFFSET_CAL_NO_SPADS_ENABLED_FAIL \
151 | "Offset Cal - one of more stages with no SPADS enables - fatal"
152 | #define VL53L1_STRING_ERROR_ZONE_CAL_NO_SAMPLE_FAIL \
153 | "Zone Cal - one of more zones with no valid samples - fatal"
154 |
155 | #define VL53L1_STRING_WARNING_REF_SPAD_CHAR_NOT_ENOUGH_SPADS \
156 | "Ref SPAD Char - Not Enough Good SPADs"
157 | #define VL53L1_STRING_WARNING_REF_SPAD_CHAR_RATE_TOO_HIGH \
158 | "Ref SPAD Char - Final Ref Rate too high"
159 | #define VL53L1_STRING_WARNING_REF_SPAD_CHAR_RATE_TOO_LOW \
160 | "Ref SPAD Char - Final Ref Rate too low"
161 |
162 | #define VL53L1_STRING_WARNING_OFFSET_CAL_MISSING_SAMPLES \
163 | "Offset Cal - Less than the requested number of valid samples"
164 | #define VL53L1_STRING_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH \
165 | "Offset Cal - Sigma estimate value too high - offset not stable"
166 | #define VL53L1_STRING_WARNING_OFFSET_CAL_RATE_TOO_HIGH \
167 | "Offset Cal - Rate too high - in pile up"
168 | #define VL53L1_STRING_WARNING_OFFSET_CAL_SPAD_COUNT_TOO_LOW \
169 | "Offset Cal - Insufficient SPADs - offset may not be stable"
170 |
171 | #define VL53L1_STRING_WARNING_ZONE_CAL_MISSING_SAMPLES \
172 | "Zone Cal - One or more zone with less than requested valid samples"
173 | #define VL53L1_STRING_WARNING_ZONE_CAL_SIGMA_TOO_HIGH \
174 | "Zone Cal - One of more zones the sigma estimate too high"
175 | #define VL53L1_STRING_WARNING_ZONE_CAL_RATE_TOO_HIGH \
176 | "Zone Cal - One of more zones with rate too high - in pile up"
177 |
178 | #define VL53L1_STRING_WARNING_XTALK_NO_SAMPLES_FOR_GRADIENT \
179 | "Xtalk - Gradient sample num = 0"
180 | #define VL53L1_STRING_WARNING_XTALK_SIGMA_LIMIT_FOR_GRADIENT \
181 | "Xtalk - Gradient Sigma > Limit"
182 | #define VL53L1_STRING_WARNING_XTALK_MISSING_SAMPLES \
183 | "Xtalk - Some missing and invalid samples"
184 |
185 | #define VL53L1_STRING_ERROR_DEVICE_FIRMWARE_TOO_OLD \
186 | "Device Firmware too old"
187 | #define VL53L1_STRING_ERROR_DEVICE_FIRMWARE_TOO_NEW \
188 | "Device Firmware too new"
189 | #define VL53L1_STRING_ERROR_UNIT_TEST_FAIL \
190 | "Unit Test Fail"
191 | #define VL53L1_STRING_ERROR_FILE_READ_FAIL \
192 | "File Read Fail"
193 | #define VL53L1_STRING_ERROR_FILE_WRITE_FAIL \
194 | "File Write Fail"
195 |
196 | #define VL53L1_STRING_ERROR_NOT_IMPLEMENTED \
197 | "Not implemented error"
198 | #define VL53L1_STRING_UNKNOW_ERROR_CODE \
199 | "Unknown Error Code"
200 |
201 | #endif /* VL53L1_USE_EMPTY_STRING */
202 |
203 |
204 | #ifdef __cplusplus
205 | }
206 | #endif
207 |
208 | #endif
209 |
210 |
--------------------------------------------------------------------------------
/sensor/vl53l1x/api/core/inc/vl53l1_preset_setup.h:
--------------------------------------------------------------------------------
1 |
2 | /* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
3 | /******************************************************************************
4 | * Copyright (c) 2020, STMicroelectronics - All Rights Reserved
5 |
6 | This file is part of VL53L1 and is dual licensed,
7 | either GPL-2.0+
8 | or 'BSD 3-clause "New" or "Revised" License' , at your option.
9 | ******************************************************************************
10 | */
11 |
12 | #ifndef _VL53L1_PRESET_SETUP_H_
13 | #define _VL53L1_PRESET_SETUP_H_
14 |
15 | #ifdef __cplusplus
16 | extern "C"
17 | {
18 | #endif
19 |
20 | /* indexes for the bare driver tuning setting API function */
21 | enum VL53L1_Tuning_t {
22 | VL53L1_TUNING_VERSION = 0,
23 | VL53L1_TUNING_PROXY_MIN,
24 | VL53L1_TUNING_SINGLE_TARGET_XTALK_TARGET_DISTANCE_MM,
25 | VL53L1_TUNING_SINGLE_TARGET_XTALK_SAMPLE_NUMBER,
26 | VL53L1_TUNING_MIN_AMBIENT_DMAX_VALID,
27 | VL53L1_TUNING_MAX_SIMPLE_OFFSET_CALIBRATION_SAMPLE_NUMBER,
28 | VL53L1_TUNING_XTALK_FULL_ROI_TARGET_DISTANCE_MM,
29 | VL53L1_TUNING_SIMPLE_OFFSET_CALIBRATION_REPEAT,
30 | VL53L1_TUNING_XTALK_FULL_ROI_BIN_SUM_MARGIN,
31 | VL53L1_TUNING_XTALK_FULL_ROI_DEFAULT_OFFSET,
32 | VL53L1_TUNING_ZERO_DISTANCE_OFFSET_NON_LINEAR_FACTOR,
33 | VL53L1_TUNING_PHASECAL_PATCH_POWER,
34 | VL53L1_TUNING_MAX_TUNABLE_KEY
35 | };
36 |
37 | /* default values for the tuning settings parameters */
38 | #define TUNING_VERSION 0x0007
39 |
40 | #define TUNING_PROXY_MIN -30 /* min distance in mm */
41 | #define TUNING_SINGLE_TARGET_XTALK_TARGET_DISTANCE_MM 600
42 | /* Target distance in mm for single target Xtalk */
43 | #define TUNING_SINGLE_TARGET_XTALK_SAMPLE_NUMBER 50
44 | /* Number of sample used for single target Xtalk */
45 | #define TUNING_MIN_AMBIENT_DMAX_VALID 8
46 | /* Minimum ambient level to state the Dmax returned by the device is valid */
47 | #define TUNING_MAX_SIMPLE_OFFSET_CALIBRATION_SAMPLE_NUMBER 50
48 | /* Maximum loops to perform simple offset calibration */
49 | #define TUNING_XTALK_FULL_ROI_TARGET_DISTANCE_MM 600
50 | /* Target distance in mm for target Xtalk from Bins method*/
51 | #define TUNING_SIMPLE_OFFSET_CALIBRATION_REPEAT 1
52 | /* Number of loops done during the simple offset calibration*/
53 | #define TUNING_ZERO_DISTANCE_OFFSET_NON_LINEAR_FACTOR_DEFAULT 9
54 | /* zero distance offset calibration non linear compensation default value */
55 |
56 | /* The following settings are related to the fix for ticket EwokP #558410 */
57 | #define TUNING_XTALK_FULL_ROI_BIN_SUM_MARGIN 24
58 | /* Acceptance margin for the xtalk_shape bin_data sum computation */
59 | #define TUNING_XTALK_FULL_ROI_DEFAULT_OFFSET 50
60 | /* Recovery value for Xtalk compensation plane offset in kcps */
61 | /* 50 stands for ~0.10 kcps cover glass in 7.9 format */
62 | /* End of settings related to the fix for ticket EwokP #558410 */
63 | #define TUNING_PHASECAL_PATCH_POWER 0
64 | /* PhaseCal duration patch tuning param
65 | * 0 default duration 15ms, 1 leads to 60ms, 2 for 240ms and 3 for 3580ms
66 | */
67 |
68 | #ifdef __cplusplus
69 | }
70 | #endif
71 |
72 | #endif /* _VL53L1_PRESET_SETUP_H_ */
73 |
--------------------------------------------------------------------------------
/sensor/vl53l1x/api/core/inc/vl53l1_register_settings.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, STMicroelectronics - All Rights Reserved
3 | *
4 | * This file is part of VL53L1 Core and is dual licensed,
5 | * either 'STMicroelectronics
6 | * Proprietary license'
7 | * or 'BSD 3-clause "New" or "Revised" License' , at your option.
8 | *
9 | ********************************************************************************
10 | *
11 | * 'STMicroelectronics Proprietary license'
12 | *
13 | ********************************************************************************
14 | *
15 | * License terms: STMicroelectronics Proprietary in accordance with licensing
16 | * terms at www.st.com/sla0081
17 | *
18 | * STMicroelectronics confidential
19 | * Reproduction and Communication of this document is strictly prohibited unless
20 | * specifically authorized in writing by STMicroelectronics.
21 | *
22 | *
23 | ********************************************************************************
24 | *
25 | * Alternatively, VL53L1 Core may be distributed under the terms of
26 | * 'BSD 3-clause "New" or "Revised" License', in which case the following
27 | * provisions apply instead of the ones mentioned above :
28 | *
29 | ********************************************************************************
30 | *
31 | * License terms: BSD 3-clause "New" or "Revised" License.
32 | *
33 | * Redistribution and use in source and binary forms, with or without
34 | * modification, are permitted provided that the following conditions are met:
35 | *
36 | * 1. Redistributions of source code must retain the above copyright notice, this
37 | * list of conditions and the following disclaimer.
38 | *
39 | * 2. Redistributions in binary form must reproduce the above copyright notice,
40 | * this list of conditions and the following disclaimer in the documentation
41 | * and/or other materials provided with the distribution.
42 | *
43 | * 3. Neither the name of the copyright holder nor the names of its contributors
44 | * may be used to endorse or promote products derived from this software
45 | * without specific prior written permission.
46 | *
47 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
48 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
51 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
53 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
54 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
55 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
56 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 | *
58 | *
59 | ********************************************************************************
60 | *
61 | */
62 |
63 | /**
64 | * @file vl53l1_register_settings.h
65 | *
66 | * @brief Device register setting defines.
67 | */
68 |
69 | #ifndef _VL53L1_REGISTER_SETTINGS_H_
70 | #define _VL53L1_REGISTER_SETTINGS_H_
71 |
72 |
73 | /** @defgroup VL53L1_RegisterSettings_group Functionality
74 | * @brief Defines the register settings for key device
75 | * configuration registers
76 | * @{
77 | */
78 |
79 | /** @defgroup VL53L1_DeviceSchedulerMode_group - Pseudo, Streaming & Hist
80 | * @brief Values below match the bit positions in the SYSTEM__MODE_START
81 | * register do not change
82 | * @{
83 | */
84 |
85 | #define VL53L1_DEVICESCHEDULERMODE_PSEUDO_SOLO 0x00
86 | #define VL53L1_DEVICESCHEDULERMODE_STREAMING 0x01
87 | #define VL53L1_DEVICESCHEDULERMODE_HISTOGRAM 0x02
88 |
89 | /** @} end of VL53L1_DeviceReadoutMode_group */
90 |
91 | /** @defgroup VL53L1_DeviceReadoutMode_group - Single, Dual, Split & Manual
92 | * @brief Values below match the bit positions in the SYSTEM__MODE_START
93 | * register do not change
94 | * @{
95 | */
96 |
97 | #define VL53L1_DEVICEREADOUTMODE_SINGLE_SD (0x00 << 2)
98 | #define VL53L1_DEVICEREADOUTMODE_DUAL_SD (0x01 << 2)
99 | #define VL53L1_DEVICEREADOUTMODE_SPLIT_READOUT (0x02 << 2)
100 | #define VL53L1_DEVICEREADOUTMODE_SPLIT_MANUAL (0x03 << 2)
101 |
102 | /** @} end of VL53L1_DeviceReadoutMode_group */
103 |
104 | /** @defgroup VL53L1_DeviceMeasurementMode_group - SingleShot, BackToBack & timed
105 | * @brief Values below match the bit positions in the SYSTEM__MODE_START
106 | * register do not change
107 | * @{
108 | */
109 |
110 | /*
111 | #define VL53L1_DEVICEMEASUREMENTMODE_STOP 0x00
112 | #define VL53L1_DEVICEMEASUREMENTMODE_SINGLESHOT 0x10
113 | #define VL53L1_DEVICEMEASUREMENTMODE_BACKTOBACK 0x20
114 | #define VL53L1_DEVICEMEASUREMENTMODE_TIMED 0x40
115 | #define VL53L1_DEVICEMEASUREMENTMODE_ABORT 0x80
116 | */
117 | #define VL53L1_DEVICEMEASUREMENTMODE_MODE_MASK 0xF0
118 | #define VL53L1_DEVICEMEASUREMENTMODE_STOP_MASK 0x0F
119 |
120 | #define VL53L1_GROUPEDPARAMETERHOLD_ID_MASK 0x02
121 |
122 | /** @} end of VL53L1_DeviceMeasurementMode_group */
123 |
124 | #define VL53L1_EWOK_I2C_DEV_ADDR_DEFAULT 0x29
125 | /*!< Device default 7-bit I2C address */
126 | #define VL53L1_OSC_FREQUENCY 0x00
127 | #define VL53L1_OSC_TRIM_DEFAULT 0x00
128 | #define VL53L1_OSC_FREQ_SET_DEFAULT 0x00
129 |
130 | #define VL53L1_RANGE_HISTOGRAM_REF 0x08
131 | #define VL53L1_RANGE_HISTOGRAM_RET 0x10
132 | #define VL53L1_RANGE_HISTOGRAM_BOTH 0x18
133 | #define VL53L1_RANGE_HISTOGRAM_INIT 0x20
134 | #define VL53L1_RANGE_VHV_INIT 0x40
135 |
136 | /* Result Status */
137 | #define VL53L1_RESULT_RANGE_STATUS 0x1F
138 |
139 | /* */
140 | #define VL53L1_SYSTEM__SEED_CONFIG__MANUAL 0x00
141 | #define VL53L1_SYSTEM__SEED_CONFIG__STANDARD 0x01
142 | #define VL53L1_SYSTEM__SEED_CONFIG__EVEN_UPDATE_ONLY 0x02
143 |
144 | /* Interrupt Config */
145 | #define VL53L1_INTERRUPT_CONFIG_LEVEL_LOW 0x00
146 | #define VL53L1_INTERRUPT_CONFIG_LEVEL_HIGH 0x01
147 | #define VL53L1_INTERRUPT_CONFIG_OUT_OF_WINDOW 0x02
148 | #define VL53L1_INTERRUPT_CONFIG_IN_WINDOW 0x03
149 | #define VL53L1_INTERRUPT_CONFIG_NEW_SAMPLE_READY 0x20
150 |
151 | /* Interrupt Clear */
152 | #define VL53L1_CLEAR_RANGE_INT 0x01
153 | #define VL53L1_CLEAR_ERROR_INT 0x02
154 |
155 | /* Sequence Config */
156 | #define VL53L1_SEQUENCE_VHV_EN 0x01
157 | #define VL53L1_SEQUENCE_PHASECAL_EN 0x02
158 | #define VL53L1_SEQUENCE_REFERENCE_PHASE_EN 0x04
159 | #define VL53L1_SEQUENCE_DSS1_EN 0x08
160 | #define VL53L1_SEQUENCE_DSS2_EN 0x10
161 | #define VL53L1_SEQUENCE_MM1_EN 0x20
162 | #define VL53L1_SEQUENCE_MM2_EN 0x40
163 | #define VL53L1_SEQUENCE_RANGE_EN 0x80
164 |
165 | /* defines for DSS__ROI_CONTROL */
166 | #define VL53L1_DSS_CONTROL__ROI_SUBTRACT 0x20
167 | #define VL53L1_DSS_CONTROL__ROI_INTERSECT 0x10
168 |
169 | #define VL53L1_DSS_CONTROL__MODE_DISABLED 0x00
170 | #define VL53L1_DSS_CONTROL__MODE_TARGET_RATE 0x01
171 | #define VL53L1_DSS_CONTROL__MODE_EFFSPADS 0x02
172 | #define VL53L1_DSS_CONTROL__MODE_BLOCKSELECT 0x03
173 |
174 | /* SPAD Readout defines
175 | *
176 | * 7:6 - SPAD_IN_SEL_REF
177 | * 5:4 - SPAD_IN_SEL_RTN
178 | * 2 - SPAD_PS_BYPASS
179 | * 0 - SPAD_EN_PULSE_EXTENDER
180 | */
181 |
182 | #define VL53L1_RANGING_CORE__SPAD_READOUT__STANDARD 0x45
183 | #define VL53L1_RANGING_CORE__SPAD_READOUT__RETURN_ARRAY_ONLY 0x05
184 | #define VL53L1_RANGING_CORE__SPAD_READOUT__REFERENCE_ARRAY_ONLY 0x55
185 | #define VL53L1_RANGING_CORE__SPAD_READOUT__RETURN_SPLIT_ARRAY 0x25
186 | #define VL53L1_RANGING_CORE__SPAD_READOUT__CALIB_PULSES 0xF5
187 |
188 |
189 | #define VL53L1_LASER_SAFETY__KEY_VALUE 0x6C
190 |
191 | /* Range Status defines
192 | *
193 | * 7 - GPH ID
194 | * 6 - Min threshold hit
195 | * 5 - Max threshold hit
196 | * 4:0 - Range Status
197 | */
198 |
199 | #define VL53L1_RANGE_STATUS__RANGE_STATUS_MASK 0x1F
200 | #define VL53L1_RANGE_STATUS__MAX_THRESHOLD_HIT_MASK 0x20
201 | #define VL53L1_RANGE_STATUS__MIN_THRESHOLD_HIT_MASK 0x40
202 | #define VL53L1_RANGE_STATUS__GPH_ID_RANGE_STATUS_MASK 0x80
203 |
204 | /* Interrupt Status defines
205 | *
206 | * 5 - GPH ID
207 | * 4:3 - Interrupt Error Status
208 | * 2:0 - Interrupt Status
209 | */
210 |
211 | #define VL53L1_INTERRUPT_STATUS__INT_STATUS_MASK 0x07
212 | #define VL53L1_INTERRUPT_STATUS__INT_ERROR_STATUS_MASK 0x18
213 | #define VL53L1_INTERRUPT_STATUS__GPH_ID_INT_STATUS_MASK 0x20
214 |
215 | /** @} end of VL53L1_RegisterSettings_group */
216 |
217 |
218 | #endif
219 |
220 | /* _VL53L1_REGISTER_SETTINGS_H_ */
221 |
222 |
223 |
--------------------------------------------------------------------------------
/sensor/vl53l1x/api/core/inc/vl53l1_silicon_core.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, STMicroelectronics - All Rights Reserved
3 | *
4 | * This file is part of VL53L1 Core and is dual licensed,
5 | * either 'STMicroelectronics
6 | * Proprietary license'
7 | * or 'BSD 3-clause "New" or "Revised" License' , at your option.
8 | *
9 | ********************************************************************************
10 | *
11 | * 'STMicroelectronics Proprietary license'
12 | *
13 | ********************************************************************************
14 | *
15 | * License terms: STMicroelectronics Proprietary in accordance with licensing
16 | * terms at www.st.com/sla0081
17 | *
18 | * STMicroelectronics confidential
19 | * Reproduction and Communication of this document is strictly prohibited unless
20 | * specifically authorized in writing by STMicroelectronics.
21 | *
22 | *
23 | ********************************************************************************
24 | *
25 | * Alternatively, VL53L1 Core may be distributed under the terms of
26 | * 'BSD 3-clause "New" or "Revised" License', in which case the following
27 | * provisions apply instead of the ones mentioned above :
28 | *
29 | ********************************************************************************
30 | *
31 | * License terms: BSD 3-clause "New" or "Revised" License.
32 | *
33 | * Redistribution and use in source and binary forms, with or without
34 | * modification, are permitted provided that the following conditions are met:
35 | *
36 | * 1. Redistributions of source code must retain the above copyright notice, this
37 | * list of conditions and the following disclaimer.
38 | *
39 | * 2. Redistributions in binary form must reproduce the above copyright notice,
40 | * this list of conditions and the following disclaimer in the documentation
41 | * and/or other materials provided with the distribution.
42 | *
43 | * 3. Neither the name of the copyright holder nor the names of its contributors
44 | * may be used to endorse or promote products derived from this software
45 | * without specific prior written permission.
46 | *
47 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
48 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
51 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
53 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
54 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
55 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
56 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 | *
58 | *
59 | ********************************************************************************
60 | *
61 | */
62 |
63 | /**
64 | * @file vl53l1_silicon_core.h
65 | *
66 | * @brief EwokPlus25 low level silicon specific API function definitions
67 | */
68 |
69 | #ifndef _VL53L1_SILICON_CORE_H_
70 | #define _VL53L1_SILICON_CORE_H_
71 |
72 | #include "vl53l1_platform.h"
73 |
74 | #ifdef __cplusplus
75 | extern "C" {
76 | #endif
77 |
78 |
79 | /**
80 | * @brief Checks if the firmware is ready for ranging (Silicon variant)
81 | *
82 | * @param[in] Dev : Device Handle
83 | * @param[out] pready : pointer to data ready flag \n
84 | * 0 = firmware not ready \n
85 | * 1 = firmware ready
86 | *
87 | * @return VL53L1_ERROR_NONE Success
88 | * @return "Other error code" See ::VL53L1_Error
89 | */
90 |
91 | VL53L1_Error VL53L1_is_firmware_ready_silicon(
92 | VL53L1_DEV Dev,
93 | uint8_t *pready);
94 |
95 |
96 | #ifdef __cplusplus
97 | }
98 | #endif
99 |
100 | #endif /* _VL53L1_SILICON_CORE_H_ */
101 |
--------------------------------------------------------------------------------
/sensor/vl53l1x/api/core/inc/vl53l1_tuning_parm_defaults.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, STMicroelectronics - All Rights Reserved
3 | *
4 | * This file is part of VL53L1 Core and is dual licensed,
5 | * either 'STMicroelectronics
6 | * Proprietary license'
7 | * or 'BSD 3-clause "New" or "Revised" License' , at your option.
8 | *
9 | ********************************************************************************
10 | *
11 | * 'STMicroelectronics Proprietary license'
12 | *
13 | ********************************************************************************
14 | *
15 | * License terms: STMicroelectronics Proprietary in accordance with licensing
16 | * terms at www.st.com/sla0081
17 | *
18 | * STMicroelectronics confidential
19 | * Reproduction and Communication of this document is strictly prohibited unless
20 | * specifically authorized in writing by STMicroelectronics.
21 | *
22 | *
23 | ********************************************************************************
24 | *
25 | * Alternatively, VL53L1 Core may be distributed under the terms of
26 | * 'BSD 3-clause "New" or "Revised" License', in which case the following
27 | * provisions apply instead of the ones mentioned above :
28 | *
29 | ********************************************************************************
30 | *
31 | * License terms: BSD 3-clause "New" or "Revised" License.
32 | *
33 | * Redistribution and use in source and binary forms, with or without
34 | * modification, are permitted provided that the following conditions are met:
35 | *
36 | * 1. Redistributions of source code must retain the above copyright notice, this
37 | * list of conditions and the following disclaimer.
38 | *
39 | * 2. Redistributions in binary form must reproduce the above copyright notice,
40 | * this list of conditions and the following disclaimer in the documentation
41 | * and/or other materials provided with the distribution.
42 | *
43 | * 3. Neither the name of the copyright holder nor the names of its contributors
44 | * may be used to endorse or promote products derived from this software
45 | * without specific prior written permission.
46 | *
47 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
48 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
51 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
53 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
54 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
55 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
56 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 | *
58 | *
59 | ********************************************************************************
60 | *
61 | */
62 |
63 | /**
64 | * @file vl53l1_tuning_parm_defaults.h
65 | *
66 | * @brief Define defaults for tuning parm list
67 | *
68 | * - Ensures coherence of internal defaults to tuning table
69 | * - Allows reduction of tuning parm list to only changes from the
70 | * standard settings defined below
71 | *
72 | */
73 |
74 |
75 | #ifndef _VL53L1_TUNING_PARM_DEFAULTS_H_
76 | #define _VL53L1_TUNING_PARM_DEFAULTS_H_
77 |
78 |
79 | #ifdef __cplusplus
80 | extern "C" {
81 | #endif
82 |
83 | /** @defgroup VL53L1_tuningparmdefault_group VL53L1 Defines
84 | * @brief VL53L1 Tuning Parm Default Values
85 | * @{
86 | */
87 |
88 | #define VL53L1_TUNINGPARM_VERSION_DEFAULT \
89 | ((uint16_t) 32771)
90 | #define VL53L1_TUNINGPARM_KEY_TABLE_VERSION_DEFAULT \
91 | ((uint16_t) 32769)
92 | #define VL53L1_TUNINGPARM_LLD_VERSION_DEFAULT \
93 | ((uint16_t) 32833)
94 | #define VL53L1_TUNINGPARM_CONSISTENCY_LITE_PHASE_TOLERANCE_DEFAULT \
95 | ((uint8_t) 2)
96 | #define VL53L1_TUNINGPARM_PHASECAL_TARGET_DEFAULT \
97 | ((uint8_t) 33)
98 | #define VL53L1_TUNINGPARM_LITE_CAL_REPEAT_RATE_DEFAULT \
99 | ((uint16_t) 0)
100 | #define VL53L1_TUNINGPARM_LITE_RANGING_GAIN_FACTOR_DEFAULT \
101 | ((uint16_t) 2011)
102 | #define VL53L1_TUNINGPARM_LITE_MIN_CLIP_MM_DEFAULT \
103 | ((uint8_t) 0)
104 | #define VL53L1_TUNINGPARM_LITE_LONG_SIGMA_THRESH_MM_DEFAULT \
105 | ((uint16_t) 360)
106 | #define VL53L1_TUNINGPARM_LITE_MED_SIGMA_THRESH_MM_DEFAULT \
107 | ((uint16_t) 360)
108 | #define VL53L1_TUNINGPARM_LITE_SHORT_SIGMA_THRESH_MM_DEFAULT \
109 | ((uint16_t) 360)
110 | #define VL53L1_TUNINGPARM_LITE_LONG_MIN_COUNT_RATE_RTN_MCPS_DEFAULT \
111 | ((uint16_t) 192)
112 | #define VL53L1_TUNINGPARM_LITE_MED_MIN_COUNT_RATE_RTN_MCPS_DEFAULT \
113 | ((uint16_t) 192)
114 | #define VL53L1_TUNINGPARM_LITE_SHORT_MIN_COUNT_RATE_RTN_MCPS_DEFAULT \
115 | ((uint16_t) 192)
116 | #define VL53L1_TUNINGPARM_LITE_SIGMA_EST_PULSE_WIDTH_DEFAULT \
117 | ((uint8_t) 8)
118 | #define VL53L1_TUNINGPARM_LITE_SIGMA_EST_AMB_WIDTH_NS_DEFAULT \
119 | ((uint8_t) 16)
120 | #define VL53L1_TUNINGPARM_LITE_SIGMA_REF_MM_DEFAULT \
121 | ((uint8_t) 1)
122 | #define VL53L1_TUNINGPARM_LITE_RIT_MULT_DEFAULT \
123 | ((uint8_t) 64)
124 | #define VL53L1_TUNINGPARM_LITE_SEED_CONFIG_DEFAULT \
125 | ((uint8_t) 2)
126 | #define VL53L1_TUNINGPARM_LITE_QUANTIFIER_DEFAULT \
127 | ((uint8_t) 2)
128 | #define VL53L1_TUNINGPARM_LITE_FIRST_ORDER_SELECT_DEFAULT \
129 | ((uint8_t) 0)
130 | #define VL53L1_TUNINGPARM_LITE_XTALK_MARGIN_KCPS_DEFAULT \
131 | ((int16_t) 0)
132 | #define VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_LITE_LONG_RANGE_DEFAULT \
133 | ((uint8_t) 14)
134 | #define VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_LITE_MED_RANGE_DEFAULT \
135 | ((uint8_t) 10)
136 | #define VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_LITE_SHORT_RANGE_DEFAULT \
137 | ((uint8_t) 6)
138 | #define VL53L1_TUNINGPARM_INITIAL_PHASE_REF_LITE_LONG_RANGE_DEFAULT \
139 | ((uint8_t) 14)
140 | #define VL53L1_TUNINGPARM_INITIAL_PHASE_REF_LITE_MED_RANGE_DEFAULT \
141 | ((uint8_t) 10)
142 | #define VL53L1_TUNINGPARM_INITIAL_PHASE_REF_LITE_SHORT_RANGE_DEFAULT \
143 | ((uint8_t) 6)
144 | #define VL53L1_TUNINGPARM_TIMED_SEED_CONFIG_DEFAULT \
145 | ((uint8_t) 1)
146 | #define VL53L1_TUNINGPARM_VHV_LOOPBOUND_DEFAULT \
147 | ((uint8_t) 32)
148 | #define VL53L1_TUNINGPARM_REFSPADCHAR_DEVICE_TEST_MODE_DEFAULT \
149 | ((uint8_t) 8)
150 | #define VL53L1_TUNINGPARM_REFSPADCHAR_VCSEL_PERIOD_DEFAULT \
151 | ((uint8_t) 11)
152 | #define VL53L1_TUNINGPARM_REFSPADCHAR_PHASECAL_TIMEOUT_US_DEFAULT \
153 | ((uint32_t) 1000)
154 | #define VL53L1_TUNINGPARM_REFSPADCHAR_TARGET_COUNT_RATE_MCPS_DEFAULT \
155 | ((uint16_t) 2560)
156 | #define VL53L1_TUNINGPARM_REFSPADCHAR_MIN_COUNTRATE_LIMIT_MCPS_DEFAULT \
157 | ((uint16_t) 1280)
158 | #define VL53L1_TUNINGPARM_REFSPADCHAR_MAX_COUNTRATE_LIMIT_MCPS_DEFAULT \
159 | ((uint16_t) 5120)
160 | #define VL53L1_TUNINGPARM_OFFSET_CAL_DSS_RATE_MCPS_DEFAULT \
161 | ((uint16_t) 2560)
162 | #define VL53L1_TUNINGPARM_OFFSET_CAL_PHASECAL_TIMEOUT_US_DEFAULT \
163 | ((uint32_t) 1000)
164 | #define VL53L1_TUNINGPARM_OFFSET_CAL_MM_TIMEOUT_US_DEFAULT \
165 | ((uint32_t) 13000)
166 | #define VL53L1_TUNINGPARM_OFFSET_CAL_RANGE_TIMEOUT_US_DEFAULT \
167 | ((uint32_t) 13000)
168 | #define VL53L1_TUNINGPARM_OFFSET_CAL_PRE_SAMPLES_DEFAULT \
169 | ((uint8_t) 8)
170 | #define VL53L1_TUNINGPARM_OFFSET_CAL_MM1_SAMPLES_DEFAULT \
171 | ((uint8_t) 40)
172 | #define VL53L1_TUNINGPARM_OFFSET_CAL_MM2_SAMPLES_DEFAULT \
173 | ((uint8_t) 9)
174 | #define VL53L1_TUNINGPARM_SPADMAP_VCSEL_PERIOD_DEFAULT \
175 | ((uint8_t) 18)
176 | #define VL53L1_TUNINGPARM_SPADMAP_VCSEL_START_DEFAULT \
177 | ((uint8_t) 15)
178 | #define VL53L1_TUNINGPARM_SPADMAP_RATE_LIMIT_MCPS_DEFAULT \
179 | ((uint16_t) 12)
180 | #define VL53L1_TUNINGPARM_LITE_DSS_CONFIG_TARGET_TOTAL_RATE_MCPS_DEFAULT \
181 | ((uint16_t) 2560)
182 | #define VL53L1_TUNINGPARM_TIMED_DSS_CONFIG_TARGET_TOTAL_RATE_MCPS_DEFAULT \
183 | ((uint16_t) 2560)
184 | #define VL53L1_TUNINGPARM_LITE_PHASECAL_CONFIG_TIMEOUT_US_DEFAULT \
185 | ((uint32_t) 1000)
186 | #define VL53L1_TUNINGPARM_TIMED_PHASECAL_CONFIG_TIMEOUT_US_DEFAULT \
187 | ((uint32_t) 1000)
188 | #define VL53L1_TUNINGPARM_LITE_MM_CONFIG_TIMEOUT_US_DEFAULT \
189 | ((uint32_t) 2000)
190 | #define VL53L1_TUNINGPARM_TIMED_MM_CONFIG_TIMEOUT_US_DEFAULT \
191 | ((uint32_t) 2000)
192 | #define VL53L1_TUNINGPARM_LITE_RANGE_CONFIG_TIMEOUT_US_DEFAULT \
193 | ((uint32_t) 63000)
194 | #define VL53L1_TUNINGPARM_TIMED_RANGE_CONFIG_TIMEOUT_US_DEFAULT \
195 | ((uint32_t) 13000)
196 | #define VL53L1_TUNINGPARM_LOWPOWERAUTO_VHV_LOOP_BOUND_DEFAULT \
197 | ((uint8_t) 3)
198 | #define VL53L1_TUNINGPARM_LOWPOWERAUTO_MM_CONFIG_TIMEOUT_US_DEFAULT \
199 | ((uint32_t) 700)
200 | #define VL53L1_TUNINGPARM_LOWPOWERAUTO_RANGE_CONFIG_TIMEOUT_US_DEFAULT \
201 | ((uint32_t) 8000)
202 |
203 |
204 | #ifdef __cplusplus
205 | }
206 | #endif
207 |
208 | #endif /* _VL53L1_LL_DEF_H_ */
209 |
210 |
211 |
--------------------------------------------------------------------------------
/sensor/vl53l1x/api/core/inc/vl53l1_wait.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, STMicroelectronics - All Rights Reserved
3 | *
4 | * This file is part of VL53L1 Core and is dual licensed,
5 | * either 'STMicroelectronics
6 | * Proprietary license'
7 | * or 'BSD 3-clause "New" or "Revised" License' , at your option.
8 | *
9 | ********************************************************************************
10 | *
11 | * 'STMicroelectronics Proprietary license'
12 | *
13 | ********************************************************************************
14 | *
15 | * License terms: STMicroelectronics Proprietary in accordance with licensing
16 | * terms at www.st.com/sla0081
17 | *
18 | * STMicroelectronics confidential
19 | * Reproduction and Communication of this document is strictly prohibited unless
20 | * specifically authorized in writing by STMicroelectronics.
21 | *
22 | *
23 | ********************************************************************************
24 | *
25 | * Alternatively, VL53L1 Core may be distributed under the terms of
26 | * 'BSD 3-clause "New" or "Revised" License', in which case the following
27 | * provisions apply instead of the ones mentioned above :
28 | *
29 | ********************************************************************************
30 | *
31 | * License terms: BSD 3-clause "New" or "Revised" License.
32 | *
33 | * Redistribution and use in source and binary forms, with or without
34 | * modification, are permitted provided that the following conditions are met:
35 | *
36 | * 1. Redistributions of source code must retain the above copyright notice, this
37 | * list of conditions and the following disclaimer.
38 | *
39 | * 2. Redistributions in binary form must reproduce the above copyright notice,
40 | * this list of conditions and the following disclaimer in the documentation
41 | * and/or other materials provided with the distribution.
42 | *
43 | * 3. Neither the name of the copyright holder nor the names of its contributors
44 | * may be used to endorse or promote products derived from this software
45 | * without specific prior written permission.
46 | *
47 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
48 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
51 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
53 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
54 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
55 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
56 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 | *
58 | *
59 | ********************************************************************************
60 | *
61 | */
62 |
63 | /**
64 | * @file vl53l1_wait.h
65 | *
66 | * @brief EwokPlus25 low level Driver wait function definitions
67 | */
68 |
69 | #ifndef _VL53L1_WAIT_H_
70 | #define _VL53L1_WAIT_H_
71 |
72 | #include "vl53l1_platform.h"
73 |
74 | #ifdef __cplusplus
75 | extern "C" {
76 | #endif
77 |
78 |
79 | /**
80 | * @brief Wait for initial firmware boot to finish
81 | *
82 | * Calls VL53L1_poll_for_boot_completion()
83 | *
84 | * @param[in] Dev : Device handle
85 | *
86 | * @return VL53L1_ERROR_NONE Success
87 | * @return "Other error code" See ::VL53L1_Error
88 | */
89 |
90 | VL53L1_Error VL53L1_wait_for_boot_completion(
91 | VL53L1_DEV Dev);
92 |
93 |
94 | /**
95 | * @brief Waits for initial firmware ready
96 | *
97 | * Only waits to see if the firmware is ready in timed and
98 | * single shot modes.
99 | *
100 | * Calls VL53L1_poll_for_firmware_ready()
101 | *
102 | * @param[in] Dev : Device handle
103 | *
104 | * @return VL53L1_ERROR_NONE Success
105 | * @return "Other error code" See ::VL53L1_Error
106 | */
107 |
108 | VL53L1_Error VL53L1_wait_for_firmware_ready(
109 | VL53L1_DEV Dev);
110 |
111 |
112 | /**
113 | * @brief Waits for the next ranging interrupt
114 | *
115 | * Calls VL53L1_poll_for_range_completion()
116 | *
117 | * @param[in] Dev : Device handle
118 | *
119 | * @return VL53L1_ERROR_NONE Success
120 | * @return "Other error code" See ::VL53L1_Error
121 | */
122 |
123 | VL53L1_Error VL53L1_wait_for_range_completion(
124 | VL53L1_DEV Dev);
125 |
126 |
127 | /**
128 | * @brief Waits for a device test mode to complete.
129 |
130 | * Calls VL53L1_poll_for_test_completion()
131 | *
132 | * @param[in] Dev : Device Handle
133 | *
134 | * @return VL53L1_ERROR_NONE Success
135 | * @return "Other error code" See ::VL53L1_Error
136 | */
137 |
138 | VL53L1_Error VL53L1_wait_for_test_completion(
139 | VL53L1_DEV Dev);
140 |
141 |
142 |
143 |
144 | /**
145 | * @brief Reads FIRMWARE__SYSTEM_STATUS register to detect if the
146 | * firmware was finished booting
147 | *
148 | * @param[in] Dev : Device handle
149 | * @param[out] pready : pointer to data ready flag \n
150 | * 0 = boot not complete \n
151 | * 1 = boot complete
152 | *
153 | * @return VL53L1_ERROR_NONE Success
154 | * @return "Other error code" See ::VL53L1_Error
155 | */
156 |
157 | VL53L1_Error VL53L1_is_boot_complete(
158 | VL53L1_DEV Dev,
159 | uint8_t *pready);
160 |
161 | /**
162 | * @brief Reads FIRMWARE__SYSTEM_STATUS register to detect if the
163 | * firmware is ready for ranging.
164 | *
165 | * @param[in] Dev : Device handle
166 | * @param[out] pready : pointer to data ready flag \n
167 | * 0 = firmware not ready \n
168 | * 1 = firmware ready
169 | *
170 | * @return VL53L1_ERROR_NONE Success
171 | * @return "Other error code" See ::VL53L1_Error
172 | */
173 |
174 | VL53L1_Error VL53L1_is_firmware_ready(
175 | VL53L1_DEV Dev,
176 | uint8_t *pready);
177 |
178 |
179 | /**
180 | * @brief Reads bit 0 of VL53L1_GPIO__TIO_HV_STATUS register to determine
181 | * if new range data is ready (available).
182 | *
183 | * Interrupt may be either active high or active low. The behaviour of bit 0
184 | * of the VL53L1_GPIO__TIO_HV_STATUS register is the same as the interrupt
185 | * signal generated on the GPIO pin.
186 | *
187 | * pdev->stat_cfg.gpio_hv_mux_ctrl bit 4 is used to select required check level
188 | *
189 | *
190 | * @param[in] Dev : Device handle
191 | * @param[out] pready : pointer to data ready flag \n
192 | * 0 = data not ready \n
193 | * 1 = new range data available
194 | *
195 | * @return VL53L1_ERROR_NONE Success
196 | * @return "Other error code" See ::VL53L1_Error
197 | */
198 |
199 | VL53L1_Error VL53L1_is_new_data_ready(
200 | VL53L1_DEV Dev,
201 | uint8_t *pready);
202 |
203 |
204 |
205 |
206 | /**
207 | * @brief Waits (polls) for initial firmware boot to finish
208 | *
209 | * After power on or a device reset via XSHUTDOWN EwokPlus25 firmware takes
210 | * about 2ms to boot. During this boot sequence elected NVM data is copied
211 | * to the device's Host & MCU G02 registers
212 | *
213 | * This function polls the FIRMWARE__SYSTEM_STATUS register to detect when
214 | * firmware is ready.
215 | *
216 | * Polling is implemented using VL53L1_WaitValueMaskEx()
217 | *
218 | * @param[in] Dev : Device handle
219 | * @param[in] timeout_ms : Wait timeout in [ms]
220 | *
221 | * @return VL53L1_ERROR_NONE Success
222 | * @return "Other error code" See ::VL53L1_Error
223 | */
224 |
225 | VL53L1_Error VL53L1_poll_for_boot_completion(
226 | VL53L1_DEV Dev,
227 | uint32_t timeout_ms);
228 |
229 |
230 | /**
231 | * @brief Waits (polls) for initial firmware ready
232 | *
233 | * Polling is implemented using VL53L1_WaitValueMaskEx()
234 | *
235 | * @param[in] Dev : Device handle
236 | * @param[in] timeout_ms : Wait timeout in [ms]
237 | *
238 | * @return VL53L1_ERROR_NONE Success
239 | * @return "Other error code" See ::VL53L1_Error
240 | */
241 |
242 | VL53L1_Error VL53L1_poll_for_firmware_ready(
243 | VL53L1_DEV Dev,
244 | uint32_t timeout_ms);
245 |
246 |
247 | /**
248 | * @brief Polls bit 0 of VL53L1_GPIO__TIO_HV_STATUS register to determine
249 | * the state of the GPIO (Interrupt) pin.
250 | *
251 | * Interrupt may be either active high or active low. The behaviour of bit 0
252 | * of the VL53L1_GPIO__TIO_HV_STATUS register is the same as the interrupt
253 | * signal generated on the GPIO pin.
254 | *
255 | * pdev->stat_cfg.gpio_hv_mux_ctrl bit 4 is used to select required check level
256 | *
257 | * Polling is implemented using VL53L1_WaitValueMaskEx()
258 | *
259 | * @param[in] Dev : Device handle
260 | * @param[in] timeout_ms : Wait timeout in [ms]
261 | *
262 | * @return VL53L1_ERROR_NONE Success
263 | * @return "Other error code" See ::VL53L1_Error
264 | */
265 |
266 | VL53L1_Error VL53L1_poll_for_range_completion(
267 | VL53L1_DEV Dev,
268 | uint32_t timeout_ms);
269 |
270 |
271 |
272 | #ifdef __cplusplus
273 | }
274 | #endif
275 |
276 | #endif /* _VL53L1_WAIT_H_ */
277 |
--------------------------------------------------------------------------------
/sensor/vl53l1x/api/core/src/vl53l1_api_strings.c:
--------------------------------------------------------------------------------
1 |
2 | // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
3 | /******************************************************************************
4 | * Copyright (c) 2020, STMicroelectronics - All Rights Reserved
5 |
6 | This file is part of VL53L1 and is dual licensed,
7 | either GPL-2.0+
8 | or 'BSD 3-clause "New" or "Revised" License' , at your option.
9 | ******************************************************************************
10 | */
11 |
12 | /**
13 | * @file vl53l1_api_strings.c
14 | * @brief VL53L1 API functions for decoding error codes to a text string
15 | */
16 |
17 | #include "vl53l1_api_core.h"
18 | #include "vl53l1_api_strings.h"
19 | #include "vl53l1_error_codes.h"
20 | #include "vl53l1_error_strings.h"
21 |
22 | #define LOG_FUNCTION_START(fmt, ...) \
23 | _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_API, fmt, ##__VA_ARGS__)
24 | #define LOG_FUNCTION_END(status, ...) \
25 | _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_API, status, ##__VA_ARGS__)
26 | #define LOG_FUNCTION_END_FMT(status, fmt, ...) \
27 | _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_API, status, fmt, \
28 | ##__VA_ARGS__)
29 |
30 |
31 | VL53L1_Error VL53L1_get_range_status_string(
32 | uint8_t RangeStatus,
33 | char *pRangeStatusString)
34 | {
35 | VL53L1_Error status = VL53L1_ERROR_NONE;
36 |
37 | LOG_FUNCTION_START("");
38 |
39 | #ifdef VL53L1_USE_EMPTY_STRING
40 | SUPPRESS_UNUSED_WARNING(RangeStatus);
41 | VL53L1_COPYSTRING(pRangeStatusString, "");
42 | #else
43 | switch (RangeStatus) {
44 | case 0:
45 | VL53L1_COPYSTRING(pRangeStatusString,
46 | VL53L1_STRING_RANGESTATUS_RANGEVALID);
47 | break;
48 | case 1:
49 | VL53L1_COPYSTRING(pRangeStatusString,
50 | VL53L1_STRING_RANGESTATUS_SIGMA);
51 | break;
52 | case 2:
53 | VL53L1_COPYSTRING(pRangeStatusString,
54 | VL53L1_STRING_RANGESTATUS_SIGNAL);
55 | break;
56 | case 3:
57 | VL53L1_COPYSTRING(pRangeStatusString,
58 | VL53L1_STRING_RANGESTATUS_MINRANGE);
59 | break;
60 | case 4:
61 | VL53L1_COPYSTRING(pRangeStatusString,
62 | VL53L1_STRING_RANGESTATUS_PHASE);
63 | break;
64 | case 5:
65 | VL53L1_COPYSTRING(pRangeStatusString,
66 | VL53L1_STRING_RANGESTATUS_HW);
67 | break;
68 |
69 | default: /**/
70 | VL53L1_COPYSTRING(pRangeStatusString,
71 | VL53L1_STRING_RANGESTATUS_NONE);
72 | }
73 | #endif
74 |
75 | LOG_FUNCTION_END(status);
76 | return status;
77 | }
78 |
79 |
80 | VL53L1_Error VL53L1_get_pal_state_string(
81 | VL53L1_State PalStateCode,
82 | char *pPalStateString)
83 | {
84 | VL53L1_Error status = VL53L1_ERROR_NONE;
85 |
86 | LOG_FUNCTION_START("");
87 |
88 | #ifdef VL53L1_USE_EMPTY_STRING
89 | SUPPRESS_UNUSED_WARNING(PalStateCode);
90 | VL53L1_COPYSTRING(pPalStateString, "");
91 | #else
92 | switch (PalStateCode) {
93 | case VL53L1_STATE_POWERDOWN:
94 | VL53L1_COPYSTRING(pPalStateString,
95 | VL53L1_STRING_STATE_POWERDOWN);
96 | break;
97 | case VL53L1_STATE_WAIT_STATICINIT:
98 | VL53L1_COPYSTRING(pPalStateString,
99 | VL53L1_STRING_STATE_WAIT_STATICINIT);
100 | break;
101 | case VL53L1_STATE_STANDBY:
102 | VL53L1_COPYSTRING(pPalStateString,
103 | VL53L1_STRING_STATE_STANDBY);
104 | break;
105 | case VL53L1_STATE_IDLE:
106 | VL53L1_COPYSTRING(pPalStateString,
107 | VL53L1_STRING_STATE_IDLE);
108 | break;
109 | case VL53L1_STATE_RUNNING:
110 | VL53L1_COPYSTRING(pPalStateString,
111 | VL53L1_STRING_STATE_RUNNING);
112 | break;
113 | case VL53L1_STATE_RESET:
114 | VL53L1_COPYSTRING(pPalStateString,
115 | VL53L1_STRING_STATE_RESET);
116 | break;
117 | case VL53L1_STATE_UNKNOWN:
118 | VL53L1_COPYSTRING(pPalStateString,
119 | VL53L1_STRING_STATE_UNKNOWN);
120 | break;
121 | case VL53L1_STATE_ERROR:
122 | VL53L1_COPYSTRING(pPalStateString,
123 | VL53L1_STRING_STATE_ERROR);
124 | break;
125 |
126 | default:
127 | VL53L1_COPYSTRING(pPalStateString,
128 | VL53L1_STRING_STATE_UNKNOWN);
129 | }
130 | #endif
131 |
132 | LOG_FUNCTION_END(status);
133 | return status;
134 | }
135 |
136 | VL53L1_Error VL53L1_get_sequence_steps_info(
137 | VL53L1_SequenceStepId SequenceStepId,
138 | char *pSequenceStepsString)
139 | {
140 | VL53L1_Error Status = VL53L1_ERROR_NONE;
141 |
142 | LOG_FUNCTION_START("");
143 |
144 | #ifdef VL53L1_USE_EMPTY_STRING
145 | SUPPRESS_UNUSED_WARNING(SequenceStepId);
146 | VL53L1_COPYSTRING(pSequenceStepsString, "");
147 | #else
148 | switch (SequenceStepId) {
149 | case VL53L1_SEQUENCESTEP_VHV:
150 | VL53L1_COPYSTRING(pSequenceStepsString,
151 | VL53L1_STRING_SEQUENCESTEP_VHV);
152 | break;
153 | case VL53L1_SEQUENCESTEP_PHASECAL:
154 | VL53L1_COPYSTRING(pSequenceStepsString,
155 | VL53L1_STRING_SEQUENCESTEP_PHASECAL);
156 | break;
157 | case VL53L1_SEQUENCESTEP_REFPHASE:
158 | VL53L1_COPYSTRING(pSequenceStepsString,
159 | VL53L1_STRING_SEQUENCESTEP_DSS1);
160 | break;
161 | case VL53L1_SEQUENCESTEP_DSS1:
162 | VL53L1_COPYSTRING(pSequenceStepsString,
163 | VL53L1_STRING_SEQUENCESTEP_DSS1);
164 | break;
165 | case VL53L1_SEQUENCESTEP_DSS2:
166 | VL53L1_COPYSTRING(pSequenceStepsString,
167 | VL53L1_STRING_SEQUENCESTEP_DSS2);
168 | break;
169 | case VL53L1_SEQUENCESTEP_MM1:
170 | VL53L1_COPYSTRING(pSequenceStepsString,
171 | VL53L1_STRING_SEQUENCESTEP_MM1);
172 | break;
173 | case VL53L1_SEQUENCESTEP_MM2:
174 | VL53L1_COPYSTRING(pSequenceStepsString,
175 | VL53L1_STRING_SEQUENCESTEP_MM2);
176 | break;
177 | case VL53L1_SEQUENCESTEP_RANGE:
178 | VL53L1_COPYSTRING(pSequenceStepsString,
179 | VL53L1_STRING_SEQUENCESTEP_RANGE);
180 | break;
181 | default:
182 | Status = VL53L1_ERROR_INVALID_PARAMS;
183 | }
184 | #endif
185 |
186 | LOG_FUNCTION_END(Status);
187 |
188 | return Status;
189 | }
190 |
191 | VL53L1_Error VL53L1_get_limit_check_info(uint16_t LimitCheckId,
192 | char *pLimitCheckString)
193 | {
194 | VL53L1_Error Status = VL53L1_ERROR_NONE;
195 |
196 | LOG_FUNCTION_START("");
197 |
198 | #ifdef VL53L1_USE_EMPTY_STRING
199 | SUPPRESS_UNUSED_WARNING(LimitCheckId);
200 | VL53L1_COPYSTRING(pLimitCheckString, "");
201 | #else
202 | switch (LimitCheckId) {
203 | case VL53L1_CHECKENABLE_SIGMA_FINAL_RANGE:
204 | VL53L1_COPYSTRING(pLimitCheckString,
205 | VL53L1_STRING_CHECKENABLE_SIGMA_FINAL_RANGE);
206 | break;
207 | case VL53L1_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE:
208 | VL53L1_COPYSTRING(pLimitCheckString,
209 | VL53L1_STRING_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE);
210 | break;
211 | default:
212 | VL53L1_COPYSTRING(pLimitCheckString,
213 | VL53L1_STRING_UNKNOW_ERROR_CODE);
214 | }
215 | #endif
216 |
217 | LOG_FUNCTION_END(Status);
218 | return Status;
219 | }
220 |
221 |
--------------------------------------------------------------------------------
/sensor/vl53l1x/api/core/src/vl53l1_core_support.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, STMicroelectronics - All Rights Reserved
3 | *
4 | * This file is part of VL53L1 Core and is dual licensed,
5 | * either 'STMicroelectronics
6 | * Proprietary license'
7 | * or 'BSD 3-clause "New" or "Revised" License' , at your option.
8 | *
9 | ********************************************************************************
10 | *
11 | * 'STMicroelectronics Proprietary license'
12 | *
13 | ********************************************************************************
14 | *
15 | * License terms: STMicroelectronics Proprietary in accordance with licensing
16 | * terms at www.st.com/sla0081
17 | *
18 | * STMicroelectronics confidential
19 | * Reproduction and Communication of this document is strictly prohibited unless
20 | * specifically authorized in writing by STMicroelectronics.
21 | *
22 | *
23 | ********************************************************************************
24 | *
25 | * Alternatively, VL53L1 Core may be distributed under the terms of
26 | * 'BSD 3-clause "New" or "Revised" License', in which case the following
27 | * provisions apply instead of the ones mentioned above :
28 | *
29 | ********************************************************************************
30 | *
31 | * License terms: BSD 3-clause "New" or "Revised" License.
32 | *
33 | * Redistribution and use in source and binary forms, with or without
34 | * modification, are permitted provided that the following conditions are met:
35 | *
36 | * 1. Redistributions of source code must retain the above copyright notice, this
37 | * list of conditions and the following disclaimer.
38 | *
39 | * 2. Redistributions in binary form must reproduce the above copyright notice,
40 | * this list of conditions and the following disclaimer in the documentation
41 | * and/or other materials provided with the distribution.
42 | *
43 | * 3. Neither the name of the copyright holder nor the names of its contributors
44 | * may be used to endorse or promote products derived from this software
45 | * without specific prior written permission.
46 | *
47 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
48 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
51 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
53 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
54 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
55 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
56 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 | *
58 | *
59 | ********************************************************************************
60 | *
61 | */
62 |
63 | /**
64 | * @file vl53l1_core_support.c
65 | *
66 | * @brief EwokPlus25 core function definition
67 | */
68 |
69 | #include "vl53l1_ll_def.h"
70 | #include "vl53l1_ll_device.h"
71 | #include "vl53l1_platform_log.h"
72 | #include "vl53l1_core_support.h"
73 | #include "vl53l1_platform_user_data.h"
74 | #include "vl53l1_platform_user_defines.h"
75 |
76 | #ifdef VL53L1_LOGGING
77 | #include "vl53l1_debug.h"
78 | #include "vl53l1_register_debug.h"
79 | #endif
80 |
81 | #define LOG_FUNCTION_START(fmt, ...) \
82 | _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_CORE, fmt, ##__VA_ARGS__)
83 | #define LOG_FUNCTION_END(status, ...) \
84 | _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_CORE, status, ##__VA_ARGS__)
85 | #define LOG_FUNCTION_END_FMT(status, fmt, ...) \
86 | _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_CORE, \
87 | status, fmt, ##__VA_ARGS__)
88 |
89 | #define trace_print(level, ...) \
90 | _LOG_TRACE_PRINT(VL53L1_TRACE_MODULE_CORE, \
91 | level, VL53L1_TRACE_FUNCTION_NONE, ##__VA_ARGS__)
92 |
93 |
94 | uint32_t VL53L1_calc_pll_period_us(
95 | uint16_t fast_osc_frequency)
96 | {
97 | /* Calculates PLL frequency using NVM fast_osc_frequency
98 | * Fast osc frequency fixed point format = unsigned 4.12
99 | *
100 | * PLL period fixed point format = unsigned 0.24
101 | * Min input fast osc frequency = 1 MHz
102 | * PLL Multiplier = 64 (fixed)
103 | * Min PLL freq = 64.0MHz
104 | * -> max PLL period = 1/ 64
105 | * -> only the 18 LS bits are used
106 | *
107 | * 2^30 = (2^24) (1.0us) * 4096 (2^12) / 64 (PLL Multiplier)
108 | */
109 |
110 | uint32_t pll_period_us = 0;
111 |
112 | LOG_FUNCTION_START("");
113 |
114 | pll_period_us = (0x01 << 30) / fast_osc_frequency;
115 |
116 | #ifdef VL53L1_LOGGING
117 | trace_print(VL53L1_TRACE_LEVEL_DEBUG,
118 | " %-48s : %10u\n", "pll_period_us",
119 | pll_period_us);
120 | #endif
121 |
122 | LOG_FUNCTION_END(0);
123 |
124 | return pll_period_us;
125 | }
126 |
127 |
128 | #ifdef PAL_EXTENDED
129 | uint32_t VL53L1_duration_maths(
130 | uint32_t pll_period_us,
131 | uint32_t vcsel_parm_pclks,
132 | uint32_t window_vclks,
133 | uint32_t elapsed_mclks)
134 | {
135 | /*
136 | * Generates the ranging duration in us
137 | *
138 | * duration_us = elapsed_mclks * vcsel_perm_pclks *
139 | * window_vclks * pll_period_us
140 | *
141 | * returned value in [us] with no fraction bits
142 | */
143 |
144 | uint64_t tmp_long_int = 0;
145 | uint32_t duration_us = 0;
146 |
147 | /* PLL period us = 0.24 18 LS bits used
148 | * window_vclks = 12.0 (2304 max)
149 | * output 30b (6.24)
150 | */
151 | duration_us = window_vclks * pll_period_us;
152 |
153 | /* down shift by 12
154 | * output 18b (6.12)
155 | */
156 | duration_us = duration_us >> 12;
157 |
158 | /* Save first part of the calc (#1) */
159 | tmp_long_int = (uint64_t)duration_us;
160 |
161 | /* Multiply elapsed macro periods (22-bit)
162 | * by VCSEL parameter 6.4 (max 63.9999)
163 | * output 32b (28.4)
164 | */
165 | duration_us = elapsed_mclks * vcsel_parm_pclks;
166 |
167 | /* down shift by 4 to remove fractional bits (#2)
168 | * output 28b (28.0)
169 | */
170 | duration_us = duration_us >> 4;
171 |
172 | /* Multiply #1 18b (6.12) by #2 28b (28.0)
173 | * output 46b (34.12)
174 | */
175 | tmp_long_int = tmp_long_int * (uint64_t)duration_us;
176 |
177 | /* Remove fractional part
178 | * output 34b (34.0)
179 | */
180 | tmp_long_int = tmp_long_int >> 12;
181 |
182 | /* Clip to 32-bits */
183 | if (tmp_long_int > 0xFFFFFFFF) {
184 | tmp_long_int = 0xFFFFFFFF;
185 | }
186 |
187 | duration_us = (uint32_t)tmp_long_int;
188 |
189 | return duration_us;
190 | }
191 |
192 |
193 | uint32_t VL53L1_isqrt(uint32_t num)
194 | {
195 |
196 | /*
197 | * Implements an integer square root
198 | *
199 | * From: http://en.wikipedia.org/wiki/Methods_of_computing_square_roots
200 | */
201 |
202 | uint32_t res = 0;
203 | uint32_t bit = 1 << 30; /* The second-to-top bit is set: 1 << 14 for 16-bits, 1 << 30 for 32 bits */
204 |
205 | /* "bit" starts at the highest power of four <= the argument. */
206 | while (bit > num) {
207 | bit >>= 2;
208 | }
209 |
210 | while (bit != 0) {
211 | if (num >= res + bit) {
212 | num -= res + bit;
213 | res = (res >> 1) + bit;
214 | } else {
215 | res >>= 1;
216 | }
217 | bit >>= 2;
218 | }
219 |
220 | return res;
221 | }
222 |
223 |
224 | uint16_t VL53L1_rate_maths(
225 | int32_t events,
226 | uint32_t time_us)
227 | {
228 | /*
229 | * Converts events into count rate
230 | *
231 | * Max events = 512 Mcps * 1sec
232 | * = 512,000,000 events
233 | * = 29b
234 | *
235 | * If events > 2^24 use 3-bit fractional bits is used internally
236 | * otherwise 7-bit fractional bits are used
237 | */
238 |
239 | uint32_t tmp_int = 0;
240 | uint32_t frac_bits = 7;
241 | uint16_t rate_mcps = 0; /* 9.7 format */
242 |
243 | /*
244 | * Clip input event range
245 | */
246 |
247 | if (events > VL53L1_SPAD_TOTAL_COUNT_MAX) {
248 | tmp_int = VL53L1_SPAD_TOTAL_COUNT_MAX;
249 | } else if (events > 0) {
250 | tmp_int = (uint32_t)events;
251 | }
252 |
253 | /*
254 | * if events > VL53L1_SPAD_TOTAL_COUNT_RES_THRES use 3 rather
255 | * than 7 fractional bits internal to function
256 | */
257 |
258 | if (events > VL53L1_SPAD_TOTAL_COUNT_RES_THRES) {
259 | frac_bits = 3;
260 | } else {
261 | frac_bits = 7;
262 | }
263 |
264 | /*
265 | * Create 3 or 7 fractional bits
266 | * output 32b (29.3 or 25.7)
267 | * Divide by range duration in [us] - no fractional bits
268 | */
269 | if (time_us > 0) {
270 | tmp_int = ((tmp_int << frac_bits) + (time_us / 2)) / time_us;
271 | }
272 |
273 | /*
274 | * Re align if reduced resolution
275 | */
276 | if (events > VL53L1_SPAD_TOTAL_COUNT_RES_THRES) {
277 | tmp_int = tmp_int << 4;
278 | }
279 |
280 | /*
281 | * Firmware internal count is 17.7 (24b) but it this
282 | * case clip to 16-bit value for reporting
283 | */
284 |
285 | if (tmp_int > 0xFFFF) {
286 | tmp_int = 0xFFFF;
287 | }
288 |
289 | rate_mcps = (uint16_t)tmp_int;
290 |
291 | return rate_mcps;
292 | }
293 |
294 | uint16_t VL53L1_rate_per_spad_maths(
295 | uint32_t frac_bits,
296 | uint32_t peak_count_rate,
297 | uint16_t num_spads,
298 | uint32_t max_output_value)
299 | {
300 |
301 | uint32_t tmp_int = 0;
302 |
303 | /* rate_per_spad Format varies with prog frac_bits */
304 | uint16_t rate_per_spad = 0;
305 |
306 | /* Calculate rate per spad with variable fractional bits */
307 |
308 | /* Frac_bits should be programmed as final frac_bits - 7 as
309 | * the pk_rate contains an inherent 7 bit resolution
310 | */
311 |
312 | if (num_spads > 0) {
313 | tmp_int = (peak_count_rate << 8) << frac_bits;
314 | tmp_int = (tmp_int + ((uint32_t)num_spads / 2)) / (uint32_t)num_spads;
315 | } else {
316 | tmp_int = ((peak_count_rate) << frac_bits);
317 | }
318 |
319 | /* Clip in case of overwrap - special code */
320 |
321 | if (tmp_int > max_output_value) {
322 | tmp_int = max_output_value;
323 | }
324 |
325 | rate_per_spad = (uint16_t)tmp_int;
326 |
327 | return rate_per_spad;
328 | }
329 |
330 | int32_t VL53L1_range_maths(
331 | uint16_t fast_osc_frequency,
332 | uint16_t phase,
333 | uint16_t zero_distance_phase,
334 | uint8_t fractional_bits,
335 | int32_t gain_factor,
336 | int32_t range_offset_mm)
337 | {
338 | /*
339 | * Converts phase information into distance in [mm]
340 | */
341 |
342 | uint32_t pll_period_us = 0; /* 0.24 format */
343 | int64_t tmp_long_int = 0;
344 | int32_t range_mm = 0;
345 |
346 | /* Calculate PLL period in [ps] */
347 |
348 | pll_period_us = VL53L1_calc_pll_period_us(fast_osc_frequency);
349 |
350 | /* Raw range in [mm]
351 | *
352 | * calculate the phase difference between return and reference phases
353 | *
354 | * phases 16b (5.11)
355 | * output 17b including sign bit
356 | */
357 |
358 | tmp_long_int = (int64_t)phase - (int64_t)zero_distance_phase;
359 |
360 | /*
361 | * multiply by the PLL period
362 | *
363 | * PLL period 24bit (0.24) but only 18 LS bits used
364 | *
365 | * Output 35b (0.35) (17b + 18b)
366 | */
367 |
368 | tmp_long_int = tmp_long_int * (int64_t)pll_period_us;
369 |
370 | /*
371 | * Down shift by 9 - Output 26b (0.26)
372 | */
373 |
374 | tmp_long_int = tmp_long_int / (0x01 << 9);
375 |
376 | /*
377 | * multiply by speed of light in air divided by 8
378 | * Factor of 8 includes 2 for the round trip and 4 scaling
379 | *
380 | * VL53L1_SPEED_OF_LIGHT_IN_AIR_DIV_8 = 16b (16.2)
381 | *
382 | * Output 42b (18.24) (16b + 26b)
383 | */
384 |
385 | tmp_long_int = tmp_long_int * VL53L1_SPEED_OF_LIGHT_IN_AIR_DIV_8;
386 |
387 | /*
388 | * Down shift by 22 - Output 20b (18.2)
389 | */
390 |
391 | tmp_long_int = tmp_long_int / (0x01 << 22);
392 |
393 | /* Add range offset */
394 | range_mm = (int32_t)tmp_long_int + range_offset_mm;
395 |
396 | /* apply correction gain */
397 | range_mm *= gain_factor;
398 | range_mm += 0x0400;
399 | range_mm /= 0x0800;
400 |
401 | /* Remove fractional bits */
402 | if (fractional_bits == 0)
403 | range_mm = range_mm / (0x01 << 2);
404 | else if (fractional_bits == 1)
405 | range_mm = range_mm / (0x01 << 1);
406 |
407 | return range_mm;
408 | }
409 | #endif
410 |
411 | uint8_t VL53L1_decode_vcsel_period(uint8_t vcsel_period_reg)
412 | {
413 | /*
414 | * Converts the encoded VCSEL period register value into
415 | * the real period in PLL clocks
416 | */
417 |
418 | uint8_t vcsel_period_pclks = 0;
419 |
420 | vcsel_period_pclks = (vcsel_period_reg + 1) << 1;
421 |
422 | return vcsel_period_pclks;
423 | }
424 |
425 |
426 | void VL53L1_decode_row_col(
427 | uint8_t spad_number,
428 | uint8_t *prow,
429 | uint8_t *pcol)
430 | {
431 |
432 | /**
433 | * Decodes the array (row,col) location from
434 | * the input SPAD number
435 | */
436 |
437 | if (spad_number > 127) {
438 | *prow = 8 + ((255-spad_number) & 0x07);
439 | *pcol = (spad_number-128) >> 3;
440 | } else {
441 | *prow = spad_number & 0x07;
442 | *pcol = (127-spad_number) >> 3;
443 | }
444 | }
445 |
446 |
--------------------------------------------------------------------------------
/sensor/vl53l1x/api/core/src/vl53l1_error_strings.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, STMicroelectronics - All Rights Reserved
3 | *
4 | * This file is part of VL53L1 Core and is dual licensed,
5 | * either 'STMicroelectronics
6 | * Proprietary license'
7 | * or 'BSD 3-clause "New" or "Revised" License' , at your option.
8 | *
9 | ********************************************************************************
10 | *
11 | * 'STMicroelectronics Proprietary license'
12 | *
13 | ********************************************************************************
14 | *
15 | * License terms: STMicroelectronics Proprietary in accordance with licensing
16 | * terms at www.st.com/sla0081
17 | *
18 | * STMicroelectronics confidential
19 | * Reproduction and Communication of this document is strictly prohibited unless
20 | * specifically authorized in writing by STMicroelectronics.
21 | *
22 | *
23 | ********************************************************************************
24 | *
25 | * Alternatively, VL53L1 Core may be distributed under the terms of
26 | * 'BSD 3-clause "New" or "Revised" License', in which case the following
27 | * provisions apply instead of the ones mentioned above :
28 | *
29 | ********************************************************************************
30 | *
31 | * License terms: BSD 3-clause "New" or "Revised" License.
32 | *
33 | * Redistribution and use in source and binary forms, with or without
34 | * modification, are permitted provided that the following conditions are met:
35 | *
36 | * 1. Redistributions of source code must retain the above copyright notice, this
37 | * list of conditions and the following disclaimer.
38 | *
39 | * 2. Redistributions in binary form must reproduce the above copyright notice,
40 | * this list of conditions and the following disclaimer in the documentation
41 | * and/or other materials provided with the distribution.
42 | *
43 | * 3. Neither the name of the copyright holder nor the names of its contributors
44 | * may be used to endorse or promote products derived from this software
45 | * without specific prior written permission.
46 | *
47 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
48 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
51 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
53 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
54 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
55 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
56 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 | *
58 | *
59 | ********************************************************************************
60 | *
61 | */
62 |
63 | /**
64 | * @file vl53l1_error_strings.c
65 | * @brief VL53L1 API functions for decoding error codes to a text string
66 | */
67 |
68 | #include "vl53l1_error_codes.h"
69 | #include "vl53l1_error_strings.h"
70 | #include "vl53l1_platform_log.h"
71 | #include "vl53l1_ll_def.h"
72 |
73 | #define LOG_FUNCTION_START(fmt, ...) \
74 | _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_API, fmt, ##__VA_ARGS__)
75 | #define LOG_FUNCTION_END(status, ...) \
76 | _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_API, status, ##__VA_ARGS__)
77 | #define LOG_FUNCTION_END_FMT(status, fmt, ...) \
78 | _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_API, \
79 | status, fmt, ##__VA_ARGS__)
80 |
81 |
82 | #ifndef VL53L1_DEBUG
83 | #define VL53L1_USE_EMPTY_STRING
84 | #endif
85 |
86 | VL53L1_Error VL53L1_get_pal_error_string(
87 | VL53L1_Error PalErrorCode,
88 | char *pPalErrorString)
89 | {
90 | VL53L1_Error Status = VL53L1_ERROR_NONE;
91 |
92 | #ifdef VL53L1_USE_EMPTY_STRING
93 | SUPPRESS_UNUSED_WARNING(PalErrorCode);
94 | #endif
95 |
96 | LOG_FUNCTION_START("");
97 |
98 | #ifdef VL53L1_USE_EMPTY_STRING
99 | VL53L1_COPYSTRING(pPalErrorString, "");
100 | #else
101 |
102 | switch (PalErrorCode) {
103 | case VL53L1_ERROR_NONE:
104 | VL53L1_COPYSTRING(pPalErrorString,
105 | VL53L1_STRING_ERROR_NONE);
106 | break;
107 | case VL53L1_ERROR_CALIBRATION_WARNING:
108 | VL53L1_COPYSTRING(pPalErrorString,
109 | VL53L1_STRING_ERROR_CALIBRATION_WARNING);
110 | break;
111 | case VL53L1_ERROR_MIN_CLIPPED:
112 | VL53L1_COPYSTRING(pPalErrorString,
113 | VL53L1_STRING_ERROR_MIN_CLIPPED);
114 | break;
115 | case VL53L1_ERROR_UNDEFINED:
116 | VL53L1_COPYSTRING(pPalErrorString,
117 | VL53L1_STRING_ERROR_UNDEFINED);
118 | break;
119 | case VL53L1_ERROR_INVALID_PARAMS:
120 | VL53L1_COPYSTRING(pPalErrorString,
121 | VL53L1_STRING_ERROR_INVALID_PARAMS);
122 | break;
123 | case VL53L1_ERROR_NOT_SUPPORTED:
124 | VL53L1_COPYSTRING(pPalErrorString,
125 | VL53L1_STRING_ERROR_NOT_SUPPORTED);
126 | break;
127 | case VL53L1_ERROR_RANGE_ERROR:
128 | VL53L1_COPYSTRING(pPalErrorString,
129 | VL53L1_STRING_ERROR_RANGE_ERROR);
130 | break;
131 | case VL53L1_ERROR_TIME_OUT:
132 | VL53L1_COPYSTRING(pPalErrorString,
133 | VL53L1_STRING_ERROR_TIME_OUT);
134 | break;
135 | case VL53L1_ERROR_MODE_NOT_SUPPORTED:
136 | VL53L1_COPYSTRING(pPalErrorString,
137 | VL53L1_STRING_ERROR_MODE_NOT_SUPPORTED);
138 | break;
139 | case VL53L1_ERROR_BUFFER_TOO_SMALL:
140 | VL53L1_COPYSTRING(pPalErrorString,
141 | VL53L1_STRING_ERROR_BUFFER_TOO_SMALL);
142 | break;
143 | case VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL:
144 | VL53L1_COPYSTRING(pPalErrorString,
145 | VL53L1_STRING_ERROR_COMMS_BUFFER_TOO_SMALL);
146 | break;
147 | case VL53L1_ERROR_GPIO_NOT_EXISTING:
148 | VL53L1_COPYSTRING(pPalErrorString,
149 | VL53L1_STRING_ERROR_GPIO_NOT_EXISTING);
150 | break;
151 | case VL53L1_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED:
152 | VL53L1_COPYSTRING(pPalErrorString,
153 | VL53L1_STRING_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED);
154 | break;
155 | case VL53L1_ERROR_CONTROL_INTERFACE:
156 | VL53L1_COPYSTRING(pPalErrorString,
157 | VL53L1_STRING_ERROR_CONTROL_INTERFACE);
158 | break;
159 | case VL53L1_ERROR_INVALID_COMMAND:
160 | VL53L1_COPYSTRING(pPalErrorString,
161 | VL53L1_STRING_ERROR_INVALID_COMMAND);
162 | break;
163 | case VL53L1_ERROR_DIVISION_BY_ZERO:
164 | VL53L1_COPYSTRING(pPalErrorString,
165 | VL53L1_STRING_ERROR_DIVISION_BY_ZERO);
166 | break;
167 | case VL53L1_ERROR_REF_SPAD_INIT:
168 | VL53L1_COPYSTRING(pPalErrorString,
169 | VL53L1_STRING_ERROR_REF_SPAD_INIT);
170 | break;
171 | case VL53L1_ERROR_GPH_SYNC_CHECK_FAIL:
172 | VL53L1_COPYSTRING(pPalErrorString,
173 | VL53L1_STRING_ERROR_GPH_SYNC_CHECK_FAIL);
174 | break;
175 | case VL53L1_ERROR_STREAM_COUNT_CHECK_FAIL:
176 | VL53L1_COPYSTRING(pPalErrorString,
177 | VL53L1_STRING_ERROR_STREAM_COUNT_CHECK_FAIL);
178 | break;
179 | case VL53L1_ERROR_GPH_ID_CHECK_FAIL:
180 | VL53L1_COPYSTRING(pPalErrorString,
181 | VL53L1_STRING_ERROR_GPH_ID_CHECK_FAIL);
182 | break;
183 | case VL53L1_ERROR_ZONE_STREAM_COUNT_CHECK_FAIL:
184 | VL53L1_COPYSTRING(pPalErrorString,
185 | VL53L1_STRING_ERROR_ZONE_STREAM_COUNT_CHECK_FAIL);
186 | break;
187 | case VL53L1_ERROR_ZONE_GPH_ID_CHECK_FAIL:
188 | VL53L1_COPYSTRING(pPalErrorString,
189 | VL53L1_STRING_ERROR_ZONE_GPH_ID_CHECK_FAIL);
190 | break;
191 |
192 | case VL53L1_ERROR_XTALK_EXTRACTION_NO_SAMPLE_FAIL:
193 | VL53L1_COPYSTRING(pPalErrorString,
194 | VL53L1_STRING_ERROR_XTALK_EXTRACTION_NO_SAMPLES_FAIL);
195 | break;
196 | case VL53L1_ERROR_XTALK_EXTRACTION_SIGMA_LIMIT_FAIL:
197 | VL53L1_COPYSTRING(pPalErrorString,
198 | VL53L1_STRING_ERROR_XTALK_EXTRACTION_SIGMA_LIMIT_FAIL);
199 | break;
200 |
201 | case VL53L1_ERROR_OFFSET_CAL_NO_SAMPLE_FAIL:
202 | VL53L1_COPYSTRING(pPalErrorString,
203 | VL53L1_STRING_ERROR_OFFSET_CAL_NO_SAMPLE_FAIL);
204 | break;
205 | case VL53L1_ERROR_OFFSET_CAL_NO_SPADS_ENABLED_FAIL:
206 | VL53L1_COPYSTRING(pPalErrorString,
207 | VL53L1_STRING_ERROR_OFFSET_CAL_NO_SPADS_ENABLED_FAIL);
208 | break;
209 | case VL53L1_ERROR_ZONE_CAL_NO_SAMPLE_FAIL:
210 | VL53L1_COPYSTRING(pPalErrorString,
211 | VL53L1_STRING_ERROR_ZONE_CAL_NO_SAMPLE_FAIL);
212 | break;
213 |
214 | case VL53L1_WARNING_OFFSET_CAL_MISSING_SAMPLES:
215 | VL53L1_COPYSTRING(pPalErrorString,
216 | VL53L1_STRING_WARNING_OFFSET_CAL_MISSING_SAMPLES);
217 | break;
218 | case VL53L1_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH:
219 | VL53L1_COPYSTRING(pPalErrorString,
220 | VL53L1_STRING_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH);
221 | break;
222 | case VL53L1_WARNING_OFFSET_CAL_RATE_TOO_HIGH:
223 | VL53L1_COPYSTRING(pPalErrorString,
224 | VL53L1_STRING_WARNING_OFFSET_CAL_RATE_TOO_HIGH);
225 | break;
226 | case VL53L1_WARNING_OFFSET_CAL_SPAD_COUNT_TOO_LOW:
227 | VL53L1_COPYSTRING(pPalErrorString,
228 | VL53L1_STRING_WARNING_OFFSET_CAL_SPAD_COUNT_TOO_LOW);
229 | break;
230 |
231 | case VL53L1_WARNING_ZONE_CAL_MISSING_SAMPLES:
232 | VL53L1_COPYSTRING(pPalErrorString,
233 | VL53L1_STRING_WARNING_ZONE_CAL_MISSING_SAMPLES);
234 | break;
235 | case VL53L1_WARNING_ZONE_CAL_SIGMA_TOO_HIGH:
236 | VL53L1_COPYSTRING(pPalErrorString,
237 | VL53L1_STRING_WARNING_ZONE_CAL_SIGMA_TOO_HIGH);
238 | break;
239 | case VL53L1_WARNING_ZONE_CAL_RATE_TOO_HIGH:
240 | VL53L1_COPYSTRING(pPalErrorString,
241 | VL53L1_STRING_WARNING_ZONE_CAL_RATE_TOO_HIGH);
242 | break;
243 |
244 | case VL53L1_WARNING_REF_SPAD_CHAR_NOT_ENOUGH_SPADS:
245 | VL53L1_COPYSTRING(pPalErrorString,
246 | VL53L1_STRING_WARNING_REF_SPAD_CHAR_NOT_ENOUGH_SPADS);
247 | break;
248 | case VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_HIGH:
249 | VL53L1_COPYSTRING(pPalErrorString,
250 | VL53L1_STRING_WARNING_REF_SPAD_CHAR_RATE_TOO_HIGH);
251 | break;
252 | case VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_LOW:
253 | VL53L1_COPYSTRING(pPalErrorString,
254 | VL53L1_STRING_WARNING_REF_SPAD_CHAR_RATE_TOO_LOW);
255 | break;
256 |
257 | case VL53L1_WARNING_XTALK_MISSING_SAMPLES:
258 | VL53L1_COPYSTRING(pPalErrorString,
259 | VL53L1_STRING_WARNING_XTALK_MISSING_SAMPLES);
260 | break;
261 | case VL53L1_WARNING_XTALK_NO_SAMPLES_FOR_GRADIENT:
262 | VL53L1_COPYSTRING(pPalErrorString,
263 | VL53L1_STRING_WARNING_XTALK_NO_SAMPLES_FOR_GRADIENT);
264 | break;
265 | case VL53L1_WARNING_XTALK_SIGMA_LIMIT_FOR_GRADIENT:
266 | VL53L1_COPYSTRING(pPalErrorString,
267 | VL53L1_STRING_WARNING_XTALK_SIGMA_LIMIT_FOR_GRADIENT);
268 | break;
269 |
270 | case VL53L1_ERROR_DEVICE_FIRMWARE_TOO_OLD:
271 | VL53L1_COPYSTRING(pPalErrorString,
272 | VL53L1_STRING_ERROR_DEVICE_FIRMWARE_TOO_OLD);
273 | break;
274 | case VL53L1_ERROR_DEVICE_FIRMWARE_TOO_NEW:
275 | VL53L1_COPYSTRING(pPalErrorString,
276 | VL53L1_STRING_ERROR_DEVICE_FIRMWARE_TOO_NEW);
277 | break;
278 | case VL53L1_ERROR_UNIT_TEST_FAIL:
279 | VL53L1_COPYSTRING(pPalErrorString,
280 | VL53L1_STRING_ERROR_UNIT_TEST_FAIL);
281 | break;
282 | case VL53L1_ERROR_FILE_READ_FAIL:
283 | VL53L1_COPYSTRING(pPalErrorString,
284 | VL53L1_STRING_ERROR_FILE_READ_FAIL);
285 | break;
286 | case VL53L1_ERROR_FILE_WRITE_FAIL:
287 | VL53L1_COPYSTRING(pPalErrorString,
288 | VL53L1_STRING_ERROR_FILE_WRITE_FAIL);
289 | break;
290 | case VL53L1_ERROR_NOT_IMPLEMENTED:
291 | VL53L1_COPYSTRING(pPalErrorString,
292 | VL53L1_STRING_ERROR_NOT_IMPLEMENTED);
293 | break;
294 | default:
295 | VL53L1_COPYSTRING(pPalErrorString,
296 | VL53L1_STRING_UNKNOW_ERROR_CODE);
297 | }
298 |
299 | #endif
300 |
301 | LOG_FUNCTION_END(Status);
302 |
303 | return Status;
304 | }
305 |
--------------------------------------------------------------------------------
/sensor/vl53l1x/api/core/src/vl53l1_silicon_core.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, STMicroelectronics - All Rights Reserved
3 | *
4 | * This file is part of VL53L1 Core and is dual licensed,
5 | * either 'STMicroelectronics
6 | * Proprietary license'
7 | * or 'BSD 3-clause "New" or "Revised" License' , at your option.
8 | *
9 | ********************************************************************************
10 | *
11 | * 'STMicroelectronics Proprietary license'
12 | *
13 | ********************************************************************************
14 | *
15 | * License terms: STMicroelectronics Proprietary in accordance with licensing
16 | * terms at www.st.com/sla0081
17 | *
18 | * STMicroelectronics confidential
19 | * Reproduction and Communication of this document is strictly prohibited unless
20 | * specifically authorized in writing by STMicroelectronics.
21 | *
22 | *
23 | ********************************************************************************
24 | *
25 | * Alternatively, VL53L1 Core may be distributed under the terms of
26 | * 'BSD 3-clause "New" or "Revised" License', in which case the following
27 | * provisions apply instead of the ones mentioned above :
28 | *
29 | ********************************************************************************
30 | *
31 | * License terms: BSD 3-clause "New" or "Revised" License.
32 | *
33 | * Redistribution and use in source and binary forms, with or without
34 | * modification, are permitted provided that the following conditions are met:
35 | *
36 | * 1. Redistributions of source code must retain the above copyright notice, this
37 | * list of conditions and the following disclaimer.
38 | *
39 | * 2. Redistributions in binary form must reproduce the above copyright notice,
40 | * this list of conditions and the following disclaimer in the documentation
41 | * and/or other materials provided with the distribution.
42 | *
43 | * 3. Neither the name of the copyright holder nor the names of its contributors
44 | * may be used to endorse or promote products derived from this software
45 | * without specific prior written permission.
46 | *
47 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
48 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
51 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
53 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
54 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
55 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
56 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 | *
58 | *
59 | ********************************************************************************
60 | *
61 | */
62 |
63 | /**
64 | * @file vl53l1_silicon_core.c
65 | *
66 | * @brief EwokPlus25 low level silicon LL Driver function definition
67 | */
68 |
69 |
70 | #include "vl53l1_ll_def.h"
71 | #include "vl53l1_platform.h"
72 | #include "vl53l1_register_map.h"
73 | #include "vl53l1_core.h"
74 | #include "vl53l1_silicon_core.h"
75 |
76 |
77 | #define LOG_FUNCTION_START(fmt, ...) \
78 | _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_CORE, fmt, ##__VA_ARGS__)
79 | #define LOG_FUNCTION_END(status, ...) \
80 | _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_CORE, status, ##__VA_ARGS__)
81 | #define LOG_FUNCTION_END_FMT(status, fmt, ...) \
82 | _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_CORE, status, fmt, ##__VA_ARGS__)
83 |
84 |
85 | VL53L1_Error VL53L1_is_firmware_ready_silicon(
86 | VL53L1_DEV Dev,
87 | uint8_t *pready)
88 | {
89 | /**
90 | * Determines if the firmware is ready to range
91 | *
92 | * There are 2 different behaviors depending on whether
93 | * power force is enabled or not
94 | */
95 |
96 | VL53L1_Error status = VL53L1_ERROR_NONE;
97 | VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
98 |
99 | uint8_t comms_buffer[5];
100 |
101 | LOG_FUNCTION_START("");
102 |
103 | /* read interrupt and power force reset status */
104 |
105 | status = VL53L1_ReadMulti(
106 | Dev,
107 | VL53L1_INTERRUPT_MANAGER__ENABLES,
108 | comms_buffer,
109 | 5);
110 |
111 | if (status == VL53L1_ERROR_NONE) {
112 |
113 | pdev->dbg_results.interrupt_manager__enables =
114 | comms_buffer[0];
115 | pdev->dbg_results.interrupt_manager__clear =
116 | comms_buffer[1];
117 | pdev->dbg_results.interrupt_manager__status =
118 | comms_buffer[2];
119 | pdev->dbg_results.mcu_to_host_bank__wr_access_en =
120 | comms_buffer[3];
121 | pdev->dbg_results.power_management__go1_reset_status =
122 | comms_buffer[4];
123 |
124 | if ((pdev->sys_ctrl.power_management__go1_power_force & 0x01) == 0x01) {
125 |
126 | if (((pdev->dbg_results.interrupt_manager__enables & 0x1F) == 0x1F) &&
127 | ((pdev->dbg_results.interrupt_manager__clear & 0x1F) == 0x1F))
128 | *pready = 0x01;
129 | else
130 | *pready = 0x00;
131 |
132 | } else {
133 |
134 | /* set ready flag if bit 0 is zero i.g G01 is in reset */
135 | if ((pdev->dbg_results.power_management__go1_reset_status & 0x01) == 0x00)
136 | *pready = 0x01;
137 | else
138 | *pready = 0x00;
139 | }
140 |
141 | }
142 |
143 | LOG_FUNCTION_END(status);
144 |
145 | return status;
146 | }
147 |
--------------------------------------------------------------------------------
/zephyr/module.yml:
--------------------------------------------------------------------------------
1 | name: hal_st
2 | build:
3 | cmake: .
4 | kconfig-ext: True
5 |
--------------------------------------------------------------------------------