浏览代码

Revert "Fix small wired EEPROM (#21337)"

Reverting commit cc3e878f90 pending further investigation.
Scott Lahteine 3 年前
父节点
当前提交
560448afed
共有 1 个文件被更改,包括 7 次插入18 次删除
  1. 7
    18
      Marlin/src/HAL/shared/eeprom_if_i2c.cpp

+ 7
- 18
Marlin/src/HAL/shared/eeprom_if_i2c.cpp 查看文件

@@ -51,18 +51,6 @@ void eeprom_init() {
51 51
 
52 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 55
 // Public functions
68 56
 // ------------------------
@@ -70,7 +58,9 @@ void _beginTransmission(const uint16_t memoryAddress) {
70 58
 void eeprom_write_byte(uint8_t *pos, unsigned char value) {
71 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 64
   Wire.write(value);
75 65
   Wire.endTransmission();
76 66
 
@@ -82,12 +72,11 @@ void eeprom_write_byte(uint8_t *pos, unsigned char value) {
82 72
 uint8_t eeprom_read_byte(uint8_t *pos) {
83 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 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 80
   return Wire.available() ? Wire.read() : 0xFF;
92 81
 }
93 82
 

正在加载...
取消
保存