How to select between multiple HW SPI peripherals
How to select between multiple HW SPI peripherals
Hello. I have checked multiple ESP32 arduino platform examples for SPI devices such as LIS3DH accelerometer, SSD1306 oled display and I cannot understand one thing. Whenever the HW SPI is initialised, it defaults to pins GPIO23(MOSI), GPIO19(MISO), GPIO18(SCLK). Since ESP32 has multiple HW SPI peripherals, what if I have wired my SPI to another HW SPI peripheral GPIO13(MOSI), GPIO12(MISO), GPIO14(SCLK). How can I change that?
-
- Posts: 827
- Joined: Mon Jul 22, 2019 3:20 pm
Re: How to select between multiple HW SPI peripherals
You will need to make a non-default SPI object and use that object to initialize your devices.
Code: Select all
SPIClass SD_SPI(VSPI);
void setup() {
Serial.begin(115200);
SD_SPI.begin(SD_SCK_PIN,SD_MISO_PIN,SD_MOSI_PIN,SD_CS_PIN);
SD.begin(SD_CS_PIN,SD_SPI);
}
Who is online
Users browsing this forum: No registered users and 91 guests