Ajout information init Gyro + robustesse Gyro

This commit is contained in:
Samuel 2023-05-18 22:26:34 +02:00
parent 542c407861
commit f5711b7a03
2 changed files with 25 additions and 10 deletions

12
gyro.c
View File

@ -4,6 +4,7 @@
#include "hardware/spi.h"
#include "hardware/structs/spi.h"
#include "Geometrie.h"
#include "Monitoring.h"
#include "spi_nb.h"
#include "Temps.h"
#include "gyro.h"
@ -73,14 +74,19 @@ void Gyro_Init(void){
// Test de la présence du gyroscope :
if(gyro_init_check()){
puts("Gyroscope non trouve");
while(1); // On s'arrête là !
Monitoring_Error("Gyroscope non trouve");
while(1){
puts("Gyroscope non trouve");
}; // On s'arrête là !
}else{
//puts("Gyroscope trouve");
if(!gyro_config()){
//puts("gyro_config ok !");
}else{
puts("gyro_config FAILED !");
Monitoring_Error("gyro_config FAILED !");
while(1){
puts("gyro_config FAILED !");
}; // On s'arrête là !
}
}

View File

@ -58,17 +58,26 @@ int gyro_get_sensor_data(uint16_t tampon_envoi[], uint8_t tampon_reception[]){
gyro_spi_wr_32bits(tampon_envoi, tampon_reception);
Gyro_traitementDonnees(tampon_reception);
if(Gyro_SensorData.SQ != 0x4){
printf("Gyro Failed - SQ bits (%#3x)!= 0x4\n", Gyro_SensorData.SQ);
affiche_tampon_32bits(tampon_reception);
Monitoring_Error("Gyro Failed - SQ bits != 0x4\n");
set_position_avec_gyroscope(0);
return 1;
if(tampon_reception[1] & 0x04){
printf("SPI ERROR\n");
return 1;
}else{
/*while(1){
affiche_tampon_32bits(tampon_reception);
printf("Gyro Failed - SQ bits (%#3x)!= 0x4\n", Gyro_SensorData.SQ);
}*/
//set_position_avec_gyroscope(0);
}
}
if(Gyro_SensorData.ST != 0x1){
printf("Gyro Failed - Status (%#3x)!= 0x1\n", Gyro_SensorData.ST);
Monitoring_Error("Gyro Failed - Status != 0x1\n");
affiche_tampon_32bits(tampon_reception);
set_position_avec_gyroscope(0);
/*while(1){
printf("Gyro Failed - Status (%#3x)!= 0x1\n", Gyro_SensorData.ST);
affiche_tampon_32bits(tampon_reception);
}*/
//set_position_avec_gyroscope(0);
return 1;
}
return 0;