1
1
/* *
2
2
* Marlin 3D Printer Firmware
3
- *
4
3
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
5
- * Copyright (c) 2016 Bob Cousins [email protected]
6
- * Copyright (c) 2015-2016 Nico Tonnhofer [email protected]
7
- * Copyright (c) 2016 Victor Perez [email protected]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
8
7
*
9
8
* This program is free software: you can redistribute it and/or modify
10
9
* it under the terms of the GNU General Public License as published by
20
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
27
#ifdef TARGET_LPC1768
24
28
25
29
#include " ../../inc/MarlinConfig.h"
26
30
27
31
#if ENABLED(SDCARD_EEPROM_EMULATION)
28
32
33
+ // #define DEBUG_SD_EEPROM_EMULATION
34
+
29
35
#include " ../shared/eeprom_api.h"
30
36
31
37
#include < chanfs/diskio.h>
@@ -38,9 +44,11 @@ FATFS fat_fs;
38
44
FIL eeprom_file;
39
45
bool eeprom_file_open = false ;
40
46
47
+ #define EEPROM_FILENAME " eeprom.dat"
41
48
#ifndef MARLIN_EEPROM_SIZE
42
49
#define MARLIN_EEPROM_SIZE size_t (0x1000 ) // 4KiB of Emulated EEPROM
43
50
#endif
51
+
44
52
size_t PersistentStore::capacity () { return MARLIN_EEPROM_SIZE; }
45
53
46
54
bool PersistentStore::access_start () {
@@ -50,7 +58,7 @@ bool PersistentStore::access_start() {
50
58
MSC_Release_Lock ();
51
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
62
if (res) MSC_Release_Lock ();
55
63
56
64
if (res == FR_OK) {
@@ -81,18 +89,20 @@ bool PersistentStore::access_finish() {
81
89
// This extra chit-chat goes away soon, but is helpful for now
82
90
// to see errors that are happening in read_data / write_data
83
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
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
108
// File function return codes for type FRESULT. This goes away soon, but
0 commit comments