/* Analyseur iTTL_V0 *********************** created 2020 by Herve QUEVAL V0 - Decode I-TTL propocol and generate TPx signal to sync Logic analyser to be run on Teensy 2.0 board with no addon cards. Input 0 Sync // pas utilisé dans le décodeur 3 Handshake 1 Data 2 Clock Output: Serial : Trace les commandes reçues D7 TP1 D8 TP2 */ //*********************** Debugging *************************************************************** // ************ constants Used here to set pin numbers ******************************************** // DSLR interface const int DSLR_DATA = 1; // in const int DSLR_Hshake = 3; // in const int DSLR_CLK = 2; // in // test - Debugging interface - activ low const int TP1 = 7; // out Preflash const int TP2 = 8; // out Power cde //Constantes ---------------- // variable globales ************************************************ // byte d; byte c; byte n; int T1; int T2; void setup() { // ******************************************************** initialisation ************************************** // setup DSLR BUS Interface pin pinMode(DSLR_DATA, INPUT_PULLUP); pinMode(DSLR_CLK, INPUT_PULLUP); pinMode(DSLR_Hshake,INPUT_PULLUP); // init and set Test pin pinMode(TP1, OUTPUT); digitalWrite(TP1, HIGH); pinMode(TP2, OUTPUT); digitalWrite(TP2, HIGH); pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, HIGH); // turn the LED on during INIT delay(2000); // wait for ??? serial USB initialized ....... Serial.println("Analyser ITTL NIKON Protocol started...."); delay(100); digitalWrite(LED_BUILTIN, LOW); // init led params T1=1600; T2=10; } //***************************************************************************************************** end Init ***** byte DSLR_ReadCopy() { // for analyses purpose; copy DATA synchronizing on Hanshake and CLK byte val = 0; while (digitalRead(DSLR_Hshake) == HIGH) { } // wait Hanshake active (low) for (byte offset = 0; offset < 8; offset++) { // loop to read the 8 bits val = val >> 1 ; while (digitalRead(DSLR_CLK) == HIGH) { } // wait clock low while (digitalRead(DSLR_CLK) == LOW ) { } // wait rising edge if (digitalRead(DSLR_DATA) == HIGH ) { val |= 0x80; } } while (digitalRead(DSLR_Hshake) == LOW) { } // wait Hanshake high return val; } void TestInput() { while (1==1) { Serial.print("2 HANDSHAKE ");Serial.print(digitalRead(DSLR_Hshake)); Serial.print(" ; 3 DATA ");Serial.print(digitalRead(DSLR_DATA)); Serial.print(" ; 4 CLK ");Serial.println(digitalRead(DSLR_CLK)); delay(200); digitalWrite(LED_BUILTIN, HIGH); delay(100); digitalWrite(LED_BUILTIN, LOW); } } void loop() { // ********************************************************************************************** Serial.println("Copy DSLR command"); while (1==1) { if (digitalRead(DSLR_Hshake) == HIGH && digitalRead(DSLR_CLK) == HIGH) { Serial.println(); break; } // Serial.print("Hshake "); Serial.print(digitalRead(DSLR_Hshake)); // Serial.print(" CLK "); Serial.println(digitalRead(DSLR_CLK)); Serial.print("."); delay(100); // attend boitier et flash actifs } while (1==1) { // trace les échanges B0 - A0 pour identifier les modifications et zone utilisés pour les différents info ISO, Mode flash, etc.. d = DSLR_ReadCopy(); Serial.print("Cde:");Serial.print(d,HEX); c=d; switch (d) { // set byte qty following command case 0xA1: n=18; break; case 0xB1: n=10; break; case 0xA2: n=46; break; case 0xB0: n=15; break; case 0xC0: n=5; break; case 0xA0: n=22; break; case 0xD0: // AF assist 01 (F0) on 00 (00) off n=2; break; case 0xD1: // pulse anti-youx rouge 1 pulse 1/64 toutes les 0,25ms jusqu,à cde stop. n=1; break; case 0xD7: n=0; digitalWrite(TP1,LOW); break; case 0xD8: n=1; break; case 0xD3: n=3; digitalWrite(TP2,LOW); break; case 0xD5: n=0; break; case 0xE0: // standby n=2; break; default: n=0; break; } while (n !=0) { // loop to read the byte of the cde. n--; d = DSLR_ReadCopy(); if (d==0xD7) { // si trame watch dog interrompue par commande 0xDn Serial.println(); Serial.print(d,HEX);Serial.println("!"); c=d; break; } Serial.write(0x2c);Serial.print(d,HEX); // Serial.print(",");Serial.print(d,HEX); // // uncomment to print D3 cde content // if (c==0xD3){ // trace uniquement 0xD3 // Serial.print(d,HEX);Serial.print(","); // if (n==0) { Serial.println(); } // } // Serial.print(d,HEX);Serial.print(","); // trace tout. } if ( c==0xD7 || c==0xD8 ) { while (digitalRead(DSLR_CLK) == HIGH) { } while (digitalRead(DSLR_CLK) == LOW) { } // attend 1ere pulse clock ( pre flash) } digitalWrite(TP1,HIGH); digitalWrite(TP2,HIGH); Serial.println(); // if (digitalRead(DSLR_Hshake) == LOW && digitalRead(DSLR_CLK) == LOW) { // if (digitalRead(DSLR_CLK) == LOW) { // boitier off // break; // } } }