From ace6097052048e07eab1507a6528e4ef95b8e3b7 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 23 Aug 2020 15:34:19 +0200 Subject: [PATCH] Allow software SPI without hardware SPI --- tasmota/support_tasmota.ino | 5 +++-- tasmota/tasmota_template.h | 2 +- tasmota/tasmota_template_ESP32.h | 2 +- tasmota/xsns_47_max31865.ino | 4 ---- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino index 25f1a4417..6aeec7665 100644 --- a/tasmota/support_tasmota.ino +++ b/tasmota/support_tasmota.ino @@ -1474,6 +1474,8 @@ void GpioInit(void) Settings.serial_config = TS_SERIAL_8N1; } +// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("DBG: Used GPIOs %d"), GPIO_SENSOR_END); + for (uint32_t i = 0; i < ARRAY_SIZE(Settings.user_template.gp.io); i++) { if ((Settings.user_template.gp.io[i] >= AGPIO(GPIO_SENSOR_END)) && (Settings.user_template.gp.io[i] < AGPIO(GPIO_USER))) { Settings.user_template.gp.io[i] = AGPIO(GPIO_USER); // Fix not supported sensor ids in template @@ -1584,7 +1586,6 @@ void GpioInit(void) SetPin(14, GPIO_SPI_CLK); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("SPI: Using GPIO12(MISO), GPIO13(MOSI) and GPIO14(CLK)")); } - soft_spi_flg = (PinUsed(GPIO_SSPI_CS) && PinUsed(GPIO_SSPI_SCLK) && (PinUsed(GPIO_SSPI_MOSI) || PinUsed(GPIO_SSPI_MISO))); #endif // USE_SPI #else // ESP32 #ifdef USE_SPI @@ -1637,9 +1638,9 @@ void GpioInit(void) } } } - soft_spi_flg = (PinUsed(GPIO_SSPI_SCLK) && (PinUsed(GPIO_SSPI_MOSI) || PinUsed(GPIO_SSPI_MISO))); #endif // USE_SPI #endif // ESP8266 - ESP32 + soft_spi_flg = (PinUsed(GPIO_SSPI_SCLK) && (PinUsed(GPIO_SSPI_MOSI) || PinUsed(GPIO_SSPI_MISO))); // Set any non-used GPIO to INPUT - Related to resetPins() in support_legacy_cores.ino // Doing it here solves relay toggles at restart. diff --git a/tasmota/tasmota_template.h b/tasmota/tasmota_template.h index 14a068120..f6d28e63d 100644 --- a/tasmota/tasmota_template.h +++ b/tasmota/tasmota_template.h @@ -445,12 +445,12 @@ const uint8_t kGpioNiceList[] PROGMEM = { #ifdef USE_SPI GPIO_SPI_CS, // SPI Chip Select GPIO_SPI_DC, // SPI Data Direction +#endif GPIO_SSPI_MISO, // Software SPI Master Input Client Output GPIO_SSPI_MOSI, // Software SPI Master Output Client Input GPIO_SSPI_SCLK, // Software SPI Serial Clock GPIO_SSPI_CS, // Software SPI Chip Select GPIO_SSPI_DC, // Software SPI Data or Command -#endif #ifdef USE_DISPLAY GPIO_BACKLIGHT, // Display backlight control GPIO_OLED_RESET, // OLED Display Reset diff --git a/tasmota/tasmota_template_ESP32.h b/tasmota/tasmota_template_ESP32.h index d2ab06ed0..75e8e5a70 100644 --- a/tasmota/tasmota_template_ESP32.h +++ b/tasmota/tasmota_template_ESP32.h @@ -285,12 +285,12 @@ const uint16_t kGpioNiceList[] PROGMEM = { AGPIO(GPIO_SPI_CLK), // SPI Clk AGPIO(GPIO_SPI_CS), // SPI Chip Select AGPIO(GPIO_SPI_DC), // SPI Data Direction +#endif AGPIO(GPIO_SSPI_MISO), // Software SPI Master Input Client Output AGPIO(GPIO_SSPI_MOSI), // Software SPI Master Output Client Input AGPIO(GPIO_SSPI_SCLK), // Software SPI Serial Clock AGPIO(GPIO_SSPI_CS), // Software SPI Chip Select AGPIO(GPIO_SSPI_DC), // Software SPI Data or Command -#endif #ifdef USE_DISPLAY AGPIO(GPIO_BACKLIGHT), // Display backlight control AGPIO(GPIO_OLED_RESET), // OLED Display Reset diff --git a/tasmota/xsns_47_max31865.ino b/tasmota/xsns_47_max31865.ino index e29054392..220af5d80 100644 --- a/tasmota/xsns_47_max31865.ino +++ b/tasmota/xsns_47_max31865.ino @@ -19,10 +19,6 @@ #ifdef USE_MAX31865 -#ifndef USE_SPI -#error "MAX31865 requires USE_SPI enabled" -#endif - #include "Adafruit_MAX31865.h" #define XSNS_47 47