Merge pull request #6766 from andrethomas/tasmota_slave

TasmotaSlave: Revert removal of RSTi
This commit is contained in:
Theo Arends 2019-10-27 19:34:41 +01:00 committed by GitHub
commit 2c8f058013
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 11 deletions

View File

@ -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,

View File

@ -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"));
}
}