Custom pinout definitions

Hi!

I use Arduino IDE to program my ESP32 module and I have a little problem:

I'd like to use the SD library with the pins 5, 18, 19, 21, but with "SD.begin()" I can only define the SS pin.

The ESP32's "pins_arduino.h" file contains the pin definitions, such as:

static const uint8_t TX = 1;
static const uint8_t RX = 3;

static const uint8_t SDA = 21;
static const uint8_t SCL = 22;

static const uint8_t SS    = 5;
static const uint8_t MOSI  = 23;
static const uint8_t MISO  = 19;
static const uint8_t SCK   = 18;

I have tried to modify the SPI pins in this file and it worked.

And I want to redefine these pins in my own "Config.h" or my own "pins_arduino.h" file (for one specific project) like this:

static const uint8_t TX = 1;
static const uint8_t RX = 3;

static const uint8_t SDA = 21;
static const uint8_t SCL = 22;

static const uint8_t SS    = 21;
static const uint8_t MOSI  = 19;
static const uint8_t MISO  =  5;
static const uint8_t SCK   = 18;

So I just copied the whole config file and made my own "Config.h" file, included it to my code and the results were like this:

redefinition of 'const uint8_t SCK'

I know I did something wrong, but I don't know how to do it. Is there even a way to do what I want?

The numbers in that file are the numbers of the pins that the functionality is hardwired to. How are you changing where the functionality is hardwired to?

So I just copied the whole config file and made my own "Config.h" file, included it to my code and the results were like this:

So, both your config file and the default one are included. I can't see THAT as a good idea.

The ESP32 has a so called GPIO matrix so any function can be mapped to any pin.

How can I use my own config instead of the default one then?

The best way to proceed is to put your modified variant files (pins_arduino.h, etc.) in their own folder under the variants folder and then create your own board entry in the ESP32 hardware package's boards.txt that specifies the modified variant.

Details here: