diff --git a/implementation/accelerometer.c b/implementation/accelerometer.c index 5c21d70..0bb3f14 100644 --- a/implementation/accelerometer.c +++ b/implementation/accelerometer.c @@ -1,6 +1,57 @@ +#include "stm32f10x.h" #include "accelerometer.h" #include "MySPI.h" #include "gpio.h" - -void MySPI_Init(SPI_TypeDef *) +void accelerometre() +{ + int dataX ; + float GX ; + int dataY ; + float GY; + int dataZ ; + float GZ; + + 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 + MySPI_Send(0X1A);//Paramétrage hors low consumption + 100Hz output data rate + MySPI_Set_NSS();//CS HIGH + + MySPI_Clear_NSS(); //CS LOW + MySPI_Send(0x31);//registre Data format + write + MySPI_Send(0x17);// + MySPI_Set_NSS();//CS HIGH + + MySPI_Clear_NSS(); //CS LOW + MySPI_Send(0xF2); + dataX = MySPI_Read()<<8; + dataX |= MySPI_Read(); + dataX &= 0xE; + GX = dataX*0.004; + dataY = MySPI_Read()<<8; + dataY |= MySPI_Read(); + dataY &= 0xE; + GY = dataY*0.004; + dataZ = MySPI_Read()<<8; + dataZ |= MySPI_Read(); + dataZ &= 0xE; + 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 0327392..1d8a585 100644 --- a/implementation/accelerometer.h +++ b/implementation/accelerometer.h @@ -2,7 +2,7 @@ #define INC_ACCELEROMETER_H_ #include "../driver/MySPI.h" - +void accelerometre(); #endif \ No newline at end of file diff --git a/keilproject/Source/Principale.c b/keilproject/Source/Principale.c index 407d6aa..79a178c 100644 --- a/keilproject/Source/Principale.c +++ b/keilproject/Source/Principale.c @@ -1,10 +1,11 @@ #include "stm32f10x.h" -#include "../../driver/MyI2C.h" -#include "../../driver/MySPI.h" -#include "../../implementation/acceleromer.h" +#include "MyI2C.h" +#include "MySPI.h" +#include "accelerometer.h" int main (void) { - - while(1){}; + + while(1){ + accelerometre();}; } diff --git a/keilproject/voilier.uvoptx b/keilproject/voilier.uvoptx index 717b623..caab44a 100644 --- a/keilproject/voilier.uvoptx +++ b/keilproject/voilier.uvoptx @@ -75,7 +75,7 @@ 1 0 - 1 + 0 18 @@ -257,7 +257,7 @@ 1 0 - 0 + 1 18 @@ -312,7 +312,7 @@ 0 ST-LINKIII-KEIL_SWO - -U066FFF504955857567155843 -O206 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(1BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8000 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM) + -U066FFF504955857567155843 -O206 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(1BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8000 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM) -WA0 -WE0 -WVCE4 -WS2710 -WM0 -WP2 0 @@ -339,7 +339,23 @@ 0 0 - 6 + 54 + 1 +
134220334
+ 0 + 0 + 0 + 0 + 0 + 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 @@ -348,7 +364,7 @@ 0 0 0 - .\Source\Principale.c + ..\implementation\accelerometer.c
diff --git a/keilproject/voilier.uvprojx b/keilproject/voilier.uvprojx index 3d304f2..ed3fe44 100644 --- a/keilproject/voilier.uvprojx +++ b/keilproject/voilier.uvprojx @@ -10,9 +10,8 @@ Simulé 0x4 ARM-ADS - 6190000::V6.19::ARMCLANG - 6190000::V6.19::ARMCLANG - 1 + 5060960::V5.06 update 7 (build 960)::.\ARM_Compiler_5.06u7 + 0 STM32F103RB @@ -324,7 +323,7 @@ 0 0 0 - 3 + 2 0 0 0 @@ -474,7 +473,7 @@ Réel 0x4 ARM-ADS - 5060960::V5.06 update 7 (build 960)::.\ARMCC + 5060960::V5.06 update 7 (build 960)::.\ARM_Compiler_5.06u7 0