void MAX30100::readFifoData() { uint8_t buffer[4]; burstRead(MAX30100_REG_FIFO_DATA, buffer, 4); // Warning: the values are always left-aligned rawIRValue = (buffer[0] << 8) | buffer[1]; rawRedValue = (buffer[2] << 8) | buffer[3]; }
void calibrate_gyro(unsigned int no_ofIterations, float *driftBuffer ){ unsigned int i; int xGyro,yGyro,zGyro; char xyzBuffer[6]; for(i=0;i<no_ofIterations;++i){ burstRead(SLAVE_ADDRESS_ITG3200, GYRO_XOUT_H_ITG3200, xyzBuffer, 6); //burst read Gyro 3- axis data xGyro = ((xyzBuffer[0] << 8) | xyzBuffer[1]); //bit shift MSB ans add to LSB yGyro = ((xyzBuffer[2] << 8) | xyzBuffer[3]); zGyro = ((xyzBuffer[4] << 8) | xyzBuffer[5]); driftBuffer[0] += xGyro; //add data to respective buffer driftBuffer[1] += yGyro; driftBuffer[2] += zGyro; } for(i=0;i<3;++i) driftBuffer[i] /= no_ofIterations; //divide with no.of iterations to get average value of the drift along each axis }