|
@@ -25,8 +25,10 @@
|
25
|
25
|
|
26
|
26
|
#include "gcode.h"
|
27
|
27
|
#include "../module/settings.h"
|
|
28
|
+ #include "../module/temperature.h"
|
28
|
29
|
#include "../libs/hex_print.h"
|
29
|
30
|
#include "../HAL/shared/eeprom_if.h"
|
|
31
|
+ #include "../HAL/shared/Delay.h"
|
30
|
32
|
|
31
|
33
|
/**
|
32
|
34
|
* Dn: G-code for development and testing
|
|
@@ -84,40 +86,23 @@
|
84
|
86
|
}
|
85
|
87
|
} break;
|
86
|
88
|
|
87
|
|
- case 3: { // D3 Read / Write EEPROM
|
88
|
|
- uint8_t *pointer = parser.hex_adr_val('A');
|
89
|
|
- uint16_t len = parser.ushortval('C', 1);
|
90
|
|
- uintptr_t addr = (uintptr_t)pointer;
|
91
|
|
- #ifndef MARLIN_EEPROM_SIZE
|
92
|
|
- #define MARLIN_EEPROM_SIZE size_t(E2END + 1)
|
93
|
|
- #endif
|
94
|
|
- NOMORE(addr, (size_t)(MARLIN_EEPROM_SIZE - 1));
|
95
|
|
- NOMORE(len, MARLIN_EEPROM_SIZE - addr);
|
96
|
|
- if (parser.seenval('X')) {
|
97
|
|
- uint16_t val = parser.hex_val('X');
|
98
|
|
- #if ENABLED(EEPROM_SETTINGS)
|
99
|
|
- persistentStore.access_start();
|
100
|
|
- while(len--) {
|
101
|
|
- int pos = 0;
|
102
|
|
- persistentStore.write_data(pos, (uint8_t *)&val, sizeof(val));
|
103
|
|
- }
|
104
|
|
- SERIAL_EOL();
|
105
|
|
- persistentStore.access_finish();
|
106
|
|
- #else
|
107
|
|
- SERIAL_ECHOLN("NO EEPROM");
|
|
89
|
+ #if ENABLED(EEPROM_SETTINGS)
|
|
90
|
+ case 3: { // D3 Read / Write EEPROM
|
|
91
|
+ uint8_t *pointer = parser.hex_adr_val('A');
|
|
92
|
+ uint16_t len = parser.ushortval('C', 1);
|
|
93
|
+ uintptr_t addr = (uintptr_t)pointer;
|
|
94
|
+ #ifndef MARLIN_EEPROM_SIZE
|
|
95
|
+ #define MARLIN_EEPROM_SIZE size_t(E2END + 1)
|
108
|
96
|
#endif
|
109
|
|
- }
|
110
|
|
- else {
|
111
|
|
- while (len--) {
|
112
|
|
- // Read bytes from EEPROM
|
|
97
|
+ NOMORE(addr, (size_t)(MARLIN_EEPROM_SIZE - 1));
|
|
98
|
+ NOMORE(len, MARLIN_EEPROM_SIZE - addr);
|
|
99
|
+ if (parser.seenval('X')) {
|
|
100
|
+ uint16_t val = parser.hex_val('X');
|
113
|
101
|
#if ENABLED(EEPROM_SETTINGS)
|
114
|
102
|
persistentStore.access_start();
|
115
|
|
- uint8_t val;
|
116
|
103
|
while(len--) {
|
117
|
104
|
int pos = 0;
|
118
|
|
- if (!persistentStore.read_data(pos, (uint8_t *)&val, sizeof(val))) {
|
119
|
|
- print_hex_byte(val);
|
120
|
|
- }
|
|
105
|
+ persistentStore.write_data(pos, (uint8_t *)&val, sizeof(val));
|
121
|
106
|
}
|
122
|
107
|
SERIAL_EOL();
|
123
|
108
|
persistentStore.access_finish();
|
|
@@ -125,9 +110,28 @@
|
125
|
110
|
SERIAL_ECHOLN("NO EEPROM");
|
126
|
111
|
#endif
|
127
|
112
|
}
|
128
|
|
- SERIAL_EOL();
|
129
|
|
- }
|
130
|
|
- } break;
|
|
113
|
+ else {
|
|
114
|
+ while (len--) {
|
|
115
|
+ // Read bytes from EEPROM
|
|
116
|
+ #if ENABLED(EEPROM_SETTINGS)
|
|
117
|
+ persistentStore.access_start();
|
|
118
|
+ uint8_t val;
|
|
119
|
+ while(len--) {
|
|
120
|
+ int pos = 0;
|
|
121
|
+ if (!persistentStore.read_data(pos, (uint8_t *)&val, sizeof(val))) {
|
|
122
|
+ print_hex_byte(val);
|
|
123
|
+ }
|
|
124
|
+ }
|
|
125
|
+ SERIAL_EOL();
|
|
126
|
+ persistentStore.access_finish();
|
|
127
|
+ #else
|
|
128
|
+ SERIAL_ECHOLN("NO EEPROM");
|
|
129
|
+ #endif
|
|
130
|
+ }
|
|
131
|
+ SERIAL_EOL();
|
|
132
|
+ }
|
|
133
|
+ } break;
|
|
134
|
+ #endif
|
131
|
135
|
|
132
|
136
|
case 4: { // D4 Read / Write PIN
|
133
|
137
|
// const uint8_t pin = parser.byteval('P');
|
|
@@ -167,6 +171,20 @@
|
167
|
171
|
SERIAL_EOL();
|
168
|
172
|
}
|
169
|
173
|
} break;
|
|
174
|
+
|
|
175
|
+ case 100: { // D100 Disable heaters and attempt a hard hang (Watchdog Test)
|
|
176
|
+ SERIAL_ECHOLN("Disabling heaters and attempting to trigger Watchdog");
|
|
177
|
+ SERIAL_ECHOLN("(USE_WATCHDOG " TERN(USE_WATCHDOG, "ENABLED", "DISABLED") ")");
|
|
178
|
+ thermalManager.disable_all_heaters();
|
|
179
|
+ delay(1000); // Allow time to print
|
|
180
|
+ DISABLE_ISRS();
|
|
181
|
+ // Use a low-level delay that does not rely on interrupts to function
|
|
182
|
+ // Do not spin forever, to avoid thermal risks if heaters are enabled and
|
|
183
|
+ // watchdog does not work.
|
|
184
|
+ DELAY_US(10000000);
|
|
185
|
+ ENABLE_ISRS();
|
|
186
|
+ SERIAL_ECHOLN("FAILURE: Watchdog did not trigger board reset.");
|
|
187
|
+ }
|
170
|
188
|
}
|
171
|
189
|
}
|
172
|
190
|
|