Fonction V1 de paramétrage et lecture des registre de l'accéléromètre.
This commit is contained in:
parent
e035bfb760
commit
8530d2a8a1
5 changed files with 85 additions and 18 deletions
|
@ -1,6 +1,57 @@
|
||||||
|
#include "stm32f10x.h"
|
||||||
#include "accelerometer.h"
|
#include "accelerometer.h"
|
||||||
#include "MySPI.h"
|
#include "MySPI.h"
|
||||||
#include "gpio.h"
|
#include "gpio.h"
|
||||||
|
|
||||||
|
void accelerometre()
|
||||||
|
{
|
||||||
|
int dataX ;
|
||||||
|
float GX ;
|
||||||
|
int dataY ;
|
||||||
|
float GY;
|
||||||
|
int dataZ ;
|
||||||
|
float GZ;
|
||||||
|
|
||||||
void MySPI_Init(SPI_TypeDef *)
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -2,7 +2,7 @@
|
||||||
#define INC_ACCELEROMETER_H_
|
#define INC_ACCELEROMETER_H_
|
||||||
|
|
||||||
#include "../driver/MySPI.h"
|
#include "../driver/MySPI.h"
|
||||||
|
void accelerometre();
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -1,10 +1,11 @@
|
||||||
#include "stm32f10x.h"
|
#include "stm32f10x.h"
|
||||||
#include "../../driver/MyI2C.h"
|
#include "MyI2C.h"
|
||||||
#include "../../driver/MySPI.h"
|
#include "MySPI.h"
|
||||||
#include "../../implementation/acceleromer.h"
|
#include "accelerometer.h"
|
||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
{
|
{
|
||||||
|
|
||||||
while(1){};
|
while(1){
|
||||||
|
accelerometre();};
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@
|
||||||
<OPTFL>
|
<OPTFL>
|
||||||
<tvExp>1</tvExp>
|
<tvExp>1</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<IsCurrentTarget>1</IsCurrentTarget>
|
<IsCurrentTarget>0</IsCurrentTarget>
|
||||||
</OPTFL>
|
</OPTFL>
|
||||||
<CpuCode>18</CpuCode>
|
<CpuCode>18</CpuCode>
|
||||||
<DebugOpt>
|
<DebugOpt>
|
||||||
|
@ -257,7 +257,7 @@
|
||||||
<OPTFL>
|
<OPTFL>
|
||||||
<tvExp>1</tvExp>
|
<tvExp>1</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<IsCurrentTarget>0</IsCurrentTarget>
|
<IsCurrentTarget>1</IsCurrentTarget>
|
||||||
</OPTFL>
|
</OPTFL>
|
||||||
<CpuCode>18</CpuCode>
|
<CpuCode>18</CpuCode>
|
||||||
<DebugOpt>
|
<DebugOpt>
|
||||||
|
@ -312,7 +312,7 @@
|
||||||
<SetRegEntry>
|
<SetRegEntry>
|
||||||
<Number>0</Number>
|
<Number>0</Number>
|
||||||
<Key>ST-LINKIII-KEIL_SWO</Key>
|
<Key>ST-LINKIII-KEIL_SWO</Key>
|
||||||
<Name>-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)</Name>
|
<Name>-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</Name>
|
||||||
</SetRegEntry>
|
</SetRegEntry>
|
||||||
<SetRegEntry>
|
<SetRegEntry>
|
||||||
<Number>0</Number>
|
<Number>0</Number>
|
||||||
|
@ -339,7 +339,23 @@
|
||||||
<Bp>
|
<Bp>
|
||||||
<Number>0</Number>
|
<Number>0</Number>
|
||||||
<Type>0</Type>
|
<Type>0</Type>
|
||||||
<LineNumber>6</LineNumber>
|
<LineNumber>54</LineNumber>
|
||||||
|
<EnabledFlag>1</EnabledFlag>
|
||||||
|
<Address>134220334</Address>
|
||||||
|
<ByteObject>0</ByteObject>
|
||||||
|
<HtxType>0</HtxType>
|
||||||
|
<ManyObjects>0</ManyObjects>
|
||||||
|
<SizeOfObject>0</SizeOfObject>
|
||||||
|
<BreakByAccess>0</BreakByAccess>
|
||||||
|
<BreakIfRCount>1</BreakIfRCount>
|
||||||
|
<Filename>C:\Users\guilh\OneDrive\Bureau\COURS\INSA AE\µC S6\voilier-team-1\implementation\accelerometer.c</Filename>
|
||||||
|
<ExecCommand></ExecCommand>
|
||||||
|
<Expression>\\cool_reel\../implementation/accelerometer.c\54</Expression>
|
||||||
|
</Bp>
|
||||||
|
<Bp>
|
||||||
|
<Number>1</Number>
|
||||||
|
<Type>0</Type>
|
||||||
|
<LineNumber>5</LineNumber>
|
||||||
<EnabledFlag>1</EnabledFlag>
|
<EnabledFlag>1</EnabledFlag>
|
||||||
<Address>0</Address>
|
<Address>0</Address>
|
||||||
<ByteObject>0</ByteObject>
|
<ByteObject>0</ByteObject>
|
||||||
|
@ -348,7 +364,7 @@
|
||||||
<SizeOfObject>0</SizeOfObject>
|
<SizeOfObject>0</SizeOfObject>
|
||||||
<BreakByAccess>0</BreakByAccess>
|
<BreakByAccess>0</BreakByAccess>
|
||||||
<BreakIfRCount>0</BreakIfRCount>
|
<BreakIfRCount>0</BreakIfRCount>
|
||||||
<Filename>.\Source\Principale.c</Filename>
|
<Filename>..\implementation\accelerometer.c</Filename>
|
||||||
<ExecCommand></ExecCommand>
|
<ExecCommand></ExecCommand>
|
||||||
<Expression></Expression>
|
<Expression></Expression>
|
||||||
</Bp>
|
</Bp>
|
||||||
|
|
|
@ -10,9 +10,8 @@
|
||||||
<TargetName>Simulé</TargetName>
|
<TargetName>Simulé</TargetName>
|
||||||
<ToolsetNumber>0x4</ToolsetNumber>
|
<ToolsetNumber>0x4</ToolsetNumber>
|
||||||
<ToolsetName>ARM-ADS</ToolsetName>
|
<ToolsetName>ARM-ADS</ToolsetName>
|
||||||
<pArmCC>6190000::V6.19::ARMCLANG</pArmCC>
|
<pCCUsed>5060960::V5.06 update 7 (build 960)::.\ARM_Compiler_5.06u7</pCCUsed>
|
||||||
<pCCUsed>6190000::V6.19::ARMCLANG</pCCUsed>
|
<uAC6>0</uAC6>
|
||||||
<uAC6>1</uAC6>
|
|
||||||
<TargetOption>
|
<TargetOption>
|
||||||
<TargetCommonOption>
|
<TargetCommonOption>
|
||||||
<Device>STM32F103RB</Device>
|
<Device>STM32F103RB</Device>
|
||||||
|
@ -324,7 +323,7 @@
|
||||||
<PlainCh>0</PlainCh>
|
<PlainCh>0</PlainCh>
|
||||||
<Ropi>0</Ropi>
|
<Ropi>0</Ropi>
|
||||||
<Rwpi>0</Rwpi>
|
<Rwpi>0</Rwpi>
|
||||||
<wLevel>3</wLevel>
|
<wLevel>2</wLevel>
|
||||||
<uThumb>0</uThumb>
|
<uThumb>0</uThumb>
|
||||||
<uSurpInc>0</uSurpInc>
|
<uSurpInc>0</uSurpInc>
|
||||||
<uC99>0</uC99>
|
<uC99>0</uC99>
|
||||||
|
@ -474,7 +473,7 @@
|
||||||
<TargetName>Réel</TargetName>
|
<TargetName>Réel</TargetName>
|
||||||
<ToolsetNumber>0x4</ToolsetNumber>
|
<ToolsetNumber>0x4</ToolsetNumber>
|
||||||
<ToolsetName>ARM-ADS</ToolsetName>
|
<ToolsetName>ARM-ADS</ToolsetName>
|
||||||
<pCCUsed>5060960::V5.06 update 7 (build 960)::.\ARMCC</pCCUsed>
|
<pCCUsed>5060960::V5.06 update 7 (build 960)::.\ARM_Compiler_5.06u7</pCCUsed>
|
||||||
<uAC6>0</uAC6>
|
<uAC6>0</uAC6>
|
||||||
<TargetOption>
|
<TargetOption>
|
||||||
<TargetCommonOption>
|
<TargetCommonOption>
|
||||||
|
|
Loading…
Reference in a new issue