Attiny85 and MPU-6050

I have some code working on my ...milenove, and wanted to "transcribe" the project to an 85.

I got an 20x4 lcd working on the i2c bus, and I wanted to add the MPU. The problem I'm having is translating the MPU-read and write functions from the Wire Library to TinyWireM/TinyWireS

Here is the code:

// --------------------------------------------------------
// MPU6050_read
//
// This is a common function to read multiple bytes 
// from an I2C device.
//
// It uses the boolean parameter for Wire.endTransMission()
// to be able to hold or release the I2C-bus. 
// This is implemented in Arduino 1.0.1.
//
// Only this function is used to read. 
// There is no function for a single byte.
//
int MPU6050_read(int start, uint8_t *buffer, int size)
{
  int i, n, error;

  Wire.beginTransmission(MPU6050_I2C_ADDRESS);
  n = Wire.write(start);
  if (n != 1)
    return (-10);

  n = Wire.endTransmission(false);    // hold the I2C-bus
  if (n != 0)
    return (n);

  // Third parameter is true: relase I2C-bus after data is read.
  Wire.requestFrom(MPU6050_I2C_ADDRESS, size, true);
  i = 0;
  while(Wire.available() && i<size)
  {
    buffer[i++]=Wire.read();
  }
  if ( i != size)
    return (-11);

  return (0);  // return : no error
}


// --------------------------------------------------------
// MPU6050_write
//
// This is a common function to write multiple bytes to an I2C device.
//
// If only a single register is written,
// use the function MPU_6050_write_reg().
//
// Parameters:
//   start : Start address, use a define for the register
//   pData : A pointer to the data to write.
//   size  : The number of bytes to write.
//
// If only a single register is written, a pointer
// to the data has to be used, and the size is
// a single byte:
//   int data = 0;        // the data to write
//   MPU6050_write (MPU6050_PWR_MGMT_1, &c, 1);
//
int MPU6050_write(int start, const uint8_t *pData, int size)
{
  int n, error;

  Wire.beginTransmission(MPU6050_I2C_ADDRESS);
  n = Wire.write(start);        // write the start address
  if (n != 1)
    return (-20);

  n = Wire.write(pData, size);  // write data bytes
  if (n != size)
    return (-21);

  error = Wire.endTransmission(true); // release the I2C-bus
  if (error != 0)
    return (error);

  return (0);         // return : no error
}

// --------------------------------------------------------
// MPU6050_write_reg
//
// An extra function to write a single register.
// It is just a wrapper around the MPU_6050_write()
// function, and it is only a convenient function
// to make it easier to write a single register.
//
int MPU6050_write_reg(int reg, uint8_t data)
{
  int error;

  error = MPU6050_write(reg, &data, 1);

  return (error);
}

I had to cut some of my added code out, to achieve the char limit of the post
Thanks in advance for your help.-Keith

What exactly is the problem?

Error messages...?

The example sketch is using Wire and I need to use TinyWireM/TinyWireS.

fungus:
What exactly is the problem?

Error messages...?

Wire.h doesnt compile for the ATTiny85.

No...but TinyWireM.h does.

yes, the example sketch was written for the full size arduinos and I was trying to get the sensor to work on my attiny85. There are memory limitations as i understand it and not all the methods from the two libraries are the same, yet they accomplish the same thing. I was wondering if someone could transcribe these functions to work with the tiny85.

Thanks

TinyWireM (at least the version I found, you haven't provided a link to the version you're using, so I simply assume you use the version I found) uses almost the same API as the Arduino Wire library so you could use it as a drop-in replacement in your case. The only difference I found, is the return value of the requestFrom() method, which is the number of bytes read in the Wire library while the TinyWireM returns 0 if successful, an error code otherwise. Because your code is not checking the return value, you don't have to change anything.