X-Git-Url: https://git.realraum.at/?a=blobdiff_plain;f=dart%2Fdart.pde;h=7fbefaf9c5b28f133a80ffabe1cc1091988e68ae;hb=d9a06db53e7eb1511cf3f9f0703987ac28e11781;hp=35b339cb775a176563b60426823484581119bafd;hpb=2d0ed8b1d34616652604d3f546c4ff9dc038ae5c;p=svn42.git diff --git a/dart/dart.pde b/dart/dart.pde index 35b339c..7fbefaf 100644 --- a/dart/dart.pde +++ b/dart/dart.pde @@ -3,16 +3,40 @@ #include //INPUT PINS digital 2-7 PIND +#define PIND_MASK B11111100 //INPUT PINS digitat 8-12 PINB +#define PINB_MASK B00011111 //INPUT PINS analog 0-4 PINC +#define PINC_MASK B00011111 + +#define INPUT_SIG_PORTD B11000000 +#define INPUT_SIG_PORTB B00011111 +#define INPUT_SIG_PORTC B00010000 + +#define OUTPUT_SIG_PORTB ( PINB_MASK & ~INPUT_SIG_PORTB ) +// B00011111 & ! B00011111 = 0 +#define OUTPUT_SIG_PORTC ( PINC_MASK & ~INPUT_SIG_PORTC ) +// B00011111 & ! B00010000 = B00001111 +#define OUTPUT_SIG_PORTD ( PIND_MASK & ~INPUT_SIG_PORTD ) +// B11111100 & ! B11000000 = 00111100 +union union16 { + byte uint8[2]; + uint16_t uint16; +}; + +union union32 { + byte uint8[4]; + uint16_t uint16[2]; + uint32_t uint32; +}; + -#define RF433_PIN 10 //********************************************************************// typedef unsigned char byte; //********************************************************************// - +/* void start_timer() { // timer 1: 2 ms @@ -30,13 +54,36 @@ void stop_timer() // stop the timer TCCR1B = 0; // no clock source TIMSK1 = 0; // disable timer interrupt } - -ISR(TIMER1_COMPA_vect) -{ -// Serial.print('a'); +*/ +byte last_input=0; +byte last_output=0; +static void PCint(uint8_t port) { + byte input = ( INPUT_SIG_PORTB & ~ PINB ) | ( ( INPUT_SIG_PORTC & ~ PINC ) <<1 ) |( INPUT_SIG_PORTD & ~ PIND ); + byte output = ( OUTPUT_SIG_PORTC & ~ PINC ) | (( OUTPUT_SIG_PORTD & ~ PIND ) <<2 ); // no output on B + + if (!input) + return; + if (last_input==input && last_output==output) + return; + last_input=input; + last_output=output; + Serial.print(output,HEX); + Serial.print('\t'); + Serial.println(input,HEX); + return; } + +SIGNAL(PCINT0_vect) { + PCint(0); +} +SIGNAL(PCINT1_vect) { + PCint(1); +} +SIGNAL(PCINT2_vect) { + PCint(2); +} void setup() { // pinMode(RF433_PIN, INPUT); // set pin to input @@ -47,32 +94,27 @@ void setup() PORTB=0; DDRD = DDRD & 3; PORTD= PORTD & 3; + DDRC=0; PORTC=0; Serial.begin(57600); - Serial.println("starting timer"); + //Serial.println("starting timer"); + PCMSK0=PINB_MASK & INPUT_SIG_PORTB; + PCMSK1=PINC_MASK & INPUT_SIG_PORTC; + PCMSK2=PIND_MASK & INPUT_SIG_PORTD; + PCICR|= B111; + // start_timer(); } -union union16 { - byte uint8[2]; - uint16_t uint16; -}; //INPUT PINS digital 2-7 PIND //INPUT PINS digitat 8-12 PINB //INPUT PINS analog 0-4 PINC void loop() { -// Serial.println("foo"); +// Serial.Serial.println("foo"); // return; - union16 data; - data.uint8[0]=PIND; - data.uint16<<=3; - data.uint8[0]|= (PINC & B11111); - data.uint16<<=5; - data.uint8[0]|= (PINB & B11111); - Serial.print(data.uint8[0]); - Serial.print(data.uint8[1]); + }