Sorry for late reply. Here is my current code. The output remains the same as posted before.
#include<SPI.h>
// Read and write operations
#define Reg_read 0x00
#define Reg_write 0x01
// Registers list
#define DREG_EULER_PHI_THETA 0x70
//define the variables to be used for data from UM7
short roll, pitch;
uint8_t byte_0,byte_1, byte_2, byte_3; //for data coming from register
void setup() {
// for serial communication between PC and arduino
Serial.begin(115200);
SPI.begin(); //Begins the SPI commnuication
//SPI.setClockDivider(SPI_CLOCK_DIV16); //Sets clock for SPI communication at 16 (16/16=1Mhz)
digitalWrite(SS,HIGH); // Setting SlaveSelect as HIGH (So master doesnt connnect with slave)
}
void loop() {
// put your main code here, to run repeatedly:
SPI.beginTransaction(SPISettings(1000000,MSBFIRST,SPI_MODE1));
digitalWrite(SS, LOW); //Starts communication with Slave connected to master
SPI.transfer(Reg_read);
delayMicroseconds(5);
SPI.transfer(DREG_EULER_PHI_THETA);
delayMicroseconds(5);
// reading the data from the register
byte_0 = SPI.transfer(Reg_read);
delayMicroseconds(5);
byte_1 = SPI.transfer(Reg_read);
delayMicroseconds(5);
byte_2 = SPI.transfer(Reg_read);
delayMicroseconds(5);
byte_3 = SPI.transfer(Reg_read);
delayMicroseconds(5); // wait for 25 microns
digitalWrite(SS,HIGH);
SPI.endTransaction();
roll = byte_0 << 8;
roll |= byte_1;
pitch = byte_2 << 8;
pitch |= byte_3;
Serial.print(roll/91.02222);
Serial.print('\t');
Serial.print(pitch/91.02222);
Serial.print('\n');
}