How to change default SPI pins with esp32s3 and Arducam Mega 3Mpx

Hello,

I get the camera module(s) on internet: the Arducam Mega 3Mpx
I work on esp32s3 with SD card mount already placed on the pcb. (ESP32-S3-4G-LTE-CAT1-A7670E)
I need to alter the default pin of SPI because the defaults pins of SPI are already used by the SD card mount.
I’ve already tried to change the pin in ArducamSpi.cpp. The program stopped with the mycam.begin()
Here is the code :

#include <Arduino.h>
#include <SPI.h>
#include "Arducam_Mega.h" // Assurez-vous que ce fichier est accessible
#include "D:\Quentin\Documents\Arduino\libraries\Arducam_Mega\src\Arducam\ArducamCamera.h"

#define HSPI_MISO 3
#define HSPI_MOSI 8
#define HSPI_SCLK 16
#define HSPI_SS   9

Arducam_Mega myCAM(HSPI_SS); // Utilisez la broche CS que vous avez définie

void setup() {
    Serial.begin(115200);

    // Initialisation de HSPI pour la caméra Arducam
    Serial.println("Initializing HSPI...");
    SPI.begin(HSPI_SCLK, HSPI_MISO, HSPI_MOSI, HSPI_SS);
    Serial.println("HSPI Started");

    // Initialisation de la caméra
    Serial.println("Initializing camera...");
    CamStatus status = myCAM.begin();
    if (status != CAM_ERR_SUCCESS) {
        Serial.println("Failed to initialize camera!");
        return;
    }
    Serial.println("Camera initialized.");

    // Prendre une photo
    Serial.println("Taking a picture...");
    status = myCAM.takePicture(CAM_IMAGE_MODE_QVGA, CAM_IMAGE_PIX_FMT_JPG);
    if (status != CAM_ERR_SUCCESS) {
        Serial.println("Failed to take picture!");
        return;
    }
    Serial.println("Picture taken.");
}

void loop() {
    // Votre code ici
}

Here is the modification of the library:

void arducamSpiBegin(void)
{
    Serial.begin(115200);
    Serial.println("Démarrage SPI");
    return SPI.begin(16,3,8,9);
}

Thanks for advance

Do you know that SPI is a bus, so it can be used to connect a more than one slave device to the master mcu?
You don't need another set of SPI pins to connect a camera, use the same pins as for SD card

That will just put the standard SPI interface, which presumably the SD card is using, onto a different set of pins, so the the SD card probably wont work no more.

What happened when you ran the Camera and SD card on the same SPI pins ?

I don't have the access to the default pin, because, it's already soldering on the PCB of esp32.

The real problem may be the different bus clock for both devices. This can be achieved by using device specific SPISettings (.SCK and .CS) for the actual device in SPI.beginTransaction().

AFAIR the ESP provides a different SPI object for each physical SPI but. Classes HSPI and VSPI?

Have you checked if the SPI pins used for the on-board SD card are also available on the modules external pins ?

ESP32-S3 4G LTE CAT1 V1.2.PDF (253,9 Ko)
Here is the schematic of the board. The pins are only access on the SD card mount. But I don't want to solder wire on the pad of the SD card mount.

Its straightforward to put an SD card on the HSPI bus on an ESP32S3.

First define the SPI class at the top of the sketch;

#include <SPI.h>
SPIClass sdSPI(HSPI);

Then define the pins used, for example;

#define SDSCK 12
#define SDMOSI 11
#define SDMISO 13
#define SDCS 10

Then in setup() start the HSPI SPI interface;

sdSPI.begin(SDSCK, SDMISO, SDMOSI, SDCS);

Then startup the SD card and check it works;

if (!SD.begin(SDCS, sdSPI))
{
  Serial.println();
  Serial.println("ERROR SD card mount failed");
  Serial.println();
 }
else
{
 Serial.println();
 Serial.println("SD card mount OK");
 Serial.println();
 }

Please provide a link to the textual description (table?) of the board pins.

I don't have the table. I need to check on the schematics to see the corresponding port.
But I know this pins:
For SD:
PIN_SD_CMD 11
PIN_SD_CLK 12
PIN_SD_D0 13

For GSM:
IO_RXD2 47
IO_TXD2 48
IO_GSM_PWRKEY 4
IO_GSM_RST 5

For I2C:
I2C_SDA 17
I2C_SCL 18

And I have these pins to connect the camera