Clean up EEPROM interfaces (#17803)

This commit is contained in:
Scott Lahteine
2020-05-01 00:04:55 -05:00
committed by GitHub
parent a226b281af
commit 2107bc5836
8 changed files with 991 additions and 1068 deletions

View File

@ -27,21 +27,18 @@
#include "../../inc/MarlinConfig.h"
#if BOTH(USE_SHARED_EEPROM, I2C_EEPROM)
#include "../HAL.h"
#include <Wire.h>
#if ENABLED(I2C_EEPROM)
#include "eeprom_if.h"
#include <Wire.h>
void eeprom_init() { Wire.begin(); }
#if ENABLED(USE_SHARED_EEPROM)
#ifndef EEPROM_WRITE_DELAY
#define EEPROM_WRITE_DELAY 5
#endif
// ------------------------
// Private Variables
// ------------------------
#ifndef EEPROM_DEVICE_ADDRESS
#define EEPROM_DEVICE_ADDRESS 0x50
#endif
@ -52,8 +49,6 @@ static constexpr uint8_t eeprom_device_address = I2C_ADDRESS(EEPROM_DEVICE_ADDRE
// Public functions
// ------------------------
void eeprom_init() { Wire.begin(); }
void eeprom_write_byte(uint8_t *pos, unsigned char value) {
const unsigned eeprom_address = (unsigned)pos;
@ -79,4 +74,5 @@ uint8_t eeprom_read_byte(uint8_t *pos) {
return Wire.available() ? Wire.read() : 0xFF;
}
#endif // USE_SHARED_EEPROM && I2C_EEPROM
#endif // USE_SHARED_EEPROM
#endif // I2C_EEPROM

View File

@ -27,11 +27,14 @@
#include "../../inc/MarlinConfig.h"
#if BOTH(USE_SHARED_EEPROM, SPI_EEPROM)
#if ENABLED(SPI_EEPROM)
#include "../HAL.h"
#include "eeprom_if.h"
void eeprom_init() {}
#if ENABLED(USE_SHARED_EEPROM)
#define CMD_WREN 6 // WREN
#define CMD_READ 2 // WRITE
#define CMD_WRITE 2 // WRITE
@ -80,4 +83,5 @@ void eeprom_write_byte(uint8_t* pos, uint8_t value) {
delay(EEPROM_WRITE_DELAY); // wait for page write to complete
}
#endif // USE_SHARED_EEPROM && I2C_EEPROM
#endif // USE_SHARED_EEPROM
#endif // I2C_EEPROM