Toggle Navigation
Hatchery
Eggs
ICE40 Smooth Fade
ice40web.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
ice40web.py
raw
Content
from machine import Pin, SPI # Pins pin_reset = Pin(16, Pin.OUT) pin_done = Pin(21) pin_miso = Pin(5) pin_mosi = Pin(17, Pin.OUT) pin_sck = Pin(19, Pin.OUT) pin_ss = Pin(18, Pin.OUT) # SPI bus spi = SPI(1, baudrate=1000000, sck=pin_sck, mosi=pin_mosi, miso=pin_miso) def program(data): # Reset the ICE40 into SPI slave download mode pin_reset.value(0) # FPGA into RESET pin_ss.value(0) # Hold down SS pin pin_reset.value(1) # Take FPGA out of RESET print("Writing...") position = 0 length = len(data) while True: if position >= length: break spi.write(data[position:position+128]) position += 128 print("Sending dummy bytes...") spi.write(bytes([0]*100)) print("Done") def run(): with open('rgb.bin', 'r') as myfile: data = myfile.read() program(data)