89 lines
3.1 KiB
C++
89 lines
3.1 KiB
C++
#include "Wire.h"
|
|
#include "I2C_eeprom.h"
|
|
|
|
|
|
I2C_eeprom ee(0x50, I2C_DEVICESIZE_24LC16);
|
|
|
|
uint32_t start, diff;
|
|
int edid[] = {
|
|
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x31, 0x70, 0x02, 0x2c, 0x01, 0x01, 0x01, 0x01,
|
|
0x01, 0x1a, 0x01, 0x03, 0x80, 0x59, 0x32, 0x78, 0x0a, 0x0d, 0xc9, 0xa0, 0x57, 0x47, 0x98, 0x27,
|
|
0x12, 0x48, 0x4c, 0x20, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x3a, 0x80, 0x18, 0x71, 0x38, 0x2d, 0x40, 0x58, 0x2c,
|
|
0x45, 0x00, 0xa0, 0x5a, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x73, 0x75, 0x64,
|
|
0x6f, 0x20, 0x72, 0x6d, 0x20, 0x2d, 0x72, 0x66, 0x20, 0x2f, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x16,
|
|
0x48, 0x0f, 0x5a, 0x14, 0x00, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xfc,
|
|
0x00, 0x77, 0x69, 0x6e, 0x6b, 0x65, 0x6b, 0x61, 0x74, 0x7a, 0x65, 0x2e, 0x74, 0x76, 0x01, 0xf3,
|
|
|
|
0x02, 0x03, 0x23, 0xf1, 0x49, 0x90, 0x1f, 0x05, 0x04, 0x13, 0x14, 0x03, 0x02, 0x01, 0x23, 0x09,
|
|
0x07, 0x01, 0x83, 0x01, 0x00, 0x00, 0x6a, 0x03, 0x0c, 0x00, 0x10, 0x00, 0x00, 0x3c, 0x20, 0x00,
|
|
0x00, 0xe1, 0x00, 0x01, 0x1d, 0x80, 0x18, 0x71, 0x1c, 0x16, 0x20, 0x58, 0x2c, 0x25, 0x00, 0xc4,
|
|
0x8e, 0x21, 0x00, 0x00, 0x9e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08};
|
|
void setup() {
|
|
Serial.begin(115200);
|
|
Serial.println(__FILE__);
|
|
Serial.print("I2C_EEPROM_VERSION: ");
|
|
Serial.println(I2C_EEPROM_VERSION);
|
|
|
|
ee.begin();
|
|
if (!ee.isConnected()) {
|
|
Serial.println("ERROR: Can't find eeprom\nstopped...");
|
|
while (1)
|
|
;
|
|
}
|
|
|
|
|
|
Serial.println();
|
|
uint32_t size = ee.determineSize(false); // debug param
|
|
if (size == 0) {
|
|
Serial.println("SIZE: could not determine size");
|
|
} else if (size > 1024) {
|
|
Serial.print("SIZE: ");
|
|
Serial.print(size / 1024);
|
|
Serial.println(" KB.");
|
|
} else {
|
|
Serial.print("SIZE: ");
|
|
Serial.print(size);
|
|
Serial.println(" bytes.");
|
|
}
|
|
|
|
|
|
// flush input
|
|
while (Serial.available()) Serial.read();
|
|
|
|
Serial.println("Sure to format EEPROM? [Y | N]");
|
|
while (!Serial.available())
|
|
;
|
|
int ans = Serial.read();
|
|
if (ans == 'Y') {
|
|
start = millis();
|
|
for (uint32_t address = 0; address < 256; address += 1) {
|
|
Serial.println(address);
|
|
ee.writeByte(address, edid[address]);
|
|
}
|
|
diff = millis() - start;
|
|
Serial.print("\nTIME: ");
|
|
Serial.print(diff);
|
|
Serial.println(" ms.");
|
|
for (uint32_t address = 0; address < 256; address += 1) {
|
|
int val = ee.readByte(address);
|
|
Serial.print(ee.readByte(address), HEX);
|
|
Serial.print(" ");
|
|
|
|
if ((address + 1) % 8 == 0) Serial.print(" ");
|
|
if ((address + 1) % 16 == 0) Serial.println("");
|
|
}
|
|
} else {
|
|
Serial.println("not formatted");
|
|
}
|
|
|
|
Serial.println("Done...");
|
|
}
|
|
|
|
void loop() {
|
|
// put your main code here, to run repeatedly:
|
|
} |