assign wifi_rxd = ftdi_txd;
assign ftdi_rxd = wifi_txd;
-- TX/RX passthru
ftdi_rxd <= wifi_txd;
wifi_rxd <= ftdi_txd;
-- Programming logic
-- SERIAL -> ESP32
-- DTR RTS -> EN IO0
-- 1 1 1 1
-- 0 0 1 1
-- 1 0 0 1
-- 0 1 1 0
S_prog_in(1) <= ftdi_ndtr;
S_prog_in(0) <= ftdi_nrts;
S_prog_out <= "01" when S_prog_in = "10" else
"10" when S_prog_in = "01" else
"11";
wifi_en <= S_prog_out(1);
wifi_gpio0 <= S_prog_out(0) and btn(0); -- holding BTN0 will hold gpio0 LOW, signal for ESP32 to take control
module ulx3s_passthru (
input wire txd,
output wire rxd,
input wire dtr,
input wire rts,
input wire esp_txd,
output wire esp_rxd,
output wire esp_en,
output wire esp_io0,
);
// TX/RX passthru
assign rxd = esp_txd;
assign esp_rxd = txd;
// Programming logic
// SERIAL -> ESP32
// DTR RTS -> EN IO0
// 1 1 1 1
// 0 0 1 1
// 1 0 0 1
// 0 1 1 0
assign esp_en = ~( dtr & ~rts);
assign esp_io0 = ~(~dtr & rts);
endmodule
@emard this one is improved. It tristates gpio0 instead if setting it high so that it can be used elsewhere if needed. Also added an enable that can be used as a reset for the esp32.
module ulx3s_passthru (
input wire txd,
output wire rxd,
input wire dtr,
input wire rts,
input wire esp_txd,
output wire esp_rxd,
output wire esp_en,
output wire esp_io0,
input wire en,
);
// TX/RX passthru
assign rxd = esp_txd;
assign esp_rxd = txd;
// Programming logic
// SERIAL -> ESP32
// DTR RTS -> EN IO0
// 1 1 1 Z
// 0 0 1 Z
// 1 0 0 Z
// 0 1 1 0
assign esp_en = (~dtr | rts) & en;
assign esp_io0 = ( dtr | ~rts) ? 1'bz : 1'b0; // we only want to drive this pin low
endmodule
can be called like
module top(
input wire clk_25mhz,
output wire ftdi_rxd,
input wire ftdi_txd,
inout wire ftdi_ndtr,
inout wire ftdi_nrts,
output wire wifi_rxd,
input wire wifi_txd,
inout wire wifi_en,
inout wire wifi_gpio0,
output [7:0] led,
input [6:0] btn,
output wire shutdown,
);
ulx3s_passthru passthru(.txd(ftdi_txd),
.rxd(ftdi_rxd),
.dtr(ftdi_ndtr),
.rts(ftdi_nrts),
.esp_txd(wifi_txd),
.esp_rxd(wifi_rxd),
.esp_en(wifi_en),
.esp_io0(wifi_gpio0),
.en(btn[0]), // btn[0] will work as a reset for esp
);
// blinky for something to do so we know its operational
assign led[0] = btn[1];
assign led[6:1] = 0;
assign led[7] = wifi_gpio0;
endmodule
assign led[7] = wifi_gpio0;
PCLK
?