#include "AccessoriesCircularBuffer.hpp"
Public Member Functions | |
AccessoriesCircularBuffer () | |
int | begin (int inStartListPos, byte inItemSize, byte inReplicaNumber) |
int | getStartRead () |
int | startWrite () |
void | clear () const |
This class implements the Atmel solution to avoid writing in EEPROM always in the same area to improve lifetime of this memory : a Circular Buffer. See http://www.atmel.com/images/doc2526.pdf . Part of the pdf file :
By having a circular buffer (O-buffer) in EEPROM it is possible to increase the number of times that a parameter can be stored in EEPROM. If the buffer has two levels the number of times that the parameter can be stored is twice the endurance of one single EEPROM cell: 200 k erase/writes. By using this approach it is possible to increase the number of times a parameter can be stored by increasing the O-buffer size. In other word, the idea is to distribute the storage of the parameter over several EEPROM locations to achieve increased parameter storage endurance. When using the Obuffer approach the parameter storage endurance equal the number of memory locations used in the O-buffer times the endurance of a single EEPROM location.
A circular buffer is a way to reduce the use of each EEPROM cell, and improve life time of the full EEPROM memory. An index of bytes is stored at the beginning of the area. Each index represents a data area.
|0|1|2|3|4||---0---|---1---|---2---|---3---|---4---|
Definition at line 29 of file AccessoriesCircularBuffer.hpp.
|
inline |
Basic constructor.
Definition at line 38 of file AccessoriesCircularBuffer.hpp.
|
inline |
Initialize the instance.
inStartListPos | EEPROM address of the begginning of the memory used for the storage |
inItemSize | Size in bytes of one item to save. |
inReplicaNumber | Number of copies of the element can be reserved for the buffer. 2 is a minimum, 255 a maximum. |
Definition at line 46 of file AccessoriesCircularBuffer.hpp.
void AccessoriesCircularBuffer::clear | ( | ) | const |
Fill with 0s the area reserved for the buffer. Use with care !
int AccessoriesCircularBuffer::getStartRead | ( | ) |
If data cannot be loaded with a single call to a 'read', this function can be called to know where to read the current good element.
int AccessoriesCircularBuffer::startWrite | ( | ) |
If data cannot be stored with a single call to a 'write', this function can be called to prepare the saving of the next good element.