Tampon matériel limité à 16 bits - il fallait en tenir compte !

This commit is contained in:
Samuel 2024-04-03 22:45:09 +02:00
parent 68e16127ba
commit c8452307fc
2 changed files with 38 additions and 4 deletions

View File

@ -117,7 +117,7 @@ int test_i2c_bus(){
int test_i2c_lecture_pico_annex(){
i2c_maitre_init();
uint8_t tampon[10];
uint8_t registre=2;
uint8_t registre=0;
uint8_t adresse = 0x17;
int ret;
@ -125,6 +125,8 @@ int test_i2c_lecture_pico_annex(){
if(ret < 0){
printf("Erreur I2C : %d", ret);
return 0;
}else{
printf("Envoi I2C: OK\n");
}
ret = i2c_read_blocking(i2c_default, adresse, tampon, 10, false);
@ -296,6 +298,8 @@ int test_i2c_ecriture_pico_annex_nb_2(){
printf("D - Bras lève pot\n");
printf("E - Attrape plante - bras 1\n");
printf("F - Attrape plante - bras 6\n");
printf("G - Detection bordure\n");
printf("H - Detection plante\n");
printf("S - Score + 1\n");
printf("\nQ - Quitter\n");
@ -303,6 +307,8 @@ int test_i2c_ecriture_pico_annex_nb_2(){
int lettre;
int continue_test=1;
uint8_t score=0;
enum validite_vl53l8_t validite_vl53l8;
float angle, distance;
time_i2c[0] = time_us_32();
time_i2c[1] = time_us_32();
@ -310,7 +316,7 @@ int test_i2c_ecriture_pico_annex_nb_2(){
i2c_annexe_init();
multicore_launch_core1(affiche_contacteur);
//multicore_launch_core1(affiche_contacteur);
while(1){
@ -362,6 +368,18 @@ int test_i2c_ecriture_pico_annex_nb_2(){
printf("=> Attrape plante - bras 6\n");
break;
case 'G':
case 'g':
i2c_annexe_set_mode_VL53L8(VL53L8_BORDURE);
printf("=> Detection bordure\n");
break;
case 'H':
case 'h':
i2c_annexe_set_mode_VL53L8(VL53L8_PLANTE);
printf("=> Detection plante\n");
break;
case 'q':
case 'Q':
multicore_reset_core1();
@ -381,6 +399,17 @@ int test_i2c_ecriture_pico_annex_nb_2(){
i2c_gestion(i2c0);
i2c_annexe_gestion();
i2c_annexe_get_VL53L8(&validite_vl53l8, &angle, &distance);
printf(">v:%d\n", validite_vl53l8);
switch(validite_vl53l8){
case VL53L8_BORDURE:
printf(">b_angle:%.2f\n>b_distance:%.2f\n", angle, distance);
break;
case VL53L8_PLANTE:
printf(">p_angle:%.2f\n>p_distance:%.2f\n", angle, distance);
break;
}
}

View File

@ -7,7 +7,8 @@
#define I2C_SDA_PIN 16
#define I2C_SCL_PIN 17
#define I2C_NB_MAX_TAMPON 20
#define I2C_NB_MAX_TAMPON 128
#define MAX_TAMPON_HARDWARE 16
enum i2c_statu_t{
I2C_STATU_LIBRE,
@ -77,7 +78,7 @@ void i2c_gestion(i2c_inst_t *i2c){
statu_reception = TRANSACTION_TERMINEE;
i2c_statu_i2c0 = I2C_STATU_LIBRE;
}
uint i=0;
while( (index_envoi < I2C_nb_a_envoyer) && (i2c_get_write_available(i2c)) ){
bool restart = false;
bool last = false;
@ -113,6 +114,10 @@ void i2c_gestion(i2c_inst_t *i2c){
}else{
index_envoi++;
}
i++;
if(i== MAX_TAMPON_HARDWARE){
break;
}
}