Bläddra i källkod

Finish STM32F4 SD-based settings storage (#14844)

Tanguy Pruvot 5 år sedan
förälder
incheckning
eecfcd124d
1 ändrade filer med 13 tillägg och 14 borttagningar
  1. 13
    14
      Marlin/src/HAL/HAL_STM32/persistent_store_sdcard.cpp

+ 13
- 14
Marlin/src/HAL/HAL_STM32/persistent_store_sdcard.cpp Visa fil

@@ -21,24 +21,23 @@
21 21
  */
22 22
 
23 23
 /**
24
- * HAL for stm32duino.com based on Libmaple and compatible (STM32F1)
25 24
  * Implementation of EEPROM settings in SD Card
26 25
  */
27 26
 
28
-#ifdef TARGET_STM32F4
27
+#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
29 28
 
30 29
 #include "../../inc/MarlinConfig.h"
31 30
 
32
-#if ENABLED(EEPROM_SETTINGS) && NONE(FLASH_EEPROM_EMULATION, SPI_EEPROM, I2C_EEPROM)
31
+#if ENABLED(EEPROM_SETTINGS) && NONE(FLASH_EEPROM_EMULATION, SRAM_EEPROM_EMULATION, SPI_EEPROM, I2C_EEPROM)
33 32
 
34 33
 #include "../shared/persistent_store_api.h"
35 34
 
36 35
 #ifndef E2END
37 36
   #define E2END 0xFFF // 4KB
38 37
 #endif
39
-#define HAL_EEPROM_SIZE (E2END + 1) // 16KB
38
+#define HAL_EEPROM_SIZE int(E2END + 1)
40 39
 
41
-#define _ALIGN(x) __attribute__ ((aligned(x))) // SDIO uint32_t* compat.
40
+#define _ALIGN(x) __attribute__ ((aligned(x)))
42 41
 static char _ALIGN(4) HAL_eeprom_data[HAL_EEPROM_SIZE];
43 42
 
44 43
 #if ENABLED(SDSUPPORT)
@@ -52,11 +51,11 @@ static char _ALIGN(4) HAL_eeprom_data[HAL_EEPROM_SIZE];
52 51
 
53 52
     SdFile file, root = card.getroot();
54 53
     if (!file.open(&root, EEPROM_FILENAME, O_RDONLY))
55
-      return false;
54
+      return true;
56 55
 
57
-    int16_t bytes_read = file.read(HAL_eeprom_data, HAL_STM32F4_EEPROM_SIZE);
56
+    int bytes_read = file.read(HAL_eeprom_data, HAL_EEPROM_SIZE);
58 57
     if (bytes_read < 0) return false;
59
-    for (; bytes_read < HAL_STM32F4_EEPROM_SIZE; bytes_read++)
58
+    for (; bytes_read < HAL_EEPROM_SIZE; bytes_read++)
60 59
       HAL_eeprom_data[bytes_read] = 0xFF;
61 60
     file.close();
62 61
     return true;
@@ -66,17 +65,17 @@ static char _ALIGN(4) HAL_eeprom_data[HAL_EEPROM_SIZE];
66 65
     if (!card.isDetected()) return false;
67 66
 
68 67
     SdFile file, root = card.getroot();
69
-    int16_t bytes_written = 0;
68
+    int bytes_written = 0;
70 69
     if (file.open(&root, EEPROM_FILENAME, O_CREAT | O_WRITE | O_TRUNC)) {
71
-      bytes_written = file.write(HAL_eeprom_data, HAL_STM32F4_EEPROM_SIZE);
70
+      bytes_written = file.write(HAL_eeprom_data, HAL_EEPROM_SIZE);
72 71
       file.close();
73 72
     }
74
-    return (bytes_written == HAL_STM32F4_EEPROM_SIZE);
73
+    return (bytes_written == HAL_EEPROM_SIZE);
75 74
   }
76 75
 
77 76
 #else // !SDSUPPORT
78 77
 
79
-  #error "Please define SPI_EEPROM (in Configuration.h) or disable EEPROM_SETTINGS."
78
+  #error "Please define an EEPROM, a SDCARD or disable EEPROM_SETTINGS."
80 79
 
81 80
 #endif // !SDSUPPORT
82 81
 
@@ -98,7 +97,7 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uin
98 97
   return false;
99 98
 }
100 99
 
101
-size_t PersistentStore::capacity() { return HAL_STM32F4_EEPROM_SIZE; }
100
+size_t PersistentStore::capacity() { return HAL_EEPROM_SIZE; }
102 101
 
103 102
 #endif // EEPROM_SETTINGS
104
-#endif // __STM32F4__
103
+#endif // STM32

Laddar…
Avbryt
Spara