diff --git a/esp-link/cgipins.c b/esp-link/cgipins.c index b763d12..c2f0f58 100644 --- a/esp-link/cgipins.c +++ b/esp-link/cgipins.c @@ -32,9 +32,9 @@ 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, \"pinvert\":%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.pin_invert); jsonHeader(connData, 200); httpdSend(connData, buff, len); @@ -49,13 +49,14 @@ int ICACHE_FLASH_ATTR cgiPinsSet(HttpdConnData *connData) { int8_t ok = 0; int8_t reset, isp, conn, ser; - uint8_t swap, rxpup; + uint8_t swap, rxpup, pinvert; ok |= getInt8Arg(connData, "reset", &reset); ok |= getInt8Arg(connData, "isp", &isp); ok |= getInt8Arg(connData, "conn", &conn); ok |= getInt8Arg(connData, "ser", &ser); ok |= getBoolArg(connData, "swap", &swap); ok |= getBoolArg(connData, "rxpup", &rxpup); + ok |= getUInt8Arg(connData, "pinvert", &pinvert); if (ok < 0) return HTTPD_CGI_DONE; char *coll; @@ -90,8 +91,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.pin_invert = pinvert; + os_printf("Pins changed: reset=%d isp=%d conn=%d ser=%d swap=%d rx-pup=%d pinvert=%X\n", + reset, isp, conn, ser, swap, rxpup, pinvert); // apply the changes serbridgeInitPins(); diff --git a/esp-link/config.h b/esp-link/config.h index c6a4058..45f3b4b 100644 --- a/esp-link/config.h +++ b/esp-link/config.h @@ -43,6 +43,7 @@ typedef struct { int8_t stop_bits; char mqtt_password[70]; // MQTT password, was 32-char mqtt_old_password char mqtt_username[70]; // MQTT username, was 32-char mqtt_old_username + uint8_t pin_invert; // invert serial pins } FlashConfig; extern FlashConfig flashConfig; diff --git a/esp-link/main.c b/esp-link/main.c index 31bcf6e..f32415d 100644 --- a/esp-link/main.c +++ b/esp-link/main.c @@ -173,7 +173,7 @@ user_init(void) { gpio_init(); gpio_output_set(0, 0, 0, (1<<15)); // some people tie it to GND, gotta ensure it's disabled // init UART - uart_init(CALC_UARTMODE(flashConfig.data_bits, flashConfig.parity, flashConfig.stop_bits), + uart_init(CALC_UARTMODE(flashConfig.data_bits, flashConfig.parity, flashConfig.stop_bits, flashConfig.pin_invert), flashConfig.baud_rate, 115200); logInit(); // must come after init of uart // Say hello (leave some time to cause break in TX after boot loader's msg diff --git a/html/home.html b/html/home.html index de9862f..8f7db36 100644 --- a/html/home.html +++ b/html/home.html @@ -96,6 +96,49 @@ TX on gpio1/TX0 and RX on gpio3/RX0, swapped is TX on gpio15 and RX on gpio13. +