Init roulis
This commit is contained in:
parent
deaa776d14
commit
6c90c91fba
5 changed files with 32 additions and 4 deletions
|
|
@ -2,9 +2,7 @@
|
|||
#include <Plateau.h>
|
||||
#include <MyTimer.h>
|
||||
#include <GPIO.h>
|
||||
#include <ADC.h>
|
||||
#include <USART.h>
|
||||
#include <MySPI.h>
|
||||
|
||||
void handler_USART1 (void) {
|
||||
//Pour le projet : Lancer PWM en fonction de la valeur du curseur
|
||||
|
|
|
|||
20
Services/roulis.c
Normal file
20
Services/roulis.c
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#include <stm32f10x.h>
|
||||
#include <roulis.h>
|
||||
#include <MySPI.h>
|
||||
|
||||
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();
|
||||
}
|
||||
11
Services/roulis.h
Normal file
11
Services/roulis.h
Normal file
|
|
@ -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
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
#ifndef INC_MYSPI_H_
|
||||
#define INC_MYSPI_H_
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue