Simple test

Ensure your device works with this simple test.

examples/fram_i2c_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4## Simple Example For CircuitPython/Python I2C FRAM Library
 5
 6import board
 7import busio
 8
 9import adafruit_fram
10
11## Create a FRAM object (default address used).
12i2c = busio.I2C(board.SCL, board.SDA)
13fram = adafruit_fram.FRAM_I2C(i2c)
14
15## Optional FRAM object with a different I2C address, as well
16## as a pin to control the hardware write protection ('WP'
17## pin on breakout). 'write_protected()' can be used
18## independent of the hardware pin.
19
20# import digitalio
21# wp = digitalio.DigitalInOut(board.D10)
22# fram = adafruit_fram.FRAM_I2C(i2c,
23#                              address=0x53,
24#                              wp_pin=wp)
25
26## Write a single-byte value to register address '0'
27
28fram[0] = 1
29
30## Read that byte to ensure a proper write.
31## Note: reads return a bytearray
32
33print(fram[0])
34
35## Or write a sequential value, then read the values back.
36## Note: reads return a bytearray. Reads also allocate
37##       a buffer the size of slice, which may cause
38##       problems on memory-constrained platforms.
39
40# values = list(range(100))  # or bytearray or tuple
41# fram[0:100] = values
42# print(fram[0:100])
examples/fram_spi_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4## Simple Example For CircuitPython/Python SPI FRAM Library
 5
 6import board
 7import busio
 8import digitalio
 9
10import adafruit_fram
11
12## Create a FRAM object.
13spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
14cs = digitalio.DigitalInOut(board.D5)
15fram = adafruit_fram.FRAM_SPI(spi, cs)
16
17## Write a single-byte value to register address '0'
18
19fram[0] = 1
20
21## Read that byte to ensure a proper write.
22## Note: 'read()' returns a bytearray
23
24print(fram[0])
25
26## Or write a sequential value, then read the values back.
27## Note: 'read()' returns a bytearray. It also allocates
28##       a buffer the size of 'length', which may cause
29##       problems on memory-constrained platforms.
30
31# values = list(range(100))  # or bytearray or tuple
32# fram[0:100] = values
33# print(fram[0:100])