33
33
34
34
#if ENABLED(SOFT_I2C_EEPROM)
35
35
#include < SlowSoftWire.h>
36
- SlowSoftWire Wire = SlowSoftWire(I2C_SDA_PIN, I2C_SCL_PIN, true );
36
+ SlowSoftWire eWire = SlowSoftWire(I2C_SDA_PIN, I2C_SCL_PIN, true );
37
37
#else
38
38
#include < Wire.h>
39
+ #define eWire Wire
39
40
#endif
40
41
41
42
void eeprom_init () {
42
- Wire .begin (
43
+ eWire .begin (
43
44
#if PINS_EXIST(I2C_SCL, I2C_SDA) && DISABLED(SOFT_I2C_EEPROM)
44
45
uint8_t (I2C_SDA_PIN), uint8_t (I2C_SCL_PIN)
45
46
#endif
@@ -75,16 +76,16 @@ static uint8_t _eeprom_calc_device_address(uint8_t * const pos) {
75
76
76
77
static void _eeprom_begin (uint8_t * const pos) {
77
78
const unsigned eeprom_address = (unsigned )pos;
78
- Wire .beginTransmission (_eeprom_calc_device_address (pos));
79
+ eWire .beginTransmission (_eeprom_calc_device_address (pos));
79
80
if (!SMALL_EEPROM)
80
- Wire .write (uint8_t ((eeprom_address >> 8 ) & 0xFF )); // Address High, if needed
81
- Wire .write (uint8_t (eeprom_address & 0xFF )); // Address Low
81
+ eWire .write (uint8_t ((eeprom_address >> 8 ) & 0xFF )); // Address High, if needed
82
+ eWire .write (uint8_t (eeprom_address & 0xFF )); // Address Low
82
83
}
83
84
84
85
void eeprom_write_byte (uint8_t *pos, uint8_t value) {
85
86
_eeprom_begin (pos);
86
- Wire .write (value);
87
- Wire .endTransmission ();
87
+ eWire .write (value);
88
+ eWire .endTransmission ();
88
89
89
90
// wait for write cycle to complete
90
91
// this could be done more efficiently with "acknowledge polling"
@@ -93,9 +94,9 @@ void eeprom_write_byte(uint8_t *pos, uint8_t value) {
93
94
94
95
uint8_t eeprom_read_byte (uint8_t *pos) {
95
96
_eeprom_begin (pos);
96
- Wire .endTransmission ();
97
- Wire .requestFrom (_eeprom_calc_device_address (pos), (byte)1 );
98
- return Wire .available () ? Wire .read () : 0xFF ;
97
+ eWire .endTransmission ();
98
+ eWire .requestFrom (_eeprom_calc_device_address (pos), (byte)1 );
99
+ return eWire .available () ? eWire .read () : 0xFF ;
99
100
}
100
101
101
102
#endif // USE_SHARED_EEPROM
0 commit comments