# uPy - RPi Pico file system for fram MB85RS64
# provided by Anthony Vogelaar, Perth Scotland
# rev 0.10  2025-01-13  initial release

from	mve_fram	import Fram
from	machine		import	Pin, SPI
    
# ============== Hardware definitions ==============

pin_led         = 25				# on-board green led
pin_spi_sck		= 18
pin_spi_mosi	= 19
pin_spi_miso	= 16
pin_spi_cs		= 17

# ============== Hardware setup  ===================

led		= Pin(pin_led, Pin.OUT, value=1)
spi	    = SPI(0, 10_000_000, sck=pin_spi_sck, mosi=pin_spi_mosi,
              miso=pin_spi_miso)
spi_cs  = Pin(pin_spi_cs, Pin.OUT, value=1)
print(spi)

# ======================= main =====================

def main():
    fram = Fram(spi, spi_cs)
    s1 = 'het kost \u20ac201.25'			# euro 101.15
    l  = fram.swrite(0x0200, s1)
    print('read :', fram.read(0x0200, l+1))
    print('sread:', fram.sread(0x0200))
    

main()
spi.deinit()
    
# ====================== End ==========================
