def _set_bits_per_word(self, bits_per_word):
        if not isinstance(bits_per_word, int):
            raise TypeError("Invalid bits_per_word type, should be integer.")
        if bits_per_word < 0 or bits_per_word > 255:
            raise ValueError("Invalid bits_per_word, must be 0-255.")

        # Set bits per word
        buf = array.array('B', [bits_per_word])
        try:
            fcntl.ioctl(self._fd, SPI._SPI_IOC_WR_BITS_PER_WORD, buf, False)
        except __HOLE__ as e:
            raise SPIError(e.errno, "Setting SPI bits per word: " + e.strerror)
dataset/ETHPy150Open vsergeev/python-periphery/periphery/spi.py/SPI._set_bits_per_word