Quelques essais supplémentaie, mais rien de concluant
This commit is contained in:
		
							parent
							
								
									16ee1109b4
								
							
						
					
					
						commit
						d7e885244d
					
				
							
								
								
									
										26
									
								
								gyro.c
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								gyro.c
									
									
									
									
									
								
							| @ -32,6 +32,7 @@ void Gyro_Init(void){ | ||||
|     // Test de la présence du gyroscope :
 | ||||
|     if(gyro_init_check()){ | ||||
|         puts("Gyroscope non trouve"); | ||||
|         gyro_config(); | ||||
|     }else{ | ||||
|         puts("Gyroscope trouve"); | ||||
|         gyro_config(); | ||||
| @ -59,12 +60,23 @@ void gyro_config(){ | ||||
|     // Xen : 1
 | ||||
| 
 | ||||
|     uint16_t tampon[2] = {0x20, 0b11101111}; | ||||
|     uint8_t tampon2[10]="\0\0\0\0\0\0\0\0\0"; | ||||
|     int statu, nb_read; | ||||
|     while(spi_nb_busy(spi0) == SPI_BUSY); | ||||
|     cs_select(); | ||||
|     int rep = spi_nb_write_data(spi0, tampon, 2); | ||||
|     if(rep == SPI_ERR_TRANSMIT_FIFO_FULL){ | ||||
|         printf("Erreur: spi_read_register: SPI_ERR_TRANSMIT_FIFO_FULL\n"); | ||||
|         //return statu;
 | ||||
|     } | ||||
|     while(spi_nb_busy(spi0) == SPI_BUSY); | ||||
|     cs_deselect(); | ||||
| 
 | ||||
|     nb_read = spi_nb_read_data_8bits(spi0, tampon2); | ||||
|     printf("%d caracteres lus\n", nb_read); | ||||
|      | ||||
|     printf("tampon2 : %#4x %#4x %#4x\n", tampon2[0], tampon2[1], tampon2[2]); | ||||
| 
 | ||||
|     if (rep == SPI_ERR_TRANSMIT_FIFO_FULL){ | ||||
|         while(1){ | ||||
|             printf("gyro_config: SPI_ERR_TRANSMIT_FIFO_FULL\n"); | ||||
| @ -91,18 +103,13 @@ int gyro_read_register_blocking(uint8_t registrer, uint8_t *tampon, uint8_t nb_a | ||||
| } | ||||
| 
 | ||||
| void Gyro_Read(uint16_t step_ms){ | ||||
|     uint8_t tampon[10]="123456789"; | ||||
|     uint8_t tampon[10]="\0\0\0\0\0\0\0\0\0"; | ||||
|     uint8_t tampon2[10]="ABCDEFGHI"; | ||||
|     int16_t rot_x, rot_y, rot_z; | ||||
|     static double angle_x=0, angle_y=0, angle_z=0; | ||||
|     int nb_recu; | ||||
| 
 | ||||
| 
 | ||||
|     //cs_select();
 | ||||
|     //while(spi_nb_read_register_8bits(spi0, 0x20, tampon, 1) == SPI_IN_PROGRESS);
 | ||||
|     //cs_deselect();
 | ||||
|     gyro_read_register_blocking(0x20, tampon, 1); | ||||
|     //printf ("Gyro CTRL1 : %#4x\n", tampon[0] );
 | ||||
| 
 | ||||
| 
 | ||||
|     spi_read_register(spi0, 0x20, tampon, 1); | ||||
|     //printf ("Gyro CTRL1 (bis) : %#4x\n", tampon[1] );
 | ||||
| @ -114,6 +121,7 @@ void Gyro_Read(uint16_t step_ms){ | ||||
|     //gyro_read_register_blocking(0x28, tampon, 6);
 | ||||
|     spi_read_register(spi0, 0x28, tampon, 6); | ||||
| 
 | ||||
| 
 | ||||
|     for(int i=0; i<10; i++){ | ||||
|         printf("%#4x ", tampon[i]); | ||||
|     } | ||||
| @ -128,5 +136,9 @@ void Gyro_Read(uint16_t step_ms){ | ||||
|      | ||||
|     printf("rx : %f, ry : %f, rz: %f\n", angle_x, angle_y, angle_z); | ||||
| 
 | ||||
|     //while(spi_nb_busy(spi0));
 | ||||
|     //spi_nb_read_data_8bits(spi0,tampon);
 | ||||
|     //printf("tampon : %s\n", tampon);
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
							
								
								
									
										2
									
								
								spi_nb.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								spi_nb.c
									
									
									
									
									
								
							| @ -146,7 +146,7 @@ void spi_nb_flush_recieve_fifo(spi_inst_t * spi){ | ||||
| uint8_t spi_nb_read_data_8bits(spi_inst_t * spi, uint8_t * buffer){ | ||||
|     uint8_t index = 0; | ||||
|     while(spi_get_hw(spi)->sr & SPI_SSPSR_RNE_BITS){ | ||||
|         buffer[index] = (uint8_t)spi_get_hw(spi)->dr & SPI_SSPDR_DATA_BITS; | ||||
|         buffer[index] = (uint8_t)spi_get_hw(spi)->dr ;//& SPI_SSPDR_DATA_BITS;
 | ||||
|         index++; | ||||
|     } | ||||
|     return index; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user