Début des test approfondis du gyroscope
This commit is contained in:
		
							parent
							
								
									654425ad41
								
							
						
					
					
						commit
						c3d19bc8bc
					
				| @ -35,6 +35,8 @@ Strategie_prise_cerises.c | ||||
| Strategie_pousse_gateau.c | ||||
| Temps.c | ||||
| Test.c | ||||
| Test_gyro.c | ||||
| Test_i2c.c | ||||
| Test_log.c | ||||
| Test_strategie.c | ||||
| Trajet.c | ||||
| @ -47,7 +49,7 @@ spi_nb.c) | ||||
| 
 | ||||
| pico_generate_pio_header(test ${CMAKE_CURRENT_LIST_DIR}/quadrature_encoder.pio) | ||||
| 
 | ||||
| add_definitions(-DGYRO_ADXRS453) | ||||
| add_definitions(-DGYRO_ADXRS453=1) | ||||
| add_definitions(-DPICO_MALLOC_PANIC=0) | ||||
| pico_enable_stdio_usb(test 1) | ||||
| pico_enable_stdio_uart(test 1) | ||||
|  | ||||
							
								
								
									
										495
									
								
								Test.c
									
									
									
									
									
								
							
							
						
						
									
										495
									
								
								Test.c
									
									
									
									
									
								
							| @ -28,6 +28,8 @@ | ||||
| #include "Trajectoire.h" | ||||
| #include "Trajet.h" | ||||
| 
 | ||||
