adafruit_fram
¶
CircuitPython/Python library to support the I2C and SPI FRAM Breakouts.
Author(s): Michael Schroeder
Implementation Notes¶
Hardware:
Adafruit I2C Non-Volatile FRAM Breakout (Product ID: 1895)
Adafruit SPI Non-Volatile FRAM Breakout (Product ID: 1897)
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://github.com/adafruit/circuitpython/releases
Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
- class adafruit_fram.FRAM(max_size: int, write_protect: bool = False, wp_pin: DigitalInOut | None = None)¶
Driver base for the FRAM Breakout.
- Parameters:
- __getitem__(address: int | slice) bytearray ¶
Read the value at the given index, or values in a slice.
# read single index fram[0] # read values 0 thru 9 with a slice fram[0:9]
- __len__() int ¶
The size of the current FRAM chip. This is one more than the highest address location that can be read or written to.
fram = adafruit_fram.FRAM_xxx() # xxx = 'I2C' or 'SPI' # size returned by len() len(fram) # can be used with range for i in range(0, len(fram))
- __setitem__(address: int | slice, value: int | Sequence[int])¶
Write the value at the given starting index.
# write single index fram[0] = 1 # write values 0 thru 4 with a list fram[0:4] = [0,1,2,3]
- property write_protected: bool¶
The status of write protection. Default value on initialization is
False
.When a
WP
pin is supplied during initialization, or usingwrite_protect_pin
, the status is tied to that pin and enables hardware-level protection.When no
WP
pin is supplied, protection is only at the software level in this library.
- class adafruit_fram.FRAM_I2C(i2c_bus: I2C, address: int = 80, write_protect: bool = False, wp_pin: DigitalInOut | None = None)¶
I2C class for FRAM.
- Parameters:
i2c_bus (I2C) – The I2C bus the FRAM is connected to.
address (int) – I2C address of FRAM. Default address is
0x50
.write_protect (bool) – Turns on/off initial write protection. Default is
False
.wp_pin – (Optional) Physical pin connected to the
WP
breakout pin. Must be adigitalio.DigitalInOut
object.
- property write_protected: bool¶
The status of write protection. Default value on initialization is
False
.When a
WP
pin is supplied during initialization, or usingwrite_protect_pin
, the status is tied to that pin and enables hardware-level protection.When no
WP
pin is supplied, protection is only at the software level in this library.
- class adafruit_fram.FRAM_SPI(spi_bus: SPI, spi_cs: DigitalInOut, write_protect: bool = False, wp_pin: DigitalInOut | None = None, baudrate: int = 100000, max_size: int = 8192)¶
SPI class for FRAM.
- Parameters:
spi_bus (SPI) – The SPI bus the FRAM is connected to.
spi_cs (DigitalInOut) – The SPI CS pin.
write_protect (bool) – Turns on/off initial write protection. Default is
False
.wp_pin – (Optional) Physical pin connected to the
WP
breakout pin. Must be adigitalio.DigitalInOut
object.baudrate (int) – SPI baudrate to use. Default is
1000000
.max_size (int) – Size of FRAM in Bytes. Default is
8192
.
- property write_protected: bool¶
The status of write protection. Default value on initialization is
False
.When a
WP
pin is supplied during initialization, or usingwrite_protect_pin
, the status is tied to that pin and enables hardware-level protection.When no
WP
pin is supplied, protection is only at the software level in this library.