Skip to content

Commit 4605207

Browse files
author
James Foster
committed
Simplify reference to EEPROM library.
1 parent 0ee5170 commit 4605207

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99
### Added
10-
- Support for mock EEPROM (but only if board supports it; added mega2560 to TestSomething config)
10+
- Support for mock EEPROM (but only if board supports it)
1111

1212
### Changed
1313
- Move repository from https://github.com/ianfixes/arduino_ci to https://github.com/Arduino-CI/arduino_ci

SampleProjects/TestSomething/test/eeprom.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#include <ArduinoUnitTests.h>
22
#include <Arduino.h>
3-
#include <EEPROM.h>
43

5-
#ifdef EEPROM_SIZE
4+
// Only run EEPROM tests if there is hardware support!
5+
#if defined(EEPROM_SIZE) || (defined(E2END) && E2END)
6+
#include <EEPROM.h>
67

78
unittest(length)
89
{

cpp/arduino/EEPROM.h

+11-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
New version by Christopher Andrews 2015.
55
66
Copy of https://github.com/arduino/ArduinoCore-megaavr/blob/c8a1dd996c783777ec46167cfd8ad3fd2e6df185/libraries/EEPROM/src/EEPROM.h
7-
modified by James Foster 2020 to work with Arduino CI.
7+
modified by James Foster in 2020 to work with Arduino CI.
88
99
This library is free software; you can redistribute it and/or
1010
modify it under the terms of the GNU Lesser General Public
@@ -27,16 +27,24 @@
2727
#include <inttypes.h>
2828
#include <avr/io.h>
2929

30+
// different EEPROM implementations have different macros that leak out
3031
#if !defined(EEPROM_SIZE) && defined(E2END) && (E2END)
3132
#define EEPROM_SIZE (E2END + 1)
3233
#endif
33-
#ifdef EEPROM_SIZE
3434

35-
// Is this all the custom code required?
35+
// Does the current board have EEPROM?
36+
#ifndef EEPROM_SIZE
37+
// In lieu of an "EEPROM.h not found" error for unsupported boards
38+
#error "EEPROM library not available for your board"
39+
#endif
40+
41+
// On a real device this would be in hardware, but we have a mock board!
3642
static uint8_t eeprom[EEPROM_SIZE];
3743
inline uint8_t eeprom_read_byte( uint8_t* index ) { return eeprom[(unsigned long) index % EEPROM_SIZE]; }
3844
inline void eeprom_write_byte( uint8_t* index, uint8_t value ) { eeprom[(unsigned long) index % EEPROM_SIZE] = value; }
3945

46+
// Everything following is from the original (referenced above)
47+
4048
/***
4149
EERef class.
4250
@@ -156,4 +164,3 @@ struct EEPROMClass{
156164

157165
static EEPROMClass EEPROM;
158166
#endif
159-
#endif

0 commit comments

Comments
 (0)