Selaa lähdekoodia

More explicit EEPROM types (#17127)

Scott Lahteine 4 vuotta sitten
vanhempi
commit
112245ee48
No account linked to committer's email address

+ 2
- 2
Marlin/src/HAL/HAL_DUE/EepromEmulation.cpp Näytä tiedosto

@@ -54,7 +54,7 @@
54 54
 
55 55
 #include "../../inc/MarlinConfig.h"
56 56
 
57
-#if ENABLED(EEPROM_SETTINGS) && NONE(I2C_EEPROM, SPI_EEPROM)
57
+#if ENABLED(FLASH_EEPROM_EMULATION)
58 58
 
59 59
 #include "../shared/Marduino.h"
60 60
 #include "../shared/persistent_store_api.h"
@@ -1016,5 +1016,5 @@ void eeprom_flush() {
1016 1016
   ee_Flush();
1017 1017
 }
1018 1018
 
1019
-#endif // EEPROM_SETTINGS && (!I2C_EEPROM && !SPI_EEPROM)
1019
+#endif // FLASH_EEPROM_EMULATION
1020 1020
 #endif // ARDUINO_ARCH_AVR

+ 6
- 0
Marlin/src/HAL/HAL_DUE/inc/Conditionals_post.h Näytä tiedosto

@@ -20,3 +20,9 @@
20 20
  *
21 21
  */
22 22
 #pragma once
23
+
24
+#if USE_EMULATED_EEPROM
25
+  #undef SRAM_EEPROM_EMULATION
26
+  #undef SDCARD_EEPROM_EMULATION
27
+  #define FLASH_EEPROM_EMULATION 1
28
+#endif

+ 2
- 2
Marlin/src/HAL/HAL_DUE/persistent_store_eeprom.cpp Näytä tiedosto

@@ -29,7 +29,7 @@
29 29
 #include "../../inc/MarlinConfig.h"
30 30
 #include "../shared/persistent_store_api.h"
31 31
 
32
-#if !defined(E2END) && NONE(I2C_EEPROM, SPI_EEPROM)
32
+#if !defined(E2END) && ENABLED(FLASH_EEPROM_EMULATION)
33 33
   #define E2END 0xFFF // Default to Flash emulated EEPROM size (EepromEmulation_Due.cpp)
34 34
 #endif
35 35
 
@@ -38,7 +38,7 @@ extern void eeprom_flush();
38 38
 bool PersistentStore::access_start() { return true; }
39 39
 
40 40
 bool PersistentStore::access_finish() {
41
-  #if NONE(I2C_EEPROM, SPI_EEPROM)
41
+  #if ENABLED(FLASH_EEPROM_EMULATION)
42 42
     eeprom_flush();
43 43
   #endif
44 44
   return true;

+ 8
- 0
Marlin/src/HAL/HAL_LPC1768/inc/Conditionals_post.h Näytä tiedosto

@@ -20,3 +20,11 @@
20 20
  *
21 21
  */
22 22
 #pragma once
23
+
24
+#if ENABLED(EEPROM_SETTINGS)
25
+  #undef USE_REAL_EEPROM
26
+  #define USE_EMULATED_EEPROM 1
27
+  #if DISABLED(FLASH_EEPROM_EMULATION)
28
+    #define SDCARD_EEPROM_EMULATION 1
29
+  #endif
30
+#endif

+ 1
- 4
Marlin/src/HAL/HAL_LPC1768/persistent_store_flash.cpp Näytä tiedosto

@@ -38,13 +38,11 @@
38 38
  */
39 39
 #include "../../inc/MarlinConfigPre.h"
40 40
 
41
-#if ENABLED(EEPROM_SETTINGS)
41
+#if ENABLED(FLASH_EEPROM_EMULATION)
42 42
 
43 43
 #include "persistent_store_api.h"
44 44
 #include "../../inc/MarlinConfig.h"
45 45
 
46
-#if ENABLED(FLASH_EEPROM_EMULATION)
47
-
48 46
 extern "C" {
49 47
   #include <lpc17xx_iap.h>
50 48
 }
@@ -128,5 +126,4 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t
128 126
 size_t PersistentStore::capacity() { return EEPROM_SIZE; }
129 127
 
130 128
 #endif // FLASH_EEPROM_EMULATION
131
-#endif // EEPROM_SETTINGS
132 129
 #endif // TARGET_LPC1768

+ 3
- 7
Marlin/src/HAL/HAL_LPC1768/persistent_store_sdcard.cpp Näytä tiedosto

@@ -22,15 +22,12 @@
22 22
  */
23 23
 #ifdef TARGET_LPC1768
24 24
 
25
-#include "../../inc/MarlinConfigPre.h"
25
+#include "../../inc/MarlinConfig.h"
26 26
 
27
-#if ENABLED(EEPROM_SETTINGS)
27
+#if ENABLED(SDCARD_EEPROM_EMULATION)
28 28
 
29
-#include "../../inc/MarlinConfig.h"
30 29
 #include "persistent_store_api.h"
31 30
 
32
-#if DISABLED(FLASH_EEPROM_EMULATION)
33
-
34 31
 #include <chanfs/diskio.h>
35 32
 #include <chanfs/ff.h>
36 33
 
@@ -178,6 +175,5 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uin
178 175
 
179 176
 size_t PersistentStore::capacity() { return 4096; } // 4KiB of Emulated EEPROM
180 177
 
181
-#endif // !FLASH_EEPROM_EMULATION
182
-#endif // EEPROM_SETTINGS
178
+#endif // SDCARD_EEPROM_EMULATION
183 179
 #endif // TARGET_LPC1768

+ 6
- 0
Marlin/src/HAL/HAL_SAMD51/inc/Conditionals_post.h Näytä tiedosto

@@ -20,3 +20,9 @@
20 20
  *
21 21
  */
22 22
 #pragma once
23
+
24
+#if USE_EMULATED_EEPROM
25
+  #undef SRAM_EEPROM_EMULATION
26
+  #undef SDCARD_EEPROM_EMULATION
27
+  #define FLASH_EEPROM_EMULATION 1
28
+#endif

+ 1
- 1
Marlin/src/HAL/HAL_SAMD51/inc/SanityCheck.h Näytä tiedosto

@@ -23,7 +23,7 @@
23 23
  * Test SAMD51 specific configuration values for errors at compile-time.
24 24
  */
25 25
 
26
-#if ENABLED(EEPROM_SETTINGS) && NONE(SPI_EEPROM, I2C_EEPROM)
26
+#if ENABLED(FLASH_EEPROM_EMULATION)
27 27
   #warning "Did you activate the SmartEEPROM? See https://github.com/GMagician/SAMD51-SmartEEprom-Manager/releases"
28 28
 #endif
29 29
 

+ 17
- 17
Marlin/src/HAL/HAL_SAMD51/persistent_store_eeprom.cpp Näytä tiedosto

@@ -27,7 +27,7 @@
27 27
 
28 28
 #include "../shared/persistent_store_api.h"
29 29
 
30
-#if NONE(SPI_EEPROM, I2C_EEPROM)
30
+#if ENABLED(FLASH_EEPROM_EMULATION)
31 31
   #define NVMCTRL_CMD(c)    do{                                                 \
32 32
                               SYNC(!NVMCTRL->STATUS.bit.READY);                 \
33 33
                               NVMCTRL->INTFLAG.bit.DONE = true;                 \
@@ -41,7 +41,7 @@
41 41
 #endif
42 42
 
43 43
 bool PersistentStore::access_start() {
44
-  #if NONE(SPI_EEPROM, I2C_EEPROM)
44
+  #if ENABLED(FLASH_EEPROM_EMULATION)
45 45
     NVMCTRL->SEECFG.reg = NVMCTRL_SEECFG_WMODE_BUFFERED;  // Buffered mode and segment reallocation active
46 46
   #endif
47 47
 
@@ -49,7 +49,7 @@ bool PersistentStore::access_start() {
49 49
 }
50 50
 
51 51
 bool PersistentStore::access_finish() {
52
-  #if NONE(SPI_EEPROM, I2C_EEPROM)
52
+  #if ENABLED(FLASH_EEPROM_EMULATION)
53 53
     NVMCTRL_FLUSH();
54 54
     if (!NVMCTRL->SEESTAT.bit.LOCK)
55 55
       NVMCTRL_CMD(NVMCTRL_CTRLB_CMD_LSEE);    // Lock E2P data write access
@@ -59,14 +59,20 @@ bool PersistentStore::access_finish() {
59 59
 }
60 60
 
61 61
 bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
62
-  #if NONE(SPI_EEPROM, I2C_EEPROM)
62
+  #if ENABLED(FLASH_EEPROM_EMULATION)
63 63
     if (NVMCTRL->SEESTAT.bit.RLOCK)
64 64
       NVMCTRL_CMD(NVMCTRL_CTRLB_CMD_USEE);    // Unlock E2P data write access
65 65
   #endif
66 66
 
67 67
   while (size--) {
68 68
     const uint8_t v = *value;
69
-    #if ANY(SPI_EEPROM, I2C_EEPROM)
69
+    #if ENABLED(FLASH_EEPROM_EMULATION)
70
+      SYNC(NVMCTRL->SEESTAT.bit.BUSY);
71
+      if (NVMCTRL->INTFLAG.bit.SEESFULL)
72
+        NVMCTRL_FLUSH();      // Next write will trigger a sector reallocation. I need to flush 'pagebuffer'
73
+      ((volatile uint8_t *)SEEPROM_ADDR)[pos] = v;
74
+      SYNC(!NVMCTRL->INTFLAG.bit.SEEWRC);
75
+    #else
70 76
       uint8_t * const p = (uint8_t * const)pos;
71 77
       if (v != eeprom_read_byte(p)) {
72 78
         eeprom_write_byte(p, v);
@@ -76,12 +82,6 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui
76 82
           return true;
77 83
         }
78 84
       }
79
-    #else
80
-      SYNC(NVMCTRL->SEESTAT.bit.BUSY);
81
-      if (NVMCTRL->INTFLAG.bit.SEESFULL)
82
-        NVMCTRL_FLUSH();      // Next write will trigger a sector reallocation. I need to flush 'pagebuffer'
83
-      ((volatile uint8_t *)SEEPROM_ADDR)[pos] = v;
84
-      SYNC(!NVMCTRL->INTFLAG.bit.SEEWRC);
85 85
     #endif
86 86
     crc16(crc, &v, 1);
87 87
     pos++;
@@ -93,11 +93,11 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui
93 93
 bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) {
94 94
   while (size--) {
95 95
     uint8_t c;
96
-    #if ANY(SPI_EEPROM, I2C_EEPROM)
97
-      c = eeprom_read_byte((uint8_t*)pos);
98
-    #else
96
+    #if ENABLED(FLASH_EEPROM_EMULATION)
99 97
       SYNC(NVMCTRL->SEESTAT.bit.BUSY);
100 98
       c = ((volatile uint8_t *)SEEPROM_ADDR)[pos];
99
+    #else
100
+      c = eeprom_read_byte((uint8_t*)pos);
101 101
     #endif
102 102
     if (writing) *value = c;
103 103
     crc16(crc, &c, 1);
@@ -108,9 +108,7 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t
108 108
 }
109 109
 
110 110
 size_t PersistentStore::capacity() {
111
-  #if ANY(SPI_EEPROM, I2C_EEPROM)
112
-    return E2END + 1;
113
-  #else
111
+  #if ENABLED(FLASH_EEPROM_EMULATION)
114 112
     const uint8_t psz = NVMCTRL->SEESTAT.bit.PSZ,
115 113
                   sblk = NVMCTRL->SEESTAT.bit.SBLK;
116 114
 
@@ -121,6 +119,8 @@ size_t PersistentStore::capacity() {
121 119
     else if (sblk <= 4 || psz == 5) return 16384;
122 120
     else if (sblk >= 9 && psz == 7) return 65536;
123 121
     else                            return 32768;
122
+  #else
123
+    return E2END + 1;
124 124
   #endif
125 125
 }
126 126
 

+ 7
- 7
Marlin/src/HAL/HAL_STM32/persistent_store_impl.cpp Näytä tiedosto

@@ -24,7 +24,7 @@
24 24
 
25 25
 #include "../../inc/MarlinConfig.h"
26 26
 
27
-#if ENABLED(EEPROM_SETTINGS) && ANY(SRAM_EEPROM_EMULATION, SPI_EEPROM, I2C_EEPROM)
27
+#if EITHER(USE_REAL_EEPROM, SRAM_EEPROM_EMULATION)
28 28
 
29 29
 #include "../shared/persistent_store_api.h"
30 30
 
@@ -41,7 +41,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui
41 41
     uint8_t v = *value;
42 42
 
43 43
     // Save to either external EEPROM, program flash or Backup SRAM
44
-    #if EITHER(SPI_EEPROM, I2C_EEPROM)
44
+    #if USE_REAL_EEPROM
45 45
       // EEPROM has only ~100,000 write cycles,
46 46
       // so only write bytes that have changed!
47 47
       uint8_t * const p = (uint8_t * const)pos;
@@ -68,7 +68,7 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t
68 68
   do {
69 69
     // Read from either external EEPROM, program flash or Backup SRAM
70 70
     const uint8_t c = (
71
-      #if EITHER(SPI_EEPROM, I2C_EEPROM)
71
+      #if USE_REAL_EEPROM
72 72
         eeprom_read_byte((uint8_t*)pos)
73 73
       #else
74 74
         (*(__IO uint8_t *)(BKPSRAM_BASE + ((uint8_t*)pos)))
@@ -85,13 +85,13 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t
85 85
 
86 86
 size_t PersistentStore::capacity() {
87 87
   return (
88
-    #if ENABLED(SRAM_EEPROM_EMULATION)
89
-      4096 // 4kB
90
-    #else
88
+    #if USE_REAL_EEPROM
91 89
       E2END + 1
90
+    #else
91
+      4096 // 4kB
92 92
     #endif
93 93
   );
94 94
 }
95 95
 
96
-#endif // EEPROM_SETTINGS && (SRAM_EEPROM_EMULATION || SPI_EEPROM || I2C_EEPROM)
96
+#endif // USE_REAL_EEPROM || SRAM_EEPROM_EMULATION
97 97
 #endif // ARDUINO_ARCH_STM32 && !STM32GENERIC

+ 3
- 3
Marlin/src/HAL/HAL_STM32/persistent_store_sdcard.cpp Näytä tiedosto

@@ -28,7 +28,7 @@
28 28
 
29 29
 #include "../../inc/MarlinConfig.h"
30 30
 
31
-#if ENABLED(EEPROM_SETTINGS) && NONE(FLASH_EEPROM_EMULATION, SRAM_EEPROM_EMULATION, SPI_EEPROM, I2C_EEPROM)
31
+#if ENABLED(SDCARD_EEPROM_EMULATION)
32 32
 
33 33
 #include "../shared/persistent_store_api.h"
34 34
 
@@ -99,5 +99,5 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uin
99 99
 
100 100
 size_t PersistentStore::capacity() { return HAL_EEPROM_SIZE; }
101 101
 
102
-#endif // EEPROM_SETTINGS
103
-#endif // STM32
102
+#endif // SDCARD_EEPROM_EMULATION
103
+#endif // STM32 && !STM32GENERIC

+ 2
- 2
Marlin/src/HAL/HAL_STM32F1/persistent_store_eeprom.cpp Näytä tiedosto

@@ -22,7 +22,7 @@
22 22
 
23 23
 #include "../../inc/MarlinConfig.h"
24 24
 
25
-#if ENABLED(EEPROM_SETTINGS) && EITHER(SPI_EEPROM, I2C_EEPROM)
25
+#if USE_REAL_EEPROM
26 26
 
27 27
 #include "../shared/persistent_store_api.h"
28 28
 
@@ -73,5 +73,5 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t
73 73
 
74 74
 size_t PersistentStore::capacity() { return E2END + 1; }
75 75
 
76
-#endif // EEPROM_SETTINGS && EITHER(SPI_EEPROM, I2C_EEPROM)
76
+#endif // USE_REAL_EEPROM
77 77
 #endif // __STM32F1__

+ 2
- 2
Marlin/src/HAL/HAL_STM32F1/persistent_store_sdcard.cpp Näytä tiedosto

@@ -29,7 +29,7 @@
29 29
 
30 30
 #include "../../inc/MarlinConfig.h"
31 31
 
32
-#if ENABLED(EEPROM_SETTINGS) && NONE(FLASH_EEPROM_EMULATION, SPI_EEPROM, I2C_EEPROM)
32
+#if ENABLED(SDCARD_EEPROM_EMULATION)
33 33
 
34 34
 #include "../shared/persistent_store_api.h"
35 35
 
@@ -100,6 +100,6 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uin
100 100
 
101 101
 size_t PersistentStore::capacity() { return HAL_EEPROM_SIZE; }
102 102
 
103
-#endif // EEPROM_SETTINGS
103
+#endif // SDCARD_EEPROM_EMULATION
104 104
 
105 105
 #endif // __STM32F1__

+ 2
- 8
Marlin/src/HAL/HAL_STM32_F4_F7/EmulatedEeprom.cpp Näytä tiedosto

@@ -27,13 +27,7 @@
27 27
 // Include configs and pins to get all EEPROM flags
28 28
 #include "../../inc/MarlinConfig.h"
29 29
 
30
-#ifdef STM32F7
31
-  #define HAS_EMULATED_EEPROM 1
32
-#else
33
-  #define HAS_EMULATED_EEPROM NONE(I2C_EEPROM, SPI_EEPROM)
34
-#endif
35
-
36
-#if HAS_EMULATED_EEPROM && ENABLED(EEPROM_SETTINGS)
30
+#if ENABLED(FLASH_EEPROM_EMULATION)
37 31
 
38 32
 // ------------------------
39 33
 // Includes
@@ -118,5 +112,5 @@ void eeprom_update_block(const void *__src, void *__dst, size_t __n) {
118 112
 
119 113
 }
120 114
 
121
-#endif // EEPROM_SETTINGS
115
+#endif // FLASH_EEPROM_EMULATION
122 116
 #endif // STM32GENERIC && (STM32F4 || STM32F7)

+ 8
- 0
Marlin/src/HAL/HAL_STM32_F4_F7/inc/Conditionals_post.h Näytä tiedosto

@@ -20,3 +20,11 @@
20 20
  *
21 21
  */
22 22
 #pragma once
23
+
24
+#if ENABLED(EEPROM_SETTINGS) && defined(STM32F7)
25
+  #undef USE_REAL_EEPROM
26
+  #define USE_EMULATED_EEPROM 1
27
+  #undef SRAM_EEPROM_EMULATION
28
+  #undef SDCARD_EEPROM_EMULATION
29
+  #define FLASH_EEPROM_EMULATION 1
30
+#endif

+ 17
- 0
Marlin/src/inc/Conditionals_post.h Näytä tiedosto

@@ -35,6 +35,23 @@
35 35
   #define HAS_LINEAR_E_JERK 1
36 36
 #endif
37 37
 
38
+#if ENABLED(EEPROM_SETTINGS)
39
+  #if NONE(FLASH_EEPROM_EMULATION, SRAM_EEPROM_EMULATION, SDCARD_EEPROM_EMULATION) && EITHER(I2C_EEPROM, SPI_EEPROM)
40
+    #define USE_REAL_EEPROM 1
41
+  #else
42
+    #define USE_EMULATED_EEPROM 1
43
+  #endif
44
+  #if NONE(USE_REAL_EEPROM, FLASH_EEPROM_EMULATION, SRAM_EEPROM_EMULATION)
45
+    #define SDCARD_EEPROM_EMULATION 1
46
+  #endif
47
+#else
48
+  #undef I2C_EEPROM
49
+  #undef SPI_EEPROM
50
+  #undef SDCARD_EEPROM_EMULATION
51
+  #undef SRAM_EEPROM_EMULATION
52
+  #undef FLASH_EEPROM_EMULATION
53
+#endif
54
+
38 55
 #ifdef TEENSYDUINO
39 56
   #undef max
40 57
   #define max(a,b) ((a)>(b)?(a):(b))

+ 2
- 2
Marlin/src/module/printcounter.h Näytä tiedosto

@@ -28,7 +28,7 @@
28 28
 // Print debug messages with M111 S2
29 29
 //#define DEBUG_PRINTCOUNTER
30 30
 
31
-#if EITHER(I2C_EEPROM, SPI_EEPROM)
31
+#if USE_REAL_EEPROM
32 32
   // round up address to next page boundary (assuming 32 byte pages)
33 33
   #define STATS_EEPROM_ADDRESS 0x40
34 34
 #else
@@ -57,7 +57,7 @@ class PrintCounter: public Stopwatch {
57 57
   private:
58 58
     typedef Stopwatch super;
59 59
 
60
-    #if EITHER(I2C_EEPROM, SPI_EEPROM) || defined(CPU_32_BIT)
60
+    #if USE_REAL_EEPROM || defined(CPU_32_BIT)
61 61
       typedef uint32_t eeprom_address_t;
62 62
     #else
63 63
       typedef uint16_t eeprom_address_t;

+ 2
- 2
Marlin/src/sd/cardreader.cpp Näytä tiedosto

@@ -370,7 +370,7 @@ void CardReader::mount() {
370 370
   else {
371 371
     flag.mounted = true;
372 372
     SERIAL_ECHO_MSG(STR_SD_CARD_OK);
373
-    #if ENABLED(EEPROM_SETTINGS) && NONE(FLASH_EEPROM_EMULATION, SPI_EEPROM, I2C_EEPROM)
373
+    #if ENABLED(SDCARD_EEPROM_EMULATION)
374 374
       settings.first_load();
375 375
     #endif
376 376
   }
@@ -622,7 +622,7 @@ void CardReader::checkautostart() {
622 622
   if (autostart_index < 0 || flag.sdprinting) return;
623 623
 
624 624
   if (!isMounted()) mount();
625
-  #if ENABLED(EEPROM_SETTINGS) && NONE(FLASH_EEPROM_EMULATION, SPI_EEPROM, I2C_EEPROM)
625
+  #if ENABLED(SDCARD_EEPROM_EMULATION)
626 626
     else settings.first_load();
627 627
   #endif
628 628
 

Loading…
Peruuta
Tallenna