1 #ifndef VIRTMEM_SPIRAM_ALLOC_H 
    2 #define VIRTMEM_SPIRAM_ALLOC_H 
   12 #include <serialram.h> 
   28 template <
typename Properties=DefaultAllocProperties>
 
   33     SerialRam::ESPISpeed SPISpeed;
 
   38         serialRAM.begin(largeAddressing, chipSelect, SPISpeed);
 
   49         serialRAM.
read((
char *)data, offset, size);
 
   56         serialRAM.write((
const char *)data, offset, size);
 
   71         largeAddressing(la), chipSelect(cs), SPISpeed(s) { this->
setPoolSize(ps); }
 
   89         largeAddressing = la; chipSelect = cs; SPISpeed = s;
 
  134 template <const SPIRamConfig *SPIChips, 
size_t chipAmount, 
typename Properties=DefaultAllocProperties>
 
  137     SerialRam serialRAM[chipAmount];
 
  141         for (uint8_t i=0; i<chipAmount; ++i)
 
  142             serialRAM[i].begin(SPIChips[i].largeAddressing, SPIChips[i].chipSelect, SPIChips[i].speed);
 
  147         for (uint8_t i=0; i<chipAmount; ++i)
 
  155         for (uint8_t i=0; i<chipAmount; ++i)
 
  157             const VPtrNum endptr = startptr + SPIChips[i].size;
 
  158             if (offset >= startptr && offset < endptr)
 
  160                 const VPtrNum p = offset - startptr; 
 
  161                 const VPtrSize sz = private_utils::minimal(size, SPIChips[i].size - p);
 
  162                 serialRAM[i].read((
char *)data, p, sz);
 
  168                 data = (
char *)data + sz;
 
  180         for (uint8_t i=0; i<chipAmount; ++i)
 
  182             const VPtrNum endptr = startptr + SPIChips[i].size;
 
  183             if (offset >= startptr && offset < endptr)
 
  185                 const VPtrNum p = offset - startptr; 
 
  186                 const VPtrSize sz = private_utils::minimal(size, SPIChips[i].size - p);
 
  187                 serialRAM[i].write((
const char *)data, p, sz);
 
  193                 data = (
const char *)data + sz;
 
  211         for (uint8_t i=0; i<chipAmount; ++i)
 
  212             ps += SPIChips[i].size;
 
  228 #endif // VIRTMEM_SPIRAM_ALLOC_H 
contains all code from virtmem 
Definition: base_alloc.cpp:22
SPIRAMVAllocP(VPtrSize ps, bool la, uint8_t cs, SerialRam::ESPISpeed s)
Constructs (but not initializes) the allocator. 
Definition: spiram_alloc.h:70
SerialRam::ESPISpeed speed
SPI speed to be used: SerialRam::SPEED_FULL, SerialRam::SPEED_HALF or SerialRam::SPEED_QUARTER. 
Definition: spiram_alloc.h:104
Base template class for virtual memory allocators. 
Definition: alloc.h:28
SPIRAMVAllocP(VPtrSize ps)
Constructs (but not initializes) the allocator. 
Definition: spiram_alloc.h:77
void setPoolSize(VPtrSize ps)
Sets the total size of the memory pool. 
Definition: base_alloc.h:155
uint32_t size
Amount of bytes this chip can hold. 
Definition: spiram_alloc.h:102
uint32_t VPtrNum
Numeric type used to store raw virtual pointer addresses. 
Definition: base_alloc.h:21
MultiSPIRAMVAllocP(void)
Definition: spiram_alloc.h:208
This struct is used to configure each SRAM chip used by a MultiSPIRAMVAllocP allocator. 
Definition: spiram_alloc.h:99
virtual memory class header 
uint32_t VPtrSize
Numeric type used to store the size of a virtual memory block. 
Definition: base_alloc.h:22
SPIRAMVAllocP(void)
Constructs (but not initializes) the allocator. 
Definition: spiram_alloc.h:78
bool largeAddressing
Does this chip needs large addressing (true if size >= 1 Mbit) 
Definition: spiram_alloc.h:101
void * read(VPtrNum p, VPtrSize size)
Reads a raw block of (virtual) memory. 
Definition: base_alloc.cpp:724
Virtual memory allocator that uses SPI (serial) RAM (i.e. the 23LC series from Microchip) as memory p...
Definition: spiram_alloc.h:29
uint8_t chipSelect
Pin assigned as chip select (CS) for this chip. 
Definition: spiram_alloc.h:103
Virtual allocator that uses multiple SRAM chips (i.e. 23LC series from Microchip) as memory pool...
Definition: spiram_alloc.h:135
void setSettings(bool la, uint8_t cs, SerialRam::ESPISpeed s)
Configures the allocator. 
Definition: spiram_alloc.h:87
SPIRAMVAllocP SPIRAMVAlloc
Shortcut to SPIRAMVAllocP with default template arguments. 
Definition: spiram_alloc.h:93