/* Multibyte write from device. A register write begins with the address and autoincrements for each additional byte in the transfer.  */
int32_t ad5770r_spi_reg_write_multiple(struct ad5770r_dev *dev, uint8_t reg_addr, uint8_t *reg_data, uint16_t count)
/* Multibyte write from device. A register write begins with the address and autoincrements for each additional byte in the transfer.  */
int32_t ad5770r_spi_reg_write_multiple(struct ad5770r_dev *dev, uint8_t reg_addr, uint8_t *reg_data, uint16_t count)
{
	int32_t ret;
	uint8_t *data;
	if (!dev | !reg_data)
		return FAILURE;
	data = (uint8_t*)calloc(count + 1, sizeof(uint8_t));
	data[0] = AD5770R_REG_WRITE(reg_addr);
	memcpy(&data[1], reg_data, count);
	ret = spi_write_and_read(dev->spi_desc, data, count + 1);
	free(data);
	return ret;
}