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
This commit is contained in:
Drashna Jaelre 2020-05-24 15:02:13 -07:00 committed by GitHub
parent 2ac3a51d71
commit 883dd2df80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -37,8 +37,9 @@
// #define DEBUG_EEPROM_OUTPUT // #define DEBUG_EEPROM_OUTPUT
#ifdef DEBUG_EEPROM_OUTPUT #if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT)
# include "print.h" # include "timer.h"
# include "debug.h"
#endif // DEBUG_EEPROM_OUTPUT #endif // DEBUG_EEPROM_OUTPUT
static inline void init_i2c_if_required(void) { 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_init(void) {}
void eeprom_driver_erase(void) { void eeprom_driver_erase(void) {
#ifdef CONSOLE_ENABLE #if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT)
uint32_t start = timer_read32(); uint32_t start = timer_read32();
#endif #endif
@ -70,7 +71,7 @@ void eeprom_driver_erase(void) {
eeprom_write_block(buf, (void *)(uintptr_t)addr, EXTERNAL_EEPROM_PAGE_SIZE); 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))); dprintf("EEPROM erase took %ldms to complete\n", ((long)(timer_read32() - start)));
#endif #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_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); 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)); dprintf("[EEPROM R] 0x%04X: ", ((int)addr));
for (size_t i = 0; i < len; ++i) { for (size_t i = 0; i < len; ++i) {
dprintf(" %02X", (int)(((uint8_t *)buf)[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]; 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)); dprintf("[EEPROM W] 0x%04X: ", ((int)target_addr));
for (uint8_t i = 0; i < write_length; i++) { for (uint8_t i = 0; i < write_length; i++) {
dprintf(" %02X", (int)(read_buf[i])); dprintf(" %02X", (int)(read_buf[i]));