Skip to content

Commit 8abcf04

Browse files
authored
Merge pull request #10 from 1a2m3/1a2m3-patch-20211208
20211208 update
2 parents b524619 + 81afc6c commit 8abcf04

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

firmware/SpdReaderWriter.ino

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <EEPROM.h>
1717
#include "SpdReaderWriterSettings.h" // Settings
1818

19-
#define VERSION 20211206 // Version number (YYYYMMDD)
19+
#define VERSION 20211208 // Version number (YYYYMMDD)
2020

2121
// RSWP RAM support bitmasks
2222
#define DDR5 (1 << 5) // Offline mode control
@@ -560,12 +560,11 @@ void cmdPinControl() {
560560
else if (pin == SA1_SWITCH) {
561561
// Toggle SA1 state
562562
if (state == ENABLE || state == DISABLE) {
563-
setConfigPin(pins[pin], state);
564-
PORT.write(getConfigPin(pins[pin]) == state ? SUCCESS : ERROR);
563+
PORT.write(setConfigPin(SA1_EN, state) ? SUCCESS : ERROR);
565564
}
566565
// Get SA1 state
567566
else if (state == GET) {
568-
PORT.write(getConfigPin(pins[pin]) == ON ? ON : OFF);
567+
PORT.write(getConfigPin(SA1_EN));
569568
}
570569
// Unknown state
571570
else {
@@ -751,9 +750,7 @@ byte rswpSupportTest() {
751750
rswpSupport |= DDR4;
752751

753752
// RSWP SA1 test
754-
if ((setConfigPin(SA1_EN, ON) && setConfigPin(SA1_EN, OFF)) &&
755-
(setConfigPin(SA1_EN, ON) ^ scanBus()) !=
756-
(setConfigPin(SA1_EN, OFF) ^ scanBus())) {
753+
if ((setConfigPin(SA1_EN, ON) && setConfigPin(SA1_EN, OFF))) {
757754
rswpSupport |= DDR3;
758755
}
759756
}
@@ -1005,22 +1002,21 @@ byte scanBus() {
10051002
// Control config pins
10061003
bool setConfigPin(uint8_t pin, bool state) {
10071004
digitalWrite(pin, state);
1008-
if (pin == SA1_SWITCH) {
1005+
1006+
if (pin == SA1_EN) {
10091007
delay(5);
1008+
// validate SA1 state against address bitmask when SA1 is high: 82-83, 86-87
1009+
byte _a1 = 0b11001100;
1010+
return scanBus() & (state ? _a1 : ~_a1);
10101011
}
10111012

10121013
return getConfigPin(pin) == state;
10131014
}
10141015

10151016
// Get config pin state
10161017
bool getConfigPin(uint8_t pin) {
1017-
// SA1 state check
1018-
if (pin == SA1_SWITCH) {
1019-
byte _a1 = 0b11001100; // valid addresses bitmask when SA1 is high: 82-83, 86-87
1020-
return (digitalRead(pin) ? ((scanBus() & _a1)) : (scanBus() & ~_a1));
1021-
}
1022-
1023-
return digitalRead(pin);
1018+
byte _a1 = 0b11001100; // addresses bitmask when SA1 is high: 82-83, 86-87
1019+
return digitalRead(pin) && (pin == SA1_EN ? scanBus() & _a1 : true);
10241020
}
10251021

10261022
// Reset config pins
@@ -1044,7 +1040,7 @@ bool ddr5SetOfflineMode(bool state) {
10441040
bool ddr5GetOfflineMode() {
10451041

10461042
// TODO: read MR48:2
1047-
return false;
1043+
return getConfigPin(OFF_EN) && false;
10481044
}
10491045

10501046
// Tests if device address is present on I2C bus

src/SpdReaderWriterDll/Settings.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ public class Settings {
77
/// <summary>
88
/// DLL version
99
/// </summary>
10-
public const int DLLVERSION = 20211206;
10+
public const int DLLVERSION = 20211208;
1111

1212
/// <summary>
1313
/// Minimum device's firmware version required
1414
/// </summary>
15-
public static int MINVERSION = 20211206;
15+
public static int MINVERSION = 20211208;
1616
}
1717
}

0 commit comments

Comments
 (0)