From 7e6c128e7a52d597dbe437ad75629cea0a6232d4 Mon Sep 17 00:00:00 2001 From: Sebastian Barrenechea Date: Mon, 4 Nov 2024 11:20:22 -0300 Subject: [PATCH 1/3] fix: delayMicroseconds for lgt8f does not play nice when value is 0 --- MemCARDuino.ino | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/MemCARDuino.ino b/MemCARDuino.ino index a25dd9f..e7c903c 100644 --- a/MemCARDuino.ino +++ b/MemCARDuino.ino @@ -166,7 +166,10 @@ byte SendCommand(byte CommandByte, int Timeout, int Delay) state = HIGH; //Set high state for ACK signal //Delay for a bit (values simulating delays between real PS1 and Memory Card) - delayMicroseconds(Delay); + if (Delay > 0) + { + delayMicroseconds(Delay); + } //Send data on the SPI bus #if defined (ARDUINO_ARCH_RP2040) || (ESP8266) || (ESP32) From 113d1e83890e7918809900c8e42f0c9a106b0aa5 Mon Sep 17 00:00:00 2001 From: Sebastian Barrenechea Date: Mon, 4 Nov 2024 17:54:52 -0300 Subject: [PATCH 2/3] fix: use SoftTransfer for lgt8fx boards --- MemCARDuino.ino | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/MemCARDuino.ino b/MemCARDuino.ino index e7c903c..fa701fd 100644 --- a/MemCARDuino.ino +++ b/MemCARDuino.ino @@ -76,6 +76,12 @@ #define DataPin 50 #define AttPin 53 #define AckPin 2 +#elif defined (ARDUINO_AVR_LARDU_328E) + #define DataPin 12 + #define CmndPin 11 + #define AttPin 10 + #define ClockPin 13 + #define AckPin 2 #else #define DataPin 12 #define AttPin 10 @@ -97,7 +103,7 @@ void PinSetup() digitalWrite(AttPin, HIGH); //Set up SPI -#if defined (ARDUINO_ARCH_RP2040) || (ESP8266) || (ESP32) +#if defined (ARDUINO_ARCH_RP2040) || (ESP8266) || (ESP32) || (ARDUINO_AVR_LARDU_328E) pinMode(ClockPin, OUTPUT); pinMode(CmndPin, OUTPUT); @@ -136,7 +142,7 @@ ICACHE_RAM_ATTR void ACK() state = !state; } -#if defined (ARDUINO_ARCH_RP2040) || (ESP8266) || (ESP32) +#if defined (ARDUINO_ARCH_RP2040) || (ESP8266) || (ESP32) || (ARDUINO_AVR_LARDU_328E) //Software SPI bit bang, turned out to be the most compatible with PocketStations byte SoftTransfer(byte data) { @@ -172,7 +178,7 @@ byte SendCommand(byte CommandByte, int Timeout, int Delay) } //Send data on the SPI bus -#if defined (ARDUINO_ARCH_RP2040) || (ESP8266) || (ESP32) +#if defined (ARDUINO_ARCH_RP2040) || (ESP8266) || (ESP32) || (ARDUINO_AVR_LARDU_328E) byte data = SoftTransfer(CommandByte); #else byte data = SPI.transfer(CommandByte); From 0f085002a5c805ac76b611a83fea6395054ddf32 Mon Sep 17 00:00:00 2001 From: Sebastian Barrenechea Date: Tue, 5 Nov 2024 08:07:24 -0300 Subject: [PATCH 3/3] chore: add lgt8fx board to readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7a5157a..7475c73 100755 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ * Arduino Mega 2560 * Espressif [ESP8266](https://github.com/esp8266/Arduino), [ESP32](https://github.com/espressif/arduino-esp32) (requires additional board URL) * [Raspberry Pi Pico](https://github.com/earlephilhower/arduino-pico) (requires additional board URL) +* Logic Green [LGT8F328P](https://github.com/dbuezas/lgt8fx) (requires additional board URL) Various other boards can be supported if they have Arduino core available with SPI library with minimal or no editing to the sketch.