Skip to content

Commit 21e0f0e

Browse files
authored
Merge pull request #334 from fpistm/eeprom_lib
Update EEPROM library
2 parents 8de2139 + 84bee6f commit 21e0f0e

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

libraries/EEPROM/library.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name=EEPROM
2-
version=2.0
2+
version=2.0.1
33
author=Arduino, Christopher Andrews
4-
maintainer=Arduino <[email protected]>
5-
sentence=Enables reading and writing to the permanent board storage. For all Arduino boards BUT Arduino DUE and Arduino ZERO.
6-
paragraph=
4+
maintainer=stm32duino
5+
sentence=Enables reading and writing to the permanent board storage.
6+
paragraph=This library allows to read and write data in a memory type, the EEPROM, that keeps its content also when the board is powered off. The amount of EEPROM available depends on the microcontroller type.
77
category=Data Storage
88
url=http://www.arduino.cc/en/Reference/EEPROM
99
architectures=stm32

libraries/EEPROM/EEPROM.h renamed to libraries/EEPROM/src/EEPROM.h

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
/***
2727
EERef class.
28-
28+
2929
This object references an EEPROM cell.
3030
Its purpose is to mimic a typical byte of RAM, however its storage is the EEPROM.
3131
This class has an overhead of two bytes, similar to storing a pointer to an EEPROM cell.
@@ -35,11 +35,11 @@ struct EERef{
3535

3636
EERef( const int index )
3737
: index( index ) {}
38-
38+
3939
//Access/read members.
4040
uint8_t operator*() const { return eeprom_read_byte( /*(uint8_t*)*/ index ); }
41-
operator const uint8_t() const { return **this; }
42-
41+
operator uint8_t() const { return **this; }
42+
4343
//Assignment/write members.
4444
EERef &operator=( const EERef &ref ) { return *this = *ref; }
4545
EERef &operator=( uint8_t in ) { return eeprom_write_byte( /*(uint8_t*)*/ index, in ), *this; }
@@ -53,47 +53,47 @@ struct EERef{
5353
EERef &operator |=( uint8_t in ) { return *this = **this | in; }
5454
EERef &operator <<=( uint8_t in ) { return *this = **this << in; }
5555
EERef &operator >>=( uint8_t in ) { return *this = **this >> in; }
56-
56+
5757
EERef &update( uint8_t in ) { return in != *this ? *this = in : *this; }
58-
58+
5959
/** Prefix increment/decrement **/
6060
EERef& operator++() { return *this += 1; }
6161
EERef& operator--() { return *this -= 1; }
62-
62+
6363
/** Postfix increment/decrement **/
64-
uint8_t operator++ (int){
64+
uint8_t operator++ (int){
6565
uint8_t ret = **this;
6666
return ++(*this), ret;
6767
}
6868

69-
uint8_t operator-- (int){
69+
uint8_t operator-- (int){
7070
uint8_t ret = **this;
7171
return --(*this), ret;
7272
}
73-
73+
7474
int index; //Index of current EEPROM cell.
7575
};
7676

7777
/***
7878
EEPtr class.
79-
79+
8080
This object is a bidirectional pointer to EEPROM cells represented by EERef objects.
81-
Just like a normal pointer type, this can be dereferenced and repositioned using
81+
Just like a normal pointer type, this can be dereferenced and repositioned using
8282
increment/decrement operators.
8383
***/
8484

8585
struct EEPtr{
8686

8787
EEPtr( const int index )
8888
: index( index ) {}
89-
90-
operator const int() const { return index; }
89+
90+
operator int() const { return index; }
9191
EEPtr &operator=( int in ) { return index = in, *this; }
92-
92+
9393
//Iterator functionality.
9494
bool operator!=( const EEPtr &ptr ) { return index != ptr.index; }
9595
EERef operator*() { return index; }
96-
96+
9797
/** Prefix & Postfix increment/decrement **/
9898
EEPtr& operator++() { return ++index, *this; }
9999
EEPtr& operator--() { return --index, *this; }
@@ -105,7 +105,7 @@ struct EEPtr{
105105

106106
/***
107107
EEPROMClass class.
108-
108+
109109
This object represents the entire EEPROM space.
110110
It wraps the functionality of EEPtr and EERef into a basic interface.
111111
This class is also 100% backwards compatible with earlier Arduino core releases.
@@ -118,20 +118,20 @@ struct EEPROMClass{
118118
uint8_t read( int idx ) { return EERef( idx ); }
119119
void write( int idx, uint8_t val ) { (EERef( idx )) = val; }
120120
void update( int idx, uint8_t val ) { EERef( idx ).update( val ); }
121-
121+
122122
//STL and C++11 iteration capability.
123123
EEPtr begin() { return 0x00; }
124124
EEPtr end() { return length(); } //Standards requires this to be the item after the last valid entry. The returned pointer is invalid.
125125
uint16_t length() { return E2END; }
126-
126+
127127
//Functionality to 'get' and 'put' objects to and from EEPROM.
128128
template< typename T > T &get( int idx, T &t ){
129129
EEPtr e = idx;
130130
uint8_t *ptr = (uint8_t*) &t;
131131
for( int count = sizeof(T) ; count ; --count, ++e ) *ptr++ = *e;
132132
return t;
133133
}
134-
134+
135135
template< typename T > const T &put( int idx, const T &t ){
136136
EEPtr e = idx;
137137
const uint8_t *ptr = (const uint8_t*) &t;

0 commit comments

Comments
 (0)