Browse Source

🐛 Fix LPC1768 SD-based EEPROM debug

Fixes #22746
Scott Lahteine 3 years ago
parent
commit
0a1211fe3f
2 changed files with 30 additions and 18 deletions
  1. 26
    16
      Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp
  2. 4
    2
      Marlin/src/pins/stm32f4/pins_ARMED.h

+ 26
- 16
Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp View File

1
 /**
1
 /**
2
  * Marlin 3D Printer Firmware
2
  * Marlin 3D Printer Firmware
3
- *
4
  * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
3
  * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
5
- * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
6
- * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
7
- * Copyright (c) 2016 Victor Perez victor_pv@hotmail.com
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
8
  *
7
  *
9
  * This program is free software: you can redistribute it and/or modify
8
  * This program is free software: you can redistribute it and/or modify
10
  * it under the terms of the GNU General Public License as published by
9
  * it under the terms of the GNU General Public License as published by
20
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
21
  *
20
  *
22
  */
21
  */
22
+
23
+/**
24
+ * Implementation of EEPROM settings in SD Card
25
+ */
26
+
23
 #ifdef TARGET_LPC1768
27
 #ifdef TARGET_LPC1768
24
 
28
 
25
 #include "../../inc/MarlinConfig.h"
29
 #include "../../inc/MarlinConfig.h"
26
 
30
 
27
 #if ENABLED(SDCARD_EEPROM_EMULATION)
31
 #if ENABLED(SDCARD_EEPROM_EMULATION)
28
 
32
 
33
+//#define DEBUG_SD_EEPROM_EMULATION
34
+
29
 #include "../shared/eeprom_api.h"
35
 #include "../shared/eeprom_api.h"
30
 
36
 
31
 #include <chanfs/diskio.h>
37
 #include <chanfs/diskio.h>
38
 FIL eeprom_file;
44
 FIL eeprom_file;
39
 bool eeprom_file_open = false;
45
 bool eeprom_file_open = false;
40
 
46
 
47
+#define EEPROM_FILENAME "eeprom.dat"
41
 #ifndef MARLIN_EEPROM_SIZE
48
 #ifndef MARLIN_EEPROM_SIZE
42
   #define MARLIN_EEPROM_SIZE size_t(0x1000) // 4KiB of Emulated EEPROM
49
   #define MARLIN_EEPROM_SIZE size_t(0x1000) // 4KiB of Emulated EEPROM
43
 #endif
50
 #endif
51
+
44
 size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; }
52
 size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; }
45
 
53
 
46
 bool PersistentStore::access_start() {
54
 bool PersistentStore::access_start() {
50
     MSC_Release_Lock();
58
     MSC_Release_Lock();
51
     return false;
59
     return false;
52
   }
60
   }
53
-  FRESULT res = f_open(&eeprom_file, "eeprom.dat", FA_OPEN_ALWAYS | FA_WRITE | FA_READ);
61
+  FRESULT res = f_open(&eeprom_file, EEPROM_FILENAME, FA_OPEN_ALWAYS | FA_WRITE | FA_READ);
54
   if (res) MSC_Release_Lock();
62
   if (res) MSC_Release_Lock();
55
 
63
 
56
   if (res == FR_OK) {
64
   if (res == FR_OK) {
81
 // This extra chit-chat goes away soon, but is helpful for now
89
 // This extra chit-chat goes away soon, but is helpful for now
82
 // to see errors that are happening in read_data / write_data
90
 // to see errors that are happening in read_data / write_data
83
 static void debug_rw(const bool write, int &pos, const uint8_t *value, const size_t size, const FRESULT s, const size_t total=0) {
91
 static void debug_rw(const bool write, int &pos, const uint8_t *value, const size_t size, const FRESULT s, const size_t total=0) {
84
-  PGM_P const rw_str = write ? PSTR("write") : PSTR("read");
85
-  SERIAL_CHAR(' ');
86
-  SERIAL_ECHOPGM_P(rw_str);
87
-  SERIAL_ECHOLNPGM("_data(", pos, ",", value, ",", size, ", ...)");
88
-  if (total) {
89
-    SERIAL_ECHOPGM(" f_");
92
+  #if ENABLED(DEBUG_SD_EEPROM_EMULATION)
93
+    PGM_P const rw_str = write ? PSTR("write") : PSTR("read");
94
+    SERIAL_CHAR(' ');
90
     SERIAL_ECHOPGM_P(rw_str);
95
     SERIAL_ECHOPGM_P(rw_str);
91
-    SERIAL_ECHOPGM("()=", s, "\n size=", size, "\n bytes_");
92
-    SERIAL_ECHOLNPGM_P(write ? PSTR("written=") : PSTR("read="), total);
93
-  }
94
-  else
95
-    SERIAL_ECHOLNPGM(" f_lseek()=", s);
96
+    SERIAL_ECHOLNPGM("_data(", pos, ",", *value, ",", size, ", ...)");
97
+    if (total) {
98
+      SERIAL_ECHOPGM(" f_");
99
+      SERIAL_ECHOPGM_P(rw_str);
100
+      SERIAL_ECHOPGM("()=", s, "\n size=", size, "\n bytes_");
101
+      SERIAL_ECHOLNPGM_P(write ? PSTR("written=") : PSTR("read="), total);
102
+    }
103
+    else
104
+      SERIAL_ECHOLNPGM(" f_lseek()=", s);
105
+  #endif
96
 }
106
 }
97
 
107
 
98
 // File function return codes for type FRESULT. This goes away soon, but
108
 // File function return codes for type FRESULT. This goes away soon, but

+ 4
- 2
Marlin/src/pins/stm32f4/pins_ARMED.h View File

38
 #define BOARD_INFO_NAME      "Arm'ed"
38
 #define BOARD_INFO_NAME      "Arm'ed"
39
 #define DEFAULT_MACHINE_NAME BOARD_INFO_NAME
39
 #define DEFAULT_MACHINE_NAME BOARD_INFO_NAME
40
 
40
 
41
-#define I2C_EEPROM
42
-#define MARLIN_EEPROM_SIZE                0x1000  // 4KB
41
+#if NO_EEPROM_SELECTED
42
+  #define I2C_EEPROM
43
+  #define MARLIN_EEPROM_SIZE              0x1000  // 4KB
44
+#endif
43
 
45
 
44
 //
46
 //
45
 // Limit Switches
47
 // Limit Switches

Loading…
Cancel
Save