virtmem
virtual memory library for Arduino
virtmem::SPIRAMVAllocP< Properties > Class Template Reference

Virtual memory allocator that uses SPI (serial) RAM (i.e. the 23LC series from Microchip) as memory pool. More...

#include <spiram_alloc.h>

Inheritance diagram for virtmem::SPIRAMVAllocP< Properties >:
virtmem::VAlloc< Properties, SPIRAMVAllocP< Properties > > virtmem::BaseVAlloc

Public Member Functions

 SPIRAMVAllocP (VPtrSize ps, bool la, uint8_t cs, SerialRam::ESPISpeed s)
 Constructs (but not initializes) the allocator. More...
 
 SPIRAMVAllocP (VPtrSize ps)
 Constructs (but not initializes) the allocator. More...
 
 SPIRAMVAllocP (void)
 Constructs (but not initializes) the allocator.
 
void setSettings (bool la, uint8_t cs, SerialRam::ESPISpeed s)
 Configures the allocator. More...
 
- Public Member Functions inherited from virtmem::VAlloc< Properties, SPIRAMVAllocP< Properties > >
VPtr< T, SPIRAMVAllocP< Properties > > alloc (VPtrSize size=sizeof(T))
 Allocates memory from the linked virtual memory allocator. More...
 
void free (VPtr< T, SPIRAMVAllocP< Properties > > &p)
 Frees a block of virtual memory. More...
 
VPtr< T, SPIRAMVAllocP< Properties > > newClass (VPtrSize size=sizeof(T))
 Allocates memory and constructs data type. More...
 
void deleteClass (VPtr< T, SPIRAMVAllocP< Properties > > &p)
 Destructs data type and frees memory. More...
 
VPtr< T, SPIRAMVAllocP< Properties > > newArray (VPtrSize elements)
 Allocates and constructs an array of objects. More...
 
void deleteArray (VPtr< T, SPIRAMVAllocP< Properties > > &p)
 Destructs and frees an array of objects. More...
 
- Public Member Functions inherited from virtmem::BaseVAlloc
void start (void)
 Starts the allocator. More...
 
void stop (void)
 Deinitializes the allocator. More...
 
void setPoolSize (VPtrSize ps)
 Sets the total size of the memory pool. More...
 
VPtrNum allocRaw (VPtrSize size)
 Allocates a piece of raw (virtual) memory. More...
 
void freeRaw (VPtrNum ptr)
 Frees a memory block for re-usage. More...
 
void * read (VPtrNum p, VPtrSize size)
 Reads a raw block of (virtual) memory. More...
 
void write (VPtrNum p, const void *d, VPtrSize size)
 Writes a piece of raw data to (virtual) memory. More...
 
void flush (void)
 Synchronizes all big memory pages. More...
 
void clearPages (void)
 Synchronizes and clears all big memory pages. More...
 
uint8_t getFreeBigPages (void) const
 
uint8_t getUnlockedSmallPages (void) const
 Returns amount of small pages which are not locked.
 
uint8_t getUnlockedMediumPages (void) const
 Returns amount of medium pages which are not locked.
 
uint8_t getUnlockedBigPages (void) const
 Returns amount of big pages which are not locked.
 
uint8_t getSmallPageCount (void) const
 Returns total amount of small pages.
 
uint8_t getMediumPageCount (void) const
 Returns total amount of medium pages.
 
uint8_t getBigPageCount (void) const
 Returns total amount of big pages.
 
VirtPageSize getSmallPageSize (void) const
 Returns the size of a small page.
 
VirtPageSize getMediumPageSize (void) const
 Returns the size of a medium page.
 
VirtPageSize getBigPageSize (void) const
 Returns the size of a big page.
 
VPtrSize getPoolSize (void) const
 Returns the size the memory pool. More...
 
VPtrSize getMemUsed (void) const
 Returns total memory used.
 
VPtrSize getMaxMemUsed (void) const
 Returns the maximum memory used so far.
 
uint32_t getBigPageReads (void) const
 Returns the times big pages were read (swapped).
 
uint32_t getBigPageWrites (void) const
 Returns the times big pages written (synchronized).
 
uint32_t getBytesRead (void) const
 Returns the amount of bytes read as a result of page swaps.
 
uint32_t getBytesWritten (void) const
 Returns the amount of bytes written as a results of page swaps.
 
void resetStats (void)
 Reset all statistics. Called by start()
 

Additional Inherited Members

- Public Types inherited from virtmem::VAlloc< Properties, SPIRAMVAllocP< Properties > >
using VPtr = virtmem::VPtr< T, SPIRAMVAllocP< Properties > >
 
- Static Public Member Functions inherited from virtmem::VAlloc< Properties, SPIRAMVAllocP< Properties > >
static VAllocgetInstance (void)
 Returns a pointer to the instance of the class. More...
 
- Protected Member Functions inherited from virtmem::BaseVAlloc
void writeZeros (VPtrNum start, VPtrSize n)
 Writes zeros to raw virtual memory. Can be used to initialize the memory pool. More...
 

Detailed Description

template<typename Properties = DefaultAllocProperties>
class virtmem::SPIRAMVAllocP< Properties >

Virtual memory allocator that uses SPI (serial) RAM (i.e. the 23LC series from Microchip) as memory pool.

This class uses an external SRAM chip as a memory pool. Interfacing occurs through the serialram library and must be installed in order to use this allocator.

Template Parameters
PropertiesAllocator properties, see DefaultAllocProperties
See also
Using virtual memory (tutorial) and MultiSPIRAMVAllocP
Examples:
spiram_simple.ino.

Constructor & Destructor Documentation

template<typename Properties = DefaultAllocProperties>
virtmem::SPIRAMVAllocP< Properties >::SPIRAMVAllocP ( VPtrSize  ps,
bool  la,
uint8_t  cs,
SerialRam::ESPISpeed  s 
)
inline

Constructs (but not initializes) the allocator.

Parameters
psTotal amount of bytes of the memory pool (i.e. the size of the SRAM chip)
latrue if large addressing (chipsize >= 1mbit) should be used
csChip select (CS) pin connected to the SRAM chip
sSPI speed (SerialRam::SPEED_FULL, SerialRam::SPEED_HALF or SerialRam::SPEED_QUARTER)
See also
setSettings and setPoolSize
template<typename Properties = DefaultAllocProperties>
virtmem::SPIRAMVAllocP< Properties >::SPIRAMVAllocP ( VPtrSize  ps)
inline

Constructs (but not initializes) the allocator.

Parameters
psTotal amount of bytes of the memory pool (i.e. the size of the SRAM chip)
See also
setSettings and setPoolSize

Member Function Documentation

template<typename Properties = DefaultAllocProperties>
void virtmem::SPIRAMVAllocP< Properties >::setSettings ( bool  la,
uint8_t  cs,
SerialRam::ESPISpeed  s 
)
inline

Configures the allocator.

See SPIRAMVAlloc::SPIRAMVAlloc for a description of the parameters.

Note
This function should only be called if the allocator is not initialized.

The documentation for this class was generated from the following file: