/* Reads the specified number of bytes over I2C.  */
err_t pca9685ReadBytes(uint8_t reg, uint8_t *buffer, size_t length)
/* Reads the specified number of bytes over I2C.  */
err_t pca9685ReadBytes(uint8_t reg, uint8_t *buffer, size_t length)
{
  uint32_t i;
  ASSERT(length <= I2C_BUFSIZE, ERROR_BUFFEROVERFLOW);
  I2CWriteLength = 2;
  I2CReadLength = 0;
  I2CMasterBuffer[0] = _pca9685Address;
  I2CMasterBuffer[1] = reg;
  i2cEngine();
  I2CWriteLength = 0;
  I2CReadLength = length;
  I2CMasterBuffer[0] = _pca9685Address | PCA9685_READBIT;
  ASSERT_I2C_STATUS(i2cEngine());
  for ( i = 0; i < length; i++ )
  {
    buffer[i] = I2CSlaveBuffer[i];
  }
  return ERROR_NONE;
}