Skip to content

Commit

Permalink
Fix i2c EEPROM compile issue when Console is enabled (qmk#9186)
Browse files Browse the repository at this point in the history
* Fix i2c EEPROM compile issue when Console is enabled

* Only use if both console and debugging is enabled
  • Loading branch information
drashna committed May 24, 2020
1 parent 2ac3a51 commit 883dd2d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions drivers/eeprom/eeprom_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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

Expand All @@ -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
}
Expand All @@ -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]));
Expand All @@ -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]));
Expand Down

0 comments on commit 883dd2d

Please sign in to comment.