|
| 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/board.hpp> |
| 13 | + |
| 14 | +// Tested with MIKROE LIGHTRANGER 12 CLICK Breakout |
| 15 | +// with VL53L8CH variant, so histogram example 12 is supported |
| 16 | +extern "C" { |
| 17 | +#include "../../../../ext/vl53/vl53/vl53lmz/examples/Example_12_cnh_data.h" |
| 18 | +#include "../../../../ext/vl53/vl53/vl53lmz/examples/Example_1_ranging_basic.h" |
| 19 | +#include "../../../../ext/vl53/vl53/vl53lmz/examples/Example_2_get_set_params.h" |
| 20 | +#include "../../../../ext/vl53/vl53/vl53lmz/examples/Example_3_ranging_modes.h" |
| 21 | +#include "../../../../ext/vl53/vl53/vl53lmz/examples/Example_5_multiple_targets_per_zone.h" |
| 22 | +} |
| 23 | + |
| 24 | +#include <modm/driver/vl53/vl53_transport.hpp> |
| 25 | + |
| 26 | +using namespace Board; |
| 27 | + |
| 28 | +using SpiMaster = SpiMaster2_Dma<Dma1::Channel0, Dma1::Channel1>; |
| 29 | +using Cs = GpioC0; |
| 30 | +using Mosi = GpioB15; |
| 31 | +using Miso = GpioC2; |
| 32 | +using Sck = GpioD3; |
| 33 | + |
| 34 | +using Rst = GpioD6; |
| 35 | +using Snc = GpioB1; |
| 36 | +using LPn = GpioA3; |
| 37 | +using Int = GpioD7; |
| 38 | + |
| 39 | +modm::Vl53SpiTransport<SpiMaster, Cs, LPn> transport; |
| 40 | + |
| 41 | +int |
| 42 | +main() |
| 43 | +{ |
| 44 | + Board::initialize(); |
| 45 | + |
| 46 | + Dma1::enable(); |
| 47 | + Leds::setOutput(); |
| 48 | + |
| 49 | + LPn::setOutput(false); |
| 50 | + Snc::setOutput(false); |
| 51 | + Cs::setOutput(true); |
| 52 | + |
| 53 | + transport.resetSensor(); |
| 54 | + |
| 55 | + SpiMaster::connect<Sck::Sck, Mosi::Mosi, Miso::Miso>(); |
| 56 | + SpiMaster::initialize<Board::SystemClock, 2.2_MHz>(); |
| 57 | + |
| 58 | + example1(&transport); |
| 59 | + example2(&transport); |
| 60 | + example3(&transport); |
| 61 | + example5(&transport); |
| 62 | + example12(&transport); |
| 63 | +} |
0 commit comments