diff options
Diffstat (limited to 'drivers/eeprom')
-rw-r--r-- | drivers/eeprom/eeprom_driver.c | 12 | ||||
-rw-r--r-- | drivers/eeprom/eeprom_i2c.c | 6 | ||||
-rw-r--r-- | drivers/eeprom/eeprom_spi.c | 12 | ||||
-rw-r--r-- | drivers/eeprom/eeprom_transient.c | 8 | ||||
-rw-r--r-- | drivers/eeprom/eeprom_transient.h | 2 |
5 files changed, 27 insertions, 13 deletions
diff --git a/drivers/eeprom/eeprom_driver.c b/drivers/eeprom/eeprom_driver.c index 6ce47faf7d..885cf21981 100644 --- a/drivers/eeprom/eeprom_driver.c +++ b/drivers/eeprom/eeprom_driver.c @@ -37,11 +37,17 @@ uint32_t eeprom_read_dword(const uint32_t *addr) { return ret; } -void eeprom_write_byte(uint8_t *addr, uint8_t value) { eeprom_write_block(&value, addr, 1); } +void eeprom_write_byte(uint8_t *addr, uint8_t value) { + eeprom_write_block(&value, addr, 1); +} -void eeprom_write_word(uint16_t *addr, uint16_t value) { eeprom_write_block(&value, addr, 2); } +void eeprom_write_word(uint16_t *addr, uint16_t value) { + eeprom_write_block(&value, addr, 2); +} -void eeprom_write_dword(uint32_t *addr, uint32_t value) { eeprom_write_block(&value, addr, 4); } +void eeprom_write_dword(uint32_t *addr, uint32_t value) { + eeprom_write_block(&value, addr, 4); +} void eeprom_update_block(const void *buf, void *addr, size_t len) { uint8_t read_buf[len]; diff --git a/drivers/eeprom/eeprom_i2c.c b/drivers/eeprom/eeprom_i2c.c index 8e80ff544f..a74a010415 100644 --- a/drivers/eeprom/eeprom_i2c.c +++ b/drivers/eeprom/eeprom_i2c.c @@ -43,7 +43,7 @@ #if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT) # include "timer.h" # include "debug.h" -#endif // DEBUG_EEPROM_OUTPUT +#endif // DEBUG_EEPROM_OUTPUT static inline void fill_target_address(uint8_t *buffer, const void *addr) { uintptr_t p = (uintptr_t)addr; @@ -91,7 +91,7 @@ void eeprom_read_block(void *buf, const void *addr, size_t len) { dprintf(" %02X", (int)(((uint8_t *)buf)[i])); } dprintf("\n"); -#endif // DEBUG_EEPROM_OUTPUT +#endif // DEBUG_EEPROM_OUTPUT } void eeprom_write_block(const void *buf, void *addr, size_t len) { @@ -122,7 +122,7 @@ void eeprom_write_block(const void *buf, void *addr, size_t len) { dprintf(" %02X", (int)(read_buf[i])); } dprintf("\n"); -#endif // DEBUG_EEPROM_OUTPUT +#endif // DEBUG_EEPROM_OUTPUT i2c_transmit(EXTERNAL_EEPROM_I2C_ADDRESS((uintptr_t)addr), complete_packet, EXTERNAL_EEPROM_ADDRESS_SIZE + write_length, 100); wait_ms(EXTERNAL_EEPROM_WRITE_TIME); diff --git a/drivers/eeprom/eeprom_spi.c b/drivers/eeprom/eeprom_spi.c index e273090854..25955498c4 100644 --- a/drivers/eeprom/eeprom_spi.c +++ b/drivers/eeprom/eeprom_spi.c @@ -52,7 +52,9 @@ # define EXTERNAL_EEPROM_SPI_TIMEOUT 100 #endif -static bool spi_eeprom_start(void) { return spi_start(EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN, EXTERNAL_EEPROM_SPI_LSBFIRST, EXTERNAL_EEPROM_SPI_MODE, EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR); } +static bool spi_eeprom_start(void) { + return spi_start(EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN, EXTERNAL_EEPROM_SPI_LSBFIRST, EXTERNAL_EEPROM_SPI_MODE, EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR); +} static spi_status_t spi_eeprom_wait_while_busy(int timeout) { uint32_t deadline = timer_read32() + timeout; @@ -80,7 +82,9 @@ static void spi_eeprom_transmit_address(uintptr_t addr) { //---------------------------------------------------------------------------------------------------------------------- -void eeprom_driver_init(void) { spi_init(); } +void eeprom_driver_init(void) { + spi_init(); +} void eeprom_driver_erase(void) { #if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT) @@ -135,7 +139,7 @@ void eeprom_read_block(void *buf, const void *addr, size_t len) { dprintf(" %02X", (int)(((uint8_t *)buf)[i])); } dprintf("\n"); -#endif // DEBUG_EEPROM_OUTPUT +#endif // DEBUG_EEPROM_OUTPUT spi_stop(); } @@ -192,7 +196,7 @@ void eeprom_write_block(const void *buf, void *addr, size_t len) { dprintf(" %02X", (int)(uint8_t)(read_buf[i])); } dprintf("\n"); -#endif // DEBUG_EEPROM_OUTPUT +#endif // DEBUG_EEPROM_OUTPUT spi_write(CMD_WRITE); spi_eeprom_transmit_address(target_addr); diff --git a/drivers/eeprom/eeprom_transient.c b/drivers/eeprom/eeprom_transient.c index b4c78c6f40..9dc4289c27 100644 --- a/drivers/eeprom/eeprom_transient.c +++ b/drivers/eeprom/eeprom_transient.c @@ -30,9 +30,13 @@ size_t clamp_length(intptr_t offset, size_t len) { return len; } -void eeprom_driver_init(void) { eeprom_driver_erase(); } +void eeprom_driver_init(void) { + eeprom_driver_erase(); +} -void eeprom_driver_erase(void) { memset(transientBuffer, 0x00, TRANSIENT_EEPROM_SIZE); } +void eeprom_driver_erase(void) { + memset(transientBuffer, 0x00, TRANSIENT_EEPROM_SIZE); +} void eeprom_read_block(void *buf, const void *addr, size_t len) { intptr_t offset = (intptr_t)addr; diff --git a/drivers/eeprom/eeprom_transient.h b/drivers/eeprom/eeprom_transient.h index d06189b246..687b8619fe 100644 --- a/drivers/eeprom/eeprom_transient.h +++ b/drivers/eeprom/eeprom_transient.h @@ -21,5 +21,5 @@ */ #ifndef TRANSIENT_EEPROM_SIZE # include "eeconfig.h" -# define TRANSIENT_EEPROM_SIZE (((EECONFIG_SIZE + 3) / 4) * 4) // based off eeconfig's current usage, aligned to 4-byte sizes, to deal with LTO +# define TRANSIENT_EEPROM_SIZE (((EECONFIG_SIZE + 3) / 4) * 4) // based off eeconfig's current usage, aligned to 4-byte sizes, to deal with LTO #endif |