86 lines
2.3 KiB
Markdown
86 lines
2.3 KiB
Markdown
Submodule VL53L8CX pour le RP2040
|
|
=====================================
|
|
|
|
Ceci est un submodule git pour intégrer facilement un capteur VL53L8CX à un projet.
|
|
|
|
Le code présent ici se base sur [Ultra lite driver (ULD) API for the VL53L8CX](https://www.st.com/en/embedded-software/stsw-img040.html)
|
|
|
|
La documentation est disponible ici : https://www.st.com/content/st_com/en/technical-documents/UM3109.html
|
|
|
|
On crée ce Submodule en se servant de la documentation disponible ici : https://git-scm.com/book/en/v2/Git-Tools-Submodules
|
|
|
|
Utilisation
|
|
===========
|
|
|
|
Ajout du sub-module
|
|
-------------------
|
|
|
|
Ajouter ce submodule à votre projet. Dans un terminal, dans le répertoire de votre projet, entrez :
|
|
|
|
git submodule add https://git.poivron-robotique.fr/Keuronde/Mod_VL53L8CX.git
|
|
|
|
Ajouter le fichier nouvellement créé .gitmodules à votre projet.
|
|
|
|
git add .gitmodules
|
|
|
|
Configuration de la compilation
|
|
-------------------------------
|
|
|
|
Dans le fichier CMakeLists.txt, ajouter le dossier du sub module:
|
|
|
|
add_subdirectory(Mod_VL53L8CX)
|
|
|
|
Intégration au code source
|
|
--------------------------
|
|
|
|
Dans le code du module, ouvrez le fichier Platform/platform.c, adaptez les macro de configuration de l'i2c
|
|
|
|
#define I2C_DEVICE i2c1
|
|
#define I2C1_SDA_PIN 14
|
|
#define I2C1_SCL_PIN 15
|
|
|
|
Dans votre code, ajout du fichier d'include :
|
|
|
|
#include "Mod_VL53L8CX/VL53L8_2024.h"
|
|
|
|
Initialisation du module :
|
|
|
|
struct VL53L8CX_Configuration Dev;
|
|
VL53L8_init(&Dev);
|
|
|
|
Lecture des distances :
|
|
|
|
struct VL53L8CX_ResultsData Results;
|
|
VL53L8_lecture(&Dev, &Results);
|
|
|
|
Affichage des distances :
|
|
|
|
for (int i=0; i< 8; i++){
|
|
for (int j=0; j< 8; j++){
|
|
printf("%3d ",Results.distance_mm[8*i+j]);
|
|
}
|
|
printf("\n");
|
|
}
|
|
|
|
Configuration applicative
|
|
-------------------------
|
|
|
|
Un système de masque permet de considéré que le capteur ne voit "rien" s'il la distance est supérieur à une certaine valeur.
|
|
Cette valeur se configure dans la variable ``masque` présente dans `VL53L8_2024.c`.
|
|
|
|
|
|
|
|
|
|
Cas où vous clonez un projet contenant des submodules
|
|
-----------------------------------------------------
|
|
|
|
Après avoir cloné le projet, initialisez les submodules:
|
|
|
|
git submodule init
|
|
|
|
git submodule update
|
|
|
|
Pour récupérer les dernières mise à jour des sub-modules :
|
|
|
|
git submodule update --remote
|