/* Writes a block of data to the Si1147 sensor.  */
uint32_t Si1147_Write_Block_Register(I2C_TypeDef *i2c, uint8_t addr, uint8_t reg, uint8_t length, uint8_t const *data)
/* Writes a block of data to the Si1147 sensor.  */
uint32_t Si1147_Write_Block_Register(I2C_TypeDef *i2c, uint8_t addr, uint8_t reg, uint8_t length, uint8_t const *data)
{
  I2C_TransferSeq_TypeDef    seq;
  I2C_TransferReturn_TypeDef ret;
  uint8_t i2c_write_data[10];
  uint8_t i2c_read_data[1];
  int i;
  seq.addr  = addr;
  seq.flags = I2C_FLAG_WRITE;
  i2c_write_data[0] = reg;
  for (i=0; i<length;i++)
  {
    i2c_write_data[i+1] = data[i];
  }
  seq.buf[0].data = i2c_write_data;
  seq.buf[0].len  = 1+length;
  seq.buf[1].data = i2c_read_data;
  seq.buf[1].len  = 0;
  ret = I2CSPM_Transfer(i2c, &seq);
  if (ret != i2cTransferDone)
  {
    return (uint32_t)ret;
  }
  return (uint32_t)0;
}