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