1+ /*
2+ * Copyright (c) 2025, Henrik Hose
3+ *
4+ * This file is part of the modm project.
5+ *
6+ * This Source Code Form is subject to the terms of the Mozilla Public
7+ * License, v. 2.0. If a copy of the MPL was not distributed with this
8+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9+ */
10+ // ----------------------------------------------------------------------------
11+
12+ #include < modm/platform.hpp>
13+
14+ #include " vl53_transport.hpp"
15+
16+ extern " C" {
17+ #include " vl53_platform.h"
18+
19+ uint8_t
20+ VL53_RdByte (VL53_Platform *p_platform, uint16_t RegisterAddress, uint8_t *p_value)
21+ {
22+ auto *iface = static_cast <modm::Vl53TransportBase *>(p_platform->transport );
23+ return iface->readByte (RegisterAddress, p_value);
24+ }
25+
26+ uint8_t
27+ VL53_WrByte (VL53_Platform *p_platform, uint16_t RegisterAddress, uint8_t value)
28+ {
29+ auto *iface = static_cast <modm::Vl53TransportBase *>(p_platform->transport );
30+ return iface->writeByte (RegisterAddress, value);
31+ }
32+
33+ uint8_t
34+ VL53_WrMulti (VL53_Platform *p_platform, uint16_t RegisterAddress, uint8_t *p_values, uint32_t size)
35+ {
36+ auto *iface = static_cast <modm::Vl53TransportBase *>(p_platform->transport );
37+ return iface->writeMulti (RegisterAddress, p_values, size);
38+ }
39+
40+ uint8_t
41+ VL53_RdMulti (VL53_Platform *p_platform, uint16_t RegisterAddress, uint8_t *p_values, uint32_t size)
42+ {
43+ auto *iface = static_cast <modm::Vl53TransportBase *>(p_platform->transport );
44+ return iface->readMulti (RegisterAddress, p_values, size);
45+ }
46+
47+ void
48+ VL53_SwapBuffer (uint8_t *buffer, uint16_t size)
49+ {
50+ uint32_t i, tmp;
51+
52+ for (i = 0 ; i < size; i = i + 4 )
53+ {
54+ tmp = (buffer[i] << 24 ) | (buffer[i + 1 ] << 16 ) | (buffer[i + 2 ] << 8 ) | (buffer[i + 3 ]);
55+
56+ memcpy (&(buffer[i]), &tmp, 4 );
57+ }
58+ }
59+
60+ uint8_t
61+ VL53_WaitMs (VL53_Platform *p_platform, uint32_t TimeMs)
62+ {
63+ modm::delay_ms (TimeMs);
64+ return 0 ;
65+ }
66+
67+ uint8_t
68+ VL53_Reset_Sensor (VL53_Platform *p_platform)
69+ {
70+ auto *iface = static_cast <modm::Vl53TransportBase *>(p_platform->transport );
71+ return iface->resetSensor ();
72+ }
73+ }
0 commit comments