diff --git a/implementation/accelerometer.c b/implementation/accelerometer.c
index 0bb3f14..6055f8a 100644
--- a/implementation/accelerometer.c
+++ b/implementation/accelerometer.c
@@ -3,28 +3,22 @@
#include "MySPI.h"
#include "gpio.h"
-void accelerometre()
+void Init_accelerometre()
{
- int dataX ;
- float GX ;
- int dataY ;
- float GY;
- int dataZ ;
- float GZ;
+ //char testReg;
- char testReg;
MySPI_Init(SPI1);
MySPI_Clear_NSS(); //CS LOW
MySPI_Send(0x2D);//Registre Auto_sleep + Write + measure a 1
MySPI_Send(0x08);// désactive
MySPI_Set_NSS();//CS HIGH
-
+ /*
MySPI_Clear_NSS(); //CS LOW
MySPI_Send(0xAD);// regisstre 0x2D en lecture
testReg = MySPI_Read(); // lecture de la valeur du registre
MySPI_Set_NSS();//CS HIGH
-
+ */
MySPI_Clear_NSS(); //CS LOW
MySPI_Send(0X2C);//Registre power consuption + Write
@@ -35,23 +29,31 @@ void accelerometre()
MySPI_Send(0x31);//registre Data format + write
MySPI_Send(0x17);//
MySPI_Set_NSS();//CS HIGH
+}
+
+void Lecture_accelerometre(float *GX, float* GY, float* GZ)
+{
+ int dataX ;
+ int dataY ;
+ int dataZ ;
MySPI_Clear_NSS(); //CS LOW
- MySPI_Send(0xF2);
- dataX = MySPI_Read()<<8;
- dataX |= MySPI_Read();
- dataX &= 0xE;
- GX = dataX*0.004;
+
+ MySPI_Send(0xF2);//lecture 1er registre accéléromètre + lecture multibytes
+ dataX = MySPI_Read()<<8; // données sur 13 bits passage 8 bit en PF
+ dataX |= MySPI_Read(); //lecture SPI
+ dataX &= 0xE; //masquage au dessus du bit 13
+ *GX = dataX*0.004;//valeur du registre x pas accelerometre
+
dataY = MySPI_Read()<<8;
dataY |= MySPI_Read();
dataY &= 0xE;
- GY = dataY*0.004;
+ *GY = dataY*0.004;
+
dataZ = MySPI_Read()<<8;
dataZ |= MySPI_Read();
dataZ &= 0xE;
- GZ = dataZ*0.004;
+ *GZ = dataZ*0.004;
+
MySPI_Set_NSS();//CS HIGH
-
-
-
}
\ No newline at end of file
diff --git a/implementation/accelerometer.h b/implementation/accelerometer.h
index 1d8a585..f0926cc 100644
--- a/implementation/accelerometer.h
+++ b/implementation/accelerometer.h
@@ -2,7 +2,7 @@
#define INC_ACCELEROMETER_H_
#include "../driver/MySPI.h"
-void accelerometre();
-
+void Init_accelerometre();
+void Lecture_accelerometre(float *GX, float* GY, float* GZ);
#endif
\ No newline at end of file
diff --git a/keilproject/Source/Principale.c b/keilproject/Source/Principale.c
index 79a178c..e412c4a 100644
--- a/keilproject/Source/Principale.c
+++ b/keilproject/Source/Principale.c
@@ -3,9 +3,11 @@
#include "MySPI.h"
#include "accelerometer.h"
+float GX, GY, GZ;
int main (void)
{
-
+ Init_accelerometre();
while(1){
- accelerometre();};
+ Lecture_accelerometre(&GX,&GY,&GZ);
+ };
}
diff --git a/keilproject/voilier.uvoptx b/keilproject/voilier.uvoptx
index caab44a..3ff1e11 100644
--- a/keilproject/voilier.uvoptx
+++ b/keilproject/voilier.uvoptx
@@ -339,9 +339,9 @@
0
0
- 54
+ 58
1
- 134220334
+ 134219020
0
0
0
@@ -350,23 +350,7 @@
1
C:\Users\guilh\OneDrive\Bureau\COURS\INSA AE\µC S6\voilier-team-1\implementation\accelerometer.c
- \\cool_reel\../implementation/accelerometer.c\54
-
-
- 1
- 0
- 5
- 1
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- ..\implementation\accelerometer.c
-
-
+ \\cool_reel\../implementation/accelerometer.c\58