Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions docs/configuration/pins.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Pin Assignments

This table lists all recommended connections for the DDS-Controller hardware. The ESP8266-01 module works at **3.3V** logic levels only. All peripherals except the LCD shield must be connected on Arduino pins **20** and above.
This table lists all recommended connections for the DDS-Controller hardware. The ESP8266-01 module works at **3.3V** logic levels only. All peripherals except the LCD shield are placed on pins **20** and above. Change the values in `firmware/config/pins_config.h` if you use a different layout.

| Arduino Pin | Peripheral | Function |
|-------------|-------------|-------------------|
| 8,9,4,5,6,7 | LCD Shield | RS,E,D4,D5,D6,D7 |
| A0 | LCD Shield | Buttons ADC |
| 10 | AD9850 | WCLK |
| 11 | AD9850 | FQUD |
| 12 | AD9850 | DATA |
| 13 | AD9850 | RESET |
| 20 | ESP8266-01 | RX (from Due TX) |
| 21 | ESP8266-01 | TX (to Due RX) |
| 24 | ESP8266-01 | GPIO2 status LED |
| 25 | DDS Output | Control line |
| 26 | ESP8266-01 | GPIO0 (OTA) |
| 22 | AD9850 | WCLK |
| 23 | AD9850 | FQUD |
| 24 | AD9850 | DATA |
| 25 | AD9850 | RESET |
| 26 | ESP8266-01 | GPIO2 status LED |
| 27 | DDS Output | Control line |
| 28 | ESP8266-01 | GPIO0 (OTA) |

