1
0
forked from tanchou/Verilog

Update FPGA constraints and reintroduce WiFi functionality with touch sensor reset handling

This commit is contained in:
Gamenight77
2025-05-27 18:45:09 +02:00
parent 168431849b
commit 47de4a955b
2 changed files with 32 additions and 10 deletions

View File

@@ -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_LOC "i_rx" 70;
IO_LOC "i_rx" 74;
IO_PORT "i_rx" IO_TYPE=LVCMOS33 PULL_MODE=UP BANK_VCCIO=3.3;
IO_LOC "i_clk" 4;

View File

@@ -17,22 +17,36 @@ const unsigned long resetHoldTime = 5000; // 5 seconds to trigger reset
unsigned long touchStartTime = 0;
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() {
// Initialize Serial for UART communication (115200 baud)
// Initialize Serial for USB debugging (115200 baud)
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
WiFiManager wifiManager;
// Check for touch sensor reset
if (checkTouchReset()) {
wifiManager.resetSettings();
Serial.println("WiFi settings reset due to touch sensor");
ESP.restart(); // Restart to apply reset
}
// Connect to WiFi using WiFiManager (creates AP if no saved credentials)
if (!wifiManager.autoConnect("ESP32_AP")) {
Serial.println("Failed to connect to WiFi and hit timeout");
ESP.restart();
}
Serial.println("WiFi connected");
Serial.print("IP address: ");
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()) {
char c = client.read();
Serial.write(c); // Send to UART
uint8_t data = client.read();
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
while (Serial.available() && client.connected()) {
char c = Serial.read();
client.write(c); // Send to TCP client
// Relay data from FPGA UART to TCP client
while (Serial2.available() && client.connected()) {
uint8_t data = Serial2.read();
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