This example shows the size and amount of memory pages of an allocator can be configured.
#include <Arduino.h>
#include <SdFat.h>
const int chipSelect = 9;
const uint32_t poolSize = 1024l * 32l;
const int spiSpeed = SPI_FULL_SPEED;
struct AllocProperties
{
static const uint8_t smallPageCount = 4, smallPageSize = 64;
static const uint8_t mediumPageCount = 4, mediumPageSize = 128;
static const uint8_t bigPageCount = 4;
static const uint16_t bigPageSize = 512;
};
SdFat sd;
Alloc valloc(poolSize);
void setup()
{
while (!Serial)
;
Serial.begin(115200);
if (!sd.begin(chipSelect, spiSpeed))
sd.initErrorHalt();
valloc.start();
delay(3000);
}
void loop()
{
*vpi = 42;
Serial.print("*vpi = "); Serial.println(*vpi);
valloc.free(vpi);
delay(1000);
}