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,7 +132,7 @@ bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc, const boo
132 132
   UINT bytes_read = 0;
133 133
   FRESULT s;
134 134
   s = f_lseek(&eeprom_file, pos);
135
-  if ( s ) {
135
+  if (s) {
136 136
    SERIAL_PROTOCOLPAIR(" read_data(", pos);          // This extra chit-chat goes away soon.  But it is helpful
137 137
    SERIAL_PROTOCOLPAIR(",", (int)value);            // right now to see errors that are happening in the
138 138
    SERIAL_PROTOCOLPAIR(",", size);             // read_data() and write_data() functions

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

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

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

@@ -1167,13 +1167,13 @@
1167 1167
 
1168 1168
     SERIAL_ECHO_START();
1169 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 1171
       if (!(i & 0x3)) idle();
1172 1172
       print_hex_word(i);
1173 1173
       SERIAL_ECHOPGM(": ");
1174 1174
       for (uint16_t j = 0; j < 16; j++) {
1175 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 1177
         print_hex_byte(cccc);
1178 1178
         SERIAL_ECHO(' ');
1179 1179
       }

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

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

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

@@ -73,6 +73,7 @@ class MarlinSettings {
73 73
         static int16_t meshes_start_index();
74 74
         FORCE_INLINE static int16_t meshes_end_index() { return meshes_end; }
75 75
         static uint16_t calc_num_meshes();
76
+        static int mesh_slot_offset(const int8_t slot);
76 77
         static void store_mesh(const int8_t slot);
77 78
         static void load_mesh(const int8_t slot, void * const into=NULL);
78 79
 
@@ -104,8 +105,8 @@ class MarlinSettings {
104 105
 
105 106
       #if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system
106 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 111
       #endif
111 112
 

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

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

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

@@ -60,6 +60,10 @@
60 60
 #define IS_RAMPS_SMART
61 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 68
 // Temperature Sensors
65 69
 //

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

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

Loading…
Cancel
Save