Skip to content

Commit 7c712b7

Browse files
committed
0.8.2 FRAM_I2C
1 parent f13d003 commit 7c712b7

File tree

10 files changed

+255
-18
lines changed

10 files changed

+255
-18
lines changed

libraries/FRAM_I2C/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

77

8+
## [0.8.2] - 2025-02-03
9+
- support AVR_ATtiny85 / 84, kudos to GiorgosXou
10+
- add **FRAM_ATTINY85_COMPILE_TEST.ino** for testing
11+
- update readme.md with ATTINY section
12+
- improve FRAM32_Performance.ino RAM usage with F()
13+
814
## [0.8.1] - 2024-07-19
915
- Fix #56, performance sketch
1016
- minor edits

libraries/FRAM_I2C/FRAM.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// FILE: FRAM.cpp
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.8.1
4+
// VERSION: 0.8.2
55
// DATE: 2018-01-24
66
// PURPOSE: Arduino library for I2C FRAM
77
// URL: https://github.com/RobTillaart/FRAM_I2C

libraries/FRAM_I2C/FRAM.h

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,25 @@
22
//
33
// FILE: FRAM.h
44
// AUTHOR: Rob Tillaart
5-
// VERSION: 0.8.1
5+
// VERSION: 0.8.2
66
// DATE: 2018-01-24
77
// PURPOSE: Arduino library for I2C FRAM
88
// URL: https://github.com/RobTillaart/FRAM_I2C
99

1010

1111
#include "Arduino.h"
12-
#include "Wire.h"
13-
14-
15-
#define FRAM_LIB_VERSION (F("0.8.1"))
12+
#if (defined(ARDUINO_attiny) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny85__)) && !defined(TwoWire_h)
13+
#include "TinyWireM.h"
14+
#define Wire TinyWireM
15+
#define TwoWire USI_TWI
16+
#pragma message(" [WARNING] Defaulting to 'TinyWireM.h'. 'Wire' is defined as 'TinyWireM', and 'TwoWire' as 'USI_TWI'.")
17+
#pragma message(" [WARNING] To override or fall back, include 'Wire.h' above the library.")
18+
#else
19+
#include "Wire.h"
20+
#endif
21+
22+
23+
#define FRAM_LIB_VERSION (F("0.8.2"))
1624

1725

1826
#define FRAM_OK 0

libraries/FRAM_I2C/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2018-2024 Rob Tillaart
3+
Copyright (c) 2018-2025 Rob Tillaart
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

libraries/FRAM_I2C/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,24 @@ Not tested: expect the **MB85RC1MT** can be addressed with 2 instances of **FRAM
9797
too with adjacent addresses.
9898

9999

100+
### ATTINY (experimental)
101+
102+
- https://github.com/RobTillaart/FRAM_I2C/pull/58
103+
104+
Since 0.8.2 there is **experimental** support of the ATtiny85 device.
105+
With the FRAM the (persistent) storage of an ATtiny increases a lot.
106+
107+
The library is not tested by me with ATtiny hardware, however compilation
108+
is confirmed to work with IDE 1.8.19 (FRAM_ATTINY85_COMPILE_TEST.ino only)
109+
110+
NOTE: the examples of the library won't work with an ATtiny85 as they are
111+
written for the **Wire.h** where ATtiny uses **TinyWireM.h**.
112+
They can however be used as a guide how to call the library functions.
113+
114+
The code is expected to work with other ATTINY devices too.
115+
If you encounter problems or success, please open an issue on GitHub.
116+
117+
100118
### Related
101119

102120
- https://github.com/RobTillaart/I2C_EEPROM (eeprom)

