Skip to content

Commit 0dcd4b2

Browse files
committed
Revert "EEPROM library to the new format"
This reverts commits: 3223d4fdca32ec03de4a3a2a0c22f2d40de5f374 77f8dd63ab102ab5d2929ac4edd5c00ae9d70493
1 parent a5d1990 commit 0dcd4b2

File tree

6 files changed

+207
-0
lines changed

6 files changed

+207
-0
lines changed

libraries/EEPROM/EEPROM.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
EEPROM.cpp - EEPROM library
3+
Copyright (c) 2006 David A. Mellis. All right reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
/******************************************************************************
21+
* Includes
22+
******************************************************************************/
23+
24+
#include <avr/eeprom.h>
25+
#include "Arduino.h"
26+
#include "EEPROM.h"
27+
28+
/******************************************************************************
29+
* Definitions
30+
******************************************************************************/
31+
32+
/******************************************************************************
33+
* Constructors
34+
******************************************************************************/
35+
36+
/******************************************************************************
37+
* User API
38+
******************************************************************************/
39+
40+
uint8_t EEPROMClass::read(int address)
41+
{
42+
return eeprom_read_byte((unsigned char *) address);
43+
}
44+
45+
void EEPROMClass::write(int address, uint8_t value)
46+
{
47+
eeprom_write_byte((unsigned char *) address, value);
48+
}
49+
50+
EEPROMClass EEPROM;

libraries/EEPROM/EEPROM.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
EEPROM.h - EEPROM library
3+
Copyright (c) 2006 David A. Mellis. All right reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
#ifndef EEPROM_h
21+
#define EEPROM_h
22+
23+
#include <inttypes.h>
24+
25+
class EEPROMClass
26+
{
27+
public:
28+
uint8_t read(int);
29+
void write(int, uint8_t);
30+
};
31+
32+
extern EEPROMClass EEPROM;
33+
34+
#endif
35+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* EEPROM Clear
3+
*
4+
* Sets all of the bytes of the EEPROM to 0.
5+
* This example code is in the public domain.
6+
7+
*/
8+
9+
#include <EEPROM.h>
10+
11+
void setup()
12+
{
13+
// write a 0 to all 512 bytes of the EEPROM
14+
for (int i = 0; i < 512; i++)
15+
EEPROM.write(i, 0);
16+
17+
// turn the LED on when we're done
18+
digitalWrite(13, HIGH);
19+
}
20+
21+
void loop()
22+
{
23+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* EEPROM Read
3+
*
4+
* Reads the value of each byte of the EEPROM and prints it
5+
* to the computer.
6+
* This example code is in the public domain.
7+
*/
8+
9+
#include <EEPROM.h>
10+
11+
// start reading from the first byte (address 0) of the EEPROM
12+
int address = 0;
13+
byte value;
14+
15+
void setup()
16+
{
17+
// initialize serial and wait for port to open:
18+
Serial.begin(9600);
19+
while (!Serial) {
20+
; // wait for serial port to connect. Needed for Leonardo only
21+
}
22+
}
23+
24+
void loop()
25+
{
26+
// read a byte from the current address of the EEPROM
27+
value = EEPROM.read(address);
28+
29+
Serial.print(address);
30+
Serial.print("\t");
31+
Serial.print(value, DEC);
32+
Serial.println();
33+
34+
// advance to the next address of the EEPROM
35+
address = address + 1;
36+
37+
// there are only 512 bytes of EEPROM, from 0 to 511, so if we're
38+
// on address 512, wrap around to address 0
39+
if (address == 512)
40+
address = 0;
41+
42+
delay(500);
43+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* EEPROM Write
3+
*
4+
* Stores values read from analog input 0 into the EEPROM.
5+
* These values will stay in the EEPROM when the board is
6+
* turned off and may be retrieved later by another sketch.
7+
*/
8+
9+
#include <EEPROM.h>
10+
11+
// the current address in the EEPROM (i.e. which byte
12+
// we're going to write to next)
13+
int addr = 0;
14+
15+
void setup()
16+
{
17+
}
18+
19+
void loop()
20+
{
21+
// need to divide by 4 because analog inputs range from
22+
// 0 to 1023 and each byte of the EEPROM can only hold a
23+
// value from 0 to 255.
24+
int val = analogRead(0) / 4;
25+
26+
// write the value to the appropriate byte of the EEPROM.
27+
// these values will remain there when the board is
28+
// turned off.
29+
EEPROM.write(addr, val);
30+
31+
// advance to the next address. there are 512 bytes in
32+
// the EEPROM, so go back to 0 when we hit 512.
33+
addr = addr + 1;
34+
if (addr == 512)
35+
addr = 0;
36+
37+
delay(100);
38+
}

libraries/EEPROM/keywords.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#######################################
2+
# Syntax Coloring Map For Ultrasound
3+
#######################################
4+
5+
#######################################
6+
# Datatypes (KEYWORD1)
7+
#######################################
8+
9+
EEPROM KEYWORD1
10+
11+
#######################################
12+
# Methods and Functions (KEYWORD2)
13+
#######################################
14+
15+
#######################################
16+
# Constants (LITERAL1)
17+
#######################################
18+

0 commit comments

Comments
 (0)