```
D20..D53 -> custom peripherals
Expand Down
2 changes: 1 addition & 1 deletion docs/hardware/esp8266.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ The ESP8266-01 module is integrated as a WiFi bridge for the DDS-Controller. It
- **GPIO0_LED** (GPIO0) controls a WiFi status LED whenever OTA updates are enabled. Otherwise this pin remains un-driven so the Arduino Due can repurpose it.
- UART pins start from Due pin **20** upward to avoid conflicts with the LCD shield.

Use level shifting if any connection might expose the ESP8266-01 to 5V. See the in-code comments in `firmware/esp/main.cpp` for further notes.
Use level shifting if any connection might expose the ESP8266-01 to 5V. Pin numbers can be remapped in `firmware/config/pins_config.h`. See the in-code comments in `firmware/esp/main.cpp` for further notes.
20 changes: 10 additions & 10 deletions docs/hardware/pinmap.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Hardware Pin Mapping – DDS-Controller

> _This document acts as the single source of truth for wiring. See `firmware/shared/config/pins.h` for the authoritative definitions._
> _This document acts as the single source of truth for wiring. Pin numbers are configured in `firmware/config/pins_config.h` and re-exported via `firmware/shared/config/pins.h`._

| Arduino Due Pin | Peripheral | Peripheral Pin | Notes |
|-----------------|-------------------|----------------|------------------------------------|
| 8, 9, 4, 5, 6, 7| LCD Keypad Shield | RS,E,D4,D5,D6,D7 | Uses standard Arduino shield layout |
| A0 | LCD Keypad Shield | Buttons ADC | Reads multiple buttons via resistor ladder |
| 10 | AD9850 DDS | WCLK | Serial clock to DDS module |
| 11 | AD9850 DDS | FQUD | Frequency update |
| 12 | AD9850 DDS | DATA | Serial data |
| 13 | AD9850 DDS | RESET | Module reset |
| 24 | ESP8266-01 | GPIO2 | WiFi status LED |
| 26 | ESP8266-01 | GPIO0 | OTA LED or Arduino control |
| 20 | ESP8266-01 | RX | Connected to Due TX (SoftwareSerial) |
| 21 | ESP8266-01 | TX | Connected to Due RX (SoftwareSerial) |
| 25 | DDS Output Enable | Control line | Toggles DDS output |
| 20 | ESP8266-01 | RX | SoftwareSerial RX from Due |
| 21 | ESP8266-01 | TX | SoftwareSerial TX to Due |
| 22 | AD9850 DDS | WCLK | Serial clock to DDS module |
| 23 | AD9850 DDS | FQUD | Frequency update |
| 24 | AD9850 DDS | DATA | Serial data |
| 25 | AD9850 DDS | RESET | Module reset |
| 26 | ESP8266-01 | GPIO2 | WiFi status LED |
| 27 | DDS Output Enable | Control line | Toggles DDS output |
| 28 | ESP8266-01 | GPIO0 | OTA trigger (keep high unless flashing) |

**Safety Notice:** The ESP8266-01 module operates at **3.3V** logic levels only. Connecting it directly to 5V will permanently damage the module.

Expand Down
27 changes: 27 additions & 0 deletions firmware/config/pins_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef FIRMWARE_PINS_CONFIG_H
#define FIRMWARE_PINS_CONFIG_H

// Default pin mapping for DDS-Controller.
// Modify these values to match your wiring.
// All custom peripherals start from pin 20 and above.

// ESP8266-01 SoftwareSerial
#define PIN_ESP_RX 20
#define PIN_ESP_TX 21

// DDS module (AD9850)
#define PIN_DDS_WCLK 22
#define PIN_DDS_FQUD 23
#define PIN_DDS_DATA 24
#define PIN_DDS_RESET 25

// Status LED on ESP GPIO2
#define PIN_ESP_LED 26

// Output enable control for DDS
#define PIN_OUTPUT_CONTROL 27

// ESP8266 GPIO0 (reserved for OTA)
#define PIN_ESP_GPIO0 28

#endif // FIRMWARE_PINS_CONFIG_H
12 changes: 12 additions & 0 deletions firmware/due/main.ino
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ void setup() {
esp_begin(espSerial, parser);
pinMode(PIN_ESP_LED, OUTPUT);
#if !USE_ESP_OTA
// Keep ESP8266 in normal boot mode when OTA is disabled
pinMode(PIN_ESP_GPIO0, OUTPUT);
digitalWrite(PIN_ESP_GPIO0, HIGH);
#endif
Expand All @@ -49,6 +50,17 @@ void setup() {

void loop() {
menu.update();
#ifdef USE_ESP
static unsigned long lastLedToggle = 0;
if (millis() - lastLedToggle > 1000) {
digitalWrite(PIN_ESP_LED, !digitalRead(PIN_ESP_LED));
lastLedToggle = millis();
}
#if !USE_ESP_OTA
// Ensure the ESP remains in run mode when OTA is disabled
digitalWrite(PIN_ESP_GPIO0, HIGH);
#endif
#endif

if (Serial.available()) {
String cmd = Serial.readStringUntil('\n');
Expand Down
3 changes: 0 additions & 3 deletions firmware/shared/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,4 @@

#define ESP_BAUD_RATE 9600

// Optional pin for controlling ESP8266 GPIO0 when OTA is disabled
#define PIN_ESP_GPIO0 26

#endif // CONFIG_H
65 changes: 52 additions & 13 deletions firmware/shared/config/pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,60 @@
#define CONFIG_PINS_H

// Centralized pin definitions for DDS-Controller hardware
// Adjust these values to match the wiring as documented in docs/hardware/pinmap.md
// All numeric values are provided by firmware/config/pins_config.h

// DDS (AD9850)
#define PIN_DDS_WCLK 10
#define PIN_DDS_FQUD 11
#define PIN_DDS_DATA 12
#define PIN_DDS_RESET 13
#include "../../config/pins_config.h"

// ESP8266-01 communication via SoftwareSerial
#define PIN_ESP_RX 20 // Due TX to ESP8266 RX
#define PIN_ESP_TX 21 // Due RX to ESP8266 TX
#define PIN_ESP_LED 24 // GPIO2 on ESP8266

// Control output
#define PIN_OUTPUT_CONTROL 25
// Re-export for firmware modules
#define OUTPUT_CONTROL_PIN PIN_OUTPUT_CONTROL

// Validate that no two pins share the same number
#define VALIDATE_PIN_UNIQUE(a,b) static_assert((a) != (b), "Pin conflict: " #a " and " #b)

VALIDATE_PIN_UNIQUE(PIN_ESP_RX, PIN_ESP_TX);
VALIDATE_PIN_UNIQUE(PIN_ESP_RX, PIN_DDS_WCLK);
VALIDATE_PIN_UNIQUE(PIN_ESP_RX, PIN_DDS_FQUD);
VALIDATE_PIN_UNIQUE(PIN_ESP_RX, PIN_DDS_DATA);
VALIDATE_PIN_UNIQUE(PIN_ESP_RX, PIN_DDS_RESET);
VALIDATE_PIN_UNIQUE(PIN_ESP_RX, PIN_ESP_LED);
VALIDATE_PIN_UNIQUE(PIN_ESP_RX, PIN_OUTPUT_CONTROL);
VALIDATE_PIN_UNIQUE(PIN_ESP_RX, PIN_ESP_GPIO0);

VALIDATE_PIN_UNIQUE(PIN_ESP_TX, PIN_DDS_WCLK);
VALIDATE_PIN_UNIQUE(PIN_ESP_TX, PIN_DDS_FQUD);
VALIDATE_PIN_UNIQUE(PIN_ESP_TX, PIN_DDS_DATA);
VALIDATE_PIN_UNIQUE(PIN_ESP_TX, PIN_DDS_RESET);
VALIDATE_PIN_UNIQUE(PIN_ESP_TX, PIN_ESP_LED);
VALIDATE_PIN_UNIQUE(PIN_ESP_TX, PIN_OUTPUT_CONTROL);
VALIDATE_PIN_UNIQUE(PIN_ESP_TX, PIN_ESP_GPIO0);

VALIDATE_PIN_UNIQUE(PIN_DDS_WCLK, PIN_DDS_FQUD);
VALIDATE_PIN_UNIQUE(PIN_DDS_WCLK, PIN_DDS_DATA);
VALIDATE_PIN_UNIQUE(PIN_DDS_WCLK, PIN_DDS_RESET);
VALIDATE_PIN_UNIQUE(PIN_DDS_WCLK, PIN_ESP_LED);
VALIDATE_PIN_UNIQUE(PIN_DDS_WCLK, PIN_OUTPUT_CONTROL);
VALIDATE_PIN_UNIQUE(PIN_DDS_WCLK, PIN_ESP_GPIO0);

VALIDATE_PIN_UNIQUE(PIN_DDS_FQUD, PIN_DDS_DATA);
VALIDATE_PIN_UNIQUE(PIN_DDS_FQUD, PIN_DDS_RESET);
VALIDATE_PIN_UNIQUE(PIN_DDS_FQUD, PIN_ESP_LED);
VALIDATE_PIN_UNIQUE(PIN_DDS_FQUD, PIN_OUTPUT_CONTROL);
VALIDATE_PIN_UNIQUE(PIN_DDS_FQUD, PIN_ESP_GPIO0);

VALIDATE_PIN_UNIQUE(PIN_DDS_DATA, PIN_DDS_RESET);
VALIDATE_PIN_UNIQUE(PIN_DDS_DATA, PIN_ESP_LED);
VALIDATE_PIN_UNIQUE(PIN_DDS_DATA, PIN_OUTPUT_CONTROL);
VALIDATE_PIN_UNIQUE(PIN_DDS_DATA, PIN_ESP_GPIO0);

VALIDATE_PIN_UNIQUE(PIN_DDS_RESET, PIN_ESP_LED);
VALIDATE_PIN_UNIQUE(PIN_DDS_RESET, PIN_OUTPUT_CONTROL);
VALIDATE_PIN_UNIQUE(PIN_DDS_RESET, PIN_ESP_GPIO0);

VALIDATE_PIN_UNIQUE(PIN_ESP_LED, PIN_OUTPUT_CONTROL);
VALIDATE_PIN_UNIQUE(PIN_ESP_LED, PIN_ESP_GPIO0);

VALIDATE_PIN_UNIQUE(PIN_OUTPUT_CONTROL, PIN_ESP_GPIO0);

#undef VALIDATE_PIN_UNIQUE

#endif // CONFIG_PINS_H
Loading