I want to reserve a space in the internal flash memory of my microcontroller (STM32L4) to store the latest 100 measured values by a sensor (in a circular FIFO Fashion) and be able to load them again when I restart the device.
My logic looks like this:
typedef struct
{
uint16_t measuredValue;
DateTime_t timestamp;
}MeasuredValue_t;
// ..
// ..
MeasuredValue_t measuredValue;
// ..
// ..
while(1)
{
GetValue(&measuredValue); // Read values (Sensor value + timestamp from the RTC)
Flash_Fifo_Push(measuredValue); // Push to buffer
Sleep(); // Sleep until the next cycle
}
My questions are:
- How to reserve this space in the linker file of my microcontroller (ARM Cortex-M4 2MB flash)?
- How to implement the circular FIFO fashion?