Skip to content
vlad0815Public

About

FM25V10 F-RAM driver for MicroPython boards

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

fm25v10

Fm25v10 Objects

class Fm25v10()

FM25V10 F-RAM driver for MicroPython-based boards.

The class can be used in two modes:

  1. Random access mode
    In this mode, read and write operations use absolute addressing.
    Addresses beyond 0x1FFFF will raise an IndexError exception.
    If a read/write operation exceeds the maximum memory size, it automatically wraps around to address 0x00 (hardware behavior).

  2. Ring buffer mode
    In this mode, omit the address argument for read/write operations.
    An internal address pointer tracks the current position. The pointer can be moved using the seek and tell methods.
    Additionally, it is possible to define a protected area that will not be touched in this mode.
    Only random access mode can read from or write to this area.
    To enable it, set the protectedAreaSize argument in the constructor. This value defines the size of the protected area,
    which will be placed at the beginning of memory (address 0x00).
    While wrapping is handled in hardware, pointer position management is performed in software.

Both modes can be mixed. This is required for writing to the protected area (if defined).

LAST_ADDR

Last accessible address (0x1FFFF) of the FM25V10 F-RAM

__init__

def __init__(spiPort: int,
             spiMosiPin: int,
             spiMisoPin: int,
             spiClockPin: int,
             spiCableSelectPin: int,
             spiBaudRate: int = 10_000_000,
             protectedAreaSize: int = None)

Initializes the FM25V10 F-RAM driver.

Args: spiPort (int): The SPI bus/port number to use.
spiMosiPin (int): GPIO pin number for MOSI (Master Out Slave In).
spiMisoPin (int): GPIO pin number for MISO (Master In Slave Out).
spiClockPin (int): GPIO pin number for the SPI clock.
spiCableSelectPin (int): GPIO pin number for chip select (CS).
spiBaudRate (int, optional): SPI bus speed in Hz. Defaults to 10_000_000.
protectedAreaSize (int, optional): Size of the protected memory area (in bytes).
If set, this area starts at address 0x00 and is accessible only in random access mode.

seekWrite

def seekWrite(addr)

Sets the address for the next relative write operation.

If the given address collides with the protected area, it is adjusted to point directly behind the protected area.

Args: addr (int): The address to set for the next write.

tellWrite

def tellWrite()

Returns the address of the next write operation.

Returns: int: The current write pointer position.

seekRead

def seekRead(addr)

Sets the address for the next relative read operation.

If the given address collides with the protected area, it is adjusted to point directly behind the protected area.

Args: addr (int): The address to set for the next read.

tellRead

def tellRead()

Returns the address of the next read operation.

Returns: int: The current read pointer position.

write

def write(data: bytearray, addr: int = None)

Writes data in absolute or relative mode.

  • Absolute write: ignores the protected area. Data is written exactly at addr.
  • Relative write: starts at the current write pointer.
  • Pointer automatically skips protected area.
  • Pointer wraps to protectedAreaSize after reaching the maximum memory address.

Args: data (bytearray): The data to write. addr (int, optional): Absolute address to write to. If None, writes relative to the current pointer.

read

def read(length: int, addr: int = None) -> bytearray

Reads data in absolute or relative mode.

  • Absolute read: reads exactly at addr, ignoring protected area.
  • Relative read: starts at the current read pointer.
  • Pointer skips protected area.
  • Pointer wraps to protectedAreaSize after reaching the maximum memory address.

Args: length (int): Number of bytes to read. addr (int, optional): Absolute address to read from. If None, reads relative to the current pointer.

Returns: bytearray: The read data.

About

FM25V10 F-RAM driver for MicroPython boards

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages