Coding the ADXRS453 Gyro using SPI, need help with SPI

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!

Hmm, some ideas: initialize the chip select pin first and set it high. Wait 100ms before the first command (see pg. 20). Fix your loop() and please use code tags (button # above the smilies).

void loop()
{
void GyroSetup()
{
...
}

This looks broken. Call GyroSetup() in setup(). loop() is empty then.

Definitely set the CS pin HIGH first, to enable the internal-pull-up, and only then call pinMode() to make it an OUTPUT.

If you just call pinMode(CSpin, OUTPUT) first you'll start an SPI transaction on the device with the SCK signal floating - anything could happen.

If you have more than one SPI device on the bus set all the CS's high before using any of them.

My prefered sequence is pull all CS high, pull SCK low, pull MOSI low, enable these as outputs, initialize SPI hardware, then start using it. If an SPI device doesn't have built-in pull-up on its CS line its best to provide a hardware pullup yourself to be absolutely sure it'll reset in a safe state.

Did you mange to get this working? Would be amazing if you could share the code, even if it isn't 100% working yet!