forked from tanchou/Verilog
Update FPGA constraints and reintroduce WiFi functionality with touch sensor reset handling
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
IO_LOC "o_tx" 69;
|
IO_LOC "o_tx" 73;
|
||||||
IO_PORT "o_tx" IO_TYPE=LVCMOS33 PULL_MODE=UP BANK_VCCIO=3.3;
|
IO_PORT "o_tx" IO_TYPE=LVCMOS33 PULL_MODE=UP BANK_VCCIO=3.3;
|
||||||
|
|
||||||
IO_LOC "i_rx" 70;
|
IO_LOC "i_rx" 74;
|
||||||
IO_PORT "i_rx" IO_TYPE=LVCMOS33 PULL_MODE=UP BANK_VCCIO=3.3;
|
IO_PORT "i_rx" IO_TYPE=LVCMOS33 PULL_MODE=UP BANK_VCCIO=3.3;
|
||||||
|
|
||||||
IO_LOC "i_clk" 4;
|
IO_LOC "i_clk" 4;
|
||||||
|
@@ -16,23 +16,37 @@ const int touchThreshold = 30; // Adjust based on testing (lower value = touch d
|
|||||||
const unsigned long resetHoldTime = 5000; // 5 seconds to trigger reset
|
const unsigned long resetHoldTime = 5000; // 5 seconds to trigger reset
|
||||||
unsigned long touchStartTime = 0;
|
unsigned long touchStartTime = 0;
|
||||||
bool touchDetected = false;
|
bool touchDetected = false;
|
||||||
|
|
||||||
|
// UART pins for FPGA communication
|
||||||
|
const int UART_RX_PIN = 16; // GPIO16 - RX from FPGA
|
||||||
|
const int UART_TX_PIN = 17; // GPIO17 - TX to FPGA
|
||||||
|
const int UART_BAUD = 115200;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// Initialize Serial for UART communication (115200 baud)
|
// Initialize Serial for USB debugging (115200 baud)
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
||||||
|
// Initialize Serial2 for FPGA communication
|
||||||
|
Serial2.begin(UART_BAUD, SERIAL_8N1, UART_RX_PIN, UART_TX_PIN);
|
||||||
|
|
||||||
|
Serial.println("ESP32 starting...");
|
||||||
|
|
||||||
// Initialize WiFiManager
|
// Initialize WiFiManager
|
||||||
WiFiManager wifiManager;
|
WiFiManager wifiManager;
|
||||||
|
|
||||||
// Check for touch sensor reset
|
// Check for touch sensor reset
|
||||||
if (checkTouchReset()) {
|
if (checkTouchReset()) {
|
||||||
wifiManager.resetSettings();
|
wifiManager.resetSettings();
|
||||||
Serial.println("WiFi settings reset due to touch sensor");
|
Serial.println("WiFi settings reset due to touch sensor");
|
||||||
ESP.restart(); // Restart to apply reset
|
ESP.restart(); // Restart to apply reset
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connect to WiFi using WiFiManager (creates AP if no saved credentials)
|
// Connect to WiFi using WiFiManager (creates AP if no saved credentials)
|
||||||
if (!wifiManager.autoConnect("ESP32_AP")) {
|
if (!wifiManager.autoConnect("ESP32_AP")) {
|
||||||
Serial.println("Failed to connect to WiFi and hit timeout");
|
Serial.println("Failed to connect to WiFi and hit timeout");
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.println("WiFi connected");
|
Serial.println("WiFi connected");
|
||||||
Serial.print("IP address: ");
|
Serial.print("IP address: ");
|
||||||
Serial.println(WiFi.localIP());
|
Serial.println(WiFi.localIP());
|
||||||
@@ -54,16 +68,24 @@ void loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Relay data from TCP client to UART
|
// Relay data from TCP client to FPGA UART
|
||||||
while (client.connected() && client.available()) {
|
while (client.connected() && client.available()) {
|
||||||
char c = client.read();
|
uint8_t data = client.read();
|
||||||
Serial.write(c); // Send to UART
|
Serial2.write(data); // Send to FPGA via Serial2
|
||||||
|
|
||||||
|
// Debug: show what we're sending to FPGA
|
||||||
|
Serial.print("Sent to FPGA: 0x");
|
||||||
|
Serial.println(data, HEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Relay data from UART to TCP client
|
// Relay data from FPGA UART to TCP client
|
||||||
while (Serial.available() && client.connected()) {
|
while (Serial2.available() && client.connected()) {
|
||||||
char c = Serial.read();
|
uint8_t data = Serial2.read();
|
||||||
client.write(c); // Send to TCP client
|
client.write(data); // Send to TCP client
|
||||||
|
|
||||||
|
// Debug: show what we received from FPGA
|
||||||
|
Serial.print("Received from FPGA: 0x");
|
||||||
|
Serial.println(data, HEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle client disconnection
|
// Handle client disconnection
|
Reference in New Issue
Block a user