diff options
author | Drashna Jaelre <drashna@live.com> | 2020-05-24 15:02:13 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-24 23:02:13 +0100 |
commit | 883dd2df80edf084d100c61c1b61782bfa5503f9 (patch) | |
tree | d1dc7255549a9a0657334063bf2cea64ac81cecb /drivers/eeprom/eeprom_i2c.c | |
parent | 2ac3a51d71a05fe46fc6967797b0d34d8fb3fcd8 (diff) | |
download | qmk_firmware-883dd2df80edf084d100c61c1b61782bfa5503f9.tar.gz qmk_firmware-883dd2df80edf084d100c61c1b61782bfa5503f9.zip |
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/eeprom_i2c.c')
-rw-r--r-- | drivers/eeprom/eeprom_i2c.c | 13 |
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 @@ | |||
37 | 37 | ||
38 | // #define DEBUG_EEPROM_OUTPUT | 38 | // #define DEBUG_EEPROM_OUTPUT |
39 | 39 | ||
40 | #ifdef DEBUG_EEPROM_OUTPUT | 40 | #if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT) |
41 | # include "print.h" | 41 | # include "timer.h" |
42 | # include "debug.h" | ||
42 | #endif // DEBUG_EEPROM_OUTPUT | 43 | #endif // DEBUG_EEPROM_OUTPUT |
43 | 44 | ||
44 | static inline void init_i2c_if_required(void) { | 45 | static inline void init_i2c_if_required(void) { |
@@ -60,7 +61,7 @@ static inline void fill_target_address(uint8_t *buffer, const void *addr) { | |||
60 | void eeprom_driver_init(void) {} | 61 | void eeprom_driver_init(void) {} |
61 | 62 | ||
62 | void eeprom_driver_erase(void) { | 63 | void eeprom_driver_erase(void) { |
63 | #ifdef CONSOLE_ENABLE | 64 | #if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT) |
64 | uint32_t start = timer_read32(); | 65 | uint32_t start = timer_read32(); |
65 | #endif | 66 | #endif |
66 | 67 | ||
@@ -70,7 +71,7 @@ void eeprom_driver_erase(void) { | |||
70 | eeprom_write_block(buf, (void *)(uintptr_t)addr, EXTERNAL_EEPROM_PAGE_SIZE); | 71 | eeprom_write_block(buf, (void *)(uintptr_t)addr, EXTERNAL_EEPROM_PAGE_SIZE); |
71 | } | 72 | } |
72 | 73 | ||
73 | #ifdef CONSOLE_ENABLE | 74 | #if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT) |
74 | dprintf("EEPROM erase took %ldms to complete\n", ((long)(timer_read32() - start))); | 75 | dprintf("EEPROM erase took %ldms to complete\n", ((long)(timer_read32() - start))); |
75 | #endif | 76 | #endif |
76 | } | 77 | } |
@@ -83,7 +84,7 @@ void eeprom_read_block(void *buf, const void *addr, size_t len) { | |||
83 | i2c_transmit(EXTERNAL_EEPROM_I2C_ADDRESS((uintptr_t)addr), complete_packet, EXTERNAL_EEPROM_ADDRESS_SIZE, 100); | 84 | i2c_transmit(EXTERNAL_EEPROM_I2C_ADDRESS((uintptr_t)addr), complete_packet, EXTERNAL_EEPROM_ADDRESS_SIZE, 100); |
84 | i2c_receive(EXTERNAL_EEPROM_I2C_ADDRESS((uintptr_t)addr), buf, len, 100); | 85 | i2c_receive(EXTERNAL_EEPROM_I2C_ADDRESS((uintptr_t)addr), buf, len, 100); |
85 | 86 | ||
86 | #ifdef DEBUG_EEPROM_OUTPUT | 87 | #if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT) |
87 | dprintf("[EEPROM R] 0x%04X: ", ((int)addr)); | 88 | dprintf("[EEPROM R] 0x%04X: ", ((int)addr)); |
88 | for (size_t i = 0; i < len; ++i) { | 89 | for (size_t i = 0; i < len; ++i) { |
89 | dprintf(" %02X", (int)(((uint8_t *)buf)[i])); | 90 | dprintf(" %02X", (int)(((uint8_t *)buf)[i])); |
@@ -110,7 +111,7 @@ void eeprom_write_block(const void *buf, void *addr, size_t len) { | |||
110 | complete_packet[EXTERNAL_EEPROM_ADDRESS_SIZE + i] = read_buf[i]; | 111 | complete_packet[EXTERNAL_EEPROM_ADDRESS_SIZE + i] = read_buf[i]; |
111 | } | 112 | } |
112 | 113 | ||
113 | #ifdef DEBUG_EEPROM_OUTPUT | 114 | #if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT) |
114 | dprintf("[EEPROM W] 0x%04X: ", ((int)target_addr)); | 115 | dprintf("[EEPROM W] 0x%04X: ", ((int)target_addr)); |
115 | for (uint8_t i = 0; i < write_length; i++) { | 116 | for (uint8_t i = 0; i < write_length; i++) { |
116 | dprintf(" %02X", (int)(read_buf[i])); | 117 | dprintf(" %02X", (int)(read_buf[i])); |