| 141 | |
| 142 | |
| 143 | bool FRAM_RINGBUFFER::load() |
| 144 | { |
| 145 | uint32_t pos = _start - 20; |
| 146 | uint32_t size = _fram->read32(pos + 0); |
| 147 | uint32_t front = _fram->read32(pos + 4); |
| 148 | uint32_t tail = _fram->read32(pos + 8); |
| 149 | uint32_t count = _fram->read32(pos + 12); |
| 150 | uint32_t checksum = _fram->read32(pos + 16); |
| 151 | // checksum test should be enough. |
| 152 | // optional these are possible |
| 153 | // (_start <= _front) && (_front < _start + _size); |
| 154 | // (_start <= _tail) && (_tail < _start + _size); |
| 155 | _saved = (checksum == size + front + tail + count); |
| 156 | if (_saved) |
| 157 | { |
| 158 | _size = size; |
| 159 | _front = front; |
| 160 | _tail = tail; |
| 161 | _count = count; |
| 162 | } |
| 163 | return _saved; |
| 164 | } |
| 165 | |
| 166 | |
| 167 | void FRAM_RINGBUFFER::wipe() |