forked from pa-pa/AskSinPP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Storage.cpp
37 lines (30 loc) · 932 Bytes
/
Storage.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//- -----------------------------------------------------------------------------------------------------------------------
// AskSin++
// 2016-10-31 papa Creative Commons - http:https://creativecommons.org/licenses/by-nc-sa/3.0/de/
//- -----------------------------------------------------------------------------------------------------------------------
#include "Storage.h"
namespace as {
Storage storage;
bool Storage::setup (uint16_t checksum) {
bool firststart = false;
uint32_t mem;
getData(0x0,(uint8_t*)&mem,4);
uint32_t magic = 0xCAFE0000 | checksum;
if(magic != mem) {
DHEXLN(mem);
DPRINT(F("Init Storage: "));
DHEXLN(magic);
// init eeprom
setData(0x0,(uint8_t*)&magic,4);
firststart = true;
}
return firststart;
}
void Storage::dump (uint16_t start, uint16_t num) {
for( uint16_t i=0; i<num; ++i ) {
DHEX(getByte(start + i));
DPRINT(F(" "));
}
DPRINT(F("\n"));
}
}