def i2c_master_write_read(self, address, length, *data):
        """Perform an I2C master write read access.

        First write the given `data` to a slave device, then read `length`
        bytes from it. For more information see the `I2C Master Read` and `I2C
        Master Write` keywords.

        Examples:
        | I2C Master Write Read | 0xa4 | 1 | 0x10           |
        | I2C Master Write Read | 0xa4 | 1 | 0x10 0x12 0x13 |
        | I2C Master Write Read | 0xa4 | 1 | 0x10 | 0x12 | 0x13 |
        """

        address = int_any_base(address)
        length = int_any_base(length)
        if len(data) == 1:
            data = list_any_input(data[0])
        else:
            data = [int_any_base(c) for c in data]
        logger.info('Writing %d bytes to %02xh: %s' %
                (len(data), address, ' '.join('%02x' % d for d in data)))
        data = ''.join('%c' % chr(c) for c in data)
        data = self._device.i2c_master_write_read(address, data, length)
        data = array.array('B', data)
        logger.info('Read %d bytes from %02xh: %s' %
                (length, address, ' '.join('%02x' % d for d in data)))
        return data
    def spi_transfer(self, *data):
        """Performs a SPI access.

        Writes a stream of bytes (given in `data`) on the SPI interface while
        reading back the same amount of bytes. The read back has the same
        length as the input data. If you want to read more data than writing on
        the bus you have to send dummy bytes.

        Examples:
        | SPI Write | 0x10           |
        | SPI Write | 0x10 0x12 0x13 |
        | SPI Write | 0x10 | 0x12 | 0x13 |
        | ${ret}=  | SPI Write | 0x10 | 0x12 | 0x13 | # ${ret} is an array of 3 bytes |
        """

        if len(data) == 1:
            data = list_any_input(data[0])
        else:
            data = [int_any_base(c) for c in data]
        logger.info('Writing %d bytes: %s' %
                (len(data), ' '.join('%02x' % d for d in data)))
        data = ''.join('%c' % chr(c) for c in data)
        data = self._device.spi_write(data)
        data = array.array('B', data)
        logger.info('Read %d bytes: %s' %
                (len(data), ' '.join('%02x' % d for d in data)))
        return data
    def i2c_master_write(self, address, *data):
        """Perform an I2C master write access.

        Writes the given `data` to a slave device with address given in the
        `address` argument. The `data` argument can either be list of bytes, a
        whitespace separated list of bytes or a single byte. See the examples
        below.

        Both the `address` and `data` can be given either as strings or
        integers.  Strings are parsed accoding to their prefix. Eg. `0x`
        denotes a hexadecimal number.

        Examples:
        | I2C Master Write | 0xa4 | 0x10           |
        | I2C Master Write | 0xa4 | 0x10 0x12 0x13 |
        | I2C Master Write | 0xa4 | 0x10 | 0x12 | 0x13 |
        """

        address = int_any_base(address)
        if len(data) == 1:
            data = list_any_input(data[0])
        else:
            data = [int_any_base(c) for c in data]
        logger.info('Writing %d bytes to %02xh: %s' %
                (len(data), address, ' '.join('%02x' % d for d in data)))
        data = ''.join('%c' % chr(c) for c in data)
        self._device.i2c_master_write(address, data)