Browse Source

Fix E2END and add EEPROM to Smart RAMPS

Reference #9983
Scott Lahteine 7 years ago
parent
commit
239902f861

+ 1
- 1
Marlin/src/HAL/HAL_LPC1768/persistent_store_impl.cpp View File

132
   UINT bytes_read = 0;
132
   UINT bytes_read = 0;
133
   FRESULT s;
133
   FRESULT s;
134
   s = f_lseek(&eeprom_file, pos);
134
   s = f_lseek(&eeprom_file, pos);
135
-  if ( s ) {
135
+  if (s) {
136
    SERIAL_PROTOCOLPAIR(" read_data(", pos);          // This extra chit-chat goes away soon.  But it is helpful
136
    SERIAL_PROTOCOLPAIR(" read_data(", pos);          // This extra chit-chat goes away soon.  But it is helpful
137
    SERIAL_PROTOCOLPAIR(",", (int)value);            // right now to see errors that are happening in the
137
    SERIAL_PROTOCOLPAIR(",", (int)value);            // right now to see errors that are happening in the
138
    SERIAL_PROTOCOLPAIR(",", size);             // read_data() and write_data() functions
138
    SERIAL_PROTOCOLPAIR(",", size);             // read_data() and write_data() functions

+ 0
- 1
Marlin/src/HAL/SpiEeprom.cpp View File

53
   return v;
53
   return v;
54
 }
54
 }
55
 
55
 
56
-
57
 void eeprom_read_block(void* dest, const void* eeprom_address, size_t n) {
56
 void eeprom_read_block(void* dest, const void* eeprom_address, size_t n) {
58
   uint8_t eeprom_temp[3];
57
   uint8_t eeprom_temp[3];
59
 
58
 

+ 2
- 2
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp View File

1167
 
1167
 
1168
     SERIAL_ECHO_START();
1168
     SERIAL_ECHO_START();
1169
     SERIAL_ECHOLNPGM("EEPROM Dump:");
1169
     SERIAL_ECHOLNPGM("EEPROM Dump:");
1170
-    for (uint16_t i = 0; i < E2END + 1; i += 16) {
1170
+    for (uint16_t i = 0; i <= E2END; i += 16) {
1171
       if (!(i & 0x3)) idle();
1171
       if (!(i & 0x3)) idle();
1172
       print_hex_word(i);
1172
       print_hex_word(i);
1173
       SERIAL_ECHOPGM(": ");
1173
       SERIAL_ECHOPGM(": ");
1174
       for (uint16_t j = 0; j < 16; j++) {
1174
       for (uint16_t j = 0; j < 16; j++) {
1175
         kkkk = i + j;
1175
         kkkk = i + j;
1176
-        eeprom_read_block(&cccc, (const void *) kkkk, sizeof(unsigned char));
1176
+        eeprom_read_block(&cccc, (const void *)kkkk, sizeof(unsigned char));
1177
         print_hex_byte(cccc);
1177
         print_hex_byte(cccc);
1178
         SERIAL_ECHO(' ');
1178
         SERIAL_ECHO(' ');
1179
       }
1179
       }

+ 6
- 2
Marlin/src/module/configuration_store.cpp View File

1494
       return (meshes_end - meshes_start_index()) / sizeof(ubl.z_values);
1494
       return (meshes_end - meshes_start_index()) / sizeof(ubl.z_values);
1495
     }
1495
     }
1496
 
1496
 
1497
+    int MarlinSettings::mesh_slot_offset(const int8_t slot) {
1498
+      return meshes_end - (slot + 1) * sizeof(ubl.z_values);
1499
+    }
1500
+
1497
     void MarlinSettings::store_mesh(const int8_t slot) {
1501
     void MarlinSettings::store_mesh(const int8_t slot) {
1498
 
1502
 
1499
       #if ENABLED(AUTO_BED_LEVELING_UBL)
1503
       #if ENABLED(AUTO_BED_LEVELING_UBL)
1509
           return;
1513
           return;
1510
         }
1514
         }
1511
 
1515
 
1516
+        int pos = mesh_slot_offset(slot);
1512
         uint16_t crc = 0;
1517
         uint16_t crc = 0;
1513
-        int pos = meshes_end - (slot + 1) * sizeof(ubl.z_values);
1514
 
1518
 
1515
         HAL::PersistentStore::access_start();
1519
         HAL::PersistentStore::access_start();
1516
         const bool status = HAL::PersistentStore::write_data(pos, (uint8_t *)&ubl.z_values, sizeof(ubl.z_values), &crc);
1520
         const bool status = HAL::PersistentStore::write_data(pos, (uint8_t *)&ubl.z_values, sizeof(ubl.z_values), &crc);
1546
           return;
1550
           return;
1547
         }
1551
         }
