From 78db2a74c78a0a303c25f7db8de2c44c67115980 Mon Sep 17 00:00:00 2001 From: moparisthebest Date: Mon, 28 Dec 2020 19:44:59 -0500 Subject: [PATCH] Add+fix ESP32 pinout --- readme.md | 50 +++++++++++++++++++++---------------------- src/Playstation.cpp | 8 +++---- src/RadioReceiver.cpp | 12 ++++++++++- src/SegaGenesis.cpp | 8 +++---- src/SnesNes.cpp | 34 +++++++++++++++++++++-------- 5 files changed, 69 insertions(+), 43 deletions(-) diff --git a/readme.md b/readme.md index f224ffb..19ed06b 100644 --- a/readme.md +++ b/readme.md @@ -25,31 +25,31 @@ Wiring | DB-25 Pins | Arduino Pro Micro GPIO | ESP32 GPIO | Radio | SNES | PSX | N64 | Gamecube | Genesis | |---------------|------------------------|------------|----------|--------|--------|----------|----------|-------------| -| 1 | 1 | | - | - | - | - | - | P1-1 | -| 2 | 2 | | - | LATCH | DATA | DATA1 | DATA1 | P1-3 | -| 3 | 3 | | - | CLOCK | CMD | - | - | P1-4 | -| 4 | 4 | | - | - | ATT | - | - | P1-6 | -| 5 | 5 | | - | - | CLK | - | - | P1-7 | -| 6 | 6 | | - | - | - | - | - | P1-9 | -| 7 | 7 | | CE | - | - | - | - | P2-7* | -| 8 | 8 | | CSN | - | - | - | - | - | -| 9 | 9 | | - | - | - | - | - | - | -| 10 | 10 | | - | - | - | - | - | - | -| 11 | 0 | | - | - | - | - | - | P1-2 | -| 12 | - | | - | - | - | - | - | - | -| 13 | - | | - | - | - | - | - | - | -| 14 | 14 | | MISO | - | - | - | - | P2-6* | -| 15 | 15 | | SCLK | - | - | - | - | P2-9* | -| 16 | 16 | | MOSI | - | - | - | - | - | -| 17 | - | | - | - | - | - | - | - | -| 18 | 18 | | - | DATA1 | - | - | - | P2-1 | -| 19 | 19 | | - | DATA2 | - | - | - | P2-2 | -| 20 | 20 | | - | DATA3 | - | - | - | P2-3 | -| 21 | 21 | | - | DATA4 | - | - | - | P2-4 | -| 22 | - | | - | - | - | - | - | - | -| 23 | - | | 3.3V VCC | - | - | 3.3V VCC | 3.3V VCC | - | -| 24 | 5V VCC | | 5V VCC | 5V VCC | 5V VCC | - | 5V VCC | PX-5 5V VCC | -| 25 | GND | | GND | GND | - | GND | GND | PX-8 GND | +| 1 | 1 | 15 | - | - | - | - | - | P1-1 | +| 2 | 2 | 2 | - | LATCH | DATA | DATA1 | DATA1 | P1-3 | +| 3 | 3 | 4 | - | CLOCK | CMD | - | - | P1-4 | +| 4 | 4 | 16 | - | - | ATT | - | - | P1-6 | +| 5 | 5 | 17 | - | - | CLK | - | - | P1-7 | +| 6 | 6 | 5 | - | - | - | - | - | P1-9 | +| 7 | 7 | 18 | CE | - | - | - | - | P2-7* | +| 8 | 8 | 19 | CSN | - | - | - | - | - | +| 9 | 9 | 21 | - | - | - | - | - | - | +| 10 | 10 | 3 | - | - | - | - | - | - | +| 11 | 0 | 1 | - | - | - | - | - | P1-2 | +| 12 | - | 22 | - | - | - | - | - | - | +| 13 | - | 23 | - | - | - | - | - | - | +| 14 | 14 | 12 | MISO | - | - | - | - | P2-6* | +| 15 | 15 | 14 | SCLK | - | - | - | - | P2-9* | +| 16 | 16 | 13 | MOSI | - | - | - | - | - | +| 17 | - | 27 | - | - | - | - | - | - | +| 18 | 18 | 26 | - | DATA1 | - | - | - | P2-1 | +| 19 | 19 | 25 | - | DATA2 | - | - | - | P2-2 | +| 20 | 20 | 33 | - | DATA3 | - | - | - | P2-3 | +| 21 | 21 | 32 | - | DATA4 | - | - | - | P2-4 | +| 22 | - | 35 | - | - | - | - | - | - | +| 23 | - | 3.3V VCC | 3.3V VCC | - | - | 3.3V VCC | 3.3V VCC | - | +| 24 | 5V VCC OUT | 5V VCC | 5V VCC | 5V VCC | 5V VCC | - | 5V VCC | PX-5 5V VCC | +| 25 | GND | GND | GND | GND | - | GND | GND | PX-8 GND | * 2nd player Genesis is incompatible with Radio because it uses the same pins, 1 player Genesis is compatible diff --git a/src/Playstation.cpp b/src/Playstation.cpp index af98161..a2cc43a 100644 --- a/src/Playstation.cpp +++ b/src/Playstation.cpp @@ -24,10 +24,10 @@ PIN # USAGE (colors from my extension cable, check your own) #if defined(ARDUINO_ARCH_ESP32) -#define DATA1 13 -#define CMD1 12 -#define ATT1 14 -#define CLK1 27 +#define DATA1 2 +#define CMD1 4 +#define ATT1 16 +#define CLK1 17 #define CTRL_BYTE_DELAY 18 diff --git a/src/RadioReceiver.cpp b/src/RadioReceiver.cpp index fb9cd64..1760bb4 100644 --- a/src/RadioReceiver.cpp +++ b/src/RadioReceiver.cpp @@ -9,7 +9,17 @@ #include "gamepad/Gamepad.h" -RF24 radio(7, 8); // CE, CSN +#if defined(ARDUINO_ARCH_ESP32) +// esp32 +#define CE_PIN 18 +#define CSN_PIN 19 +#else +// micro +#define CE_PIN 7 +#define CSN_PIN 8 +#endif // ARDUINO_ARCH_ESP32 + +RF24 radio(CE_PIN, CSN_PIN); const byte address[13] = "OpenRetroPad"; diff --git a/src/SegaGenesis.cpp b/src/SegaGenesis.cpp index b8f9058..315a2d0 100644 --- a/src/SegaGenesis.cpp +++ b/src/SegaGenesis.cpp @@ -70,17 +70,17 @@ static const int DATA_PIN[GAMEPAD_COUNT][PIN_COUNT] = { #if defined(ARDUINO_ARCH_ESP32) static const int DATA_PIN_SELECT[GAMEPAD_COUNT] = { - 5, + 17, #if GAMEPAD_COUNT > 1 - 25, + 18, #endif }; //individual data pin for each controller static const int DATA_PIN[GAMEPAD_COUNT][PIN_COUNT] = { - {15, 2, 4, 16, 17, 18}, + {15, 1, 2, 4, 16, 5}, #if GAMEPAD_COUNT > 1 - {36, 39, 34, 35, 33, 27}, + {26, 25, 33, 32, 12, 14}, #endif }; diff --git a/src/SnesNes.cpp b/src/SnesNes.cpp index 76140e2..9d6786f 100644 --- a/src/SnesNes.cpp +++ b/src/SnesNes.cpp @@ -6,6 +6,31 @@ #endif #define BUTTON_COUNT 12 // SNES has 12, NES only has 8 +//shared pins between all controllers +#if defined(ARDUINO_ARCH_ESP32) +// ESP32 +static const int LATCH_PIN = 2; // brown +static const int CLOCK_PIN = 4; // white + +//individual data pin for each controller +static const int DATA_PIN[GAMEPAD_COUNT] = { + 26, +#if GAMEPAD_COUNT > 1 + 25, +#endif +#if GAMEPAD_COUNT > 2 + 33, +#endif +#if GAMEPAD_COUNT > 3 + 32, +#endif +}; + +#else +// micro +static const int LATCH_PIN = 2; // brown +static const int CLOCK_PIN = 3; // white + //individual data pin for each controller static const int DATA_PIN[GAMEPAD_COUNT] = { 18, @@ -20,15 +45,6 @@ static const int DATA_PIN[GAMEPAD_COUNT] = { #endif }; -//shared pins between all controllers -#if defined(CONFIG_BT_ENABLED) -// ESP32 -static const int LATCH_PIN = 16; // brown -static const int CLOCK_PIN = 17; // white -#else -// micro -static const int LATCH_PIN = 2; // brown -static const int CLOCK_PIN = 3; // white #endif // power red, ground black