|
|
|
@ -39,7 +39,7 @@
|
|
|
|
|
// Private Variables
|
|
|
|
|
// ------------------------
|
|
|
|
|
|
|
|
|
|
static uint8_t eeprom_device_address = 0x50;
|
|
|
|
|
static constexpr uint8_t eeprom_device_address = I2C_ADDRESS(0x50);
|
|
|
|
|
|
|
|
|
|
// ------------------------
|
|
|
|
|
// Public functions
|
|
|
|
@ -54,7 +54,7 @@ void eeprom_write_byte(uint8_t *pos, unsigned char value) {
|
|
|
|
|
|
|
|
|
|
eeprom_init();
|
|
|
|
|
|
|
|
|
|
Wire.beginTransmission(I2C_ADDRESS(eeprom_device_address));
|
|
|
|
|
Wire.beginTransmission(eeprom_device_address);
|
|
|
|
|
Wire.write((int)(eeprom_address >> 8)); // MSB
|
|
|
|
|
Wire.write((int)(eeprom_address & 0xFF)); // LSB
|
|
|
|
|
Wire.write(value);
|
|
|
|
@ -70,7 +70,7 @@ void eeprom_write_byte(uint8_t *pos, unsigned char value) {
|
|
|
|
|
void eeprom_update_block(const void *pos, void* eeprom_address, size_t n) {
|
|
|
|
|
eeprom_init();
|
|
|
|
|
|
|
|
|
|
Wire.beginTransmission(I2C_ADDRESS(eeprom_device_address));
|
|
|
|
|
Wire.beginTransmission(eeprom_device_address);
|
|
|
|
|
Wire.write((int)((unsigned)eeprom_address >> 8)); // MSB
|
|
|
|
|
Wire.write((int)((unsigned)eeprom_address & 0xFF)); // LSB
|
|
|
|
|
Wire.endTransmission();
|
|
|
|
@ -82,7 +82,7 @@ void eeprom_update_block(const void *pos, void* eeprom_address, size_t n) {
|
|
|
|
|
flag |= Wire.read() ^ ptr[c];
|
|
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
|
Wire.beginTransmission(I2C_ADDRESS(eeprom_device_address));
|
|
|
|
|
Wire.beginTransmission(eeprom_device_address);
|
|
|
|
|
Wire.write((int)((unsigned)eeprom_address >> 8)); // MSB
|
|
|
|
|
Wire.write((int)((unsigned)eeprom_address & 0xFF)); // LSB
|
|
|
|
|
Wire.write((uint8_t*)pos, n);
|
|
|
|
@ -99,7 +99,7 @@ uint8_t eeprom_read_byte(uint8_t *pos) {
|
|
|
|
|
|
|
|
|
|
eeprom_init();
|
|
|
|
|
|
|
|
|
|
Wire.beginTransmission(I2C_ADDRESS(eeprom_device_address));
|
|
|
|
|
Wire.beginTransmission(eeprom_device_address);
|
|
|
|
|
Wire.write((int)(eeprom_address >> 8)); // MSB
|
|
|
|
|
Wire.write((int)(eeprom_address & 0xFF)); // LSB
|
|
|
|
|
Wire.endTransmission();
|
|
|
|
@ -111,7 +111,7 @@ uint8_t eeprom_read_byte(uint8_t *pos) {
|
|
|
|
|
void eeprom_read_block(void* pos, const void* eeprom_address, size_t n) {
|
|
|
|
|
eeprom_init();
|
|
|
|
|
|
|
|
|
|
Wire.beginTransmission(I2C_ADDRESS(eeprom_device_address));
|
|
|
|
|
Wire.beginTransmission(eeprom_device_address);
|
|
|
|
|
Wire.write((int)((unsigned)eeprom_address >> 8)); // MSB
|
|
|
|
|
Wire.write((int)((unsigned)eeprom_address & 0xFF)); // LSB
|
|
|
|
|
Wire.endTransmission();
|
|
|
|
|