/* Sets the PWM output of the specified channel.  */
err_t pca9685SetPWM(uint16_t channel, uint16_t on, uint16_t off)
/* Sets the PWM output of the specified channel.  */
err_t pca9685SetPWM(uint16_t channel, uint16_t on, uint16_t off)
{
  ASSERT(_pca9685Initialised, ERROR_DEVICENOTINITIALISED);
  if (on > 0xFFF)
  {
    on = 0xFFF;
  }
  if (off < on)
  {
    off = on;
  }
  if (off > 0xFFF)
  {
    off = 0xFFF;
  }
  ASSERT_STATUS(pca9685Write8(PCA9685_REG_LED0_ON_L+4*channel, on & 0xFF));
  ASSERT_STATUS(pca9685Write8(PCA9685_REG_LED0_ON_H+4*channel, on >> 8));
  ASSERT_STATUS(pca9685Write8(PCA9685_REG_LED0_OFF_L+4*channel, off & 0xFF));
  ASSERT_STATUS(pca9685Write8(PCA9685_REG_LED0_OFF_H+4*channel, off >> 8));
  return ERROR_NONE;
}