Browse Source

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
pull/9194/head 0.8.183
Drashna Jaelre 4 years ago
committed by GitHub
parent
commit
883dd2df80
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 6 deletions
  1. +7
    -6
      drivers/eeprom/eeprom_i2c.c

+ 7
- 6
drivers/eeprom/eeprom_i2c.c View File

@ -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]));


Loading…
Cancel
Save