Browse Source

Revert "Fix small wired EEPROM (#21337)"

Reverting commit cc3e878f90 pending further investigation.
Scott Lahteine 3 years ago
parent
commit
560448afed
1 changed files with 7 additions and 18 deletions
  1. 7
    18
      Marlin/src/HAL/shared/eeprom_if_i2c.cpp

+ 7
- 18
Marlin/src/HAL/shared/eeprom_if_i2c.cpp View File

51
 
51
 
52
 static constexpr uint8_t eeprom_device_address = I2C_ADDRESS(EEPROM_DEVICE_ADDRESS);
52
 static constexpr uint8_t eeprom_device_address = I2C_ADDRESS(EEPROM_DEVICE_ADDRESS);
53
 
53
 
54
-void _beginTransmission(const uint16_t memoryAddress) {
55
-  if (MARLIN_EEPROM_SIZE > 0x4000) {  // Use two-byte addressing for EEPROMs >16kb
56
-    Wire.beginTransmission(eeprom_device_address);
57
-    Wire.write(memoryAddress >> 8);   // Address High Byte
58
-  }
59
-  else {
60
-    const uint8_t addr = eeprom_device_address | byte((memoryAddress >> 8) & 0x07);
61
-    Wire.beginTransmission(addr);
62
-  }
63
-  Wire.write(memoryAddress & 0xFF);   // Address Low Byte (or only byte for chips <= 16Kb like 24C02/04/08/16)
64
-}
65
-
66
 // ------------------------
54
 // ------------------------
67
 // Public functions
55
 // Public functions
68
 // ------------------------
56
 // ------------------------
70
 void eeprom_write_byte(uint8_t *pos, unsigned char value) {
58
 void eeprom_write_byte(uint8_t *pos, unsigned char value) {
71
   const unsigned eeprom_address = (unsigned)pos;
59
   const unsigned eeprom_address = (unsigned)pos;
72
 
60
 
73
-  _beginTransmission(eeprom_address);
61
+  Wire.beginTransmission(eeprom_device_address);
62
+  Wire.write(int(eeprom_address >> 8));   // MSB
63
+  Wire.write(int(eeprom_address & 0xFF)); // LSB
74
   Wire.write(value);
64
   Wire.write(value);
75
   Wire.endTransmission();
65
   Wire.endTransmission();
76
 
66
 
82
 uint8_t eeprom_read_byte(uint8_t *pos) {
72
 uint8_t eeprom_read_byte(uint8_t *pos) {
83
   const unsigned eeprom_address = (unsigned)pos;
73
   const unsigned eeprom_address = (unsigned)pos;
84
 
74
 
85
-  _beginTransmission(eeprom_address);
75
+  Wire.beginTransmission(eeprom_device_address);
76
+  Wire.write(int(eeprom_address >> 8));   // MSB
77
+  Wire.write(int(eeprom_address & 0xFF)); // LSB
86
   Wire.endTransmission();
78
   Wire.endTransmission();
87
-
88
-  // For EEPROMs <=16Kb the lower address bits are used for 2Kb page address
89
-  const int addr = eeprom_device_address | (MARLIN_EEPROM_SIZE <= 0x4000 ? byte((eeprom_address >> 8) & 0x07) : byte(0));
90
-  Wire.requestFrom(addr, byte(1));
79
+  Wire.requestFrom(eeprom_device_address, (byte)1);
91
   return Wire.available() ? Wire.read() : 0xFF;
80
   return Wire.available() ? Wire.read() : 0xFF;
92
 }
81
 }
93
 
82
 

Loading…
Cancel
Save