def readReg(self, reg, n_bytes=1):
    """ Reads and returns the given number of bytes (default 1) from the given
        register as a list. """
    # Limit to 6-bit address space:
    reg &= 0x3f

    if self.mode == self.MODE_I2C:
      return self.bus.readTransaction(self.i2c_addr, reg, n_bytes)

    elif self.mode == self.MODE_SPI:
      # Set read bit:
      reg |= 1<<7
      if (n_bytes > 1):
        # Set multiple byte bit:
        reg |= 1<<6
      self.bus.setClockMode(self.spi_cs, self.SPI_CLOCK_MODE)
      self.bus.setMaxFrequency(self.spi_cs, self.spi_frequency)
      return self.bus.transfer(self.spi_cs, [reg] + [0]*n_bytes)[1:]
dataset/ETHPy150Open graycatlabs/PyBBIO/bbio/libraries/ADXL345/ADXL345.py/ADXL345.readReg/original