Example #1
0
    def transaction(self, dataToSend):
        """Perform a simultaneous read/write transaction with the device

        :param dataToSend: The data to be written out to the device

        :returns: data received from the device
        """
        return hal.spiTransaction(self.port, dataToSend)
Example #2
0
    def transaction(self, dataToSend):
        """Perform a simultaneous read/write transaction with the device

        :param dataToSend: The data to be written out to the device
        :type dataToSend: iterable of bytes

        :returns: data received from the device
        
        Usage::
        
            # send byte string
            data = spi.transaction(b'stuff')
            
            # send list of integers
            data = spi.transaction([0x01, 0x02])
        """
        return hal.spiTransaction(self.port, dataToSend)
Example #3
0
    def transaction(self, dataToSend):
        """Perform a simultaneous read/write transaction with the device

        :param dataToSend: The data to be written out to the device
        :type dataToSend: iterable of bytes

        :returns: data received from the device
        
        Usage::
        
            # send byte string
            data = spi.transaction(b'stuff')
            
            # send list of integers
            data = spi.transaction([0x01, 0x02])
        """
        return hal.spiTransaction(self.port, dataToSend)
Example #4
0
    def read(self, initiate, size):
        """Read a word from the receive FIFO.

        Waits for the current transfer to complete if the receive FIFO is
        empty.

        If the receive FIFO is empty, there is no active transfer, and
        initiate is False, errors.

        :param initiate: If True, this function pushes "0" into the
            transmit buffer and initiates a transfer.  If False, this function
            assumes that data is already in the receive FIFO from a previous
            write.
        :param size: Number of bytes to read.

        :returns: received data bytes
        """
        if initiate:
            return hal.spiTransaction(self.port, [0]*size)
        else:
            return hal.spiRead(self.port, size)
Example #5
0
    def read(self, initiate, size):
        """Read a word from the receive FIFO.

        Waits for the current transfer to complete if the receive FIFO is
        empty.

        If the receive FIFO is empty, there is no active transfer, and
        initiate is False, errors.

        :param initiate: If True, this function pushes "0" into the
            transmit buffer and initiates a transfer.  If False, this function
            assumes that data is already in the receive FIFO from a previous
            write.
        :param size: Number of bytes to read.

        :returns: received data bytes
        """
        if initiate:
            return hal.spiTransaction(self.port, [0] * size)
        else:
            return hal.spiRead(self.port, size)