🔨 Prevent SlowSoftWire + Wire name conflict (#25707)
This commit is contained in:
committed by
Scott Lahteine
parent
44b06d7561
commit
d5548556d3
@@ -33,13 +33,14 @@
|
|||||||
|
|
||||||
#if ENABLED(SOFT_I2C_EEPROM)
|
#if ENABLED(SOFT_I2C_EEPROM)
|
||||||
#include <SlowSoftWire.h>
|
#include <SlowSoftWire.h>
|
||||||
SlowSoftWire Wire = SlowSoftWire(I2C_SDA_PIN, I2C_SCL_PIN, true);
|
SlowSoftWire eWire = SlowSoftWire(I2C_SDA_PIN, I2C_SCL_PIN, true);
|
||||||
#else
|
#else
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
|
#define eWire Wire
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void eeprom_init() {
|
void eeprom_init() {
|
||||||
Wire.begin(
|
eWire.begin(
|
||||||
#if PINS_EXIST(I2C_SCL, I2C_SDA) && DISABLED(SOFT_I2C_EEPROM)
|
#if PINS_EXIST(I2C_SCL, I2C_SDA) && DISABLED(SOFT_I2C_EEPROM)
|
||||||
uint8_t(I2C_SDA_PIN), uint8_t(I2C_SCL_PIN)
|
uint8_t(I2C_SDA_PIN), uint8_t(I2C_SCL_PIN)
|
||||||
#endif
|
#endif
|
||||||
@@ -75,16 +76,16 @@ static uint8_t _eeprom_calc_device_address(uint8_t * const pos) {
|
|||||||
|
|
||||||
static void _eeprom_begin(uint8_t * const pos) {
|
static void _eeprom_begin(uint8_t * const pos) {
|
||||||
const unsigned eeprom_address = (unsigned)pos;
|
const unsigned eeprom_address = (unsigned)pos;
|
||||||
Wire.beginTransmission(_eeprom_calc_device_address(pos));
|
eWire.beginTransmission(_eeprom_calc_device_address(pos));
|
||||||
if (!SMALL_EEPROM)
|
if (!SMALL_EEPROM)
|
||||||
Wire.write(uint8_t((eeprom_address >> 8) & 0xFF)); // Address High, if needed
|
eWire.write(uint8_t((eeprom_address >> 8) & 0xFF)); // Address High, if needed
|
||||||
Wire.write(uint8_t(eeprom_address & 0xFF)); // Address Low
|
eWire.write(uint8_t(eeprom_address & 0xFF)); // Address Low
|
||||||
}
|
}
|
||||||
|
|
||||||
void eeprom_write_byte(uint8_t *pos, uint8_t value) {
|
void eeprom_write_byte(uint8_t *pos, uint8_t value) {
|
||||||
_eeprom_begin(pos);
|
_eeprom_begin(pos);
|
||||||
Wire.write(value);
|
eWire.write(value);
|
||||||
Wire.endTransmission();
|
eWire.endTransmission();
|
||||||
|
|
||||||
// wait for write cycle to complete
|
// wait for write cycle to complete
|
||||||
// this could be done more efficiently with "acknowledge polling"
|
// this could be done more efficiently with "acknowledge polling"
|
||||||
@@ -93,9 +94,9 @@ void eeprom_write_byte(uint8_t *pos, uint8_t value) {
|
|||||||
|
|
||||||
uint8_t eeprom_read_byte(uint8_t *pos) {
|
uint8_t eeprom_read_byte(uint8_t *pos) {
|
||||||
_eeprom_begin(pos);
|
_eeprom_begin(pos);
|
||||||
Wire.endTransmission();
|
eWire.endTransmission();
|
||||||
Wire.requestFrom(_eeprom_calc_device_address(pos), (byte)1);
|
eWire.requestFrom(_eeprom_calc_device_address(pos), (byte)1);
|
||||||
return Wire.available() ? Wire.read() : 0xFF;
|
return eWire.available() ? eWire.read() : 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // USE_SHARED_EEPROM
|
#endif // USE_SHARED_EEPROM
|
||||||
|
@@ -174,7 +174,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAS_U8GLIB_I2C_OLED && PINS_EXIST(I2C_SCL, I2C_SDA) && DISABLED(SOFT_I2C_EEPROM)
|
#if HAS_U8GLIB_I2C_OLED && PINS_EXIST(I2C_SCL, I2C_SDA) && DISABLED(SOFT_I2C_EEPROM)
|
||||||
#include "Wire.h"
|
#include <Wire.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Encoder Handling
|
// Encoder Handling
|
||||||
|
Reference in New Issue
Block a user