Parcourir la source

Compile less code with EEPROM off

Scott Lahteine il y a 8 ans
Parent
révision
6f389158d7
1 fichiers modifiés avec 36 ajouts et 36 suppressions
  1. 36
    36
      Marlin/configuration_store.cpp

+ 36
- 36
Marlin/configuration_store.cpp Voir le fichier

@@ -133,42 +133,6 @@
133 133
   #include "mesh_bed_leveling.h"
134 134
 #endif
135 135
 
136
-uint16_t eeprom_checksum;
137
-const char version[4] = EEPROM_VERSION;
138
-
139
-bool eeprom_write_error;
140
-
141
-void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size) {
142
-  if (eeprom_write_error) return;
143
-  while (size--) {
144
-    uint8_t * const p = (uint8_t * const)pos;
145
-    const uint8_t v = *value;
146
-    // EEPROM has only ~100,000 write cycles,
147
-    // so only write bytes that have changed!
148
-    if (v != eeprom_read_byte(p)) {
149
-      eeprom_write_byte(p, v);
150
-      if (eeprom_read_byte(p) != v) {
151
-        SERIAL_ECHO_START;
152
-        SERIAL_ECHOLNPGM(MSG_ERR_EEPROM_WRITE);
153
-        eeprom_write_error = true;
154
-        return;
155
-      }
156
-    }
157
-    eeprom_checksum += v;
158
-    pos++;
159
-    value++;
160
-  };
161
-}
162
-void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) {
163
-  do {
164
-    uint8_t c = eeprom_read_byte((unsigned char*)pos);
165
-    *value = c;
166
-    eeprom_checksum += c;
167
-    pos++;
168
-    value++;
169
-  } while (--size);
170
-}
171
-
172 136
 /**
173 137
  * Post-process after Retrieve or Reset
174 138
  */
@@ -198,6 +162,42 @@ void Config_Postprocess() {
198 162
 
199 163
 #if ENABLED(EEPROM_SETTINGS)
200 164
 
165
+  uint16_t eeprom_checksum;
166
+  const char version[4] = EEPROM_VERSION;
167
+
168
+  bool eeprom_write_error;
169
+
170
+  void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size) {
171
+    if (eeprom_write_error) return;
172
+    while (size--) {
173
+      uint8_t * const p = (uint8_t * const)pos;
174
+      const uint8_t v = *value;
175
+      // EEPROM has only ~100,000 write cycles,
176
+      // so only write bytes that have changed!
177
+      if (v != eeprom_read_byte(p)) {
178
+        eeprom_write_byte(p, v);
179
+        if (eeprom_read_byte(p) != v) {
180
+          SERIAL_ECHO_START;
181
+          SERIAL_ECHOLNPGM(MSG_ERR_EEPROM_WRITE);
182
+          eeprom_write_error = true;
183
+          return;
184
+        }
185
+      }
186
+      eeprom_checksum += v;
187
+      pos++;
188
+      value++;
189
+    };
190
+  }
191
+  void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) {
192
+    do {
193
+      uint8_t c = eeprom_read_byte((unsigned char*)pos);
194
+      *value = c;
195
+      eeprom_checksum += c;
196
+      pos++;
197
+      value++;
198
+    } while (--size);
199
+  }
200
+
201 201
   #define DUMMY_PID_VALUE 3000.0f
202 202
   #define EEPROM_START() int eeprom_index = EEPROM_OFFSET
203 203
   #define EEPROM_SKIP(VAR) eeprom_index += sizeof(VAR)

Chargement…
Annuler
Enregistrer