-
Notifications
You must be signed in to change notification settings - Fork 0
/
avr-eeprom.h
84 lines (84 loc) · 2.95 KB
/
avr-eeprom.h
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//-----------------------------------------------------------------------------
#ifndef EEPROM_H
#define EEPROM_H
//----------------------------------------------------------------------------
#include <avr/eeprom.h>
//----------------------------------------------------------------------------
#define EEPROG __attribute__((section(".eeprog")))
#define EEBYTE _EEBYTE __attribute__((section(".eeprom")))
#define EEWORD _EEWORD __attribute__((section(".eeprom")))
#define EEDWORD _EEDWORD __attribute__((section(".eeprom")))
#define EEQWORD _EEQWORD __attribute__((section(".eeprom")))
//----------------------------------------------------------------------------
class _EEBYTE
{
public:
BYTE data;
template <typename Type>
void operator = (const Type& new_value)
{ eeprom_write_byte(&data, (BYTE) new_value); }
void operator = (const _EEBYTE& new_value);
_EEBYTE* operator & ();
bool operator == (const int cmp_value);
BYTE operator ++ (const int);
BYTE operator -- (const int);
BYTE operator += (const BYTE& value);
BYTE operator -= (const BYTE& value);
operator BYTE();
};
//-----------------------------------------------------------------------------
class _EEWORD
{
public:
WORD data;
template <typename Type>
void operator = (const Type& new_value)
{ eeprom_write_word(&data, (WORD) new_value); }
void operator = (const _EEWORD& new_value);
_EEWORD* operator & ();
bool operator == (const int cmp_value);
WORD operator ++ (const int);
WORD operator -- (const int);
WORD operator += (const WORD& value);
WORD operator -= (const WORD& value);
operator WORD();
};
//-----------------------------------------------------------------------------
class _EEDWORD
{
public:
DWORD data;
template <typename Type>
void operator = (const Type& new_value)
{ eeprom_write_dword(&data, (DWORD) new_value); }
void operator = (const _EEDWORD& new_value);
_EEDWORD* operator & ();
bool operator == (const DWORD& cmp_value);
DWORD operator ++ (const int);
DWORD operator -- (const int);
DWORD operator += (const DWORD& value);
DWORD operator -= (const DWORD& value);
operator DWORD();
};
//-----------------------------------------------------------------------------
class _EEQWORD
{
private:
QWORD eeprom_read_qword(const QWORD* ptr);
void eeprom_write_qword(QWORD* ptr, const QWORD& value);
public:
QWORD data;
template <typename Type>
void operator = (const Type& new_value)
{ eeprom_write_qword(&data, (QWORD) new_value); }
void operator = (const _EEQWORD& new_value);
_EEQWORD* operator & ();
bool operator == (const DWORD& cmp_value);
DWORD operator ++ (const int);
DWORD operator -- (const int);
DWORD operator += (const DWORD& value);
DWORD operator -= (const DWORD& value);
operator QWORD();
};
//-----------------------------------------------------------------------------
#endif