Skip to content

Commit 650e6fc

Browse files
authored
🔨 Prevent SlowSoftWire + Wire name conflict (MarlinFirmware#25707)
1 parent c034819 commit 650e6fc

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

Marlin/src/HAL/shared/eeprom_if_i2c.cpp

+11-10
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@
3333

3434
#if ENABLED(SOFT_I2C_EEPROM)
3535
#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);
3737
#else
3838
#include <Wire.h>
39+
#define eWire Wire
3940
#endif
4041

4142
void eeprom_init() {
42-
Wire.begin(
43+
eWire.begin(
4344
#if PINS_EXIST(I2C_SCL, I2C_SDA) && DISABLED(SOFT_I2C_EEPROM)
4445
uint8_t(I2C_SDA_PIN), uint8_t(I2C_SCL_PIN)
4546
#endif
@@ -75,16 +76,16 @@ static uint8_t _eeprom_calc_device_address(uint8_t * const pos) {
7576

7677
static void _eeprom_begin(uint8_t * const pos) {
7778
const unsigned eeprom_address = (unsigned)pos;
78-
Wire.beginTransmission(_eeprom_calc_device_address(pos));
79+
eWire.beginTransmission(_eeprom_calc_device_address(pos));
7980
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
8283
}
8384

8485
void eeprom_write_byte(uint8_t *pos, uint8_t value) {
8586
_eeprom_begin(pos);
86-
Wire.write(value);
87-
Wire.endTransmission();
87+
eWire.write(value);
88+
eWire.endTransmission();
8889

8990
// wait for write cycle to complete
9091
// this could be done more efficiently with "acknowledge polling"
@@ -93,9 +94,9 @@ void eeprom_write_byte(uint8_t *pos, uint8_t value) {
9394

9495
uint8_t eeprom_read_byte(uint8_t *pos) {
9596
_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;
99100
}
100101

101102
#endif // USE_SHARED_EEPROM

Marlin/src/lcd/marlinui.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
174174
#endif
175175

176176
#if HAS_U8GLIB_I2C_OLED && PINS_EXIST(I2C_SCL, I2C_SDA) && DISABLED(SOFT_I2C_EEPROM)
177-
#include "Wire.h"
177+
#include <Wire.h>
178178
#endif
179179

180180
// Encoder Handling

0 commit comments

Comments
 (0)