Kaynağa Gözat

Merge pull request #9056 from thinkyhead/bf2_new_eeprom_powers

[2.0.x] New EEPROM powers
Scott Lahteine 7 yıl önce
ebeveyn
işleme
013c911a82
No account linked to committer's email address

+ 2
- 2
Marlin/src/HAL/HAL_AVR/persistent_store_impl.cpp Dosyayı Görüntüle

@@ -38,10 +38,10 @@ bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
38 38
   return false;
39 39
 }
40 40
 
41
-bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc) {
41
+bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc, const bool writing/*=true*/) {
42 42
   do {
43 43
     uint8_t c = eeprom_read_byte((unsigned char*)pos);
44
-    *value = c;
44
+    if (writing) *value = c;
45 45
     crc16(crc, &c, 1);
46 46
     pos++;
47 47
     value++;

+ 2
- 2
Marlin/src/HAL/HAL_DUE/persistent_store_impl.cpp Dosyayı Görüntüle

@@ -43,10 +43,10 @@ bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
43 43
   return false;
44 44
 }
45 45
 
46
-bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc) {
46
+bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc, const bool writing/*=true*/) {
47 47
   do {
48 48
     uint8_t c = eeprom_read_byte((unsigned char*)pos);
49
-    *value = c;
49
+    if (writing) *value = c;
50 50
     crc16(crc, &c, 1);
51 51
     pos++;
52 52
     value++;

+ 10
- 3
Marlin/src/HAL/HAL_LPC1768/persistent_store_impl.cpp Dosyayı Görüntüle

@@ -128,7 +128,7 @@ bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
128 128
   return (bytes_written != size);  // return true for any error
129 129
 }
130 130
 
131
-bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc) {
131
+bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc, const bool writing/*=true*/) {
132 132
   UINT bytes_read = 0;
133 133
   FRESULT s;
134 134
   s = f_lseek(&eeprom_file, pos);
@@ -140,7 +140,15 @@ bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc) {
140 140
    SERIAL_PROTOCOLLNPAIR(" f_lseek()=", (int)s);
141 141
    return true;
142 142
   }
143
-  s = f_read(&eeprom_file, (void *)value, size, &bytes_read);
143
+  if (writing) {
144
+    s = f_read(&eeprom_file, (void *)value, size, &bytes_read);
145
+    crc16(crc, value, size);
146
+  }
147
+  else {
148
+    uint8_t temp[size];
149
+    s = f_read(&eeprom_file, (void *)temp, size, &bytes_read);
150
+    crc16(crc, temp, size);
151
+  }
144 152
   if (s) {
145 153
    SERIAL_PROTOCOLPAIR(" read_data(", pos);         // This extra chit-chat goes away soon.  But it is helpful
146 154
    SERIAL_PROTOCOLPAIR(",", (int)value);           // right now to see errors that are happening in the
@@ -151,7 +159,6 @@ bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc) {
151 159
    SERIAL_PROTOCOLLNPAIR("\n bytes_read=",  bytes_read);
152 160
    return true;
153 161
   }
154
-  crc16(crc, value, size);
155 162
   pos = pos + size;
156 163
   return bytes_read != size;  // return true for any error
157 164
 }

+ 4
- 4
Marlin/src/HAL/HAL_STM32F1/persistent_store_flash.cpp Dosyayı Görüntüle

@@ -93,13 +93,13 @@ bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
93 93
   return true;
94 94
 }
95 95
 
96
-void read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc) {
96
+void read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc, const bool writing/*=true*/) {
97 97
   for (uint16_t i = 0; i < size; i++) {
98 98
     byte* accessPoint = (byte*)(pageBase + pos + i);
99
-    value[i] = *accessPoint;
99
+    uint8_t c = *accessPoint;
100
+    if (writing) value[i] = c;
101
+    crc16(crc, &c, 1);
100 102
   }
101
-
102
-  crc16(crc, value, size);
103 103
   pos += ((size + 1) & ~1);
104 104
 }
105 105
 

+ 4
- 4
Marlin/src/HAL/HAL_STM32F1/persistent_store_impl.cpp Dosyayı Görüntüle

@@ -62,7 +62,6 @@ bool access_start() {
62 62
   return true;
63 63
 }
64 64
 
65
-
66 65
 bool access_finish(){
67 66
   if (!card.cardOK) return false;
68 67
   int16_t bytes_written = 0;
@@ -81,11 +80,12 @@ bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
81 80
   return false;
82 81
 }
83 82
 
