I trying to write a program to read information from the gyro.
Here is the link to the datasheet of the gyro I am using. http://www.analog.com/static/imported-files/data_sheets/ADXRS453.pdf
The code that I have so far:
void setup()
{
SPI.begin(); //Tell SPI to start
SPI.setBitOrder(MSBFIRST); //Tells SPI to make order MSB first
SPI.setClockDivider(SPI_CLOCK_DIV2); //sets SPI clock to 8MHz
SPI.setDataMode(SPI_MODE0); 0 phase, 0 polarity
pinMode(40,OUTPUT); //my chip select pin
Serial.begin(9600);
digitalWrite(40, HIGH); //sets cs to high
}
void loop()
{
void GyroSetup()
{
delay(1000);
digitalWrite(40,LOW); //sets chip select to transfer data
byte result1 = SPI.transfer(0x20); //sends a byte of data
long FinalResult = result1;
byte result2 = SPI.transfer(0x00);
FinalResult = FinalResult << 8; //sets final result as final 32 bit number, i shift the bits every time before i add the new result from the transfer
FinalResult = FinalResult + result2;
byte result3 = SPI.transfer(0x00);
FinalResult = FinalResult << 8;
FinalResult = FinalResult + result3;
byte result4 = SPI.transfer(0x03);
FinalResult = FinalResult << 8;
FinalResult = FinalResult + result4;
digitalWrite(40,HIGH); //de-selects chip select
Serial.print(FinalResult,HEX); //output value
delay(2000);
}
In the datasheet it says the intial response to 0x2000003, which is what i sent should be 0x1 but im not getting that. any help would be great!