def transceive(spi,csPin,busyPin,cmd: int,len: int) -> bytearray:
    """
    Method to receive data by an SPI slave after sending a command.
    
    Parameters
    -----
    spi : spi object from busio.SPI
    csPin : control slave pin from board.D##
    cmd : opcode of command
    len : number of bytes to receive

    Returns
    -----
    arr : bytearray of length len with received bytes
    """
    # wait until BUSY goes low
    while busyPin.value:
        pass

    arr = bytearray(len)
    csPin = False

    spi.writeto(bytes([cmd]))
    spi.readinto(arr)

    csPin = True
    return arr