FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
Loading...
Searching...
No Matches
vl53l0x_internals.h
1// Copyright 2016-2023 Jean-Francois Poilpret
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
16
17#ifndef VL53L0X_INTERNALS_H
18#define VL53L0X_INTERNALS_H
19
20#include "../flash.h"
21#include "../i2c_device_utilities.h"
22#include "vl53l0x_registers.h"
23#include "vl53l0x_types.h"
24
25namespace devices::vl53l0x_internals
26{
27 using Register = devices::vl53l0x::Register;
28
29 namespace stop_variable
30 {
31 // Write buffers
32 static constexpr uint8_t PRE_BUFFER[] PROGMEM =
33 {
34 uint8_t(Register::POWER_MANAGEMENT), 0x01,
35 0xFF, 0x01,
36 uint8_t(Register::SYSRANGE_START), 0x00,
37 };
38 static constexpr uint8_t POST_BUFFER[] PROGMEM =
39 {
40 uint8_t(Register::SYSRANGE_START), 0x01,
41 0xFF, 0x00,
42 uint8_t(Register::POWER_MANAGEMENT), 0x00,
43 };
44
45 // Size of write buffers
46 static constexpr uint8_t PRE_BUFFER_SIZE = sizeof(PRE_BUFFER);
47 static constexpr uint8_t POST_BUFFER_SIZE = sizeof(POST_BUFFER);
48 }
49
50 namespace stop_continuous_ranging
51 {
52 // Write buffers
53 static constexpr uint8_t BUFFER[] PROGMEM =
54 {
55 uint8_t(Register::SYSRANGE_START), 0x01,
56 0xFF, 0x01,
57 uint8_t(Register::SYSRANGE_START), 0x00,
58 uint8_t(Register::SYSTEM_STOP_VARIABLE), 0x00,
59 uint8_t(Register::SYSRANGE_START), 0x01,
60 0xFF, 0x00,
61 };
62
63 // Size of write buffers
64 static constexpr uint8_t BUFFER_SIZE = sizeof(BUFFER);
65 }
66
67 // Constants for get_SPAD_info() method
68 //--------------------------------------
69 namespace spad_info
70 {
71 // Write buffers
72 static constexpr uint8_t BUFFER1[] PROGMEM =
73 {
74 uint8_t(Register::POWER_MANAGEMENT), 0x01,
75 0xFF, 0x01,
76 uint8_t(Register::SYSRANGE_START), 0x00,
77 0xFF, 0x06,
78 };
79
80 static constexpr uint8_t BUFFER2[] PROGMEM =
81 {
82 0xFF, 0x07,
83 0x81, 0x01,
84 uint8_t(Register::POWER_MANAGEMENT), 0x01,
85 0x94, 0x6B,
86 };
87
88 static constexpr uint8_t BUFFER3[] PROGMEM =
89 {
90 0x81, 0x00,
91 0xFF, 0x06,
92 };
93
94 static constexpr uint8_t BUFFER4[] PROGMEM =
95 {
96 0xFF, 0x01,
97 uint8_t(Register::SYSRANGE_START), 0x01,
98 0xFF, 0x00,
99 uint8_t(Register::POWER_MANAGEMENT), 0x00,
100 };
101
102 // Size of write buffers
103 static constexpr uint8_t BUFFER1_SIZE = sizeof(BUFFER1);
104 static constexpr uint8_t BUFFER2_SIZE = sizeof(BUFFER2);
105 static constexpr uint8_t BUFFER3_SIZE = sizeof(BUFFER3);
106 static constexpr uint8_t BUFFER4_SIZE = sizeof(BUFFER4);
107 }
108
109 // Constants for load_tuning_settings() method
110 //---------------------------------------------
111 namespace load_tuning_settings
112 {
113 // Write buffer
114 static constexpr uint8_t BUFFER[] PROGMEM =
115 {
116 // load tuning settings (hard-coded defaults)
117 0xFF, 0x01,
118 uint8_t(Register::SYSRANGE_START), 0x00,
119 0xFF, 0x00,
120 0x09, 0x00,
121 0x10, 0x00,
122 0x11, 0x00,
123 0x24, 0x01,
124 0x25, 0xFF,
125 0x75, 0x00,
126 0xFF, 0x01,
127 0x4E, 0x2C,
128 0x48, 0x00,
129 0x30, 0x20,
130 0xFF, 0x00,
131 0x30, 0x09,
132 0x54, 0x00,
133 0x31, 0x04,
134 0x32, 0x03,
135 0x40, 0x83,
136 0x46, 0x25,
137 0x60, 0x00,
138 0x27, 0x00,
139 0x50, 0x06,
140 0x51, 0x00,
141 0x52, 0x96,
142 0x56, 0x08,
143 0x57, 0x30,
144 0x61, 0x00,
145 0x62, 0x00,
146 0x64, 0x00,
147 0x65, 0x00,
148 0x66, 0xA0,
149 0xFF, 0x01,
150 0x22, 0x32,
151 0x47, 0x14,
152 0x49, 0xFF,
153 0x4A, 0x00,
154 0xFF, 0x00,
155 0x7A, 0x0A,
156 0x7B, 0x00,
157 0x78, 0x21,
158 0xFF, 0x01,
159 0x23, 0x34,
160 0x42, 0x00,
161 0x44, 0xFF,
162 0x45, 0x26,
163 0x46, 0x05,
164 0x40, 0x40,
165 0x0E, 0x06,
166 0x20, 0x1A,
167 0x43, 0x40,
168 0xFF, 0x00,
169 0x34, 0x03,
170 0x35, 0x44,
171 0xFF, 0x01,
172 0x31, 0x04,
173 0x4B, 0x09,
174 0x4C, 0x05,
175 0x4D, 0x04,
176 0xFF, 0x00,
177 0x44, 0x00,
178 0x45, 0x20,
179 0x47, 0x08,
180 0x48, 0x28,
181 0x67, 0x00,
182 0x70, 0x04,
183 0x71, 0x01,
184 0x72, 0xFE,
185 0x76, 0x00,
186 0x77, 0x00,
187 0xFF, 0x01,
188 0x0D, 0x01,
189 0xFF, 0x00,
190 uint8_t(Register::POWER_MANAGEMENT), 0x01,
191 0x01, 0xF8,
192 0xFF, 0x01,
193 0x8E, 0x01,
194 uint8_t(Register::SYSRANGE_START), 0x01,
195 0xFF, 0x00,
196 uint8_t(Register::POWER_MANAGEMENT), 0x00
197 };
198 // Size of write buffer
199 static constexpr uint8_t BUFFER_SIZE = sizeof(BUFFER);
200 }
201
202 // Constants for set_reference_SPADs() method
203 //--------------------------------------------
204 namespace set_reference_spads
205 {
206 // Write buffer
207 static constexpr uint8_t BUFFER[] PROGMEM =
208 {
209 0xFF, 0x01,
210 uint8_t(Register::DYNAMIC_SPAD_REF_EN_START_OFFSET), 0x00,
211 uint8_t(Register::DYNAMIC_SPAD_NUM_REQUESTED_REF_SPAD), 0x2C,
212 0xFF, 0x00,
213 uint8_t(Register::GLOBAL_CONFIG_REF_EN_START_SELECT), 0xB4
214 };
215
216 // Size of write buffer
217 static constexpr uint8_t BUFFER_SIZE = sizeof(BUFFER);
218 }
219}
220#endif /* VL53L0X_INTERNALS_H */
API to handle Time-of-Flight ranging sensor VL53L0X I2C chip.