Serial Read in ADXL345

Hi my ADXL345 Accelerometer comes with a given code that uses Bit bang SPI Function.

void spi_out(byte spidat){
  byte bitnum=8;

    spiread=0;
    // start spi bit bang
    while(bitnum>0){
       
      pinMode(spiclk,OUTPUT);    // SPI CLK =0
      if((spidat & 0x80)!=0)
        pinMode(spimosi,INPUT);  // MOSI = 1 if MSB =1
        else
        pinMode(spimosi,OUTPUT);  // else MOSI = 0
      
      spidat=spidat<<1; 
      pinMode(spiclk,INPUT);  // SPI CLK = 1
      
      // read spi data
      spiread=spiread<<1;
      
      if(digitalRead(spimiso)==HIGH) spiread |= 0x01; // shift in a 1 if MISO is 1

      pinMode(spimosi,INPUT);  // reset MOSI to 1
      bitnum--; 
    }

  
}

/*  Initialize ADXL345 */

void  init_adxl(void){
  delay(250);
  pinMode(spics,OUTPUT);  // CS=0   
  //Write to register 0x31, DATA FORMAT
  spi_out(0x31);
  // uncomment your desired range
  spi_out(0x0B); //full resolution, +/- 16g range
  //spi_out(0x0A); //full resolution, +/- 8g range
  //spi_out(0x09); //full resolution, +/- 4g range
 // spi_out(0x08); //full resolution, +/- 2g range
  
  pinMode(spics,INPUT);  //CS HIGH
  delay(1);
    pinMode(spics,OUTPUT);  // CS=0   
  
  // Write to register 0x2d, POWER_CTL
  spi_out(0x2d);
  //set to measure mode
  spi_out(0x08);
  pinMode(spics,INPUT);  //CS HIGH
  delay(1);
}

/*
   Read all 3 axis x,y,z
*/

void read_xyz(void){
  int i;
    pinMode(spics,OUTPUT);  // CS=0   
  //Set start address to 0x32
  //D7= 1 for read and D6=1 for sequential read
  spi_out(0xF2);
  // dump xyz content to array
  for(i=0;i<6;i++){
    spi_out(0x00);
    xyz[i]=spiread;
  }
  
  // merge to convert to 16 bits
  x=((int)xyz[1]<<8) + xyz[0];
  y=((int)xyz[3]<<8) + xyz[2];
  z=((int)xyz[5]<<8) + xyz[4];
  
  pinMode(spics,INPUT);  //CS HIGH
}

I do not understand some of them, like the 0x80 and the like.

I am just wondering if I could just use the basic DigitalReadSerial on this one without using the SPI function? Will it read the same result as it does when using the Bit bang SPI function?

The connection of my ADXL345 to Arduino is this:

[ADXL345 > Arduino Board]:
CLK > pin7
MISO > pin6
MOSI > pin5
CS > pin4
VDO > 3.3V
GND > GND

..there is something very wierd with that code.

haha what is it?

Anyway, this is the entire code:

// Pin usage, change assignment if you want to
const byte  spiclk=7;    // connect to ADXL CLK
const byte  spimiso=6;  // connect to ADXL DO
const byte spimosi=5;  // connect to ADXL DI
const byte spics=4;    // connect to ADXL CS
// Don't forget, connect ADXL VDD-GND to gizDuino/Arduino +3.3V-GND


byte  xyz[8];  // raw data storage
int x,y,z;    // x, y, z accelerometer data

byte spiread;

void setup(void){
  Serial.begin(9600);      // serial i/o for test output
  init_adxl();            // initialize ADXL345
  
}

void loop(void){

  read_xyz();            // read ADXL345 accelerometer

  // and then send results to serial port
  // view results by using IDE Tools>Serial Monitor
 
  delay(500);

}

void spi_out(byte spidat){
  byte bitnum=8;

    spiread=0;
    // start spi bit bang
    while(bitnum>0){
       
      pinMode(spiclk,OUTPUT);    // SPI CLK =0
      if((spidat & 0x80)!=0)
        pinMode(spimosi,INPUT);  // MOSI = 1 if MSB =1
        else
        pinMode(spimosi,OUTPUT);  // else MOSI = 0
      
      spidat=spidat<<1; 
      pinMode(spiclk,INPUT);  // SPI CLK = 1
      
      // read spi data
      spiread=spiread<<1;
      
      if(digitalRead(spimiso)==HIGH) spiread |= 0x01; // shift in a 1 if MISO is 1

      pinMode(spimosi,INPUT);  // reset MOSI to 1
      bitnum--; 
    }

  
}

/*  Initialize ADXL345 */

void  init_adxl(void){
  delay(250);
  pinMode(spics,OUTPUT);  // CS=0   
  //Write to register 0x31, DATA FORMAT
  spi_out(0x31);
  // uncomment your desired range
  spi_out(0x0B); //full resolution, +/- 16g range
  //spi_out(0x0A); //full resolution, +/- 8g range
  //spi_out(0x09); //full resolution, +/- 4g range
 // spi_out(0x08); //full resolution, +/- 2g range
  
  pinMode(spics,INPUT);  //CS HIGH
  delay(1);
    pinMode(spics,OUTPUT);  // CS=0   
  
  // Write to register 0x2d, POWER_CTL
  spi_out(0x2d);
  //set to measure mode
  spi_out(0x08);
  pinMode(spics,INPUT);  //CS HIGH
  delay(1);
}

/*
   Read all 3 axis x,y,z
*/

void read_xyz(void){
  int i;
    pinMode(spics,OUTPUT);  // CS=0   
  //Set start address to 0x32
  //D7= 1 for read and D6=1 for sequential read
  spi_out(0xF2);
  // dump xyz content to array
  for(i=0;i<6;i++){
    spi_out(0x00);
    xyz[i]=spiread;
  }
  
  // merge to convert to 16 bits
  x=((int)xyz[1]<<8) + xyz[0];
  y=((int)xyz[3]<<8) + xyz[2];
  z=((int)xyz[5]<<8) + xyz[4];
  
  pinMode(spics,INPUT);  //CS HIGH
}