84
-bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc) {
83
+bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc, const bool writing/*=true*/) {
85 84
   for (int i = 0; i < size; i++) {
86
-    value[i] = HAL_STM32F1_eeprom_content [pos + i];
85
+    uint8_t c = HAL_STM32F1_eeprom_content[pos + i];
86
+    if (writing) value[i] = c`;
87
+    crc16(crc, &c, 1);
87 88
   }
88
-  crc16(crc, value, size);
89 89
   pos += size;
90 90
   return false;
91 91
 }

+ 2
- 2
Marlin/src/HAL/HAL_TEENSY35_36/persistent_store_impl.cpp Dosyayı Görüntüle

@@ -38,10 +38,10 @@ bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
38 38
   return false;
39 39
 }
40 40
 
41
-bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc) {
41
+bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc, const bool writing/*=true*/) {
42 42
   do {
43 43
     uint8_t c = eeprom_read_byte((unsigned char*)pos);
44
-    *value = c;
44
+    if (writing) *value = c;
45 45
     crc16(crc, &c, 1);
46 46
     pos++;
47 47
     value++;

+ 1
- 1
Marlin/src/HAL/persistent_store_api.h Dosyayı Görüntüle

@@ -10,7 +10,7 @@ namespace PersistentStore {
10 10
 bool access_start();
11 11
 bool access_finish();
12 12
 bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc);
13
-bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc);
13
+bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc, const bool writing=true);
14 14
 
15 15
 } // PersistentStore
16 16
 } // HAL

+ 3
- 9
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp Dosyayı Görüntüle

@@ -309,12 +309,6 @@
309 309
 
310 310
   void unified_bed_leveling::G29() {
311 311
 
312
-    if (!settings.calc_num_meshes()) {
313
-      SERIAL_PROTOCOLLNPGM("?Enable EEPROM and init with");
314
-      SERIAL_PROTOCOLLNPGM("M502, M500, M501 in that order.\n");
315
-      return;
316
-    }
317
-
318 312
     if (g29_parameter_parsing()) return; // abort if parsing the simple parameters causes a problem,
319 313
 
320 314
     // Check for commands that require the printer to be homed
@@ -1272,8 +1266,8 @@
1272 1266
       SERIAL_EOL();
1273 1267
       safe_delay(50);
1274 1268
 
1275
-      SERIAL_PROTOCOLPAIR("Meshes go from ", hex_address((void*)settings.get_start_of_meshes()));
1276
-      SERIAL_PROTOCOLLNPAIR(" to ", hex_address((void*)settings.get_end_of_meshes()));
1269
+      SERIAL_PROTOCOLPAIR("Meshes go from ", hex_address((void*)settings.meshes_start_index()));
1270
+      SERIAL_PROTOCOLLNPAIR(" to ", hex_address((void*)settings.meshes_end_index()));
1277 1271
       safe_delay(50);
1278 1272
 
1279 1273
       SERIAL_PROTOCOLLNPAIR("sizeof(ubl) :  ", (int)sizeof(ubl));
@@ -1282,7 +1276,7 @@
1282 1276
       SERIAL_EOL();
1283 1277
       safe_delay(25);
1284 1278
 
1285
-      SERIAL_PROTOCOLLNPAIR("EEPROM free for UBL: ", hex_address((void*)(settings.get_end_of_meshes() - settings.get_start_of_meshes())));
1279
+      SERIAL_PROTOCOLLNPAIR("EEPROM free for UBL: ", hex_address((void*)(settings.meshes_end_index() - settings.meshes_start_index())));
1286 1280
       safe_delay(50);
1287 1281
 
1288 1282
       SERIAL_PROTOCOLPAIR("EEPROM can hold ", settings.calc_num_meshes());

Marlin/src/gcode/eeprom/M500-M503.cpp → Marlin/src/gcode/eeprom/M500-M504.cpp Dosyayı Görüntüle

@@ -55,3 +55,15 @@ void GcodeSuite::M502() {
55 55
   }
56 56
 
57 57
 #endif // !DISABLE_M503
58
+
59
+#if ENABLED(EEPROM_SETTINGS)
60
+  /**
61
+   * M504: Validate EEPROM Contents
62
+   */
63
+  void GcodeSuite::M504() {
64
+    if (settings.validate()) {
65
+      SERIAL_ECHO_START();
66
+      SERIAL_ECHOLNPGM("EEPROM OK");
67
+    }
68
+  }
69
+#endif

+ 3
- 0
Marlin/src/gcode/gcode.cpp Dosyayı Görüntüle

@@ -610,6 +610,9 @@ void GcodeSuite::process_parsed_command() {
610 610
       #if DISABLED(DISABLE_M503)
611 611
         case 503: M503(); break;  // M503: print settings currently in memory
612 612
       #endif
613
+      #if ENABLED(EEPROM_SETTINGS)
614
+        case 504: M504(); break;  // M504: Validate EEPROM contents
615
+      #endif
613 616
 
614 617
       #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
615 618
         case 540: M540(); break;  // M540: Set abort on endstop hit for SD printing

+ 4
- 1
Marlin/src/gcode/gcode.h Dosyayı Görüntüle

@@ -271,8 +271,8 @@ public:
271 271
     static WorkspacePlane workspace_plane;
272 272
   #endif
273 273
 
274
+  #define MAX_COORDINATE_SYSTEMS 9
274 275
   #if ENABLED(CNC_COORDINATE_SYSTEMS)
275
-    #define MAX_COORDINATE_SYSTEMS 9
276 276
     static int8_t active_coordinate_system;
277 277
     static float coordinate_system[MAX_COORDINATE_SYSTEMS][XYZ];
278 278
     static bool select_coordinate_system(const int8_t _new);
@@ -681,6 +681,9 @@ private:
681 681
   #if DISABLED(DISABLE_M503)
682 682
     static void M503();
683 683
   #endif
684
+  #if ENABLED(EEPROM_SETTINGS)
685
+    static void M504();
686
+  #endif
684 687
 
685 688
   #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
686 689
     static void M540();

+ 0
- 1
Marlin/src/lcd/ultralcd.cpp Dosyayı Görüntüle

@@ -2309,7 +2309,6 @@ void kill_screen(const char* lcd_msg) {
2309 2309
       MENU_BACK(MSG_UBL_LEVEL_BED);
2310 2310
       if (!WITHIN(ubl_storage_slot, 0, a - 1)) {
2311 2311
         STATIC_ITEM(MSG_NO_STORAGE);
2312
-        STATIC_ITEM(MSG_INIT_EEPROM);
2313 2312
       }
2314 2313
       else {
2315 2314
         MENU_ITEM_EDIT(int3, MSG_UBL_STORAGE_SLOT, &ubl_storage_slot, 0, a - 1);

+ 475
- 372
Marlin/src/module/configuration_store.cpp
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle


+ 15
- 13
Marlin/src/module/configuration_store.h Dosyayı Görüntüle

@@ -29,31 +29,31 @@ class MarlinSettings {
29 29
   public:
30 30
     MarlinSettings() { }
31 31
 
32
+    static uint16_t datasize();
33
+
32 34
     static void reset();
33
-    static bool save();
35
+    static bool save();   // Return 'true' if data was saved
34 36
 
35 37
     FORCE_INLINE static bool init_eeprom() {
36 38
       bool success = true;
37 39
       reset();
38 40
       #if ENABLED(EEPROM_SETTINGS)
39
-        if ((success = save())) {
40
-          #if ENABLED(AUTO_BED_LEVELING_UBL)
41
-            success = load(); // UBL uses load() to know the end of EEPROM
42
-          #elif ENABLED(EEPROM_CHITCHAT)
43
-            report();
44
-          #endif
45
-        }
41
+        success = save();
42
+        #if ENABLED(EEPROM_CHITCHAT)
43
+          if (success) report();
44
+        #endif
46 45
       #endif
47 46
       return success;
48 47
     }
49 48
 
50 49
     #if ENABLED(EEPROM_SETTINGS)
51
-      static bool load();
50
+      static bool load();     // Return 'true' if data was loaded ok
51
+      static bool validate(); // Return 'true' if EEPROM data is ok
52 52
 
53 53
       #if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system
54 54
                                          // That can store is enabled
55
-        FORCE_INLINE static int16_t get_start_of_meshes() { return meshes_begin; }
56
-        FORCE_INLINE static int16_t get_end_of_meshes() { return meshes_end; }
55
+        static int16_t meshes_start_index();
56
+        FORCE_INLINE static int16_t meshes_end_index() { return meshes_end; }
57 57
         static uint16_t calc_num_meshes();
58 58
         static void store_mesh(const int8_t slot);
59 59
         static void load_mesh(const int8_t slot, void * const into=NULL);
@@ -77,16 +77,18 @@ class MarlinSettings {
77 77
     static void postprocess();
78 78
 
79 79
     #if ENABLED(EEPROM_SETTINGS)
80
-      static bool eeprom_error;
80
+
81
+      static bool eeprom_error, validating;
81 82
 
82 83
       #if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system
83 84
                                          // That can store is enabled
84
-        static int16_t meshes_begin;
85 85
         const static int16_t meshes_end = E2END - 128; // 128 is a placeholder for the size of the MAT; the MAT will always
86 86
                                                        // live at the very end of the eeprom
87 87
 
88 88
       #endif
89 89
 
90
+      static bool _load();
91
+      static bool size_error(const uint16_t size);
90 92
     #endif
91 93
 };
92 94
 

Loading…
İptal
Kaydet