-*/
-static void PCint(uint8_t port) {
- Serial.println(port);
- return;
- union32 data;
- data.uint32=0;
- data.uint8[0]=PIND;
- data.uint8[1]=PINC;
- data.uint8[2]=PINB;
- data.uint8[0]|= !PIND_MASK;
- data.uint8[1]|= !PINC_MASK;
- data.uint8[2]|= !PINB_MASK;
- data.uint8[3]=0xff;
- //PINS with signal:
- //1
- //3
- //9
- //14
- //15
- //21
- //22
- //23
-
- for(int i=0;i<32; i++)
- {
- if (! (data.uint32 & 1 ))
- Serial.println(i);
- data.uint32>>=1;
- }
- //Serial.print(data.uint8[1]);
+
+ISR(TIMER1_COMPA_vect)
+{
+ stop_timer();
+ PCICR|= B111;
+}
+
+
+byte last_input=0;
+byte last_output=0;
+static void PCint() {
+ byte PINB_COPY = PINB;
+ byte PINC_COPY = PINC;
+ byte PIND_COPY = PIND;
+ byte output = ( OUTPUT_SIG_PORTC & ~ PINC_COPY ) | (( OUTPUT_SIG_PORTD & ~ PIND_COPY ) <<2 ); // no output on B
+ byte input = ( INPUT_SIG_PORTB & ~ PINB_COPY ) | ( ( INPUT_SIG_PORTC & ~ PINC_COPY ) <<1 ) |( INPUT_SIG_PORTD & ~ PIND_COPY );
+
+ if (!input)
+ return;
+ if (!output)
+ return;
+ //if (last_input==input && last_output==output)
+ //return;
+ last_input=input;
+ last_output=output;
+// Serial.print(output,HEX);
+// Serial.print('\t');
+// Serial.print(input,HEX);
+// Serial.print('\t');
+
+ byte value=0;
+ while(input>>=1)
+ value++;
+ value<<=3;
+ while(output>>=1)
+ value++;
+ Serial.println(value,HEX);
+ PCICR&= ~ B111; // Disable Interrupt
+ start_timer();