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