def read(self, initiate: bool, size: int) -> bytes: """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.transactionSPI(self.port, [0] * size) else: return hal.readSPI(self.port, size)