Module fonctionnel

This commit is contained in:
Samuel 2026-07-25 23:03:16 +02:00
parent bd253952b1
commit 1d82bcb01d
7 changed files with 65 additions and 11 deletions

View File

@ -12,7 +12,7 @@
"name": "Linux",
"intelliSenseMode": "linux-gcc-arm",
"includePath": [
"${myDefaultIncludePath}",
"${myDefaultIncludePath}"
],
"compilerPath": "/usr/bin/arm-none-eabi-gcc",
"cStandard": "c11",

View File

@ -11,6 +11,9 @@ add_library(Mod_VL53L8
Platform/platform.c
)
target_include_directories(Mod_VL53L8 PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/VL53L8CX_ULD_API/inc/
)
target_link_libraries(Mod_VL53L8
pico_stdlib

View File

@ -16,15 +16,32 @@
#include "hardware/i2c.h"
#include <stdio.h>
// Configuration of the I2C communication
#define I2C_DEVICE i2c1
#define I2C1_SDA_PIN 14
#define I2C1_SCL_PIN 15
#define I2C_SUCCESS 0
#define I2C_FAILED 1
#define I2C_BUFFER_EXCEEDED 2
#define I2C_DEVICE i2c1
#define MAX_I2C_BUFFER 0x8100
void platform_i2c_init(void){
i2c_init(I2C_DEVICE, 400 * 1000);
printf("Initialisation des broches\n");
printf("%d et %d en I2C\n", I2C1_SDA_PIN, I2C1_SCL_PIN);
gpio_set_function(I2C1_SDA_PIN, GPIO_FUNC_I2C);
gpio_set_function(I2C1_SCL_PIN, GPIO_FUNC_I2C);
gpio_pull_up(I2C1_SDA_PIN);
gpio_pull_up(I2C1_SCL_PIN);
}
/// @brief Blocking function allowing to write a register on an I2C device
/// @param address_7_bits
/// @param index : register to write

View File

@ -163,4 +163,6 @@ uint8_t WaitMs(
VL53L8CX_Platform *p_platform,
uint32_t TimeMs);
void platform_i2c_init(void);
#endif // _PLATFORM_H_

View File

@ -1,7 +1,12 @@
Submodule Communication pour le RP2040
Submodule VL53L8CX pour le RP2040
=====================================
Ceci est un submodule git pour intégrer facilement notre protocole de communication à un projet.
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
@ -28,22 +33,44 @@ Dans le fichier CMakeLists.txt, ajouter le dossier du sub module:
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
Ajout du fichier d'include :
Dans votre code, ajout du fichier d'include :
#include "RP2040_Servomoteurs/Servomoteur.h"
#include "Mod_VL53L8CX/VL53L8_2024.h"
Initialisation du module :
struct VL53L8CX_Configuration Dev;
VL53L8_init(&Dev);
Lecture des distances
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
-----------------------------------------------------

View File

@ -12,6 +12,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "vl53l8cx_api.h"
#include "vl53l8cx_buffers.h"

View File

@ -8,9 +8,10 @@ int masque[64]={
3000,3000,3000,3000,3000,3000,3000,3000,
3000,3000,3000,3000,3000,3000,3000,3000,
3000,3000,3000,3000,3000,3000,3000,3000,
350,350,350,350,350,350,350,350,
281,286,299,306,310,314,302,286,
195,200,202,206,213,200,200,202
3000,3000,3000,3000,3000,3000,3000,3000,
3000,3000,3000,3000,3000,3000,3000,3000,
3000,3000,3000,3000,3000,3000,3000,3000,
};
float old_min_distance;
@ -18,6 +19,9 @@ float old_min_distance;
void VL53L8_init(VL53L8CX_Configuration * Dev){
uint8_t status, isAlive, isReady, i;
// Initialise i2c
platform_i2c_init();
/*********************************/
/* Customer platform */
@ -106,7 +110,7 @@ void VL53L8_lecture(VL53L8CX_Configuration * Dev, VL53L8CX_ResultsData * Results
error = vl53l8cx_get_ranging_data(Dev, Results);
if(error){
printf("Error VL53L8\n");
VL53L8_init(Dev);
//VL53L8_init(Dev);
}