1548
 
1552
 
1553
+        int pos = mesh_slot_offset(slot);
1549
         uint16_t crc = 0;
1554
         uint16_t crc = 0;
1550
-        int pos = meshes_end - (slot + 1) * sizeof(ubl.z_values);
1551
         uint8_t * const dest = into ? (uint8_t*)into : (uint8_t*)&ubl.z_values;
1555
         uint8_t * const dest = into ? (uint8_t*)into : (uint8_t*)&ubl.z_values;
1552
 
1556
 
1553
         HAL::PersistentStore::access_start();
1557
         HAL::PersistentStore::access_start();

+ 3
- 2
Marlin/src/module/configuration_store.h View File

73
         static int16_t meshes_start_index();
73
         static int16_t meshes_start_index();
74
         FORCE_INLINE static int16_t meshes_end_index() { return meshes_end; }
74
         FORCE_INLINE static int16_t meshes_end_index() { return meshes_end; }
75
         static uint16_t calc_num_meshes();
75
         static uint16_t calc_num_meshes();
76
+        static int mesh_slot_offset(const int8_t slot);
76
         static void store_mesh(const int8_t slot);
77
         static void store_mesh(const int8_t slot);
77
         static void load_mesh(const int8_t slot, void * const into=NULL);
78
         static void load_mesh(const int8_t slot, void * const into=NULL);
78
 
79
 
104
 
105
 
105
       #if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system
106
       #if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system
106
                                          // That can store is enabled
107
                                          // That can store is enabled
107
-        const static int16_t meshes_end = E2END - 128; // 128 is a placeholder for the size of the MAT; the MAT will always
108
-                                                       // live at the very end of the eeprom
108
+        static constexpr int16_t meshes_end = E2END - 128; // 128 is a placeholder for the size of the MAT; the MAT will always
109
+                                                           // live at the very end of the eeprom
109
 
110
 
110
       #endif
111
       #endif
111
 
112
 

+ 2
- 1
Marlin/src/pins/pins_RADDS.h View File

151
 #define SDSS                4
151
 #define SDSS                4
152
 #define PS_ON_PIN          40
152
 #define PS_ON_PIN          40
153
 
153
 
154
+// I2C EEPROM with 8K of space
154
 #define I2C_EEPROM
155
 #define I2C_EEPROM
155
-#define E2END 0x2000
156
+#define E2END 0x1FFF
156
 
157
 
157
 //
158
 //
158
 // LCD / Controller
159
 // LCD / Controller

+ 4
- 0
Marlin/src/pins/pins_RAMPS_SMART.h View File

60
 #define IS_RAMPS_SMART
60
 #define IS_RAMPS_SMART
61
 #include "pins_RAMPS.h"
61
 #include "pins_RAMPS.h"
62
 
62
 
63
+// I2C EEPROM with 4K of space
64
+#define I2C_EEPROM
65
+#define E2END 0xFFF
66
+
63
 //
67
 //
64
 // Temperature Sensors
68
 // Temperature Sensors
65
 //
69
 //

+ 1
- 1
Marlin/src/pins/pins_RURAMPS4D.h View File

175
 //
175
 //
176
 // EEPROM
176
 // EEPROM
177
 //
177
 //
178
-#define E2END 0x8000  // 32Kb (24lc256)
178
+#define E2END 0x7FFF  // 32Kb (24lc256)
179
 #define I2C_EEPROM    // EEPROM on I2C-0
179
 #define I2C_EEPROM    // EEPROM on I2C-0
180
 //#define EEPROM_SD   // EEPROM on SDCARD
180
 //#define EEPROM_SD   // EEPROM on SDCARD
181
 //#define SPI_EEPROM  // EEPROM on SPI-0
181
 //#define SPI_EEPROM  // EEPROM on SPI-0

Loading…
Cancel
Save