TasmotaSlave: Revert removal of RSTi

This commit is contained in:
andrethomas 2019-10-27 20:10:25 +02:00
parent fef6d0c7c5
commit 2658497526
2 changed files with 22 additions and 11 deletions

View File

@ -208,9 +208,10 @@ enum UserSelectablePins {
GPIO_SM2135_DAT, // SM2135 Dat GPIO_SM2135_DAT, // SM2135 Dat
GPIO_DEEPSLEEP, // Kill switch for deepsleep GPIO_DEEPSLEEP, // Kill switch for deepsleep
GPIO_EXS_ENABLE, // EXS MCU Enable GPIO_EXS_ENABLE, // EXS MCU Enable
GPIO_TASMOTASLAVE_TXD, // Arduino Slave TX GPIO_TASMOTASLAVE_TXD, // Slave TX
GPIO_TASMOTASLAVE_RXD, // Arduino Slave RX GPIO_TASMOTASLAVE_RXD, // Slave RX
GPIO_TASMOTASLAVE_RST, // Arduino Reset Pin GPIO_TASMOTASLAVE_RST, // Slave Reset Pin
GPIO_TASMOTASLAVE_RST_INV, // Slave Reset Inverted
GPIO_SENSOR_END }; GPIO_SENSOR_END };
// Programmer selectable GPIO functionality // Programmer selectable GPIO functionality
@ -289,7 +290,7 @@ const char kSensorNames[] PROGMEM =
D_SENSOR_DDSU666_TX "|" D_SENSOR_DDSU666_RX "|" D_SENSOR_DDSU666_TX "|" D_SENSOR_DDSU666_RX "|"
D_SENSOR_SM2135_CLK "|" D_SENSOR_SM2135_DAT "|" D_SENSOR_SM2135_CLK "|" D_SENSOR_SM2135_DAT "|"
D_SENSOR_DEEPSLEEP "|" D_SENSOR_EXS_ENABLE "|" 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 = const char kSensorNamesFixed[] PROGMEM =
@ -705,7 +706,8 @@ const uint8_t kGpioNiceList[] PROGMEM = {
#ifdef USE_TASMOTA_SLAVE #ifdef USE_TASMOTA_SLAVE
GPIO_TASMOTASLAVE_TXD, // Tasmota Slave TX GPIO_TASMOTASLAVE_TXD, // Tasmota Slave TX
GPIO_TASMOTASLAVE_RXD, // Tasmota Slave RX GPIO_TASMOTASLAVE_RXD, // Tasmota Slave RX
GPIO_TASMOTASLAVE_RST, // Tasmota Reset Pin GPIO_TASMOTASLAVE_RST, // Tasmota Slave Reset
GPIO_TASMOTASLAVE_RST_INV, // Tasmota Slave Reset Inverted
#endif #endif
#ifdef USE_RDM6300 #ifdef USE_RDM6300
GPIO_RDM6300_RX, GPIO_RDM6300_RX,

View File

@ -134,6 +134,7 @@ struct TSLAVE {
uint32_t spi_hex_size = 0; uint32_t spi_hex_size = 0;
uint32_t spi_sector_counter = 0; uint32_t spi_sector_counter = 0;
uint8_t spi_sector_cursor = 0; uint8_t spi_sector_cursor = 0;
uint8_t inverted = LOW;
bool type = false; bool type = false;
bool flashing = false; bool flashing = false;
bool SerialEnabled = false; bool SerialEnabled = false;
@ -198,9 +199,11 @@ uint8_t TasmotaSlave_UpdateInit(void)
void TasmotaSlave_Reset(void) void TasmotaSlave_Reset(void)
{ {
if (TSlave.SerialEnabled) { if (TSlave.SerialEnabled) {
digitalWrite(pin[GPIO_TASMOTASLAVE_RST], LOW); digitalWrite(pin[GPIO_TASMOTASLAVE_RST], !TSlave.inverted);
delay(1); 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); delay(5);
} }
} }
@ -408,15 +411,21 @@ void TasmotaSlave_Init(void)
return; return;
} }
if (!TSlave.SerialEnabled) { 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); 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->begin(USE_TASMOTA_SLAVE_SERIAL_SPEED)) {
if (TasmotaSlave_Serial->hardwareSerial()) { if (TasmotaSlave_Serial->hardwareSerial()) {
ClaimSerial(); 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); pinMode(pin[GPIO_TASMOTASLAVE_RST], OUTPUT);
TasmotaSlave_Reset();
TSlave.SerialEnabled = true; TSlave.SerialEnabled = true;
TasmotaSlave_Reset();
AddLog_P2(LOG_LEVEL_INFO, PSTR("Tasmota Slave Enabled")); AddLog_P2(LOG_LEVEL_INFO, PSTR("Tasmota Slave Enabled"));
} }
} }