diff --git a/tasmota/tasmota_template.h b/tasmota/tasmota_template.h index b63118bf3..bf361ca0f 100644 --- a/tasmota/tasmota_template.h +++ b/tasmota/tasmota_template.h @@ -208,9 +208,10 @@ enum UserSelectablePins { GPIO_SM2135_DAT, // SM2135 Dat GPIO_DEEPSLEEP, // Kill switch for deepsleep GPIO_EXS_ENABLE, // EXS MCU Enable - GPIO_TASMOTASLAVE_TXD, // Arduino Slave TX - GPIO_TASMOTASLAVE_RXD, // Arduino Slave RX - GPIO_TASMOTASLAVE_RST, // Arduino Reset Pin + GPIO_TASMOTASLAVE_TXD, // Slave TX + GPIO_TASMOTASLAVE_RXD, // Slave RX + GPIO_TASMOTASLAVE_RST, // Slave Reset Pin + GPIO_TASMOTASLAVE_RST_INV, // Slave Reset Inverted GPIO_SENSOR_END }; // Programmer selectable GPIO functionality @@ -289,7 +290,7 @@ const char kSensorNames[] PROGMEM = D_SENSOR_DDSU666_TX "|" D_SENSOR_DDSU666_RX "|" D_SENSOR_SM2135_CLK "|" D_SENSOR_SM2135_DAT "|" D_SENSOR_DEEPSLEEP "|" D_SENSOR_EXS_ENABLE "|" - D_SENSOR_SLAVE_TX "|" D_SENSOR_SLAVE_RX "|" D_SENSOR_SLAVE_RESET "|" + D_SENSOR_SLAVE_TX "|" D_SENSOR_SLAVE_RX "|" D_SENSOR_SLAVE_RESET "|" D_SENSOR_SLAVE_RESET "i|" ; const char kSensorNamesFixed[] PROGMEM = @@ -703,9 +704,10 @@ const uint8_t kGpioNiceList[] PROGMEM = { GPIO_PN532_RXD, // PN532 HSU Rx #endif #ifdef USE_TASMOTA_SLAVE - GPIO_TASMOTASLAVE_TXD, // Tasmota Slave TX - GPIO_TASMOTASLAVE_RXD, // Tasmota Slave RX - GPIO_TASMOTASLAVE_RST, // Tasmota Reset Pin + GPIO_TASMOTASLAVE_TXD, // Tasmota Slave TX + GPIO_TASMOTASLAVE_RXD, // Tasmota Slave RX + GPIO_TASMOTASLAVE_RST, // Tasmota Slave Reset + GPIO_TASMOTASLAVE_RST_INV, // Tasmota Slave Reset Inverted #endif #ifdef USE_RDM6300 GPIO_RDM6300_RX, diff --git a/tasmota/xdrv_31_tasmota_slave.ino b/tasmota/xdrv_31_tasmota_slave.ino index dff94182b..2a413516f 100644 --- a/tasmota/xdrv_31_tasmota_slave.ino +++ b/tasmota/xdrv_31_tasmota_slave.ino @@ -134,6 +134,7 @@ struct TSLAVE { uint32_t spi_hex_size = 0; uint32_t spi_sector_counter = 0; uint8_t spi_sector_cursor = 0; + uint8_t inverted = LOW; bool type = false; bool flashing = false; bool SerialEnabled = false; @@ -198,9 +199,11 @@ uint8_t TasmotaSlave_UpdateInit(void) void TasmotaSlave_Reset(void) { if (TSlave.SerialEnabled) { - digitalWrite(pin[GPIO_TASMOTASLAVE_RST], LOW); + digitalWrite(pin[GPIO_TASMOTASLAVE_RST], !TSlave.inverted); delay(1); - digitalWrite(pin[GPIO_TASMOTASLAVE_RST], HIGH); + digitalWrite(pin[GPIO_TASMOTASLAVE_RST], TSlave.inverted); + delay(1); + digitalWrite(pin[GPIO_TASMOTASLAVE_RST], !TSlave.inverted); delay(5); } } @@ -408,15 +411,21 @@ void TasmotaSlave_Init(void) return; } if (!TSlave.SerialEnabled) { - if ((pin[GPIO_TASMOTASLAVE_RXD] < 99) && (pin[GPIO_TASMOTASLAVE_TXD] < 99) && (pin[GPIO_TASMOTASLAVE_RST] < 99)) { + if ((pin[GPIO_TASMOTASLAVE_RXD] < 99) && (pin[GPIO_TASMOTASLAVE_TXD] < 99) && + ((pin[GPIO_TASMOTASLAVE_RST] < 99) || (pin[GPIO_TASMOTASLAVE_RST_INV] < 99))) { TasmotaSlave_Serial = new TasmotaSerial(pin[GPIO_TASMOTASLAVE_RXD], pin[GPIO_TASMOTASLAVE_TXD], 1, 0, 200); if (TasmotaSlave_Serial->begin(USE_TASMOTA_SLAVE_SERIAL_SPEED)) { if (TasmotaSlave_Serial->hardwareSerial()) { ClaimSerial(); } + if (pin[GPIO_TASMOTASLAVE_RST_INV] < 99) { + pin[GPIO_TASMOTASLAVE_RST] = pin[GPIO_TASMOTASLAVE_RST_INV]; + pin[GPIO_TASMOTASLAVE_RST_INV] = 99; + TSlave.inverted = HIGH; + } pinMode(pin[GPIO_TASMOTASLAVE_RST], OUTPUT); - TasmotaSlave_Reset(); TSlave.SerialEnabled = true; + TasmotaSlave_Reset(); AddLog_P2(LOG_LEVEL_INFO, PSTR("Tasmota Slave Enabled")); } }