from . import strobe, get_addr

def burst_write(spi, addr, data):
    """Write multiple bytes to FIFO or registers"""
    BURST = get_addr("BURST")
    spi.xfer2([addr | BURST] + data)


def send_packet(data):
    # Flush TX FIFO
    SFTX = get_addr("SFTX")
    strobe(SFTX)  

    # Load data to TX FIFO (fixed length)
    TXFIFO = get_addr("TXFIFO")
    burst_write(TXFIFO, data)  # 0x3F = TX FIFO

    # Strobe STX to transmit
    STX = get_addr("STX")
    strobe(STX)  # STX

    print(f"Sent: {data}")