libraries/FRAM_I2C/examples/FRAM32_Performance/FRAM32_Performance.ino

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void setup()
2020
{
2121
Serial.begin(115200);
2222
Serial.println(__FILE__);
23-
Serial.print("FRAM_LIB_VERSION: ");
23+
Serial.print(F("FRAM_LIB_VERSION: "));
2424
Serial.println(FRAM_LIB_VERSION);
2525
Serial.println();
2626
Serial.println();
@@ -37,7 +37,7 @@ void setup()
3737
for (int s = 1; s < 9; s++) // test up to 800 KB
3838
{
3939
uint32_t speed = s * 100000UL;
40-
Serial.print("CLOCK: ");
40+
Serial.print(F("CLOCK: "));
4141
Serial.println(speed);
4242
Wire.setClock(speed);
4343
testReadWriteLarge();
@@ -60,30 +60,30 @@ void testReadWriteLarge()
6060
start = micros();
6161
fram.write(1000, (uint8_t*)ar, 1200);
6262
stop = micros();
63-
Serial.print("WRITE 1200 bytes TIME: \t");
63+
Serial.print(F("WRITE 1200 bytes TIME: \t"));
6464
Serial.print(stop - start);
65-
Serial.print(" us ==> \t");
65+
Serial.print(F(" us ==> \t"));
6666
Serial.print((stop - start) / 1200.0, 2);
67-
Serial.println(" us/byte.");
67+
Serial.println(F(" us/byte."));
6868
delay(100);
6969

7070
for (int i = 0; i < 600; i++) ar[i] = 0;
7171

7272
start = micros();
7373
fram.read(1000, (uint8_t*)ar, 1200);
7474
stop = micros();
75-
Serial.print("READ 1200 bytes TIME: \t");
75+
Serial.print(F("READ 1200 bytes TIME: \t"));
7676
Serial.print(stop - start);
77-
Serial.print(" us ==> \t");
77+
Serial.print(F(" us ==> \t"));
7878
Serial.print((stop - start) / 1200.0, 2);
79-
Serial.println(" us/byte.");
79+
Serial.println(F(" us/byte."));
8080
delay(100);
8181

8282
for (int i = 0; i < 600; i++)
8383
{
8484
if (ar[i] != i)
8585
{
86-
Serial.print("FAIL: \t");
86+
Serial.print(F("FAIL: \t"));
8787
Serial.print(ar[i]);
8888
Serial.print('\t');
8989
Serial.println(i);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
platforms:
2+
rpipico:
3+
board: rp2040:rp2040:rpipico
4+
package: rp2040:rp2040
5+
gcc:
6+
features:
7+
defines:
8+
- ARDUINO_ARCH_RP2040
9+
warnings:
10+
flags:
11+
12+
packages:
13+
rp2040:rp2040:
14+
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
15+
16+
compile:
17+
# Choosing to run compilation tests on 2 different Arduino platforms
18+
platforms:
19+
# - uno
20+
# - due
21+
# - zero
22+
# - leonardo
23+
# - m4
24+
# - esp32
25+
# - esp8266
26+
# - mega2560
27+
# - rpipico
28+
# - nano_every
29+
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
//
2+
// FILE: FRAM_ATTINY85_COMPILE_TEST.ino
3+
// AUTHOR: Rob Tillaart
4+
// PURPOSE: compile test for FRAM library with ATTINY85
5+
// URL: https://github.com/RobTillaart/FRAM_I2C
6+
//
7+
//
8+
// WARNING: not tested with hardware, only compilation.
9+
// this example is for checking if there are compile errors.
10+
// TESTED: IDE: 1.8.19 ATTINY85
11+
//
12+
13+
14+
#include "TinyWireM.h"
15+
#include "FRAM.h"
16+
17+
18+
FRAM fram;
19+
20+
uint32_t start;
21+
uint32_t stop;
22+
23+
24+
void setup()
25+
{
26+
TinyWireM.begin();
27+
28+
fram.begin(0x50);
29+
30+
testID();
31+
testFRAMmemory();
32+
testReadWriteSmall();
33+
testReadWriteLarge();
34+
// testWriteText();
35+
// testReadText1();
36+
// testReadText2();
37+
}
38+
39+
40+
void loop()
41+
{
42+
}
43+
44+
45+
void testID()
46+
{
47+
int x = fram.getManufacturerID();
48+
int y = fram.getProductID();
49+
int s = fram.getSize();
50+
}
51+
52+
void testFRAMmemory()
53+
{
54+
55+
start = millis();
56+
uint8_t val = 0x55;
57+
for (uint16_t addr = 0; addr < 32768; addr++)
58+
{
59+
fram.write8(addr, val);
60+
if (fram.read8(addr) != 0x55)
61+
{
62+
}
63+
if (addr % 1000 == 0)
64+
{
65+
}
66+
}
67+
stop = millis();
68+
}
69+
70+
71+
void testReadWriteSmall()
72+
{
73+
uint8_t t8 = 0xFE;
74+
fram.write8(1000, t8);
75+
if (fram.read8(1000) != 0xFE)
76+
{
77+
}
78+
else
79+
{
80+
}
81+
82+
83+
uint16_t t16 = 0xFADE;
84+
fram.write16(1000, t16);
85+
if (fram.read16(1000) != 0xFADE)
86+
{
87+
88+
}
89+
else
90+
{
91+
92+
}
93+
94+
95+
uint32_t t32 = 0xFADEFACE;
96+
fram.write32(1000, t32);
97+
if (fram.read32(1000) != 0xFADEFACE)
98+
{
99+
100+
}
101+
else
102+
{
103+
}
104+
105+
}
106+
107+
108+
void testReadWriteLarge()
109+
{
110+
uint8_t ar[20];
111+
for (int i = 0; i < 20; i++) ar[i] = i;
112+
113+
start = millis();
114+
fram.write(1000, ar, 20);
115+
stop = millis();
116+
117+
for (int i = 0; i < 20; i++) ar[i] = 0;
118+
119+
start = millis();
120+
fram.read(1000, ar, 20);
121+
stop = millis();
122+
123+
for (int i = 0; i < 20; i++)
124+
{
125+
if (ar[i] != i)
126+
{
127+
}
128+
}
129+
130+
}
131+
132+
133+
void testWriteText()
134+
{
135+
char str[5][16] =
136+
{
137+
"Hello world 0",
138+
"Hello world 1",
139+
"Hello world 2",
140+
"Hello world 3",
141+
"Hello world 4",
142+
};
143+
144+
start = millis();
145+
fram.write(2000, (uint8_t *)str, 80);
146+
stop = millis();
147+
}
148+
149+
150+
void testReadText1()
151+
{
152+
char str[5][16];
153+
154+
start = millis();
155+
fram.read(2000, (uint8_t *)str, 80);
156+
stop = millis();
157+
158+
for (int i = 0; i < 5; i++)
159+
{
160+
}
161+
}
162+
163+
164+
void testReadText2()
165+
{
166+
char str[16];
167+
168+
for (int i = 0; i < 5; i++)
169+
{
170+
fram.read(2000 + 16 * i, (uint8_t *)str, 16);
171+
}
172+
}
173+
174+
175+
176+
// -- END OF FILE --

libraries/FRAM_I2C/library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"type": "git",
1616
"url": "https://github.com/RobTillaart/FRAM_I2C.git"
1717
},
18-
"version": "0.8.1",
18+
"version": "0.8.2",
1919
"license": "MIT",
2020
"frameworks": "*",
2121
"platforms": "*",

libraries/FRAM_I2C/library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=FRAM_I2C
2-
version=0.8.1
2+
version=0.8.2
33
author=Rob Tillaart <[email protected]>
44
maintainer=Rob Tillaart <[email protected]>
55
sentence=Arduino library for I2C FRAM for persistent storage.

0 commit comments

Comments
 (0)