Skip to content

Commit

Permalink
Merge pull request #41 from barrenechea/lgt8fx-support
Browse files Browse the repository at this point in the history
Add LGT8F328P Support
  • Loading branch information
ShendoXT authored Nov 9, 2024
2 parents 464ef4c + 0f08500 commit 68c11a8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
17 changes: 13 additions & 4 deletions MemCARDuino.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);

Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -166,10 +172,13 @@ 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)
#if defined (ARDUINO_ARCH_RP2040) || (ESP8266) || (ESP32) || (ARDUINO_AVR_LARDU_328E)
byte data = SoftTransfer(CommandByte);
#else
byte data = SPI.transfer(CommandByte);
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit 68c11a8

Please sign in to comment.