Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LGT8F328P Support #41

Merged
merged 3 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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