mirror of
https://github.com/arendst/Tasmota.git
synced 2026-07-27 20:05:46 +00:00
Add support SPI bus2 for Ethernet and SDCard (#24433)
This commit is contained in:
@@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file.
|
||||
|
||||
## [15.2.0.5]
|
||||
### Added
|
||||
- Support SPI bus2 for Ethernet and SDCard (#24433)
|
||||
|
||||
### Breaking Changed
|
||||
|
||||
|
||||
@@ -116,6 +116,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
|
||||
### Added
|
||||
- Support for TCA9554 8-bit I/O expander mutually exclusive with PCA9557
|
||||
- Support for Adafruit I2C QT Rotary Encoder [#24270](https://github.com/arendst/Tasmota/issues/24270)
|
||||
- Support SPI bus2 for Ethernet and SDCard [#24433](https://github.com/arendst/Tasmota/issues/24433)
|
||||
- Improv USB CDC connected devices
|
||||
- Dingtian `SetOption81 1` to invert input and `SetOption133 1` to invert output [#24364](https://github.com/arendst/Tasmota/issues/24364)
|
||||
- Zigbee support for `int24` type [#24334](https://github.com/arendst/Tasmota/issues/24334)
|
||||
|
||||
@@ -11,6 +11,10 @@
|
||||
* Basic SPI routines supporting two busses
|
||||
\*********************************************************************************************/
|
||||
|
||||
#ifdef ESP32
|
||||
SPIClass SPI_HSPI(HSPI); // Uses HSPI
|
||||
#endif // ESP32
|
||||
|
||||
SPIClass *SpiBegin(uint32 bus = 1);
|
||||
SPIClass *SpiBegin(uint32 bus) {
|
||||
SPIClass *spi;
|
||||
@@ -43,7 +47,6 @@ SPIClass *SpiBegin(uint32 bus) {
|
||||
/********************************************************************************************/
|
||||
|
||||
void AddLogSpi(uint32_t hardware, int clk, int mosi, int miso) {
|
||||
#ifndef FIRMWARE_MINIMAL
|
||||
uint32_t enabled = TasmotaGlobal.soft_spi_enabled;
|
||||
char hwswbus[8];
|
||||
if (hardware) {
|
||||
@@ -73,5 +76,4 @@ void AddLogSpi(uint32_t hardware, int clk, int mosi, int miso) {
|
||||
hwswbus, clk, mosi, miso);
|
||||
break;
|
||||
}
|
||||
#endif // FIRMWARE_MINIMAL
|
||||
}
|
||||
|
||||
@@ -211,12 +211,16 @@ void UfsCheckSDCardInit(void) {
|
||||
|
||||
#ifdef ESP8266
|
||||
SPI.begin();
|
||||
if (SD.begin(cs)) {
|
||||
#endif // ESP8266
|
||||
#ifdef ESP32
|
||||
SPI.begin(Pin(GPIO_SPI_CLK, spi_bus), Pin(GPIO_SPI_MISO, spi_bus), Pin(GPIO_SPI_MOSI, spi_bus), -1);
|
||||
if (1 == spi_bus) {
|
||||
SPI_HSPI.begin(Pin(GPIO_SPI_CLK, spi_bus), Pin(GPIO_SPI_MISO, spi_bus), Pin(GPIO_SPI_MOSI, spi_bus), -1);
|
||||
} else {
|
||||
SPI.begin(Pin(GPIO_SPI_CLK), Pin(GPIO_SPI_MISO), Pin(GPIO_SPI_MOSI), -1);
|
||||
}
|
||||
if (SD.begin(cs, (1 == spi_bus) ? SPI_HSPI : SPI)) {
|
||||
#endif // ESP32
|
||||
|
||||
if (SD.begin(cs)) {
|
||||
#ifdef ESP8266
|
||||
ufsp = &SDFS;
|
||||
#endif // ESP8266
|
||||
@@ -234,7 +238,7 @@ void UfsCheckSDCardInit(void) {
|
||||
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UFS "SDCard mounted"));
|
||||
#endif // ESP8266
|
||||
#ifdef ESP32
|
||||
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UFS "SDCard mounted (SPI mode) with %d kB free"), UfsInfo(1, 0));
|
||||
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UFS "SDCard mounted (SPI bus%d) with %d kB free"), spi_bus +1, UfsInfo(1, 0));
|
||||
#endif // ESP32
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,33 +274,41 @@ void EthernetInit(void) {
|
||||
bool init_ok = false;
|
||||
if (!eth_uses_spi) {
|
||||
#if CONFIG_ETH_USE_ESP32_EMAC
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32P4
|
||||
init_ok = (ETH.begin((eth_phy_type_t)eth_type, Settings->eth_address, eth_mdc, eth_mdio, eth_power, EMAC_CLK_EXT_IN));
|
||||
#else
|
||||
init_ok = (ETH.begin((eth_phy_type_t)eth_type, Settings->eth_address, eth_mdc, eth_mdio, eth_power, (eth_clock_mode_t)Settings->eth_clk_mode));
|
||||
#endif //CONFIG_IDF_TARGET_ESP32P4
|
||||
#ifndef FIRMWARE_MINIMAL
|
||||
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ETH "Ethernet using RMII"));
|
||||
#endif // FIRMWARE_MINIMAL
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32P4
|
||||
init_ok = (ETH.begin((eth_phy_type_t)eth_type, Settings->eth_address, eth_mdc, eth_mdio, eth_power, EMAC_CLK_EXT_IN));
|
||||
#else
|
||||
init_ok = (ETH.begin((eth_phy_type_t)eth_type, Settings->eth_address, eth_mdc, eth_mdio, eth_power, (eth_clock_mode_t)Settings->eth_clk_mode));
|
||||
#endif //CONFIG_IDF_TARGET_ESP32P4
|
||||
#endif // CONFIG_ETH_USE_ESP32_EMAC
|
||||
} else {
|
||||
#if CONFIG_SOC_SPI_PERIPH_NUM > 2
|
||||
if (1 == spi_bus) {
|
||||
if (SPI_MOSI_MISO != TasmotaGlobal.spi_enabled2) {
|
||||
if ((1 == spi_bus) && (SPI_MOSI_MISO != TasmotaGlobal.spi_enabled2)) {
|
||||
#ifndef FIRMWARE_MINIMAL
|
||||
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ETH "No SPI bus2 GPIO defined"));
|
||||
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ETH "No SPI bus2 GPIO defined"));
|
||||
#endif // FIRMWARE_MINIMAL
|
||||
return;
|
||||
}
|
||||
init_ok = (ETH.begin((eth_phy_type_t)eth_type, Settings->eth_address, eth_mdc, eth_mdio, eth_power, SPI3_HOST, Pin(GPIO_SPI_CLK, 1), Pin(GPIO_SPI_MISO, 1), Pin(GPIO_SPI_MOSI, 1), ETH_PHY_SPI_FREQ_MHZ));
|
||||
return;
|
||||
} else
|
||||
#endif // CONFIG_SOC_SPI_PERIPH_NUM > 2
|
||||
{
|
||||
if (SPI_MOSI_MISO != TasmotaGlobal.spi_enabled) {
|
||||
if (SPI_MOSI_MISO != TasmotaGlobal.spi_enabled) {
|
||||
#ifndef FIRMWARE_MINIMAL
|
||||
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ETH "No SPI bus1 GPIO defined"));
|
||||
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ETH "No SPI bus1 GPIO defined"));
|
||||
#endif // FIRMWARE_MINIMAL
|
||||
return;
|
||||
}
|
||||
init_ok = (ETH.begin((eth_phy_type_t)eth_type, Settings->eth_address, eth_mdc, eth_mdio, eth_power, SPI2_HOST, Pin(GPIO_SPI_CLK), Pin(GPIO_SPI_MISO), Pin(GPIO_SPI_MOSI), ETH_PHY_SPI_FREQ_MHZ));
|
||||
return;
|
||||
}
|
||||
#ifndef FIRMWARE_MINIMAL
|
||||
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ETH "Ethernet using SPI (bus%d)"), spi_bus +1);
|
||||
#endif // FIRMWARE_MINIMAL
|
||||
init_ok = (ETH.begin((eth_phy_type_t)eth_type, Settings->eth_address,
|
||||
eth_mdc, eth_mdio, eth_power,
|
||||
#if CONFIG_SOC_SPI_PERIPH_NUM > 2
|
||||
(1 == spi_bus) ? SPI3_HOST : SPI2_HOST,
|
||||
#else
|
||||
SPI2_HOST,
|
||||
#endif
|
||||
Pin(GPIO_SPI_CLK, spi_bus), Pin(GPIO_SPI_MISO, spi_bus), Pin(GPIO_SPI_MOSI, spi_bus)));
|
||||
}
|
||||
if (!init_ok) {
|
||||
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ETH "Bad EthType %i or init error"),eth_type);
|
||||
|
||||
Reference in New Issue
Block a user