aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/eeprom
diff options
context:
space:
mode:
authorGravatar Drashna Jaelre <drashna@live.com>2020-05-24 15:02:13 -0700
committerGravatar GitHub <noreply@github.com>2020-05-24 23:02:13 +0100
commit883dd2df80edf084d100c61c1b61782bfa5503f9 (patch)
treed1dc7255549a9a0657334063bf2cea64ac81cecb /drivers/eeprom
parent2ac3a51d71a05fe46fc6967797b0d34d8fb3fcd8 (diff)
downloadqmk_firmware-883dd2df80edf084d100c61c1b61782bfa5503f9.tar.gz
Fix i2c EEPROM compile issue when Console is enabled (#9186)
* Fix i2c EEPROM compile issue when Console is enabled * Only use if both console and debugging is enabled
Diffstat (limited to 'drivers/eeprom')
-rw-r--r--drivers/eeprom/eeprom_i2c.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/eeprom/eeprom_i2c.c b/drivers/eeprom/eeprom_i2c.c
index 88be2be06..ca8af3da5 100644
--- a/drivers/eeprom/eeprom_i2c.c
+++ b/drivers/eeprom/eeprom_i2c.c
@@ -37,8 +37,9 @@
// #define DEBUG_EEPROM_OUTPUT
-#ifdef DEBUG_EEPROM_OUTPUT
-# include "print.h"
+#if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT)
+# include "timer.h"
+# include "debug.h"
#endif // DEBUG_EEPROM_OUTPUT
static inline void init_i2c_if_required(void) {
@@ -60,7 +61,7 @@ static inline void fill_target_address(uint8_t *buffer, const void *addr) {
void eeprom_driver_init(void) {}
void eeprom_driver_erase(void) {
-#ifdef CONSOLE_ENABLE
+#if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT)
uint32_t start = timer_read32();
#endif
@@ -70,7 +71,7 @@ void eeprom_driver_erase(void) {
eeprom_write_block(buf, (void *)(uintptr_t)addr, EXTERNAL_EEPROM_PAGE_SIZE);
}
-#ifdef CONSOLE_ENABLE
+#if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT)
dprintf("EEPROM erase took %ldms to complete\n", ((long)(timer_read32() - start)));
#endif
}
@@ -83,7 +84,7 @@ void eeprom_read_block(void *buf, const void *addr, size_t len) {
i2c_transmit(EXTERNAL_EEPROM_I2C_ADDRESS((uintptr_t)addr), complete_packet, EXTERNAL_EEPROM_ADDRESS_SIZE, 100);
i2c_receive(EXTERNAL_EEPROM_I2C_ADDRESS((uintptr_t)addr), buf, len, 100);
-#ifdef DEBUG_EEPROM_OUTPUT
+#if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT)
dprintf("[EEPROM R] 0x%04X: ", ((int)addr));
for (size_t i = 0; i < len; ++i) {
dprintf(" %02X", (int)(((uint8_t *)buf)[i]));
@@ -110,7 +111,7 @@ void eeprom_write_block(const void *buf, void *addr, size_t len) {
complete_packet[EXTERNAL_EEPROM_ADDRESS_SIZE + i] = read_buf[i];
}
-#ifdef DEBUG_EEPROM_OUTPUT
+#if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT)
dprintf("[EEPROM W] 0x%04X: ", ((int)target_addr));
for (uint8_t i = 0; i < write_length; i++) {
dprintf(" %02X", (int)(read_buf[i]));