added TX-en UI back in

fix-master
Thorsten von Eicken 7 years ago
parent d7823b0947
commit 7d0ac42e62
No known key found for this signature in database
GPG Key ID: C7F972A59D834B46
  1. 17
      esp-link/cgipins.c
  2. 8
      esp-link/config.c
  3. 1
      esp-link/config.h
  4. 5
      esp-link/main.c
  5. 6
      html/home.html
  6. 16
      html/ui.js
  7. 32
      serial/serbridge.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<<ser)) { coll = "Serial LED"; goto collision; }
pins |= 1 << ser;
}
if (tx_enable >= 0) {
if (pins & (1<<tx_enable)) { coll = "TX Enable"; goto collision; }
pins |= 1 << tx_enable;
}
if (swap) {
if (pins & (1<<15)) { coll = "Uart TX"; goto collision; }
if (pins & (1<<13)) { coll = "Uart RX"; goto collision; }
@ -90,8 +96,9 @@ int ICACHE_FLASH_ATTR cgiPinsSet(HttpdConnData *connData) {
flashConfig.ser_led_pin = ser;
flashConfig.swap_uart = swap;
flashConfig.rx_pullup = rxpup;
os_printf("Pins changed: reset=%d isp=%d conn=%d ser=%d swap=%d rx-pup=%d\n",
reset, isp, conn, ser, swap, rxpup);
flashConfig.tx_enable_pin = tx_enable;
os_printf("Pins changed: reset=%d isp=%d conn=%d ser=%d swap=%d rx-pup=%d tx_enable=%d\n",
reset, isp, conn, ser, swap, rxpup, tx_enable);
// apply the changes
serbridgeInitPins();

@ -34,6 +34,7 @@ FlashConfig flashDefault = {
.data_bits = EIGHT_BITS,
.parity = NONE_BITS,
.stop_bits = ONE_STOP_BIT,
.tx_enable_pin = -1,
};
typedef union {
@ -160,6 +161,13 @@ bool ICACHE_FLASH_ATTR configRestore(void) {
flashConfig.parity = flashDefault.parity;
flashConfig.stop_bits = flashDefault.stop_bits;
}
if (flashConfig.tx_enable_pin == 0 &&
(flashConfig.conn_led_pin == 0 || flashConfig.reset_pin == 0 ||
flashConfig.isp_pin == 0 || flashConfig.ser_led_pin == 0)) {
// just added tx_enable_pin and it got the default 0, which is not good, need to default to
// disabled.
flashConfig.tx_enable_pin = -1;
}
return true;
}

@ -41,6 +41,7 @@ typedef struct {
int8_t data_bits;
int8_t parity;
int8_t stop_bits;
int8_t tx_enable_pin;
} FlashConfig;
extern FlashConfig flashConfig;

@ -163,10 +163,11 @@ void ICACHE_FLASH_ATTR
user_init(void) {
system_timer_reinit();
// uncomment the following three lines to see flash config messages for troubleshooting
// uncomment the following three lines to see flash config messages for troubleshooting
//uart_init(115200, 115200);
//logInit();
//os_delay_us(100000L);
//os_delay_us(60000L);
// get the flash config so we know how to init things
//configWipe(); // uncomment to reset the config for testing purposes
bool restoreOk = configRestore();

@ -76,6 +76,12 @@
<div class="popup">Second signal to program &#xb5;C.
AVR:not used, esp8266:gpio2, ARM:ISP</div>
</div>
<div class="pure-control-group">
<label for="pin-txen">TX Enable</label>
<select id="pin-txen"></select>
<div class="popup">A pin that should be asserted high while transmitting
(eg. to put RS/485 trancievers into TX mode)</div>
</div>
<div class="pure-control-group">
<label for="pin-conn">Conn LED</label>
<select id="pin-conn"></select>

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

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

Loading…
Cancel
Save