Skip to content

Commit 477db1a

Browse files
committed
Initial commit
0 parents  commit 477db1a

File tree

9 files changed

+1873
-0
lines changed

9 files changed

+1873
-0
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

ISSUE_TEMPLATE.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
### Subject of the issue
2+
Describe your issue here. If you reference a datasheet please specify which one and in which section (ie, the protocol manual, section 5.1.2). Additionally, screenshots are easy to paste into github.
3+
4+
### Your workbench
5+
* What development board or microcontroller are you using?
6+
* What version of hardware or breakout board are you using?
7+
* How is the breakout board wired to your microcontroller?
8+
* How is everything being powered?
9+
* Are there any additional details that may help us help you?
10+
11+
### Steps to reproduce
12+
Tell us how to reproduce this issue. Please post stripped down example code demonstrating your issue.
13+
14+
### Expected behavior
15+
Tell us what should happen
16+
17+
### Actual behavior
18+
Tell us what happens instead

LICENSE.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
SparkFun License Information
2+
============================
3+
4+
SparkFun uses two different licenses for our files — one for hardware and one for code.
5+
6+
Hardware
7+
---------
8+
9+
**SparkFun hardware is released under [Creative Commons Share-alike 4.0 International](http://creativecommons.org/licenses/by-sa/4.0/).**
10+
11+
Note: This is a human-readable summary of (and not a substitute for) the [license](http://creativecommons.org/licenses/by-sa/4.0/legalcode).
12+
13+
You are free to:
14+
15+
Share — copy and redistribute the material in any medium or format
16+
Adapt — remix, transform, and build upon the material
17+
for any purpose, even commercially.
18+
The licensor cannot revoke these freedoms as long as you follow the license terms.
19+
Under the following terms:
20+
21+
Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
22+
ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.
23+
No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
24+
Notices:
25+
26+
You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable exception or limitation.
27+
No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material.
28+
29+
30+
Code
31+
--------
32+
33+
**SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT).**
34+
35+
The MIT License (MIT)
36+
37+
Copyright (c) 2016 SparkFun Electronics
38+
39+
Permission is hereby granted, free of charge, to any person obtaining a copy
40+
of this software and associated documentation files (the "Software"), to deal
41+
in the Software without restriction, including without limitation the rights
42+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
43+
copies of the Software, and to permit persons to whom the Software is
44+
furnished to do so, subject to the following conditions:
45+
46+
The above copyright notice and this permission notice shall be included in all
47+
copies or substantial portions of the Software.
48+
49+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
50+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
51+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
52+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
53+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
54+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
55+
SOFTWARE.

README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
SparkFun External EEPROM Arduino Library
2+
===========================================================
3+
4+
![SparkFun Qwiic EEPROM](https://cdn.sparkfun.com//assets/parts/1/7/7/0/1/18355-SparkFun_Qwiic_EEPROM_Breakout_-_512Kbit-01.jpg)
5+
6+
[*SparkFun Qwiic EEPROM (COM-18355)*](https://www.sparkfun.com/products/18355)
7+
8+
A simple-to-use I2C library for talking to any EEPROM. It uses the same template system found in the Arduino EEPROM library so you can use the same get() and put() functions.
9+
10+
The device-specific specs (overall size, page size, write times, etc) are auto-detected. This library works with all types and allows the various settings to be set at runtime. All read and write restrictions associated with pages are taken care of. You can access the external memory as if it was contiguous.
11+
12+
Best used with the Qwiic EEPROM: https://www.sparkfun.com/products/18355
13+
14+
This library can be installed via the Arduino Library manager. Search for **SparkFun External EEPROM**.
15+
16+
The method for autodetection is as follows. The original data on the EEPROM is maintained once autodetection is complete:
17+
18+
* Address Bytes: Smaller EEPROMs use one address byte and larger EEPROMs use 2 address bytes. The auto-detection routine attempts to read a byte and then write a new byte. If the read/write fails, the address byte count is increased and a write attempt is tried again. Once the correct number of address bytes is detected, the original value is written back to EEPROM.
19+
20+
* Page Size: 256 bytes of EEPROM are read individually (to avoid page reads). Then, new bytes are generated that are random *and* different from the original data. The new bytes are written to EEPROM in increasing page size tests (8 bytes, then 16, etc) until the data does not match. Then the original data is written back to the EEPROM. Note: The page size may be reported as 32 bytes when the actual page size is larger. This is because of the size of the I2C buffer available on your microcontroller's Arduino core's Wire implementation. On some platforms (such as Arduino Uno) the I2C write buffer is 32 bytes. Once the two write bytes are removed, that leaves only 30 bytes available for sequential reads/writes. For maximum write speeds, use a platform that has a larger buffer than the page size of the EEPROM you are using.
21+
22+
* Memory Size: Once address bytes and page size are determined, single bytes are read, then written, then checked at the end of the potential EEPROM space. For example, byte 65535 is read for its original value and stored. Then a new, different value is written to location 65535. If the read/write fails, we know the EEPROM is one size down (32768 bytes, aka 24XX256).
23+
24+
* Page write time: This setting is not detected at begin(). All EEPROMs have a max write time of 5ms. Testing with a logic analyzer has shown that all EEPROMs respect this max and have an average of ~4.5ms for a page write. Attempting to trim the page write time lower than 5ms is much less worthwhile than using up a properly sized page size setting with an adequately sized I2C write buffer. In other words, read and write as many bytes as the page size can handle, don't worry about setting the page write time to 4ms or 5ms. Note: The 24XXM02 has a 10ms max page write time.
25+
26+
Want to help? Please do! We are always looking for ways to improve and build out features of this library.
27+
28+
Thanks to:
29+
30+
* Hutch67 for correcting the [test for pollForWriteComplete setting](https://github.com/sparkfun/SparkFun_External_EEPROM_Arduino_Library/pull/4/files)
31+
* [TinaJ_kay](https://github.com/TylerBird) for correcting [ambiguous int declaration](https://github.com/sparkfun/SparkFun_External_EEPROM_Arduino_Library/pull/7) and adding STM32 support
32+
33+
Repository Contents
34+
-------------------
35+
36+
* **/examples** - Example sketches for the library (.ino). Run these from the Arduino IDE.
37+
* **/src** - Source files for the library (.cpp, .h).
38+
* **keywords.txt** - Keywords from this library that will be highlighted in the Arduino IDE.
39+
* **library.properties** - General library properties for the Arduino package manager.
40+
41+
Documentation
42+
--------------
43+
44+
* **[Installing an Arduino Library Guide](https://learn.sparkfun.com/tutorials/installing-an-arduino-library)** - Basic information on how to install an Arduino library.
45+
46+
License Information
47+
-------------------
48+
49+
This product is _**open source**_!
50+
51+
Various bits of the code have different licenses applied. Anything SparkFun wrote is beerware; if you see me (or any other SparkFun employee) at the local, and you've found our code helpful, please buy us a round!
52+
53+
Please use, reuse, and modify these files as you see fit. Please maintain attribution to SparkFun Electronics and release anything derivative under the same license.
54+
55+
Distributed as-is; no warranty is given.
56+
57+
- Your friends at SparkFun.
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/*
2+
Read and write settings and calibration data to an external I2C EEPROM
3+
By: Nathan Seidle
4+
SparkFun Electronics
5+
Date: December 11th, 2019
6+
License: This code is public domain but you buy me a beer if you use this
7+
and we meet someday (Beerware license).
8+
Feel like supporting our work? Buy a board from SparkFun!
9+
https://www.sparkfun.com/products/14764
10+
11+
This example demonstrates how to read and write various variables to memory.
12+
13+
The I2C EEPROM should have all its ADR pins set to GND (0). This is default
14+
on the Qwiic board.
15+
16+
Hardware Connections:
17+
Plug the SparkFun Qwiic EEPROM to an Uno, Artemis, or other Qwiic equipped board
18+
Load this sketch
19+
Open output window at 115200bps
20+
*/
21+
22+
#include <Wire.h>
23+
24+
#include "SparkFun_External_EEPROM.h" // Click here to get the library: http://librarymanager/All#SparkFun_External_EEPROM
25+
ExternalEEPROM myMem;
26+
27+
void setup()
28+
{
29+
Serial.begin(115200);
30+
Serial.println("Qwiic EEPROM example");
31+
32+
Wire.begin();
33+
34+
if (myMem.begin() == false)
35+
{
36+
Serial.println("No memory detected. Freezing.");
37+
while (1)
38+
;
39+
}
40+
Serial.println("Memory detected!");
41+
42+
uint32_t eepromSizeBytes = myMem.getMemorySizeBytes();
43+
Serial.print("Detected EEPROM size (bytes): ");
44+
Serial.print(eepromSizeBytes);
45+
Serial.print(" - EEPROM Type: 24XX");
46+
if (eepromSizeBytes == 16)
47+
Serial.print("00");
48+
else
49+
{
50+
if ((eepromSizeBytes * 8 / 1024) < 10) Serial.print("0");
51+
Serial.print(eepromSizeBytes * 8 / 1024);
52+
}
53+
Serial.println();
54+
55+
Serial.print("Detected number of address bytes: ");
56+
Serial.println(myMem.getAddressBytes());
57+
58+
Serial.print("Detected pageSizeBytes: ");
59+
Serial.println(myMem.getPageSizeBytes());
60+
61+
//Yes you can read and write bytes, but you shouldn't!
62+
byte myValue1 = 200;
63+
myMem.write(0, myValue1); //(location, data)
64+
65+
byte myRead1 = myMem.read(0);
66+
Serial.print("I read (should be 200): ");
67+
Serial.println(myRead1);
68+
69+
//You should use gets and puts. This will automatically and correctly arrange
70+
//the bytes for larger variable types.
71+
int myValue2 = -366;
72+
myMem.put(10, myValue2); //(location, data)
73+
int myRead2;
74+
myMem.get(10, myRead2); //location to read, thing to put data into
75+
Serial.print("I read (should be -366): ");
76+
Serial.println(myRead2);
77+
78+
float myValue3 = -7.35;
79+
myMem.put(20, myValue3); //(location, data)
80+
float myRead3;
81+
myMem.get(20, myRead3); //location to read, thing to put data into
82+
Serial.print("I read (should be -7.35): ");
83+
Serial.println(myRead3);
84+
85+
String myString = "Hi, I am just a simple test string";
86+
unsigned long nextEEPROMLocation = myMem.putString(30, myString);
87+
String myRead4 = "";
88+
myMem.getString(30, myRead4);
89+
Serial.print("I read: ");
90+
Serial.println(myRead4);
91+
Serial.print("Next available EEPROM location: ");
92+
Serial.println(nextEEPROMLocation);
93+
}
94+
95+
void loop()
96+
{
97+
}

keywords.txt

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#######################################
2+
# Syntax Coloring Map
3+
#######################################
4+
5+
#######################################
6+
# Datatypes (KEYWORD1)
7+
#######################################
8+
9+
ExternalEEPROM KEYWORD1
10+
11+
#######################################
12+
# Methods and Functions (KEYWORD2)
13+
#######################################
14+
15+
read KEYWORD2
16+
write KEYWORD2
17+
begin KEYWORD2
18+
isConnected KEYWORD2
19+
isBusy KEYWORD2
20+
erase KEYWORD2
21+
22+
detectMemorySizeBytes KEYWORD2
23+
setMemorySizeBytes KEYWORD2
24+
getMemorySizeBytes KEYWORD2
25+
setMemorySize KEYWORD2
26+
getMemorySize KEYWORD2
27+
length KEYWORD2
28+
29+
detectPageSizeBytes KEYWORD2
30+
setPageSizeBytes KEYWORD2
31+
getPageSizeBytes KEYWORD2
32+
setPageSize KEYWORD2
33+
getPageSize KEYWORD2
34+
35+
detectAddressBytes KEYWORD2
36+
setAddressBytes KEYWORD2
37+
getAddressBytes KEYWORD2
38+
39+
detectWriteTimeMs KEYWORD2
40+
setWriteTimeMs KEYWORD2
41+
getWriteTimeMs KEYWORD2
42+
setPageWriteTime KEYWORD2
43+
getPageWriteTime KEYWORD2
44+
45+
enablePollForWriteComplete KEYWORD2
46+
disablePollForWriteComplete KEYWORD2
47+
get KEYWORD2
48+
put KEYWORD2
49+
setI2CBufferSize KEYWORD2
50+
getI2CBufferSize KEYWORD2
51+
putString KEYWORD2
52+
getString KEYWORD2
53+
detectMemorySizeBytes KEYWORD2
54+
55+
#######################################
56+
# Constants (LITERAL1)
57+
#######################################
58+

library.properties

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=SparkFun External EEPROM Arduino Library
2+
version=3.0.0
3+
author=SparkFun Electronics
4+
maintainer=SparkFun Electronics <sparkfun.com>
5+
sentence=Library for I2C Communication with external EEPROMs
6+
paragraph=A library for the advanced control of any I2C based EEPROM. This library writes extremely fast and automatically handles the writing of pages to make the entire EEPROM act as one large writable block. Automatically reads and writes ints, floats, arrays, and structs. Automatically detected EEPROM specs including memory size, page size, address bytes, and write times. Works with all EEPROMs including very large >512kbit EEPROMs and any Wire port (Wire1, etc). Use with <a href="https://www.sparkfun.com/products/18355">Qwiic EEPROM</a> to make it easy to read and write cal data and other user settings. Configurable I2C buffer size increases throughput up to 30kB/s. Includes an example that reads binary file from SD and auto writes/verifies to EEPROM. Tested with 24LC00, 24LC01B, 24AA02, 24LC04B, 24LC16BH, 24LC32A, 24LC256, CAT24C512, 24LC1025, and 24LC1026.
7+
category=Data Storage
8+
url=https://github.com/sparkfun/SparkFun_External_EEPROM_Arduino_Library
9+
architectures=*

0 commit comments

Comments
 (0)