diff --git a/Services/Plateau.c b/Services/Plateau.c index 3d315b2..67da5bc 100644 --- a/Services/Plateau.c +++ b/Services/Plateau.c @@ -2,9 +2,7 @@ #include #include #include -#include #include -#include void handler_USART1 (void) { //Pour le projet : Lancer PWM en fonction de la valeur du curseur diff --git a/Services/roulis.c b/Services/roulis.c new file mode 100644 index 0000000..f88b48a --- /dev/null +++ b/Services/roulis.c @@ -0,0 +1,20 @@ +#include +#include +#include + +void MyRoulis_Init(void){ + MySPI_Init(SPI1); + MySPI_Clear_NSS(); + + // Initialisation des registres externes + MySPI_Send((0x2D|(1<<7))); // On veut écrire à l'adresse de POWER_CTL : 0x2D + MySPI_Send(1<<3); // On veut mettre le bit "measure" à 1; + + MySPI_Send((0x2C)|(1<<7)); // On veut écrire à l'adresse de BW_RATE + MySPI_Send(0x0A); + + MySPI_Send((0x31)|(1<<7)); // On veut écrire à l'adresse de DATA_FORMAT + MySPI_Send(0x03); + + MySPI_Set_NSS(); +} \ No newline at end of file diff --git a/Services/roulis.h b/Services/roulis.h new file mode 100644 index 0000000..6ed98a5 --- /dev/null +++ b/Services/roulis.h @@ -0,0 +1,11 @@ +#ifndef MYROULIS_H +#define MYROULIS_H + +/* Description des besoins au niveau service (ne pas oublier de gérer cs/NSS !!!) +- Fonction d'init de l'accéléromètre +- Fonction de calcul angle de roulis sur interruption externe GPIOA pin 6 +*/ + +void MyRoulis_Init(void); + +#endif \ No newline at end of file diff --git a/drivers/MySPI.c b/drivers/MySPI.c index dd81b82..5147a58 100644 --- a/drivers/MySPI.c +++ b/drivers/MySPI.c @@ -39,7 +39,7 @@ void MySPI_Send(char ByteToSend){ char MySPI_Read(void){ while (!(SPI1->SR & SPI_SR_TXE)){} // Attend que DR soit vide - MySPI_Send(0x00); // Pour trasmettre la clock + SPI1->DR = 0x00; // Pour trasmettre la clock while (!(SPI1->SR & SPI_SR_RXNE)) {} // On attend de recevoir dans buffer de reception le byte return SPI1->DR; } diff --git a/drivers/MySPI.h b/drivers/MySPI.h index f1ceb9b..2e60ca7 100644 --- a/drivers/MySPI.h +++ b/drivers/MySPI.h @@ -1,4 +1,3 @@ - #ifndef INC_MYSPI_H_ #define INC_MYSPI_H_