/* This API reads the 8-bit data from the given register in the sensor.  */
static uint16_t read_regs(uint8_t addr, uint8_t *data, uint8_t len, const struct bma4_dev *dev)
/* This API reads the 8-bit data from the given register in the sensor.  */
static uint16_t read_regs(uint8_t addr, uint8_t *data, uint8_t len, const struct bma4_dev *dev)
{
    uint16_t rslt = 0;
    uint16_t temp_len = len + dev->dummy_byte;
    uint16_t i;
    if (dev->interface == BMA4_SPI_INTERFACE) {
        addr = addr | BMA4_SPI_RD_MASK;
    }
    if (temp_len > BMA4_MAX_BUFFER_SIZE) {
        rslt |= BMA4_E_OUT_OF_RANGE;
    }
    if (rslt == BMA4_OK) {
        rslt |= dev->bus_read(dev->dev_addr, addr, temp_buff, temp_len);
        for (i = 0; i < len; i++) {
            data[i] = temp_buff[i + dev->dummy_byte];
        }
    }
    return rslt;
}