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 B11111111
13 #define INPUT_SIG_PORTC B11111111
14 #define INPUT_SIG_PORTB B11111111
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) {
57 data.uint8[0]|= !PIND_MASK;
58 data.uint8[1]|= !PINC_MASK;
59 data.uint8[2]|= !PINB_MASK;
71 for(int i=0;i<32; i++)
73 if (! (data.uint32 & 1 ))
77 //Serial.print(data.uint8[1]);
93 // pinMode(RF433_PIN, INPUT); // set pin to input
94 // digitalWrite(RF433_PIN, LOW); // turn of pullup resistors
105 //Serial.println("starting timer");
106 PCMSK0=PINB_MASK & INPUT_SIG_PORTB;
107 PCMSK1=PINC_MASK & INPUT_SIG_PORTC;
108 PCMSK2=PIND_MASK & INPUT_SIG_PORTD;
115 //INPUT PINS digital 2-7 PIND
116 //INPUT PINS digitat 8-12 PINB
117 //INPUT PINS analog 0-4 PINC
120 // Serial.Serial.println("foo");