Skip to content
Open
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
14 changes: 14 additions & 0 deletions Constants.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
#ifndef Constants_h
#define Constants_h

// ---------------------------------------------------------------------------
// Serial pin assignments
// ---------------------------------------------------------------------------
// Serial1 carries the lens<->body data line (LENS7).
// RX = PIN_SERIAL1_RX (always reads lens->body direction)
// TX = PIN_SERIAL1_TX_ACTIVE (non-LISTEN_ONLY: sends lens->body)
// TX = PIN_SERIAL1_TX_LISTEN (LISTEN_ONLY: routed to unused pin)
//
// Serial2 carries the body<->lens data line (BODY7).
// RX = PIN_SERIAL2_RX (reads body->lens direction)
const int PIN_SERIAL1_RX = 0;
const int PIN_SERIAL1_TX_ACTIVE = 1;
const int PIN_SERIAL1_TX_LISTEN = 5; // TX routed here when not transmitting
const int PIN_SERIAL2_RX = 9;

const String LENS_TO_BODY = "Lens->Body ";
const String BODY_TO_LENS = "Body->Lens ";
Expand Down
14 changes: 11 additions & 3 deletions E-Mount.ino
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ void finishMessage() {
void setup() {
Serial.begin(115200);

Serial1.setRX(0);
Serial1.setTX(LISTEN_ONLY ? 5 : 1);
Serial1.setRX(PIN_SERIAL1_RX);
Serial1.setTX(LISTEN_ONLY ? PIN_SERIAL1_TX_LISTEN : PIN_SERIAL1_TX_ACTIVE);
Serial1.begin(750000, SERIAL_8N1);

Serial2.setRX(9);
Serial2.setRX(PIN_SERIAL2_RX);
Serial2.begin(750000, SERIAL_8N1);

pinMode(PIN_BODY_VD_LENS, INPUT);
Expand Down Expand Up @@ -137,7 +137,11 @@ void setLowspeedMode(){
if(highspeedMode == false) {
return;
}
// Re-apply pin assignments before begin() to avoid reverting to hardware defaults
Serial1.setRX(PIN_SERIAL1_RX);
Serial1.setTX(LISTEN_ONLY ? PIN_SERIAL1_TX_LISTEN : PIN_SERIAL1_TX_ACTIVE);
Serial1.begin(750000, SERIAL_8N1);
Serial2.setRX(PIN_SERIAL2_RX);
Serial2.begin(750000, SERIAL_8N1);
highspeedMode = false;
}
Expand All @@ -146,7 +150,11 @@ void setHighspeedMode(){
if(highspeedMode) {
return;
}
// Re-apply pin assignments before begin() to avoid reverting to hardware defaults
Serial1.setRX(PIN_SERIAL1_RX);
Serial1.setTX(LISTEN_ONLY ? PIN_SERIAL1_TX_LISTEN : PIN_SERIAL1_TX_ACTIVE);
Serial1.begin(1500000, SERIAL_8N1);
Serial2.setRX(PIN_SERIAL2_RX);
Serial2.begin(1500000, SERIAL_8N1);
highspeedMode = true;
}
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,12 @@ To interface with a camera you can construct a jig using a macro extension tube
![Circuit Diagram](/circuitdiagram.png)

Appologies for the quality of the above diagram (it's easier than modeling the whole Teensy in Eagle)

> **Note on pin assignments (see issue [#1](https://github.com/LexOptical/E-Mount/issues/1)):** The circuit diagram above reflects the **LISTEN_ONLY** wiring, where Teensy PIN0 (Serial1 RX) is connected to the LENS7 data line for passive sniffing.
>
> When operating in **non-LISTEN_ONLY mode** (emulating a lens), the firmware also uses **PIN1 (Serial1 TX)** to send data back to the camera body. In this mode, PIN1 must also be connected to the LENS7 data line. The firmware automatically selects the correct TX pin in `setup()` based on the `LISTEN_ONLY` flag in `Config.h`.
>
> | Mode | PIN0 (Serial1 RX) | PIN1 (Serial1 TX) | PIN9 (Serial2 RX) |
> |------|-------------------|-------------------|-------------------|
> | LISTEN_ONLY | LENS7 (lens->body) | unused (routed to PIN5) | Body->lens line |
> | Emulation | Body->lens line | LENS7 (lens->body) | Body->lens line |