|
@@ -22,6 +22,7 @@
|
22
|
22
|
|
23
|
23
|
/**
|
24
|
24
|
* HAL for stm32duino.com based on Libmaple and compatible (STM32F1)
|
|
25
|
+ * Implementation of EEPROM settings in SD Card
|
25
|
26
|
*/
|
26
|
27
|
|
27
|
28
|
#ifdef __STM32F1__
|
|
@@ -37,7 +38,8 @@
|
37
|
38
|
#endif
|
38
|
39
|
#define HAL_STM32F1_EEPROM_SIZE (E2END + 1)
|
39
|
40
|
|
40
|
|
-static char HAL_STM32F1_eeprom_content[HAL_STM32F1_EEPROM_SIZE];
|
|
41
|
+#define _ALIGN(x) __attribute__ ((aligned(x))) // SDIO uint32_t* compat.
|
|
42
|
+static char _ALIGN(4) HAL_STM32F1_eeprom_content[HAL_STM32F1_EEPROM_SIZE];
|
41
|
43
|
|
42
|
44
|
#if ENABLED(SDSUPPORT)
|
43
|
45
|
|
|
@@ -52,7 +54,7 @@ static char HAL_STM32F1_eeprom_content[HAL_STM32F1_EEPROM_SIZE];
|
52
|
54
|
if (!file.open(&root, EEPROM_FILENAME, O_RDONLY))
|
53
|
55
|
return false;
|
54
|
56
|
|
55
|
|
- int16_t bytes_read = file.read(HAL_STM32F1_eeprom_content, HAL_STM32F1_EEPROM_SIZE);
|
|
57
|
+ int bytes_read = file.read(HAL_STM32F1_eeprom_content, HAL_STM32F1_EEPROM_SIZE);
|
56
|
58
|
if (bytes_read < 0) return false;
|
57
|
59
|
for (; bytes_read < HAL_STM32F1_EEPROM_SIZE; bytes_read++)
|
58
|
60
|
HAL_STM32F1_eeprom_content[bytes_read] = 0xFF;
|
|
@@ -64,7 +66,7 @@ static char HAL_STM32F1_eeprom_content[HAL_STM32F1_EEPROM_SIZE];
|
64
|
66
|
if (!card.isDetected()) return false;
|
65
|
67
|
|
66
|
68
|
SdFile file, root = card.getroot();
|
67
|
|
- int16_t bytes_written = 0;
|
|
69
|
+ int bytes_written = 0;
|
68
|
70
|
if (file.open(&root, EEPROM_FILENAME, O_CREAT | O_WRITE | O_TRUNC)) {
|
69
|
71
|
bytes_written = file.write(HAL_STM32F1_eeprom_content, HAL_STM32F1_EEPROM_SIZE);
|
70
|
72
|
file.close();
|