| #include "Test_gyro.h" | ||||
| #include "Test_i2c.h" | ||||
| #include "Test_log.h" | ||||
| #include "Test_strategie.h" | ||||
| #include "Test.h" | ||||
| @ -52,13 +54,7 @@ int test_asser_position_avance(void); | ||||
| int test_asser_position_avance_et_tourne(int, int); | ||||
| int test_transition_gyro_pas_gyro(void); | ||||
| int test_trajectoire(void); | ||||
| int test_i2c_bus(void); | ||||
| void affiche_localisation(void); | ||||
| int test_i2c_lecture_pico_annex(); | ||||
| int test_i2c_lecture_pico_annex_nb(); | ||||
| int test_i2c_lecture_pico_annex_nb2(); | ||||
| int test_i2c_ecriture_pico_annex_nb(); | ||||
| int test_i2c_ecriture_pico_annex_nb_2(); | ||||
| int test_aller_retour(); | ||||
| void test_trajectoire_teleplot(); | ||||
| int test_capteurs_balise(void); | ||||
| @ -87,14 +83,11 @@ int mode_test(){ | ||||
|     printf("O - Analyse obstacle\n"); | ||||
|     printf("P - Asser Position - perturbation\n"); | ||||
|     printf("Q - Asser Position - transition Gyro -> Pas gyro\n"); | ||||
|     printf("R - Test des logs\n"); | ||||
|     printf("R - Test des logs...\n"); | ||||
|     printf("S - Test du gyroscope...\n"); | ||||
|     printf("T - Trajectoire\n"); | ||||
|     printf("U - Scan du bus i2c\n"); | ||||
|     printf("U - Tests i2c...\n"); | ||||
|     printf("V - APDS_9960\n"); | ||||
|     printf("W - Com i2c Pico Annexe\n"); | ||||
|     printf("X - Com i2c Pico Annexe - non bloquant\n"); | ||||
|     printf("Y - I2C - Turbine & porte\n"); | ||||
|     printf("Z - I2C - Turbine & porte + contacteurs - fonctions encapsulees\n"); | ||||
|     stdio_flush(); | ||||
|     int rep = getchar_timeout_us(TEST_TIMEOUT_US); | ||||
|     stdio_flush(); | ||||
| @ -188,6 +181,11 @@ int mode_test(){ | ||||
|     case 'r': | ||||
|         while(test_log()); | ||||
|         break; | ||||
|      | ||||
|     case 'S': | ||||
|     case 's': | ||||
|         while(test_gyro()); | ||||
|         break; | ||||
| 
 | ||||
|     case 'T': | ||||
|     case 't': | ||||
| @ -196,7 +194,7 @@ int mode_test(){ | ||||
| 
 | ||||
|     case 'U': | ||||
|     case 'u': | ||||
|         while(test_i2c_bus()); | ||||
|         while(test_i2c()); | ||||
|         break; | ||||
| 
 | ||||
|     case 'V': | ||||
| @ -204,26 +202,6 @@ int mode_test(){ | ||||
|         while(test_APDS9960()); | ||||
|         break; | ||||
| 
 | ||||
|     case 'W': | ||||
|     case 'w': | ||||
|         while(test_i2c_lecture_pico_annex()); | ||||
|         break; | ||||
| 
 | ||||
|     case 'X': | ||||
|     case 'x': | ||||
|         while(test_i2c_lecture_pico_annex_nb2()); | ||||
|         break; | ||||
| 
 | ||||
|     case 'Y': | ||||
|     case 'y': | ||||
|         while(test_i2c_ecriture_pico_annex_nb()); | ||||
|         break; | ||||
| 
 | ||||
|     case 'Z': | ||||
|     case 'z': | ||||
|         while(test_i2c_ecriture_pico_annex_nb_2()); | ||||
|         break; | ||||
| 
 | ||||
|     case PICO_ERROR_TIMEOUT: | ||||
|         iteration--;         | ||||
|         if(iteration == 0){ | ||||
| @ -277,9 +255,7 @@ int test_capteurs_balise(void){ | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| bool reserved_addr(uint8_t addr) { | ||||
|     return (addr & 0x78) == 0 || (addr & 0x78) == 0x78; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| int test_APDS9960(){ | ||||
|     int lettre; | ||||
| @ -300,453 +276,6 @@ int test_APDS9960(){ | ||||
|     return 1; | ||||
| } | ||||
| 
 | ||||
| int test_i2c_lecture_pico_annex(){ | ||||
|     i2c_maitre_init(); | ||||
|     uint8_t tampon[10]; | ||||
|     uint8_t registre=2; | ||||
|     uint8_t adresse = 0x17; | ||||
|     int ret;  | ||||
|      | ||||
|     ret = i2c_write_blocking(i2c0, adresse,®istre, 1, false); | ||||
|     if(ret < 0){ | ||||
|         printf("Erreur I2C : %d", ret); | ||||
|         return 0; | ||||
|     } | ||||
| 
 | ||||
|     ret = i2c_read_blocking(i2c_default, adresse, tampon, 10, false); | ||||
|     if(ret < 0){ | ||||
|         printf("Erreur I2C : %d", ret); | ||||
|     }else{ | ||||
|         for(int i=0; i<10; i++){ | ||||
|             printf("%c", tampon[i]); | ||||
|         } | ||||
|         printf("\n"); | ||||
| 
 | ||||
|         for(int i=0; i<10; i++){ | ||||
|             printf("%2x ", tampon[i]); | ||||
|         } | ||||
|         printf("\n"); | ||||
|     } | ||||
|     return test_continue_test(); | ||||
| } | ||||
| 
 | ||||
| int test_i2c_lecture_pico_annex_nb(){ | ||||
|     i2c_maitre_init(); | ||||
|     uint8_t tampon[10]; | ||||
|     uint8_t registre=2; | ||||
|     uint8_t adresse = 0x17; | ||||
|     uint32_t time_i2c[5]; | ||||
|     const uint8_t T_MAX_I2C = 10; | ||||
|     int ret;  | ||||
| 
 | ||||
|     time_i2c[0] = time_us_32(); | ||||
| 
 | ||||
|     // On charge l'adresse de l'esclave
 | ||||
|     i2c0->hw->enable = 0; | ||||
|     i2c0->hw->tar = adresse; | ||||
|     i2c0->hw->enable = 1; | ||||
| 
 | ||||
|     // On envoie l'adresse du registre à lire
 | ||||
|     // Pas de stop, pas de restart, écriture : 0, 
 | ||||
| 
 | ||||
|     i2c0->hw->data_cmd = registre; | ||||
| 
 | ||||
|     uint8_t first = false; | ||||
|     uint8_t last = false; | ||||
| 
 | ||||
|     for(int i=0; i<T_MAX_I2C; i++){ | ||||
|         first = false; | ||||
|         last = false; | ||||
|         if (i == 0){ | ||||
|             first = true; | ||||
|         } | ||||
|         if(i == T_MAX_I2C -1){ | ||||
|             last = true; | ||||
|         } | ||||
| 
 | ||||
|         i2c0->hw->data_cmd = | ||||
|                 bool_to_bit(first) << I2C_IC_DATA_CMD_RESTART_LSB | | ||||
|                 bool_to_bit(last) << I2C_IC_DATA_CMD_STOP_LSB | | ||||
|                 I2C_IC_DATA_CMD_CMD_BITS; // -> 1 for read
 | ||||
|     } | ||||
| 
 | ||||
|     time_i2c[1] = time_us_32() - time_i2c[0] ; | ||||
| 
 | ||||
|     // On attend la fin de la transaction i2c
 | ||||
|     while(i2c0->hw->status & I2C_IC_STATUS_MST_ACTIVITY_BITS); | ||||
| 
 | ||||
|     time_i2c[2] = time_us_32() - time_i2c[0] ; | ||||
| 
 | ||||
|     // On lit le tampon I2C
 | ||||
|     // uint8_t * dst;
 | ||||
|     // dst = tampon;
 | ||||
|      | ||||
|     for(int i=0; i<T_MAX_I2C; i++){ | ||||
|         // On attend une donnée
 | ||||
|         while(!i2c_get_read_available(i2c0)); | ||||
| 
 | ||||
|         // Code erreur
 | ||||
|         if(i2c0->hw->tx_abrt_source){ | ||||
|             printf("Erreur I2C: Abort : %4x\n", i2c0->hw->tx_abrt_source); | ||||
|         } | ||||
| 
 | ||||
|         //On lit la donnée
 | ||||
|         tampon[i] = (uint8_t) i2c0->hw->data_cmd; | ||||
|     } | ||||
| 
 | ||||
|     time_i2c[3] = time_us_32() - time_i2c[0] ; | ||||
| 
 | ||||
|     // Affichage
 | ||||
|     for(int i=0; i<T_MAX_I2C; i++){ | ||||
|         printf("%c", tampon[i]); | ||||
|     } | ||||
|     printf("\n"); | ||||
| 
 | ||||
|     for(int i=0; i<T_MAX_I2C; i++){ | ||||
|         printf("%2x ", tampon[i]); | ||||
|     } | ||||
|     printf("\n"); | ||||
| 
 | ||||
|     printf("T_init: %u, T_attente: %u, T_lecture: %u\n", time_i2c[1], time_i2c[2], time_i2c[3]); | ||||
| 
 | ||||
|     return test_continue_test(); | ||||
| } | ||||
| 
 | ||||
| int test_i2c_lecture_pico_annex_nb2(){ | ||||
|     i2c_maitre_init(); | ||||
| 
 | ||||
|     uint8_t tampon[10]; | ||||
|     uint8_t registre=8; | ||||
|     uint8_t adresse = 0x17; | ||||
|     uint32_t time_i2c[5]; | ||||
|     const uint8_t T_MAX_I2C = 10; | ||||
|     enum i2c_resultat_t retour_i2c = I2C_EN_COURS; | ||||
| 
 | ||||
|     time_i2c[0] = time_us_32(); | ||||
|     time_i2c[2] = 0; | ||||
| 
 | ||||
|     while(retour_i2c == I2C_EN_COURS){ | ||||
|         time_i2c[1] = time_us_32(); // Pour mesurer le temps d'execution
 | ||||
|         i2c_gestion(i2c0); | ||||
|         retour_i2c = i2c_lire_registre_nb(adresse, registre, tampon, T_MAX_I2C); | ||||
|         time_i2c[2] += time_us_32() - time_i2c[1]; // Pour mesurer le temps d'execution
 | ||||
|         sleep_us(100); // Attente, ou le reste du code
 | ||||
|     } | ||||
|     time_i2c[3] = time_us_32() - time_i2c[0]; | ||||
| 
 | ||||
|     // Affichage
 | ||||
|     for(int i=0; i<T_MAX_I2C; i++){ | ||||
|         printf("%c", tampon[i]); | ||||
|     } | ||||
|     printf("\n"); | ||||
| 
 | ||||
|     for(int i=0; i<T_MAX_I2C; i++){ | ||||
|         printf("%2x ", tampon[i]); | ||||
|     } | ||||
|     printf("\n"); | ||||
| 
 | ||||
|     printf("Temps lecture : %u microsecondes, temps specifique i2c : %u microsecondes.\n", time_i2c[3], time_i2c[2]); | ||||
| 
 | ||||
|     return test_continue_test(); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| int test_i2c_ecriture_pico_annex_nb(){ | ||||
|     i2c_maitre_init(); | ||||
| 
 | ||||
|     uint8_t tampon[10]; | ||||
|     uint8_t registre=0x09; | ||||
|     uint8_t adresse = 0x17; | ||||
|     uint32_t time_i2c[5]; | ||||
|     const uint8_t T_I2C_ENVOI = 2; | ||||
|     static uint8_t commande=0; | ||||
|     enum i2c_resultat_t retour_i2c = I2C_EN_COURS; | ||||
| 
 | ||||
| 
 | ||||
|     printf("F - Ferme porte\n"); | ||||
|     printf("O - Ouvre porte\n"); | ||||
|     printf("T - Turbine On\n"); | ||||
|     printf("U - Turbine Off\n"); | ||||
|     printf("P - Propulseur On\n"); | ||||
|     printf("M - Propulseur Off\n"); | ||||
|     printf("Q pour quitter\n"); | ||||
| 
 | ||||
|     int lettre; | ||||
|     do{  | ||||
|         lettre = getchar_timeout_us(0); | ||||
|         stdio_flush(); | ||||
| 
 | ||||
|     }while(lettre == PICO_ERROR_TIMEOUT || lettre == '\0'); | ||||
| 
 | ||||
|     tampon[1] = 0x0; | ||||
|     switch(lettre){ | ||||
|         case 'F': | ||||
|         case 'f': | ||||
|             commande = commande | 0x02; // 0b0000 0010
 | ||||
|             printf("=> Ferme porte\n"); | ||||
|             break; | ||||
| 
 | ||||
|         case 'O': | ||||
|         case 'o': | ||||
|             commande = commande & 0xFD; // 0b1111 1101
 | ||||
|             printf("=> Ouvre porte\n"); | ||||
|             break; | ||||
|          | ||||
|         case 't': | ||||
|         case 'T': | ||||
|             commande = commande | 0x01; // 0b0000 0001
 | ||||
|             printf("=> Active turbine\n"); | ||||
|             break; | ||||
|          | ||||
|         case 'u': | ||||
|         case 'U': | ||||
|             commande = commande & 0xFE; // 0b1111 1110
 | ||||
|             printf("=> Arrete turbine\n"); | ||||
|             break; | ||||
|          | ||||
|         case 'p': | ||||
|         case 'P': | ||||
|             commande = commande | 0x04; // 0b0000 0100
 | ||||
|             printf("=> Active propulseur\n"); | ||||
|             break; | ||||
|          | ||||
|         case 'm': | ||||
|         case 'M': | ||||
|             commande = commande & 0xFB; // 0b1111 1011
 | ||||
|             printf("=> Arrete propulseur\n"); | ||||
|             break; | ||||
|              | ||||
|         case 'q': | ||||
|         case 'Q': | ||||
|             return 0; | ||||
|             break; | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     tampon[0] = 54; | ||||
|     tampon[1] = commande; | ||||
| 
 | ||||
|     time_i2c[0] = time_us_32(); | ||||
|     time_i2c[2] = 0; | ||||
| 
 | ||||
|     while(retour_i2c == I2C_EN_COURS){ | ||||
|         time_i2c[1] = time_us_32(); // Pour mesurer le temps d'execution
 | ||||
|         i2c_gestion(i2c0); | ||||
|         retour_i2c = i2c_ecrire_registre_nb(adresse, registre, tampon, T_I2C_ENVOI); | ||||
|         time_i2c[2] += time_us_32() - time_i2c[1]; // Pour mesurer le temps d'execution
 | ||||
|         sleep_us(100); // Attente, ou le reste du code
 | ||||
|     } | ||||
|     time_i2c[3] = time_us_32() - time_i2c[0]; | ||||
| 
 | ||||
|     printf("Temps lecture : %u microsecondes, temps specifique i2c : %u microsecondes.\n", time_i2c[3], time_i2c[2]); | ||||
| 
 | ||||
|     return 1; | ||||
| } | ||||
| 
 | ||||
| void affiche_contacteur(){ | ||||
|     while(1){ | ||||
|         printf(">contacteur_butee_A:%d\n", i2c_annexe_get_contacteur_butee_A()); | ||||
|         printf(">contacteur_butee_C:%d\n", i2c_annexe_get_contacteur_butee_C()); | ||||
|         printf(">contacteur_longer_A:%d\n", i2c_annexe_get_contacteur_longer_A()); | ||||
|         printf(">contacteur_longer_C:%d\n", i2c_annexe_get_contacteur_longer_C()); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// @brief Test les fonctions définies dans I2C_Annexe
 | ||||
| /// @return 1 pour continuer le test, 0 pour arrêter le test
 | ||||
| int test_i2c_ecriture_pico_annex_nb_2(){ | ||||
|     i2c_maitre_init(); | ||||
| 
 | ||||
|     uint32_t time_i2c[5]; | ||||
|     const uint8_t T_I2C_ENVOI = 2; | ||||
|     static uint8_t commande=0; | ||||
|     enum i2c_resultat_t retour_i2c = I2C_EN_COURS; | ||||
| 
 | ||||
| 
 | ||||
|      | ||||
|     printf("D - Deguisement On\n"); | ||||
|     printf("E - Deguisement Off\n"); | ||||
|     printf("F - Ferme porte\n"); | ||||
|     printf("G - Mi-Ferme porte\n"); | ||||
|     printf("O - Ouvre porte\n"); | ||||
|     printf("T - Turbine On\n"); | ||||
|     printf("U - Turbine Off\n"); | ||||
|     printf("P - Propulseur On\n"); | ||||
|     printf("M - Propulseur Off\n"); | ||||
|     printf("S - Score + 1\n"); | ||||
|     printf("B - Bras deplie\n"); | ||||
|     printf("N - Bras plie 1\n"); | ||||
|      | ||||
| 
 | ||||
|     int lettre; | ||||
|     int continue_test=1; | ||||
|     uint8_t score=0; | ||||
| 
 | ||||
|     time_i2c[0] = time_us_32(); | ||||
|     time_i2c[1] = time_us_32(); | ||||
|     time_i2c[2] = 0; | ||||
| 
 | ||||
|     multicore_launch_core1(affiche_contacteur); | ||||
| 
 | ||||
|     while(continue_test){ | ||||
|         lettre = getchar_timeout_us(0); | ||||
|         if(lettre != PICO_ERROR_TIMEOUT && lettre != '\0'){ | ||||
|             printf("lettre !\n"); | ||||
|             switch(lettre){ | ||||
|                 case 'd': | ||||
|                 case 'D': | ||||
|                     i2c_annexe_active_deguisement(); | ||||
|                     printf("=> Active déguisement\n"); | ||||
|                     break; | ||||
| 
 | ||||
|                 case 'E': | ||||
|                 case 'e': | ||||
|                     i2c_annexe_desactive_deguisement(); | ||||
|                     printf("=> Desactive déguisement\n"); | ||||
|                     break; | ||||
| 
 | ||||
|                 case 'F': | ||||
|                 case 'f': | ||||
|                     i2c_annexe_ferme_porte(); | ||||
|                     printf("=> Ferme porte\n"); | ||||
|                     break; | ||||
| 
 | ||||
|                 case 'G': | ||||
|                 case 'g': | ||||
|                     i2c_annexe_mi_ferme_porte(); | ||||
|                     printf("=> Ferme porte\n"); | ||||
|                     break; | ||||
| 
 | ||||
|                 case 'O': | ||||
|                 case 'o': | ||||
|                     i2c_annexe_ouvre_porte(); | ||||
|                     printf("=> Ouvre porte\n"); | ||||
|                     break; | ||||
|                  | ||||
|                 case 't': | ||||
|                 case 'T': | ||||
|                     i2c_annexe_active_turbine(); | ||||
|                     printf("=> Active turbine\n"); | ||||
|                     break; | ||||
|                  | ||||
|                 case 'u': | ||||
|                 case 'U': | ||||
|                     i2c_annexe_desactive_turbine(); | ||||
|                     printf("=> Arrete turbine\n"); | ||||
|                     break; | ||||
| 
 | ||||
|                 case 'm': | ||||
|                 case 'M': | ||||
|                     i2c_annexe_desactive_propulseur(); | ||||
|                     printf("=> Arrete propulseur\n"); | ||||
|                     break; | ||||
| 
 | ||||
|                 case 'p': | ||||
|                 case 'P': | ||||
|                     i2c_annexe_active_propulseur(); | ||||
|                     printf("=> Active propulseur\n"); | ||||
|                     break; | ||||
| 
 | ||||
|                 case 'q': | ||||
|                 case 'Q': | ||||
|                     continue_test=0; | ||||
|                     printf("Quitte\n"); | ||||
|                     break; | ||||
| 
 | ||||
|                 case 's': | ||||
|                 case 'S': | ||||
|                     score++; | ||||
|                     i2c_annexe_envoie_score(score); | ||||
|                     break; | ||||
| 
 | ||||
|                 case 'b': | ||||
|                 case 'B': | ||||
|                     i2c_annexe_deplie_bras(); | ||||
|                     printf("=> Deplie bras\n"); | ||||
|                     break; | ||||
| 
 | ||||
|                 case 'n': | ||||
|                 case 'N': | ||||
|                     i2c_annexe_plie_bras(); | ||||
|                     printf("=> Plie bras\n"); | ||||
|                     break; | ||||
|                  | ||||
|                 default: | ||||
|                     printf("lettre non reconnue: %d %c\n", lettre, lettre); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         i2c_gestion(i2c0);         | ||||
|         i2c_annexe_gestion(); | ||||
| 
 | ||||
|     } | ||||
|     multicore_reset_core1(); | ||||
| 
 | ||||
|     return test_continue_test(); | ||||
| } | ||||
| 
 | ||||
| int test_i2c_bus(){ | ||||
|     // Adresse I2C : 0b0100 000 R/W
 | ||||
|     // Lecture des broches sur les registres 0 et 1
 | ||||
|     // Registre 2 et 3 : valeur des broches en sorties
 | ||||
|     // Registre 4 et 5 : INversion de polarité
 | ||||
|     // Registre 6 et 7 : Configuration entrée (1) ou sortie (0)
 | ||||
| 
 | ||||
|     uint8_t reception[8]; | ||||
|     uint8_t emission[8]; | ||||
|     //uint8_t adresse = 0b0100000;
 | ||||
|     uint8_t adresse = 0x20; | ||||
|     int statu; | ||||
|     int lettre; | ||||
| 
 | ||||
|     emission[0]=6; // Registre à lire
 | ||||
| 
 | ||||
|     i2c_maitre_init(); | ||||
|     // Scan bus I2C - cf SDK
 | ||||
|     printf("\nI2C Bus Scan\n"); | ||||
|     printf("   0 1 2 3 4 5 6 7 8 9 A B C D E F\n"); | ||||
|     for (int addr = 0; addr < (1 << 7); ++addr) { | ||||
|         if (addr % 16 == 0) { | ||||
|             printf("%02x ", addr); | ||||
|         } | ||||
|         int ret; | ||||
|         uint8_t rxdata=0x55; | ||||
|         if (reserved_addr(addr)) | ||||
|             ret = PICO_ERROR_GENERIC; | ||||
|         else | ||||
|             ret = i2c_read_blocking(i2c_default, addr, &rxdata, 1, false); | ||||
|          | ||||
|         printf(ret < 0 ? "." : "@"); | ||||
|         printf(addr % 16 == 15 ? "\n" : " "); | ||||
|     } | ||||
|     printf("Done.\n"); | ||||
|     return 0; | ||||
| 
 | ||||
|     do{     | ||||
|         statu = i2c_write_blocking (i2c0, adresse, emission, 1, 0); | ||||
|         if(statu == PICO_ERROR_GENERIC){ | ||||
|             printf("Emission : Address not acknowledged, no device present.\n"); | ||||
|             return 0; | ||||
|         }else{ | ||||
|             printf("Emission : Ok\n"); | ||||
|         } | ||||
| 
 | ||||
|         statu = i2c_read_blocking(i2c0, adresse, reception, 2, 0); | ||||
|         if(statu == PICO_ERROR_GENERIC){ | ||||
|             printf("Reception : Address not acknowledged, no device present.\n"); | ||||
|             return 0; | ||||
|         }else{ | ||||
|             printf("Recetion : Ok\n"); | ||||
|         } | ||||
|         printf("%2.x%2.x\n",reception[0], reception[1]); | ||||
|          | ||||
|         lettre = getchar_timeout_us(0); | ||||
|         stdio_flush(); | ||||
|     }while(lettre == PICO_ERROR_TIMEOUT); | ||||
| 
 | ||||
|     return 0; | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| void test_trajectoire_printf(){ | ||||
|     struct position_t _position; | ||||
|  | ||||
							
								
								
									
										63
									
								
								Test_gyro.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								Test_gyro.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,63 @@ | ||||
| #include "pico/stdlib.h" | ||||
| #include "gyro.h" | ||||
| #include "gyro_ADXRS453.h" | ||||
| #include "Log.h" | ||||
| #include <stdio.h> | ||||
| 
 | ||||
| 
 | ||||
| #define TEST_TIMEOUT_US 10000000 | ||||
| 
 | ||||
| int test_gyro_vitesse_brute(void); | ||||
| 
 | ||||
| // Test du gyroscope
 | ||||
| // 1 - lecture continue de la valeur brute de l'angle
 | ||||
| 
 | ||||
| int test_gyro(){ | ||||
|     int lettre; | ||||
| 
 | ||||
|     while(1){ | ||||
| 
 | ||||
|         do{ | ||||
|             printf("A : Lecture brute\n"); | ||||
|             printf("Q : Quitter\n"); | ||||
|              | ||||
|             lettre = getchar_timeout_us(TEST_TIMEOUT_US); | ||||
|             stdio_flush(); | ||||
|         }while(lettre == PICO_ERROR_TIMEOUT ||lettre == 0); | ||||
| 
 | ||||
|         switch(lettre){ | ||||
| 
 | ||||
|             case 'A': | ||||
|             case 'a': | ||||
|                 while(test_gyro_vitesse_brute()); | ||||
|                 break; | ||||
| 
 | ||||
|             case 'Q': | ||||
|             case 'q': | ||||
|                 return 0; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void affichage(){ | ||||
|     while(1){ | ||||
|         Log_gestion(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| int test_gyro_vitesse_brute(void){ | ||||
|     printf("Lecture vitesse brute\n"); | ||||
|     uint16_t tampon_envoi[4]; | ||||
|     uint8_t tampon_reception[4]; | ||||
|     Log_init(); | ||||
|     Gyro_init_spi(); | ||||
|     Gyro_init_config(); | ||||
| 
 | ||||
|     struct t_angle_gyro angle_gyro; | ||||
|     printf("Debut acquisition\n"); | ||||
|     while(1){ | ||||
|         gyro_get_vitesse_brute(&angle_gyro, NULL); | ||||
|         printf("%2.2f rad\n", angle_gyro.rot_z); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
							
								
								
									
										1
									
								
								Test_gyro.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								Test_gyro.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | ||||
| int test_gyro(void); | ||||
							
								
								
									
										421
									
								
								Test_i2c.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										421
									
								
								Test_i2c.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,421 @@ | ||||
| #include "pico/stdlib.h" | ||||
| #include "pico/multicore.h" | ||||
| #include "hardware/i2c.h" | ||||
| #include "i2c_annexe.h" | ||||
| #include "i2c_maitre.h" | ||||
| #include "Test_i2c.h" | ||||
| #include <stdio.h> | ||||
| 
 | ||||
| #define TEST_TIMEOUT_US 10000000 | ||||
| 
 | ||||
| void affiche_contacteur(void); | ||||
| 
 | ||||
| int test_i2c_bus(void); | ||||
| int test_i2c_lecture_pico_annex(void); | ||||
| int test_i2c_lecture_pico_annex_nb2(void); | ||||
| int test_i2c_ecriture_pico_annex_nb(void); | ||||
| int test_i2c_ecriture_pico_annex_nb_2(void); | ||||
| bool reserved_addr(uint8_t addr); | ||||
| 
 | ||||
| 
 | ||||
| int test_i2c(){ | ||||
|     int lettre; | ||||
| 
 | ||||
|     while(1){ | ||||
| 
 | ||||
|         do{ | ||||
|             printf("A : Scan bus I2C\n"); | ||||
|             printf("B : Lecture I2C bloquante\n"); | ||||
|             printf("C : Lecture I2C non bloquante\n"); | ||||
|             printf("D : Ecriture I2C non bloquante\n"); | ||||
|             printf("E : Ecriture I2C non bloquante - fonctions encapsulées\n");             | ||||
|             printf("Q : Quitter\n"); | ||||
|              | ||||
|             lettre = getchar_timeout_us(TEST_TIMEOUT_US); | ||||
|             stdio_flush(); | ||||
|         }while(lettre == PICO_ERROR_TIMEOUT ||lettre == 0); | ||||
| 
 | ||||
|         switch(lettre){ | ||||
| 
 | ||||
|             case 'A': | ||||
|             case 'a': | ||||
|                 while(test_i2c_bus()); | ||||
|                 break; | ||||
| 
 | ||||
|             case 'B': | ||||
|             case 'b': | ||||
|                 while(test_i2c_lecture_pico_annex()); | ||||
|                 break; | ||||
| 
 | ||||
|             case 'C': | ||||
|             case 'c': | ||||
|                 while(test_i2c_lecture_pico_annex_nb2()); | ||||
|                 break; | ||||
| 
 | ||||
|             case 'D': | ||||
|             case 'd': | ||||
|                 while(test_i2c_ecriture_pico_annex_nb()); | ||||
|                 break; | ||||
| 
 | ||||
|             case 'E': | ||||
|             case 'e': | ||||
|                 while(test_i2c_ecriture_pico_annex_nb_2()); | ||||
|                 break; | ||||
| 
 | ||||
|             case 'Q': | ||||
|             case 'q': | ||||
|                 return 0; | ||||
|         } | ||||
|     } | ||||
|      | ||||
| } | ||||
| 
 | ||||
| bool reserved_addr(uint8_t addr) { | ||||
|     return (addr & 0x78) == 0 || (addr & 0x78) == 0x78; | ||||
| } | ||||
| 
 | ||||
| /// @brief Scan le bus I2C
 | ||||
| /// @return 0
 | ||||
| int test_i2c_bus(){ | ||||
|     uint8_t reception[8]; | ||||
|     uint8_t emission[8]; | ||||
|     //uint8_t adresse = 0b0100000;
 | ||||
|     int statu; | ||||
|     int lettre; | ||||
| 
 | ||||
|     emission[0]=6; // Registre à lire
 | ||||
| 
 | ||||
|     i2c_maitre_init(); | ||||
|     // Scan bus I2C - cf SDK
 | ||||
|     printf("\nI2C Bus Scan\n"); | ||||
|     printf("   0 1 2 3 4 5 6 7 8 9 A B C D E F\n"); | ||||
|     for (int addr = 0; addr < (1 << 7); ++addr) { | ||||
|         if (addr % 16 == 0) { | ||||
|             printf("%02x ", addr); | ||||
|         } | ||||
|         int ret; | ||||
|         uint8_t rxdata=0x55; | ||||
|         if (reserved_addr(addr)) | ||||
|             ret = PICO_ERROR_GENERIC; | ||||
|         else{ | ||||
|             absolute_time_t time_out = get_absolute_time(); | ||||
|             time_out += 100000; // Ajout 100 ms
 | ||||
|             ret = i2c_read_blocking_until(i2c_default, addr, &rxdata, 1, false, time_out); | ||||
|         } | ||||
|          | ||||
|         printf(ret < 0 ? "." : "@"); | ||||
|         printf(addr % 16 == 15 ? "\n" : " "); | ||||
|     } | ||||
|     printf("Done.\n"); | ||||
|     return 0; | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| /// @brief Test de lecture I2C - Attention cette fonction écrit 1 octet avant de lire... 
 | ||||
| /// @return 0
 | ||||
| int test_i2c_lecture_pico_annex(){ | ||||
|     i2c_maitre_init(); | ||||
|     uint8_t tampon[10]; | ||||
|     uint8_t registre=2; | ||||
|     uint8_t adresse = 0x17; | ||||
|     int ret;  | ||||
|      | ||||
|     ret = i2c_write_blocking(i2c0, adresse, ®istre, 1, false); | ||||
|     if(ret < 0){ | ||||
|         printf("Erreur I2C : %d", ret); | ||||
|         return 0; | ||||
|     } | ||||
| 
 | ||||
|     ret = i2c_read_blocking(i2c_default, adresse, tampon, 10, false); | ||||
|     if(ret < 0){ | ||||
|         printf("Erreur I2C : %d", ret); | ||||
|     }else{ | ||||
|         for(int i=0; i<10; i++){ | ||||
|             printf("%c", tampon[i]); | ||||
|         } | ||||
|         printf("\n"); | ||||
| 
 | ||||
|         for(int i=0; i<10; i++){ | ||||
|             printf("%2x ", tampon[i]); | ||||
|         } | ||||
|         printf("\n"); | ||||
|     } | ||||
|     return 0; | ||||
| } | ||||
| 
 | ||||
| /// @brief Lecture I2C non bloquante
 | ||||
| /// @return 0
 | ||||
| int test_i2c_lecture_pico_annex_nb2(){ | ||||
|     i2c_maitre_init(); | ||||
| 
 | ||||
|     uint8_t tampon[10]; | ||||
|     uint8_t registre=8; | ||||
|     uint8_t adresse = 0x17; | ||||
|     uint32_t time_i2c[5]; | ||||
|     const uint8_t T_MAX_I2C = 10; | ||||
|     enum i2c_resultat_t retour_i2c = I2C_EN_COURS; | ||||
| 
 | ||||
|     time_i2c[0] = time_us_32(); | ||||
|     time_i2c[2] = 0; | ||||
| 
 | ||||
|     while(retour_i2c == I2C_EN_COURS){ | ||||
|         time_i2c[1] = time_us_32(); // Pour mesurer le temps d'execution
 | ||||
|         i2c_gestion(i2c0); | ||||
|         retour_i2c = i2c_lire_registre_nb(adresse, registre, tampon, T_MAX_I2C); | ||||
|         time_i2c[2] += time_us_32() - time_i2c[1]; // Pour mesurer le temps d'execution
 | ||||
|         sleep_us(100); // Attente, ou le reste du code
 | ||||
|     } | ||||
|     time_i2c[3] = time_us_32() - time_i2c[0]; | ||||
| 
 | ||||
|     // Affichage
 | ||||
|     for(int i=0; i<T_MAX_I2C; i++){ | ||||
|         printf("%c", tampon[i]); | ||||
|     } | ||||
|     printf("\n"); | ||||
| 
 | ||||
|     for(int i=0; i<T_MAX_I2C; i++){ | ||||
|         printf("%2x ", tampon[i]); | ||||
|     } | ||||
|     printf("\n"); | ||||
| 
 | ||||
|     printf("Temps lecture : %u microsecondes, temps specifique i2c : %u microsecondes.\n", time_i2c[3], time_i2c[2]); | ||||
| 
 | ||||
|     return 0; | ||||
| } | ||||
| 
 | ||||
| /// @brief Ecrit sur le bus I2C 
 | ||||
| /// @return 1 pour continuer le test, 0 pour quitter
 | ||||
| int test_i2c_ecriture_pico_annex_nb(){ | ||||
|     i2c_maitre_init(); | ||||
| 
 | ||||
|     uint8_t tampon[10]; | ||||
|     uint8_t registre=0x09; | ||||
|     uint8_t adresse = 0x17; | ||||
|     uint32_t time_i2c[5]; | ||||
|     const uint8_t T_I2C_ENVOI = 2; | ||||
|     static uint8_t commande=0; | ||||
|     enum i2c_resultat_t retour_i2c = I2C_EN_COURS; | ||||
| 
 | ||||
| 
 | ||||
|     printf("F - Ferme porte\n"); | ||||
|     printf("O - Ouvre porte\n"); | ||||
|     printf("T - Turbine On\n"); | ||||
|     printf("U - Turbine Off\n"); | ||||
|     printf("P - Propulseur On\n"); | ||||
|     printf("M - Propulseur Off\n"); | ||||
|     printf("Q pour quitter\n"); | ||||
| 
 | ||||
|     int lettre; | ||||
|     do{  | ||||
|         lettre = getchar_timeout_us(0); | ||||
|         stdio_flush(); | ||||
| 
 | ||||
|     }while(lettre == PICO_ERROR_TIMEOUT || lettre == '\0'); | ||||
| 
 | ||||
|     tampon[1] = 0x0; | ||||
|     switch(lettre){ | ||||
|         case 'F': | ||||
|         case 'f': | ||||
|             commande = commande | 0x02; // 0b0000 0010
 | ||||
|             printf("=> Ferme porte\n"); | ||||
|             break; | ||||
| 
 | ||||
|         case 'O': | ||||
|         case 'o': | ||||
|             commande = commande & 0xFD; // 0b1111 1101
 | ||||
|             printf("=> Ouvre porte\n"); | ||||
|             break; | ||||
|          | ||||
|         case 't': | ||||
|         case 'T': | ||||
|             commande = commande | 0x01; // 0b0000 0001
 | ||||
|             printf("=> Active turbine\n"); | ||||
|             break; | ||||
|          | ||||
|         case 'u': | ||||
|         case 'U': | ||||
|             commande = commande & 0xFE; // 0b1111 1110
 | ||||
|             printf("=> Arrete turbine\n"); | ||||
|             break; | ||||
|          | ||||
|         case 'p': | ||||
|         case 'P': | ||||
|             commande = commande | 0x08; // 0b0000 1000
 | ||||
|             printf("=> Active propulseur\n"); | ||||
|             break; | ||||
|          | ||||
|         case 'm': | ||||
|         case 'M': | ||||
|             commande = commande & 0xF7; // 0b1111 0111
 | ||||
|             printf("=> Arrete propulseur\n"); | ||||
|             break; | ||||
|              | ||||
|         case 'q': | ||||
|         case 'Q': | ||||
|             return 0; | ||||
|             break; | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     tampon[0] = 54; | ||||
|     tampon[1] = commande; | ||||
| 
 | ||||
|     time_i2c[0] = time_us_32(); | ||||
|     time_i2c[2] = 0; | ||||
| 
 | ||||
|     while(retour_i2c == I2C_EN_COURS){ | ||||
|         time_i2c[1] = time_us_32(); // Pour mesurer le temps d'execution
 | ||||
|         i2c_gestion(i2c0); | ||||
|         retour_i2c = i2c_ecrire_registre_nb(adresse, registre, tampon, T_I2C_ENVOI); | ||||
|         time_i2c[2] += time_us_32() - time_i2c[1]; // Pour mesurer le temps d'execution
 | ||||
|         sleep_us(100); // Attente, ou le reste du code
 | ||||
|     } | ||||
|     time_i2c[3] = time_us_32() - time_i2c[0]; | ||||
| 
 | ||||
|     printf("Temps lecture : %u microsecondes, temps specifique i2c : %u microsecondes.\n", time_i2c[3], time_i2c[2]); | ||||
| 
 | ||||
|     return 1; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| /// @brief Test les fonctions définies dans I2C_Annexe
 | ||||
| /// @return 0
 | ||||
| int test_i2c_ecriture_pico_annex_nb_2(){ | ||||
|     i2c_maitre_init(); | ||||
| 
 | ||||
|     uint32_t time_i2c[5]; | ||||
|     const uint8_t T_I2C_ENVOI = 2; | ||||
|     static uint8_t commande=0; | ||||
|     enum i2c_resultat_t retour_i2c = I2C_EN_COURS; | ||||
| 
 | ||||
| 
 | ||||
|      | ||||
|     printf("D - Deguisement On\n"); | ||||
|     printf("E - Deguisement Off\n"); | ||||
|     printf("F - Ferme porte\n"); | ||||
|     printf("G - Mi-Ferme porte\n"); | ||||
|     printf("O - Ouvre porte\n"); | ||||
|     printf("T - Turbine On\n"); | ||||
|     printf("U - Turbine Off\n"); | ||||
|     printf("P - Propulseur On\n"); | ||||
|     printf("M - Propulseur Off\n"); | ||||
|     printf("S - Score + 1\n"); | ||||
|     printf("B - Bras deplie\n"); | ||||
|     printf("N - Bras plie 1\n"); | ||||
|      | ||||
| 
 | ||||
|     int lettre; | ||||
|     int continue_test=1; | ||||
|     uint8_t score=0; | ||||
| 
 | ||||
|     time_i2c[0] = time_us_32(); | ||||
|     time_i2c[1] = time_us_32(); | ||||
|     time_i2c[2] = 0; | ||||
| 
 | ||||
|     multicore_launch_core1(affiche_contacteur); | ||||
| 
 | ||||
| 
 | ||||
|     while(1){ | ||||
|         lettre = getchar_timeout_us(0); | ||||
|         if(lettre != PICO_ERROR_TIMEOUT && lettre != '\0'){ | ||||
|             printf("lettre !\n"); | ||||
|             switch(lettre){ | ||||
|                 case 'd': | ||||
|                 case 'D': | ||||
|                     i2c_annexe_active_deguisement(); | ||||
|                     printf("=> Active déguisement\n"); | ||||
|                     break; | ||||
| 
 | ||||
|                 case 'E': | ||||
|                 case 'e': | ||||
|                     i2c_annexe_desactive_deguisement(); | ||||
|                     printf("=> Desactive déguisement\n"); | ||||
|                     break; | ||||
| 
 | ||||
|                 case 'F': | ||||
|                 case 'f': | ||||
|                     i2c_annexe_ferme_porte(); | ||||
|                     printf("=> Ferme porte\n"); | ||||
|                     break; | ||||
| 
 | ||||
|                 case 'G': | ||||
|                 case 'g': | ||||
|                     i2c_annexe_mi_ferme_porte(); | ||||
|                     printf("=> Ferme porte\n"); | ||||
|                     break; | ||||
| 
 | ||||
|                 case 'O': | ||||
|                 case 'o': | ||||
|                     i2c_annexe_ouvre_porte(); | ||||
|                     printf("=> Ouvre porte\n"); | ||||
|                     break; | ||||
|                  | ||||
|                 case 't': | ||||
|                 case 'T': | ||||
|                     i2c_annexe_active_turbine(); | ||||
|                     printf("=> Active turbine\n"); | ||||
|                     break; | ||||
|                  | ||||
|                 case 'u': | ||||
|                 case 'U': | ||||
|                     i2c_annexe_desactive_turbine(); | ||||
|                     printf("=> Arrete turbine\n"); | ||||
|                     break; | ||||
| 
 | ||||
|                 case 'm': | ||||
|                 case 'M': | ||||
|                     i2c_annexe_desactive_propulseur(); | ||||
|                     printf("=> Arrete propulseur\n"); | ||||
|                     break; | ||||
| 
 | ||||
|                 case 'p': | ||||
|                 case 'P': | ||||
|                     i2c_annexe_active_propulseur(); | ||||
|                     printf("=> Active propulseur\n"); | ||||
|                     break; | ||||
| 
 | ||||
|                 case 'q': | ||||
|                 case 'Q': | ||||
|                     multicore_reset_core1(); | ||||
|                     return 0; | ||||
| 
 | ||||
|                 case 's': | ||||
|                 case 'S': | ||||
|                     score++; | ||||
|                     i2c_annexe_envoie_score(score); | ||||
|                     break; | ||||
| 
 | ||||
|                 case 'b': | ||||
|                 case 'B': | ||||
|                     i2c_annexe_deplie_bras(); | ||||
|                     printf("=> Deplie bras\n"); | ||||
|                     break; | ||||
| 
 | ||||
|                 case 'n': | ||||
|                 case 'N': | ||||
|                     i2c_annexe_plie_bras(); | ||||
|                     printf("=> Plie bras\n"); | ||||
|                     break; | ||||
|                  | ||||
|                 default: | ||||
|                     printf("lettre non reconnue: %d %c\n", lettre, lettre); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         i2c_gestion(i2c0);         | ||||
|         i2c_annexe_gestion(); | ||||
| 
 | ||||
|     } | ||||
|      | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| void affiche_contacteur(){ | ||||
|     while(1){ | ||||
|         printf(">contacteur_butee_A:%d\n", i2c_annexe_get_contacteur_butee_A()); | ||||
|         printf(">contacteur_butee_C:%d\n", i2c_annexe_get_contacteur_butee_C()); | ||||
|         printf(">contacteur_longer_A:%d\n", i2c_annexe_get_contacteur_longer_A()); | ||||
|         printf(">contacteur_longer_C:%d\n", i2c_annexe_get_contacteur_longer_C()); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										2
									
								
								Test_i2c.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								Test_i2c.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | ||||
| 
 | ||||
| int test_i2c(void); | ||||
							
								
								
									
										21
									
								
								gyro.c
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								gyro.c
									
									
									
									
									
								
							| @ -50,8 +50,7 @@ struct t_angle_gyro_float gyro_get_vitesse(void){ | ||||
|     return vitesse_gyro; | ||||
| } | ||||
| 
 | ||||
| void Gyro_Init(void){ | ||||
|     // 
 | ||||
| void Gyro_init_spi(){ | ||||
|     gpio_set_function(0, GPIO_FUNC_SPI); // SDI (ancien : 16)
 | ||||
|     gpio_set_function(2, GPIO_FUNC_SPI); // SCK (ancien : 18)
 | ||||
|     gpio_set_function(3, GPIO_FUNC_SPI); // SDO (ancien : 19)
 | ||||
| @ -64,14 +63,12 @@ void Gyro_Init(void){ | ||||
|     vitesse_calibration = NULL; | ||||
|     vitesse_angulaire = &_vitesse_angulaire; | ||||
| 
 | ||||
|     //uint speed = spi_init(spi0, 10 * 1000); // SPI init @ 10 kHz
 | ||||
|     uint speed = spi_init(spi0, 2 * 1000 * 1000); // SPI init @ 2 MHz
 | ||||
|      | ||||
|     //printf("vitesse SPI : %d\n", speed);
 | ||||
| 
 | ||||
|     uint speed = spi_init(spi0, 2 * 1000 * 1000); // SPI init @ 2 MHz    
 | ||||
| 
 | ||||
|     spi_set_format(spi0, 8, SPI_CPHA_0, SPI_CPOL_0, SPI_MSB_FIRST); | ||||
| } | ||||
| 
 | ||||
| void Gyro_init_config(){ | ||||
|     // Test de la présence du gyroscope :
 | ||||
|     if(gyro_init_check()){ | ||||
|         Monitoring_Error("Gyroscope non trouve"); | ||||
| @ -93,7 +90,17 @@ void Gyro_Init(void){ | ||||
|         } | ||||
|     } | ||||
|     sleep_ms(150); // Temps d'init du gyroscope
 | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| void Gyro_Init(void){ | ||||
|     // Initialisation du SPI
 | ||||
|     Gyro_init_spi(); | ||||
|      | ||||
|     // Initialisation fonctionnelle du gyroscope
 | ||||
|     Gyro_init_config(); | ||||
|      | ||||
|     // Calibration du gyroscope
 | ||||
|     gyro_calibration(); | ||||
|      | ||||
| } | ||||
|  | ||||
							
								
								
									
										4
									
								
								gyro.h
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								gyro.h
									
									
									
									
									
								
							| @ -6,4 +6,6 @@ void gyro_affiche(struct t_angle_gyro_float angle_gyro, char * titre); | ||||
| void gyro_set_angle_radian(float angle_radian); | ||||
| struct t_angle_gyro_float gyro_get_angle_degres(void); | ||||
| struct t_angle_gyro_float gyro_get_vitesse(void); | ||||
| int16_t gyro_get_temp(void); | ||||
| int16_t gyro_get_temp(void); | ||||
| void Gyro_init_spi(void); | ||||
| void Gyro_init_config(void); | ||||
| @ -44,6 +44,8 @@ void i2c_maitre_init(void){ | ||||
|     printf("%d et %d en I2C\n", I2C_SDA_PIN, I2C_SCL_PIN); | ||||
|     gpio_set_function(I2C_SDA_PIN, GPIO_FUNC_I2C); | ||||
|     gpio_set_function(I2C_SCL_PIN, GPIO_FUNC_I2C); | ||||
|     gpio_pull_up(I2C_SDA_PIN); | ||||
|     gpio_pull_up(I2C_SDA_PIN); | ||||
| 
 | ||||
|     i2c_statu_i2c0 = I2C_STATU_LIBRE; | ||||
| } | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user