diff --git a/esp-link/cgipins.c b/esp-link/cgipins.c index b763d12..bf4754d 100644 --- a/esp-link/cgipins.c +++ b/esp-link/cgipins.c @@ -32,9 +32,10 @@ int ICACHE_FLASH_ATTR cgiPinsGet(HttpdConnData *connData) { int len; len = os_sprintf(buff, - "{ \"reset\":%d, \"isp\":%d, \"conn\":%d, \"ser\":%d, \"swap\":%d, \"rxpup\":%d }", + "{ \"reset\":%d, \"isp\":%d, \"conn\":%d, \"ser\":%d, \"swap\":%d, \"rxpup\":%d, \"txen\":%d }", flashConfig.reset_pin, flashConfig.isp_pin, flashConfig.conn_led_pin, - flashConfig.ser_led_pin, !!flashConfig.swap_uart, !!flashConfig.rx_pullup); + flashConfig.ser_led_pin, !!flashConfig.swap_uart, !!flashConfig.rx_pullup, + flashConfig.tx_enable_pin); jsonHeader(connData, 200); httpdSend(connData, buff, len); @@ -48,7 +49,7 @@ int ICACHE_FLASH_ATTR cgiPinsSet(HttpdConnData *connData) { } int8_t ok = 0; - int8_t reset, isp, conn, ser; + int8_t reset, isp, conn, ser, tx_enable; uint8_t swap, rxpup; ok |= getInt8Arg(connData, "reset", &reset); ok |= getInt8Arg(connData, "isp", &isp); @@ -56,6 +57,7 @@ int ICACHE_FLASH_ATTR cgiPinsSet(HttpdConnData *connData) { ok |= getInt8Arg(connData, "ser", &ser); ok |= getBoolArg(connData, "swap", &swap); ok |= getBoolArg(connData, "rxpup", &rxpup); + ok |= getInt8Arg(connData, "txen", &tx_enable); if (ok < 0) return HTTPD_CGI_DONE; char *coll; @@ -75,6 +77,10 @@ int ICACHE_FLASH_ATTR cgiPinsSet(HttpdConnData *connData) { if (pins & (1<= 0) { + if (pins & (1<Second signal to program µC. AVR:not used, esp8266:gpio2, ARM:ISP +
+ + + +
diff --git a/html/ui.js b/html/ui.js index 67361c9..eb50b4c 100644 --- a/html/ui.js +++ b/html/ui.js @@ -393,12 +393,12 @@ function showNotification(text) { //===== GPIO Pin mux card var pinPresets = { - // array: reset, isp, conn, ser, swap, rxpup - "esp-01": [ 0, -1, 2, -1, 0, 1 ], - "esp-12": [ 12, 14, 0, 2, 0, 1 ], - "esp-12 swap": [ 1, 3, 0, 2, 1, 1 ], - "esp-bridge": [ 12, 13, 0, 14, 0, 0 ], - "wifi-link-12": [ 1, 3, 0, 2, 1, 0 ], + // array: reset, isp, conn, ser, swap, rxpup, txen + "esp-01": [ 0, -1, 2, -1, 0, 1, -1 ], + "esp-12": [ 12, 14, 0, 2, 0, 1, -1 ], + "esp-12 swap": [ 1, 3, 0, 2, 1, 1, -1 ], + "esp-bridge": [ 12, 13, 0, 14, 0, 0, -1 ], + "wifi-link-12": [ 1, 3, 0, 2, 1, 0, -1 ], }; function createPresets(sel) { @@ -418,6 +418,7 @@ function createPresets(sel) { setPP("ser", pp[3]); setPP("swap", pp[4]); $("#pin-rxpup").checked = !!pp[5]; + setPP("txen", pp[6]); sel.value = 0; }; @@ -453,6 +454,7 @@ function displayPins(resp) { createSelectForPin("ser", resp["ser"]); $("#pin-swap").value = resp["swap"]; $("#pin-rxpup").checked = !!resp["rxpup"]; + createSelectForPin("txen", resp["txen"]); createPresets($("#pin-preset")); $("#pin-spinner").setAttribute("hidden", ""); @@ -469,7 +471,7 @@ function setPins(ev) { ev.preventDefault(); var url = "/pins"; var sep = "?"; - ["reset", "isp", "conn", "ser", "swap"].forEach(function(p) { + ["reset", "isp", "conn", "ser", "swap", "txen"].forEach(function(p) { url += sep + p + "=" + $("#pin-"+p).value; sep = "&"; }); diff --git a/serial/serbridge.c b/serial/serbridge.c index 7ba8e8e..ff85694 100644 --- a/serial/serbridge.c +++ b/serial/serbridge.c @@ -18,7 +18,7 @@ static struct espconn serbridgeConn1; // plain bridging port static struct espconn serbridgeConn2; // programming port static esp_tcp serbridgeTcp1, serbridgeTcp2; -static int8_t mcu_reset_pin, mcu_isp_pin; +static int8_t mcu_reset_pin, mcu_isp_pin, tx_enable_pin; uint8_t in_mcu_flashing; // for disabling slip during MCU flashing @@ -557,9 +557,10 @@ serbridgeInitPins() { mcu_reset_pin = flashConfig.reset_pin; mcu_isp_pin = flashConfig.isp_pin; + tx_enable_pin = flashConfig.tx_enable_pin; #ifdef SERBR_DBG - os_printf("Serbridge pins: reset=%d isp=%d swap=%d\n", - mcu_reset_pin, mcu_isp_pin, flashConfig.swap_uart); + os_printf("Serbridge pins: reset=%d isp=%d tx_enable=%d swap=%d\n", + mcu_reset_pin, mcu_isp_pin, tx_enable_pin, flashConfig.swap_uart); #endif if (flashConfig.swap_uart) { @@ -578,12 +579,25 @@ serbridgeInitPins() system_uart_de_swap(); } - // set both pins to 1 before turning them on so we don't cause a reset - if (mcu_isp_pin >= 0) GPIO_OUTPUT_SET(mcu_isp_pin, 1); - if (mcu_reset_pin >= 0) GPIO_OUTPUT_SET(mcu_reset_pin, 1); - // switch pin mux to make these pins GPIO pins - if (mcu_reset_pin >= 0) makeGpio(mcu_reset_pin); - if (mcu_isp_pin >= 0) makeGpio(mcu_isp_pin); + /* set both pins to 1 before turning them on (so we don't cause a reset) + * then switch pin mux to make these pins GPIO pins + */ + if (mcu_isp_pin >= 0) { + GPIO_OUTPUT_SET(mcu_isp_pin, 1); + makeGpio(mcu_isp_pin); + } + + if (mcu_reset_pin >= 0) { + GPIO_OUTPUT_SET(mcu_reset_pin, 1); + makeGpio(mcu_reset_pin); + } + + // set TX_ENABLE to 0 so we start up listening + if (tx_enable_pin >= 0) { + GPIO_OUTPUT_SET(tx_enable_pin, 0); + makeGpio(tx_enable_pin); + } + //uart0_set_tx_enable_pin(tx_enable_pin); // must set to -1 if that's its value } // Start transparent serial bridge TCP server on specified port (typ. 23)