/ examples / fram_spi_simpletest.py
fram_spi_simpletest.py
 1  ## Simple Example For CircuitPython/Python SPI FRAM Library
 2  
 3  import board
 4  import busio
 5  import digitalio
 6  import adafruit_fram
 7  
 8  ## Create a FRAM object.
 9  spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
10  cs = digitalio.DigitalInOut(board.D5)
11  fram = adafruit_fram.FRAM_SPI(spi, cs)
12  
13  ## Write a single-byte value to register address '0'
14  
15  fram[0] = 1
16  
17  ## Read that byte to ensure a proper write.
18  ## Note: 'read()' returns a bytearray
19  
20  print(fram[0])
21  
22  ## Or write a sequential value, then read the values back.
23  ## Note: 'read()' returns a bytearray. It also allocates
24  ##       a buffer the size of 'length', which may cause
25  ##       problems on memory-constrained platforms.
26  
27  # values = list(range(100)) # or bytearray or tuple
28  # fram[0] = values
29  # print(fram[0:99])