Add additional fixes to EEPROM driver selection (#7274) (#266)

* Add additional fixes to EEPROM driver selection (#7274)

- uprintf -> dprintf
- Fix atsam "vendor" eeprom.
- Bump Kinetis K20x to 64 bytes, too.
- Rollback Kinetis to 32 bytes as partitioning can only be done once. Add warning about changing the value.
- Change RAM-backed "fake" EEPROM implementations to match eeconfig's current usage.
- Add 24LC128 by request.

* format code according to conventions [skip ci]

Co-authored-by: Nick Brassel <nick@tzarc.org>
Co-authored-by: QMK Bot <hello@qmk.fm>
Co-authored-by: Florian Didron <fdidron@users.noreply.github.com>
This commit is contained in:
Drashna Jaelre
2020-02-14 01:06:06 -08:00
committed by Florian Didron
parent 30ed4bdb38
commit ebd4b1dc1e
7 changed files with 126 additions and 13 deletions
+46
View File
@@ -0,0 +1,46 @@
/* Copyright 2019 Nick Brassel (tzarc)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <string.h>
#include "eeprom_driver.h"
void eeprom_driver_init(void) {
/* Any initialisation code */
}
void eeprom_driver_erase(void) {
/* Wipe out the EEPROM, setting values to zero */
}
void eeprom_read_block(void *buf, const void *addr, size_t len) {
/*
Read a block of data:
buf: target buffer
addr: 0-based offset within the EEPROM
len: length to read
*/
}
void eeprom_write_block(const void *buf, void *addr, size_t len) {
/*
Write a block of data:
buf: target buffer
addr: 0-based offset within the EEPROM
len: length to write
*/
}
+6 -6
View File
@@ -76,11 +76,11 @@ void eeprom_read_block(void *buf, const void *addr, size_t len) {
i2c_receive(EXTERNAL_EEPROM_I2C_ADDRESS((intptr_t)addr), buf, len, 100);
#ifdef DEBUG_EEPROM_OUTPUT
uprintf("[EEPROM R] 0x%04X: ", ((int)addr));
dprintf("[EEPROM R] 0x%04X: ", ((int)addr));
for (size_t i = 0; i < len; ++i) {
uprintf(" %02X", (int)(((uint8_t *)buf)[i]));
dprintf(" %02X", (int)(((uint8_t *)buf)[i]));
}
uprintf("\n");
dprintf("\n");
#endif // DEBUG_EEPROM_OUTPUT
}
@@ -103,11 +103,11 @@ void eeprom_write_block(const void *buf, void *addr, size_t len) {
}
#ifdef DEBUG_EEPROM_OUTPUT
uprintf("[EEPROM W] 0x%04X: ", ((int)target_addr));
dprintf("[EEPROM W] 0x%04X: ", ((int)target_addr));
for (uint8_t i = 0; i < write_length; i++) {
uprintf(" %02X", (int)(read_buf[i]));
dprintf(" %02X", (int)(read_buf[i]));
}
uprintf("\n");
dprintf("\n");
#endif // DEBUG_EEPROM_OUTPUT
i2c_transmit(EXTERNAL_EEPROM_I2C_ADDRESS((intptr_t)addr), complete_packet, EXTERNAL_EEPROM_ADDRESS_SIZE + write_length, 100);
+1 -1
View File
@@ -20,7 +20,7 @@
#include "eeprom_driver.h"
#include "eeprom_transient.h"
static uint8_t transientBuffer[TRANSIENT_EEPROM_SIZE] = {0};
__attribute__((aligned(4))) static uint8_t transientBuffer[TRANSIENT_EEPROM_SIZE] = {0};
size_t clamp_length(intptr_t offset, size_t len) {
if (offset + len > TRANSIENT_EEPROM_SIZE) {
+2 -1
View File
@@ -20,5 +20,6 @@
The size of the transient EEPROM buffer size.
*/
#ifndef TRANSIENT_EEPROM_SIZE
# define TRANSIENT_EEPROM_SIZE 64
# include "eeconfig.h"
# define TRANSIENT_EEPROM_SIZE (((EECONFIG_SIZE + 3) / 4) * 4) // based off eeconfig's current usage, aligned to 4-byte sizes, to deal with LTO
#endif