class documentation

class PSRAM(picoware_psram.PSRAM):

View In Hierarchy

MicroPython PSRAM interface with automatic GC-managed objects.

Provides a high-level and low-level interface to PSRAM memory for allocating, managing, and utilizing PSRAM in MicroPython applications.

Methods

  • is_ready
    Check if PSRAM is initialized and ready for use.
  • size
    Get total PSRAM memory size in bytes.
  • test
    Run a PSRAM test to verify functionality.
  • write
    Write data to PSRAM memory at a specific address.
  • write8
    Write an 8-bit value to a specific PSRAM address.
  • write16
    Write a 16-bit value to a specific PSRAM address.
  • write32
    Write a 32-bit value to a specific PSRAM address.
  • write32_bulk
    Write multiple 32-bit values to PSRAM starting at a specific address.
  • read
    Read data from PSRAM memory at a specific address.
  • read8
    Read an 8-bit value from a specific PSRAM address.
  • read16
    Read a 16-bit value from a specific PSRAM address.
  • read32
    Read a 32-bit value from a specific PSRAM address.
  • read32_bulk
    Read multiple 32-bit values from PSRAM starting at a specific address.
  • fill
    Fill a region of PSRAM memory with a specific byte value.
  • copy
    Copy data from one PSRAM location to another.
  • alloc_object
    Allocate PSRAM memory for a Python object and return a PSRAMObject
  • get_next_free
    Get the next free PSRAM memory address.
  • mem_free
    Get the amount of free PSRAM memory in bytes.
  • collect
    Compact PSRAM free list, Returns the total moved.
  • malloc
    Allocate PSRAM memory for the given data and return a PSRAMObject.
  • memcpy
    Copy memory from one PSRAM location to another.
  • memset
    Set memory region to a specific byte value using DMA-optimized fill.
Method from_file Load data from a file into PSRAM memory.
Method malloc Allocate PSRAM memory for the given data.
Method memcpy Copy memory from one PSRAM location to another.
Method memset Set a memory region to a specific byte value.
Property free_heap_size Get free PSRAM memory in bytes.
Property next_free_addr Get the next free PSRAM memory address.
Property total_heap_size Get total PSRAM memory size in bytes.
Property used_heap_size Get used PSRAM memory in bytes.
def from_file(self, storage, addr, file_path, chunk_size: int = 2048) -> int:

Load data from a file into PSRAM memory.

Parameters
storage:objectStorage instance used to read the file.
addr:intPSRAM address to write the data to.
file_path:strPath of the file to load.
chunk_size:intNumber of bytes to read per chunk. Defaults to 2048.
Returns
intThe size of the data loaded, or -1 if the file could not be opened.
def malloc(self, data) -> PSRAMObject:

Allocate PSRAM memory for the given data.

Parameters
data:objectThe Python object to store in PSRAM.
Returns
PSRAMObjectA PSRAMObject wrapping the data.
def memcpy(self, dest_addr, src_addr, length):

Copy memory from one PSRAM location to another.

Parameters
dest_addr:intDestination PSRAM address.
src_addr:intSource PSRAM address.
length:intNumber of bytes to copy.
def memset(self, addr, value, length):

Set a memory region to a specific byte value.

Parameters
addr:intPSRAM address of the region.
value:intByte value to fill with.
length:intNumber of bytes to fill.
@property
free_heap_size: int =

Get free PSRAM memory in bytes.

@property
next_free_addr: int =

Get the next free PSRAM memory address.

@property
total_heap_size: int =

Get total PSRAM memory size in bytes.

@property
used_heap_size: int =

Get used PSRAM memory in bytes.