193 |
miho |
1 |
// EEPROM.C - knihovna pro pohodlny zapis a cteni promennych do a z pameti |
|
|
2 |
// EEPROM a to pro ruzne typy promennych. |
|
|
3 |
// |
|
|
4 |
// (c)miho 2002 |
|
|
5 |
// |
|
|
6 |
// Historie: |
|
|
7 |
// |
|
|
8 |
// 0.00 Uvodni verze |
|
|
9 |
// 0.01 Formalni zmena |
|
|
10 |
|
|
|
11 |
|
|
|
12 |
// Priklad: |
|
|
13 |
// |
|
|
14 |
// int32 MyInt; // deklarace typu (libovolne delky) |
|
|
15 |
// EE_WR(10, MyInt); // zapis promenne MyInt do EEPROM od adresy 10 |
|
|
16 |
// EE_RD(10, MyInt); // zpetne nacteni promenne MyInt z EEPROM |
|
|
17 |
// |
|
|
18 |
|
|
|
19 |
|
|
|
20 |
// Makro pro jednotne ukladani a vybirani dat (promennych) do a z pameti EEPROM |
|
|
21 |
// |
|
|
22 |
#define EE_WR(EEAddress, Data) EE_Write(EEAddress, &Data, sizeof(Data)) |
|
|
23 |
#define EE_RD(EEAddress, Data) EE_Read (EEAddress, &Data, sizeof(Data)) |
|
|
24 |
|
|
|
25 |
|
|
|
26 |
// Ulozeni promenne do pameti EEPROM |
|
|
27 |
// |
|
|
28 |
void EE_Write(int EEAddress, DataPtr, Len) |
|
|
29 |
{ |
|
|
30 |
do |
|
|
31 |
write_eeprom(EEAddress++, *DataPtr++); |
|
|
32 |
while (--Len); |
|
|
33 |
} |
|
|
34 |
|
|
|
35 |
|
|
|
36 |
// Nacteni promenne z pameti EEPROM |
|
|
37 |
// |
|
|
38 |
void EE_Read(int EEAddress, DataPtr, Len) |
|
|
39 |
{ |
|
|
40 |
do |
|
|
41 |
*DataPtr++ = read_eeprom(EEAddress++); |
|
|
42 |
while (--Len); |
|
|
43 |
} |