Skip to content

Commit 6934169

Browse files
authored
Merge pull request #27 from 1a2m3/20220805
20220806 update
2 parents d266bbd + 36430da commit 6934169

File tree

8 files changed

+463
-723
lines changed

8 files changed

+463
-723
lines changed

src/SpdReaderWriter/Example.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,20 @@ public static void Example_BasicUse() {
5454
myDevice.ProbeAddress(); // You can omit the address if myDevice already has "I2CAddress" set
5555

5656
// Set SPD size to DDR4's EEPROM size (512 bytes)
57-
myDevice.SpdSize = Ram.SpdSize.DDR4;
57+
myDevice.DataLength = Spd.DataLength.DDR4;
5858

5959
// The device can also be initialized in one line, like so:
60-
Arduino myOtherDevice = new Arduino(ReaderSettings, PortName, 80, Ram.SpdSize.DDR4);
60+
Arduino myOtherDevice = new Arduino(ReaderSettings, PortName, 80, Spd.DataLength.DDR4);
6161

6262
// Read first byte at offset 0
6363
byte firstByte = Eeprom.ReadByte(myDevice, 0);
6464

6565
// Read last byte (located at offset 511, not 512!)
66-
byte lastByte = Eeprom.ReadByte(myDevice, (ushort)(myDevice.SpdSize - 1));
66+
byte lastByte = Eeprom.ReadByte(myDevice, (ushort)(myDevice.DataLength - 1));
6767

6868
// Read the entire EEPROM, 1 byte at a time
69-
byte[] spdDump = new byte[(int)myDevice.SpdSize];
70-
for (ushort i = 0; i < (int)myDevice.SpdSize; i++) {
69+
byte[] spdDump = new byte[(int)myDevice.DataLength];
70+
for (ushort i = 0; i < (int)myDevice.DataLength; i++) {
7171
spdDump[i] = Eeprom.ReadByte(myDevice, i);
7272
}
7373

@@ -100,7 +100,7 @@ public static void Example_TestRealDevice() {
100100
realDevice.Scan(); //{ 80 }
101101

102102
// Test a real device
103-
Arduino myReader = new Arduino(ReaderSettings, PortName, 0x50, Ram.SpdSize.DDR4);
103+
Arduino myReader = new Arduino(ReaderSettings, PortName, 0x50, Spd.DataLength.DDR4);
104104
myReader.Test(); //true
105105
}
106106

@@ -109,15 +109,15 @@ public static void Example_TestRealDevice() {
109109
/// </summary>
110110
public static void Example_DuplicateRam() {
111111
// Copy SPD contents from one DIMM to another
112-
Arduino source = new Arduino(ReaderSettings, "COM1", 80, Ram.SpdSize.DDR4);
113-
Arduino destination = new Arduino(ReaderSettings, "COM4", 82, source.SpdSize);
112+
Arduino source = new Arduino(ReaderSettings, "COM1", 80, Spd.DataLength.DDR4);
113+
Arduino destination = new Arduino(ReaderSettings, "COM4", 82, source.DataLength);
114114

115-
for (ushort i = 0; i < (int)source.SpdSize; i++) {
115+
for (ushort i = 0; i < (int)source.DataLength; i++) {
116116
Eeprom.WriteByte(destination, i, Eeprom.ReadByte(source, i));
117117
}
118118

119119
// Verify contents
120-
for (ushort i = 0; i < (int)source.SpdSize; i++) {
120+
for (ushort i = 0; i < (int)source.DataLength; i++) {
121121
if (Eeprom.ReadByte(source, i) != Eeprom.ReadByte(destination, i)) {
122122
// Mismatched contents detected
123123
}
@@ -129,7 +129,7 @@ public static void Example_DuplicateRam() {
129129
/// </summary>
130130
public static void Example_FixCRC() {
131131

132-
Arduino myReader = new Arduino(ReaderSettings, PortName, 0x52, Ram.SpdSize.DDR4);
132+
Arduino myReader = new Arduino(ReaderSettings, PortName, 0x52, Spd.DataLength.DDR4);
133133

134134
// Read first 126 bytes
135135
byte[] spdHeader = Eeprom.ReadByte(myReader, 0, 126);
@@ -158,8 +158,8 @@ public static void Example_FixCRC() {
158158
/// Erase SPD contents (fill with 0xFF's)
159159
/// </summary>
160160
public static void Example_EraseSPD() {
161-
Arduino myReader = new Arduino(ReaderSettings, PortName, 0x50, Ram.SpdSize.DDR4);
162-
for (ushort i = 0; i <= (int)myReader.SpdSize; i++) {
161+
Arduino myReader = new Arduino(ReaderSettings, PortName, 0x50, Spd.DataLength.DDR4);
162+
for (ushort i = 0; i <= (int)myReader.DataLength; i++) {
163163
Eeprom.UpdateByte(myReader, i, 0xFF);
164164
Console.WriteLine(i.ToString());
165165
}

src/SpdReaderWriter/Program.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ private static void WriteEeprom() {
285285
Reader.I2CAddress);
286286

287287
if (inputFile.Length > (int)Spd.GetSpdSize(Reader)) {
288-
throw new Exception($"File \"{filePath}\" is larger than {Reader.SpdSize} bytes.");
288+
throw new Exception($"File \"{filePath}\" is larger than {Reader.DataLength} bytes.");
289289
}
290290

291291
int bytesWritten = 0;
@@ -425,7 +425,7 @@ private static void EnableRswp() {
425425

426426
}
427427
else { // No block number specified, protect all available
428-
if (Spd.GetRamType(Reader) == Ram.Type.DDR4) {
428+
if (Spd.GetRamType(Reader) == Spd.RamType.DDR4) {
429429
block = new[] { 0, 1, 2, 3 };
430430
}
431431
else { // DDR3 + DDR2
@@ -583,10 +583,10 @@ static void ConsoleDisplayByte(int pos, byte b, int bpr = 16, bool showOffset =
583583
ConsoleColor[] colors = {
584584
ConsoleColor.DarkGray,
585585
ConsoleColor.Gray,
586-
ConsoleColor.Red,
587586
ConsoleColor.DarkRed,
588-
ConsoleColor.DarkYellow,
587+
ConsoleColor.Red,
589588
ConsoleColor.Yellow,
589+
ConsoleColor.DarkYellow,
590590
ConsoleColor.Green,
591591
ConsoleColor.DarkGreen,
592592
ConsoleColor.DarkCyan,

0 commit comments

Comments
 (0)