-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
2,207 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: VL53L4CD Continuous Integration | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths-ignore: | ||
- '*' | ||
- '**.md' | ||
- '**.txt' | ||
pull_request: | ||
paths-ignore: | ||
- '*' | ||
- '**.md' | ||
- '**.txt' | ||
jobs: | ||
astyle_check: | ||
runs-on: ubuntu-latest | ||
name: AStyle check | ||
steps: | ||
# First of all, clone the repo using the checkout action. | ||
- name: Checkout | ||
uses: actions/checkout@main | ||
|
||
- name: Astyle check | ||
id: Astyle | ||
uses: stm32duino/actions/astyle-check@main | ||
|
||
# Use the output from the `Astyle` step | ||
- name: Astyle Errors | ||
if: failure() | ||
run: | | ||
cat ${{ steps.Astyle.outputs.astyle-result }} | ||
exit 1 | ||
spell-check: | ||
runs-on: ubuntu-latest | ||
name: Spell check | ||
steps: | ||
- uses: actions/checkout@main | ||
- uses: arduino/actions/libraries/spell-check@master | ||
with: | ||
ignore-words-list: "./extras/codespell-ignore-words-list.txt" | ||
lib_build: | ||
runs-on: ubuntu-latest | ||
name: Library compilation | ||
steps: | ||
# First of all, clone the repo using the checkout action. | ||
- name: Checkout | ||
uses: actions/checkout@main | ||
|
||
- name: Compilation | ||
id: Compile | ||
uses: stm32duino/actions/compile-examples@main | ||
with: | ||
board-pattern: "NUCLEO_L476RG" | ||
|
||
# Use the output from the `Compile` step | ||
- name: Compilation Errors | ||
if: failure() | ||
run: | | ||
cat ${{ steps.Compile.outputs.compile-result }} | ||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# VL53L4CD | ||
Arduino library to support the VL53L4CD Time-of-Flight ranging sensor. | ||
|
||
## API | ||
|
||
This sensor uses I2C to communicate. And I2C instance is required to access to the sensor. | ||
The APIs provide simple distance measure in both polling and interrupt modes. | ||
|
||
## Examples | ||
|
||
There are 2 examples with the VL53L4CD library. | ||
|
||
In order to use these examples you need to connect the VL53L4CD satellite sensor directly to the Nucleo board with wires as explained below: | ||
- pin 1 (GND) of the VL53L4CD satellite connected to GND of the Nucleo board | ||
- pin 2 (VDD) of the VL53L4CD satellite connected to 3V3 pin of the Nucleo board | ||
- pin 3 (SCL) of the VL53L4CD satellite connected to pin D15 (SCL) of the Nucleo board | ||
- pin 4 (SDA) of the VL53L4CD satellite connected to pin D14 (SDA) of the Nucleo board | ||
- pin 5 (GPIO1) of the VL53L4CD satellite connected to pin A2 of the Nucleo board | ||
- pin 6 (XSHUT) of the VL53L4CD satellite connected to pin A1 of the Nucleo board | ||
|
||
* VL53L4CD_Sat_HelloWorld: This example code is to show how to get proximity | ||
values of the VL53L4CD satellite sensor in polling mode. | ||
|
||
* VL53L4CD_Sat_HelloWorld_Interrupt: This example code is to show how to get proximity | ||
values of the VL53L4CD satellite sensor in interrupt mode. | ||
|
||
## Documentation | ||
|
||
You can find the source files at | ||
https://github.com/stm32duino/VL53L4CD | ||
|
||
The VL53L4CD datasheet is available at | ||
https://www.st.com/content/st_com/en/products/imaging-and-photonics-solutions/proximity-sensors/vl53l4cd.html |
132 changes: 132 additions & 0 deletions
132
examples/VL53L4CD_Sat_HelloWorld/VL53L4CD_Sat_HelloWorld.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
/** | ||
****************************************************************************** | ||
* @file VL53L4CD_Sat_HelloWorld.ino | ||
* @author STMicroelectronics | ||
* @version V1.0.0 | ||
* @date 29 November 2021 | ||
* @brief Arduino test application for the STMicrolectronics VL53L4CD | ||
* proximity sensor satellite based on FlightSense. | ||
* This application makes use of C++ classes obtained from the C | ||
* components' drivers. | ||
****************************************************************************** | ||
* @attention | ||
* | ||
* <h2><center>© COPYRIGHT(c) 2021 STMicroelectronics</center></h2> | ||
* | ||
* Redistribution and use in source and binary forms, with or without modification, | ||
* are permitted provided that the following conditions are met: | ||
* 1. Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* 3. Neither the name of STMicroelectronics nor the names of its contributors | ||
* may be used to endorse or promote products derived from this software | ||
* without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
****************************************************************************** | ||
*/ | ||
|
||
/* | ||
* To use this sketch you need to connect the VL53L4CD satellite sensor directly to the Nucleo board with wires in this way: | ||
* pin 1 (GND) of the VL53L4CD satellite connected to GND of the Nucleo board | ||
* pin 2 (VDD) of the VL53L4CD satellite connected to 3V3 pin of the Nucleo board | ||
* pin 3 (SCL) of the VL53L4CD satellite connected to pin D15 (SCL) of the Nucleo board | ||
* pin 4 (SDA) of the VL53L4CD satellite connected to pin D14 (SDA) of the Nucleo board | ||
* pin 5 (GPIO1) of the VL53L4CD satellite connected to pin A2 of the Nucleo board | ||
* pin 6 (XSHUT) of the VL53L4CD satellite connected to pin A1 of the Nucleo board | ||
*/ | ||
/* Includes ------------------------------------------------------------------*/ | ||
#include <Arduino.h> | ||
#include <Wire.h> | ||
#include <vl53l4cd_class.h> | ||
#include <string.h> | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#include <stdint.h> | ||
#include <assert.h> | ||
#include <stdlib.h> | ||
|
||
#define DEV_I2C Wire | ||
#define SerialPort Serial | ||
|
||
#ifndef LED_BUILTIN | ||
#define LED_BUILTIN 13 | ||
#endif | ||
#define LedPin LED_BUILTIN | ||
|
||
// Components. | ||
VL53L4CD sensor_vl53l4cd_sat(&DEV_I2C, A1); | ||
|
||
/* Setup ---------------------------------------------------------------------*/ | ||
|
||
void setup() | ||
{ | ||
// Led. | ||
pinMode(LedPin, OUTPUT); | ||
|
||
// Initialize serial for output. | ||
SerialPort.begin(115200); | ||
SerialPort.println("Starting..."); | ||
|
||
// Initialize I2C bus. | ||
DEV_I2C.begin(); | ||
|
||
// Configure VL53L4CD satellite component. | ||
sensor_vl53l4cd_sat.begin(); | ||
|
||
// Switch off VL53L4CD satellite component. | ||
sensor_vl53l4cd_sat.VL53L4CD_Off(); | ||
|
||
//Initialize VL53L4CD satellite component. | ||
sensor_vl53l4cd_sat.InitSensor(); | ||
|
||
// Program the highest possible TimingBudget, without enabling the | ||
// low power mode. This should give the best accuracy | ||
sensor_vl53l4cd_sat.VL53L4CD_SetRangeTiming(200, 0); | ||
|
||
// Start Measurements | ||
sensor_vl53l4cd_sat.VL53L4CD_StartRanging(); | ||
} | ||
|
||
void loop() | ||
{ | ||
uint8_t NewDataReady = 0; | ||
VL53L4CD_Result_t results; | ||
uint8_t status; | ||
char report[64]; | ||
|
||
do { | ||
status = sensor_vl53l4cd_sat.VL53L4CD_CheckForDataReady(&NewDataReady); | ||
} while (!NewDataReady); | ||
|
||
//Led on | ||
digitalWrite(LedPin, HIGH); | ||
|
||
if ((!status) && (NewDataReady != 0)) { | ||
// (Mandatory) Clear HW interrupt to restart measurements | ||
sensor_vl53l4cd_sat.VL53L4CD_ClearInterrupt(); | ||
|
||
// Read measured distance. RangeStatus = 0 means valid data | ||
sensor_vl53l4cd_sat.VL53L4CD_GetResult(&results); | ||
snprintf(report, sizeof(report), "Status = %3u, Distance = %5u mm, Signal = %6u kcps/spad\r\n", | ||
results.range_status, | ||
results.distance_mm, | ||
results.signal_per_spad_kcps); | ||
SerialPort.print(report); | ||
} | ||
|
||
//Led off | ||
digitalWrite(LedPin, LOW); | ||
} |
Oops, something went wrong.