# Read the JEDEC ID from the flash chip on the Lattice IceBlink40 board. This # example demonstrates the usage of the bit-level I/O and SPI functions. The # board has MISO=PB3, MOSI=PB2, SS=PB0, SCK=PB1, CRESET=PB6 & POWER=C2. # import fl VID_PID = "1D50:602B:0001" PROG_CONFIG = "B3B2B0B1" handle = fl.FLHandle() try: fl.flInitialise(0) # Connect, reset the board, open SPI interface & get SS port: handle = fl.flOpen(VID_PID) fl.flMultiBitPortAccess(handle, "B6-,C2-") # RESET low & cut the power fl.flSleep(10) fl.flSingleBitPortAccess(handle, 2, 2, fl.PIN_HIGH) # power on in RESET fl.progOpen(handle, PROG_CONFIG) (port, bit) = fl.progGetPort(handle, fl.LP_SS) fl.flSingleBitPortAccess(handle, port, bit, fl.PIN_HIGH) # Send JEDEC device-id command, retrieve three bytes back fl.flSingleBitPortAccess(handle, port, bit, fl.PIN_LOW) fl.spiSend(handle, b"\x9F", fl.SPI_MSBFIRST) bs = fl.spiRecv(handle, 3, fl.SPI_MSBFIRST) print("JEDEC ID: {}".format( " ".join(["{:02X}".format(b) for b in bs]))) fl.flSingleBitPortAccess(handle, port, bit, fl.PIN_HIGH) # Close SPI interface, release reset and close connection
conn = fl.FLHandle() try: fl.flInitialise(0) if ( not fl.flIsDeviceAvailable(VID_PID) ): print("Loading firmware...") fl.flLoadStandardFirmware("04b4:8613", VID_PID) print("Awaiting...") fl.flAwaitDevice(VID_PID, 600) conn = fl.flOpen(VID_PID) fl.flSingleBitPortAccess(conn, 3, 7, fl.PIN_LOW) print("flMultiBitPortAccess() returned {:032b}".format( fl.flMultiBitPortAccess(conn, "D7+"))) fl.flSleep(100) print("flGetFirmwareID(): {:04X}".format(fl.flGetFirmwareID(conn))) print("flGetFirmwareVersion(): {:08X}".format(fl.flGetFirmwareVersion(conn))) print("flIsNeroCapable(): {}".format(fl.flIsNeroCapable(conn))) print("flIsCommCapable(): {}".format(fl.flIsCommCapable(conn, CONDUIT))) fl.progOpen(conn, PROG_CONFIG) print("progGetPort(): {") (port, bit) = fl.progGetPort(conn, fl.LP_MISO) print(" MISO: {:c}{}".format(ord('A')+port, bit)) (port, bit) = fl.progGetPort(conn, fl.LP_MOSI) print(" MOSI: {:c}{}".format(ord('A')+port, bit)) (port, bit) = fl.progGetPort(conn, fl.LP_SS) print(" SS: {:c}{}".format(ord('A')+port, bit))
# Read the JEDEC ID from the flash chip on the Lattice IceBlink40 board. This # example demonstrates the usage of the bit-level I/O and SPI functions. The # board has MISO=PB3, MOSI=PB2, SS=PB0, SCK=PB1, CRESET=PB6 & POWER=C2. # import fl VID_PID = "1D50:602B:0001" PROG_CONFIG = "B3B2B0B1" handle = fl.FLHandle() try: fl.flInitialise(0) # Connect, reset the board, open SPI interface & get SS port: handle = fl.flOpen(VID_PID) fl.flMultiBitPortAccess(handle, "B6-,C2-") # RESET low & cut the power fl.flSleep(10) fl.flSingleBitPortAccess(handle, 2, 2, fl.PIN_HIGH) # power on in RESET fl.progOpen(handle, PROG_CONFIG) (port, bit) = fl.progGetPort(handle, fl.LP_SS) fl.flSingleBitPortAccess(handle, port, bit, fl.PIN_HIGH) # Send JEDEC device-id command, retrieve three bytes back fl.flSingleBitPortAccess(handle, port, bit, fl.PIN_LOW) fl.spiSend(handle, b"\x9F", fl.SPI_MSBFIRST) bs = fl.spiRecv(handle, 3, fl.SPI_MSBFIRST) print("JEDEC ID: {}".format(" ".join(["{:02X}".format(b) for b in bs]))) fl.flSingleBitPortAccess(handle, port, bit, fl.PIN_HIGH) # Close SPI interface, release reset and close connection fl.progClose(handle)
ivp = argList.i[0] print("Loading firmware into {}...".format(ivp)) fl.flLoadStandardFirmware(ivp, vp) print("Awaiting renumeration...") if not fl.flAwaitDevice(vp, 600): raise fl.FLException("FPGALink device did not renumerate properly as {}".format(vp)) print("Attempting to open connection to FPGALink device {} again...".format(vp)) handle = fl.flOpen(vp) else: raise fl.FLException("Could not open FPGALink device at {} and no initial VID:PID was supplied".format(vp)) if argList.d: print("Configuring ports...") rb = "{:0{}b}".format(fl.flMultiBitPortAccess(handle, argList.d[0]), 32) print( "Readback: 28 24 20 16 12 8 4 0\n {} {} {} {} {} {} {} {}".format( rb[0:4], rb[4:8], rb[8:12], rb[12:16], rb[16:20], rb[20:24], rb[24:28], rb[28:32] ) ) fl.flSleep(100) conduit = 1 if argList.c: conduit = int(argList.c[0]) isNeroCapable = fl.flIsNeroCapable(handle) isCommCapable = fl.flIsCommCapable(handle, conduit) fl.flSelectConduit(handle, conduit)
ivp = argList.i[0] print("Loading firmware into {}...".format(ivp)) fl.flLoadStandardFirmware(ivp, vp); print("Awaiting renumeration...") if ( not fl.flAwaitDevice(vp, 600) ): raise fl.FLException("FPGALink device did not renumerate properly as {}".format(vp)) print("Attempting to open connection to FPGALink device {} again...".format(vp)) handle = fl.flOpen(vp) else: raise fl.FLException("Could not open FPGALink device at {} and no initial VID:PID was supplied".format(vp)) if ( argList.d ): print("Configuring ports...") rb = "{:0{}b}".format(fl.flMultiBitPortAccess(handle, argList.d[0]), 32) print("Readback: 28 24 20 16 12 8 4 0\n {} {} {} {} {} {} {} {}".format( rb[0:4], rb[4:8], rb[8:12], rb[12:16], rb[16:20], rb[20:24], rb[24:28], rb[28:32])) fl.flSleep(100) conduit = 1 if ( argList.c ): conduit = int(argList.c[0]) isNeroCapable = fl.flIsNeroCapable(handle) isCommCapable = fl.flIsCommCapable(handle, conduit) fl.flSelectConduit(handle, conduit) if ( argList.q ): if ( isNeroCapable ): chain = fl.jtagScanChain(handle, argList.q[0])