aboutsummaryrefslogtreecommitdiffstats
path: root/tmk_core/common/arm_atsam/eeprom.c
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/common/arm_atsam/eeprom.c')
-rw-r--r--tmk_core/common/arm_atsam/eeprom.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/tmk_core/common/arm_atsam/eeprom.c b/tmk_core/common/arm_atsam/eeprom.c
index 44a0bf4d7..a69f38282 100644
--- a/tmk_core/common/arm_atsam/eeprom.c
+++ b/tmk_core/common/arm_atsam/eeprom.c
@@ -16,9 +16,12 @@
#include "eeprom.h"
-#define EEPROM_SIZE 32
+#ifndef EEPROM_SIZE
+# include "eeconfig.h"
+# define EEPROM_SIZE (((EECONFIG_SIZE+3)/4)*4) // based off eeconfig's current usage, aligned to 4-byte sizes, to deal with LTO
+#endif
-static uint8_t buffer[EEPROM_SIZE];
+__attribute__((aligned(4))) static uint8_t buffer[EEPROM_SIZE];
uint8_t eeprom_read_byte(const uint8_t *addr) {
uintptr_t offset = (uintptr_t)addr;
@@ -40,7 +43,7 @@ uint32_t eeprom_read_dword(const uint32_t *addr) {
return eeprom_read_byte(p) | (eeprom_read_byte(p + 1) << 8) | (eeprom_read_byte(p + 2) << 16) | (eeprom_read_byte(p + 3) << 24);
}
-void eeprom_read_block(void *buf, const void *addr, uint32_t len) {
+void eeprom_read_block(void *buf, const void *addr, size_t len) {
const uint8_t *p = (const uint8_t *)addr;
uint8_t * dest = (uint8_t *)buf;
while (len--) {
@@ -62,7 +65,7 @@ void eeprom_write_dword(uint32_t *addr, uint32_t value) {
eeprom_write_byte(p, value >> 24);
}
-void eeprom_write_block(const void *buf, void *addr, uint32_t len) {
+void eeprom_write_block(const void *buf, void *addr, size_t len) {
uint8_t * p = (uint8_t *)addr;
const uint8_t *src = (const uint8_t *)buf;
while (len--) {
@@ -86,7 +89,7 @@ void eeprom_update_dword(uint32_t *addr, uint32_t value) {
eeprom_write_byte(p, value >> 24);
}
-void eeprom_update_block(const void *buf, void *addr, uint32_t len) {
+void eeprom_update_block(const void *buf, void *addr, size_t len) {
uint8_t * p = (uint8_t *)addr;
const uint8_t *src = (const uint8_t *)buf;
while (len--) {