adafruit_fram

CircuitPython/Python library to support the I2C and SPI FRAM Breakouts.

  • Author(s): Michael Schroeder

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_fram.FRAM(max_size, write_protect=False, wp_pin=None)

Driver base for the FRAM Breakout.

__getitem__(address)

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__()

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, value)

Write the value at the given starting index.

# write single index
fram[0] = 1

# write values 0 thru 4 with a list
fram[0] = [0,1,2,3]
write_protected

The status of write protection. Default value on initialization is False.

When a WP pin is supplied during initialization, or using write_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.

write_wraparound

Determines if sequential writes will wrapaound highest memory address (len(FRAM) - 1) address. If False, and a requested write will extend beyond the maximum size, an exception is raised.

class adafruit_fram.FRAM_I2C(i2c_bus, address=80, write_protect=False, wp_pin=None)

I2C class for FRAM.

Param:~busio.I2C i2c_bus: The I2C bus the FRAM is connected to.
Param:int address: I2C address of FRAM. Default address is 0x50.
Param:bool write_protect: Turns on/off initial write protection. Default is False.
Param:wp_pin: (Optional) Physical pin connected to the WP breakout pin. Must be a digitalio.DigitalInOut object.
write_protected

The status of write protection. Default value on initialization is False.

When a WP pin is supplied during initialization, or using write_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_cs, write_protect=False, wp_pin=None, baudrate=100000, max_size=8192)

SPI class for FRAM.

Param:

~busio.SPI spi_bus: The SPI bus the FRAM is connected to.

Param:

~digitalio.DigitalInOut spi_cs: The SPI CS pin.

Param:

bool write_protect: Turns on/off initial write protection. Default is False.

Param:

wp_pin: (Optional) Physical pin connected to the WP breakout pin. Must be a digitalio.DigitalInOut object.

Parameters:
  • baudrate (int) – SPI baudrate to use. Default is 1000000.
  • max_size (int) – Size of FRAM in Bytes. Default is 8192.
write_protected

The status of write protection. Default value on initialization is False.

When a WP pin is supplied during initialization, or using write_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.