Преглед изворни кода

Finish STM32F4 SD-based settings storage (#14844)

Tanguy Pruvot пре 5 година
родитељ
комит
eecfcd124d
1 измењених фајлова са 13 додато и 14 уклоњено
  1. 13
    14
      Marlin/src/HAL/HAL_STM32/persistent_store_sdcard.cpp

+ 13
- 14
Marlin/src/HAL/HAL_STM32/persistent_store_sdcard.cpp Прегледај датотеку

21
  */
21
  */
22
 
22
 
23
 /**
23
 /**
24
- * HAL for stm32duino.com based on Libmaple and compatible (STM32F1)
25
  * Implementation of EEPROM settings in SD Card
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
 #include "../../inc/MarlinConfig.h"
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
 #include "../shared/persistent_store_api.h"
33
 #include "../shared/persistent_store_api.h"
35
 
34
 
36
 #ifndef E2END
35
 #ifndef E2END
37
   #define E2END 0xFFF // 4KB
36
   #define E2END 0xFFF // 4KB
38
 #endif
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
 static char _ALIGN(4) HAL_eeprom_data[HAL_EEPROM_SIZE];
41
 static char _ALIGN(4) HAL_eeprom_data[HAL_EEPROM_SIZE];
43
 
42
 
44
 #if ENABLED(SDSUPPORT)
43
 #if ENABLED(SDSUPPORT)
52
 
51
 
53
     SdFile file, root = card.getroot();
52
     SdFile file, root = card.getroot();
54
     if (!file.open(&root, EEPROM_FILENAME, O_RDONLY))
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
     if (bytes_read < 0) return false;
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
       HAL_eeprom_data[bytes_read] = 0xFF;
59
       HAL_eeprom_data[bytes_read] = 0xFF;
61
     file.close();
60
     file.close();
62
     return true;
61
     return true;
66
     if (!card.isDetected()) return false;
65
     if (!card.isDetected()) return false;
67
 
66
 
68
     SdFile file, root = card.getroot();
67
     SdFile file, root = card.getroot();
69
-    int16_t bytes_written = 0;
68
+    int bytes_written = 0;
70
     if (file.open(&root, EEPROM_FILENAME, O_CREAT | O_WRITE | O_TRUNC)) {
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
       file.close();
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
 #else // !SDSUPPORT
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
 #endif // !SDSUPPORT
80
 #endif // !SDSUPPORT
82
 
81
 
98
   return false;
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
 #endif // EEPROM_SETTINGS
102
 #endif // EEPROM_SETTINGS
104
-#endif // __STM32F4__
103
+#endif // STM32

Loading…
Откажи
Сачувај