2 #include <avr/interrupt.h>
5 //INPUT PINS digital 2-7 PIND
6 #define PIND_MASK B11111100
7 //INPUT PINS digitat 8-12 PINB
8 #define PINB_MASK B00011111
9 //INPUT PINS analog 0-4 PINC
10 #define PINC_MASK B00011111
12 #define INPUT_SIG_PORTD B11000000
13 #define INPUT_SIG_PORTB B00011111
14 #define INPUT_SIG_PORTC B00010000
27 //********************************************************************//
29 typedef unsigned char byte;
31 //********************************************************************//
36 TCCR1A = 0; // prescaler 1:8, WGM = 4 (CTC)
37 TCCR1B = 1<<WGM12 | 1<<CS11; //
38 OCR1A = 159; // (1+159)*8 = 1280 -> 0.08ms @ 16 MHz -> 1*alpha
39 // OCR1A = 207; // (1+207)*8 = 1664 -> 0.104ms @ 16 MHz -> 1*alpha
40 TCNT1 = 0; // reseting timer
41 TIMSK1 = 1<<OCIE1A; // enable Interrupt
44 void stop_timer() // stop the timer
47 TCCR1B = 0; // no clock source
48 TIMSK1 = 0; // disable timer interrupt
51 static void PCint(uint8_t port) {
59 data.uint8[0]|= !PIND_MASK;
60 data.uint8[1]|= !PINC_MASK;
61 data.uint8[2]|= !PINB_MASK;
73 for(int i=0;i<32; i++)
75 if (! (data.uint32 & 1 ))
79 //Serial.print(data.uint8[1]);
95 // pinMode(RF433_PIN, INPUT); // set pin to input
96 // digitalWrite(RF433_PIN, LOW); // turn of pullup resistors
107 //Serial.println("starting timer");
108 PCMSK0=PINB_MASK & INPUT_SIG_PORTB;
109 PCMSK1=PINC_MASK & INPUT_SIG_PORTC;
110 PCMSK2=PIND_MASK & INPUT_SIG_PORTD;
117 //INPUT PINS digital 2-7 PIND
118 //INPUT PINS digitat 8-12 PINB
119 //INPUT PINS analog 0-4 PINC
122 // Serial.Serial.println("foo");