Adafruit ST7735 + RP2040 SPI1? (SOLVED)

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
IAmOrion
 
Posts: 74
Joined: Thu May 14, 2015 8:22 am

Adafruit ST7735 + RP2040 SPI1? (SOLVED)

Post by IAmOrion »

Hi There,
Could just be "woods for the trees" but I can't seem to figure out how to make the Adafruit ST7735 library use the RP2040s SPI1 hardware pins instead of SPI0?

For numerous reasons I need to use the SPI1 hardware pins so using the default SPI0 pins isn't an option in this case. I know I can include the SPI pin numbers I want to use in the constructor but that makes it Software SPI and is much slower than Hardware - so how can I use the second (SPI1) pins?

My SPI1 pins are already defined in the appropriate pins_arduino.h as:

Code: Select all

#define PIN_SPI1_MISO  (12u)
#define PIN_SPI1_MOSI  (15u)
#define PIN_SPI1_SCK   (14u)
#define PIN_SPI1_SS    (13u)
Last edited by IAmOrion on Wed Oct 26, 2022 5:42 pm, edited 1 time in total.

User avatar
adafruit_support_carter
 
Posts: 29056
Joined: Tue Nov 29, 2016 2:45 pm

Re: Adafruit ST7735 + RP2040 SPI1?

Post by adafruit_support_carter »

What RP2040 based board are you using? It looks like you are directly editing a core file?

User avatar
IAmOrion
 
Posts: 74
Joined: Thu May 14, 2015 8:22 am

Re: Adafruit ST7735 + RP2040 SPI1?

Post by IAmOrion »

adafruit_support_carter wrote: Wed Oct 26, 2022 5:27 pm What RP2040 based board are you using? It looks like you are directly editing a core file?
It's a Waveshare RP2040 Zero (https://www.waveshare.com/rp2040-zero.htm?sku=20187)

Yes, I added a board variant specifically for the Waveshare hence the pins_arduino.h edit, but isn't the board irrelevant? The RP2040 has 2 hardware SPI's - SPI0 and SPI1. By default, all libraries use SPI0 as expected, but I need to use SPI1

EDIT: Apologies, I'm just dumb! I misread

Code: Select all

#if !defined(ESP8266)
  Adafruit_ST7735(SPIClass *spiClass, int8_t cs, int8_t dc, int8_t rst);
#endif // end !ESP8266
thinking it was ONLY ESP8266 but just realised it's actually !ESP8266 :facepalm: (I missed the !) ha

So it works perfectly using Adafruit_ST7735(&SPI1, TFT_CS, TFT_DC, TFT_RST);

Apologies again, SOLVED

User avatar
adafruit_support_carter
 
Posts: 29056
Joined: Tue Nov 29, 2016 2:45 pm

Re: Adafruit ST7735 + RP2040 SPI1? (SOLVED)

Post by adafruit_support_carter »

but isn't the board irrelevant?
Only in that it matters to edit the pins for the board variant and then select that board in Arduino. Otherwise the settings might not take effect. The layers of Arduino abstraction can be confusing. You typically don't edit the core files. But sounds like you figured it out.

And, yep, the second part being ref'ing &SPI1 in code.

Glad it's working!

User avatar
IAmOrion
 
Posts: 74
Joined: Thu May 14, 2015 8:22 am

Re: Adafruit ST7735 + RP2040 SPI1? (SOLVED)

Post by IAmOrion »

adafruit_support_carter wrote: Wed Oct 26, 2022 5:50 pm
but isn't the board irrelevant?
Only in that it matters to edit the pins for the board variant and then select that board in Arduino. Otherwise the settings might not take effect. The layers of Arduino abstraction can be confusing. You typically don't edit the core files. But sounds like you figured it out.

And, yep, the second part being ref'ing &SPI1 in code.

Glad it's working!
Ah I see, yeah I've never edited core board files before, but I was pointed in the right direction by Earle Phillhower (and thus created the Waveshare variant submitted to his core). So my particular pins_arduino.h is correct and working :)

I was just being dumb - my apologies again

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”