33
44#ifdef ESP32
55
6+ #include " ../Helpers/Hardware_device_info.h"
7+
68// ESP32 VSPI:
79// SCK = 18
810// MISO = 19
3537
3638
3739# if CONFIG_IDF_TARGET_ESP32S3 // ESP32-S3
38- #define VSPI_FSPI_SHORT_STRING " FSPI"
40+ #define VSPI_FSPI_SHORT_STRING " FSPI ( " STRINGIFY(FSPI_HOST) " ) "
3941# elif CONFIG_IDF_TARGET_ESP32S2 // ESP32-S2
40- #define VSPI_FSPI_SHORT_STRING " FSPI"
41- # elif CONFIG_IDF_TARGET_ESP32C2 // ESP32-C2
42- #define VSPI_FSPI_SHORT_STRING " FSPI"
43- # elif CONFIG_IDF_TARGET_ESP32C3 // ESP32-C3
44- #define VSPI_FSPI_SHORT_STRING " SPI"
45- # elif CONFIG_IDF_TARGET_ESP32C5 // ESP32-C5
46- #define VSPI_FSPI_SHORT_STRING " FSPI"
47- # elif CONFIG_IDF_TARGET_ESP32C6 // ESP32-C6
48- #define VSPI_FSPI_SHORT_STRING " FSPI"
49- # elif CONFIG_IDF_TARGET_ESP32C61 // ESP32-C61
50- #define VSPI_FSPI_SHORT_STRING " FSPI"
51- # elif CONFIG_IDF_TARGET_ESP32P4 // ESP32-P4
52- #define VSPI_FSPI_SHORT_STRING " FSPI"
42+ #define VSPI_FSPI_SHORT_STRING " FSPI (" STRINGIFY(FSPI_HOST) " )"
43+ #elif CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C5 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32C61 || CONFIG_IDF_TARGET_ESP32P4
44+ # if SOC_SPI_PERIPH_NUM > 2
45+ #define VSPI_FSPI_SHORT_STRING " FSPI (" STRINGIFY(VSPI_HOST) " )"
46+ # else
47+ #define VSPI_FSPI_SHORT_STRING " SPI" // STRINGIFY(VSPI_HOST)
48+ # endif
49+
5350# elif CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
54- #define VSPI_FSPI_SHORT_STRING " VSPI"
51+ #define VSPI_FSPI_SHORT_STRING " VSPI ( " STRINGIFY(VSPI_HOST) " ) "
5552
5653# else // if CONFIG_IDF_TARGET_ESP32S2
5754# error Target CONFIG_IDF_TARGET is not supported
5855# endif // if CONFIG_IDF_TARGET_ESP32S2
5956
57+ #if SOC_SPI_PERIPH_NUM > 2
58+ #ifdef ESP32_CLASSIC
59+ #define HSPI_SHORT_STRING " HSPI (" STRINGIFY(HSPI_HOST) " )"
60+ #else
61+ #define HSPI_SHORT_STRING STRINGIFY (HSPI_HOST)
62+ #endif
63+ #endif
64+
6065
6166const __FlashStringHelper* getSPI_optionToString (SPI_Options_e option) {
6267 switch (option) {
@@ -65,43 +70,73 @@ const __FlashStringHelper* getSPI_optionToString(SPI_Options_e option) {
6570 case SPI_Options_e::Vspi_Fspi:
6671 return F (
6772 VSPI_FSPI_SHORT_STRING
68- " : CLK=GPIO- " STRINGIFY (VSPI_FSPI_SCK)
69- " , MISO=GPIO- " STRINGIFY (VSPI_FSPI_MISO)
70- " , MOSI=GPIO- " STRINGIFY (VSPI_FSPI_MOSI) );
73+ " : CLK=" STRINGIFY (VSPI_FSPI_SCK)
74+ " , MISO=" STRINGIFY (VSPI_FSPI_MISO)
75+ " , MOSI=" STRINGIFY (VSPI_FSPI_MOSI) );
7176#ifdef ESP32_CLASSIC
7277 case SPI_Options_e::Hspi:
7378 return F (
74- " HSPI "
75- " : CLK=GPIO- " STRINGIFY (HSPI_SCLK)
76- " , MISO=GPIO- " STRINGIFY (HSPI_MISO)
77- " , MOSI=GPIO- " STRINGIFY (HSPI_MOSI) );
79+ HSPI_SHORT_STRING
80+ " : CLK=" STRINGIFY (HSPI_SCLK)
81+ " , MISO=" STRINGIFY (HSPI_MISO)
82+ " , MOSI=" STRINGIFY (HSPI_MOSI) );
7883
7984
8085#endif
81- case SPI_Options_e::UserDefined:
82- return F (" User-defined: CLK, MISO, MOSI GPIO-pins" );
86+ case SPI_Options_e::UserDefined_VSPI:
87+ return F (" User-defined " VSPI_FSPI_SHORT_STRING);
88+ #if SOC_SPI_PERIPH_NUM > 2
89+ case SPI_Options_e::UserDefined_HSPI:
90+ return F (" User-defined " HSPI_SHORT_STRING);
91+ #endif
8392 }
8493 return F (" Unknown" );
8594}
8695
96+ const __FlashStringHelper* get_vspi_fspi_str ()
97+ {
98+ return F (VSPI_FSPI_SHORT_STRING);
99+ }
100+
87101const String getSPI_optionToShortString (SPI_Options_e option, uint8_t spi_bus) {
102+ #ifdef ESP32
103+ String res;
88104 switch (option) {
89105 case SPI_Options_e::None:
90106 return F (" Disabled" );
91107 case SPI_Options_e::Vspi_Fspi:
92- return F (VSPI_FSPI_SHORT_STRING);
108+ res = F (VSPI_FSPI_SHORT_STRING);
109+ break ;
93110#ifdef ESP32_CLASSIC
94111 case SPI_Options_e::Hspi:
95- return F (" HSPI" );
112+ res = F (" HSPI" );
113+ break ;
114+ #endif
115+ case SPI_Options_e::UserDefined_VSPI:
116+ res = F (" User-defined " VSPI_FSPI_SHORT_STRING);
117+ break ;
118+ #if SOC_SPI_PERIPH_NUM > 2
119+ case SPI_Options_e::UserDefined_HSPI:
120+ res = F (" User-defined " HSPI_SHORT_STRING);
121+ break ;
96122#endif
97- case SPI_Options_e::UserDefined:
98- #ifdef ESP32
99- return concat (F (" User-defined SPI Bus " ), spi_bus);
100- #endif // ifdef ESP32
101- #ifdef ESP8266
123+ }
124+ if (!res.isEmpty ()) {
125+ if (getSPIBusCount () > 1 ) {
126+ return concat (res + F (" bus " ), spi_bus);
127+ }
128+ return res;
129+ }
130+ #else
131+ switch (option) {
132+ case SPI_Options_e::None:
133+ return F (" Disabled" );
134+ case SPI_Options_e::Vspi_Fspi:
135+ return F (VSPI_FSPI_SHORT_STRING);
136+ case SPI_Options_e::UserDefined_VSPI:
102137 return F (" User-defined SPI" );
103- #endif // ifdef ESP8266
104138 }
139+ #endif
105140 return F (" Unknown" );
106141}
107142
0 commit comments