Subversion Repositories HomeAutomation

Rev

Rev 1137 | Rev 1202 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1137 Rev 1138
Line 48... Line 48...
48
    /* Check which pin that have had a change and call the callback.*/
48
    /* Check which pin that have had a change and call the callback.*/
49
    //printf("I\n");
49
    //printf("I\n");
50
    for (p = 0; p < PCINT_NUM_PCINTS; p++)
50
    for (p = 0; p < PCINT_NUM_PCINTS; p++)
51
    {
51
    {
52
        if (pcints[p].pcintBit < 8) {
52
        if (pcints[p].pcintBit < 8) {
53
            if (pcints[p].lastStatus != ((rPinB & (1 << pcints[p].pcintBit)) != 0)) {
53
            if (pcints[p].lastStatus != (rPinB & (1 << pcints[p].pcintBit))) {
54
                pcints[p].lastStatus = ((rPinB & (1 << pcints[p].pcintBit)) != 0);
54
                pcints[p].lastStatus = (rPinB & (1 << pcints[p].pcintBit));
55
                pcints[p].callback(p, pcints[p].lastStatus);
55
                pcints[p].callback(p, pcints[p].lastStatus);
56
            }
56
            }
57
        } else if (pcints[p].pcintBit < 16) {
57
        } else if (pcints[p].pcintBit < 16) {
58
            if (pcints[p].lastStatus != ((rPinC & (1 << pcints[p].pcintBit%8)) != 0)) {
58
            if (pcints[p].lastStatus != (rPinC & (1 << pcints[p].pcintBit%8))) {
59
                pcints[p].lastStatus = ((rPinC & (1 << pcints[p].pcintBit%8)) != 0);
59
                pcints[p].lastStatus = (rPinC & (1 << pcints[p].pcintBit%8));
60
                pcints[p].callback(p, pcints[p].lastStatus);
60
                pcints[p].callback(p, pcints[p].lastStatus);
61
            }
61
            }
62
        } else if (pcints[p].pcintBit < 24) {
62
        } else if (pcints[p].pcintBit < 24) {
63
            if (pcints[p].lastStatus != ((rPinD & (1 << pcints[p].pcintBit%8)) != 0)) {
63
            if (pcints[p].lastStatus != (rPinD & (1 << pcints[p].pcintBit%8))) {
64
                pcints[p].lastStatus = ((rPinD & (1 << pcints[p].pcintBit%8)) != 0);
64
                pcints[p].lastStatus = (rPinD & (1 << pcints[p].pcintBit%8));
65
                pcints[p].callback(p, pcints[p].lastStatus);
65
                pcints[p].callback(p, pcints[p].lastStatus);
66
            }
66
            }
67
        }
67
        }
68
    }
68
    }
69
   
69
   
Line 114... Line 114...
114
#endif
114
#endif
115
        pcints[pcint_id].pcintBit = pcintBit;
115
        pcints[pcint_id].pcintBit = pcintBit;
116
        pcints[pcint_id].lastStatus = 0;
116
        pcints[pcint_id].lastStatus = 0;
117
        if (callback != 0) {
117
        if (callback != 0) {
118
            if (pcints[pcint_id].pcintBit < 8) {
118
            if (pcints[pcint_id].pcintBit < 8) {
119
                pcints[pcint_id].lastStatus = ((PINB & (1 << pcints[pcint_id].pcintBit%8)) != 0);
119
                pcints[pcint_id].lastStatus = (PINB & (1 << pcints[pcint_id].pcintBit%8));
120
                PCMSK0 |= (1<<pcints[pcint_id].pcintBit%8);
120
                PCMSK0 |= (1<<pcints[pcint_id].pcintBit%8);
121
//printf("PCMSK %u\n", PCMSK0);
121
//printf("PCMSK %u\n", PCMSK0);
122
            } else if (pcints[pcint_id].pcintBit < 16) {
122
            } else if (pcints[pcint_id].pcintBit < 16) {
123
                pcints[pcint_id].lastStatus = ((PINC & (1 << pcints[pcint_id].pcintBit%8)) != 0);
123
                pcints[pcint_id].lastStatus = (PINC & (1 << pcints[pcint_id].pcintBit%8));
124
                PCMSK1 |= (1<<pcints[pcint_id].pcintBit%8);
124
                PCMSK1 |= (1<<pcints[pcint_id].pcintBit%8);
125
//printf("PCMSK1 %u\n", PCMSK1);
125
//printf("PCMSK1 %u\n", PCMSK1);
126
            } else if (pcints[pcint_id].pcintBit < 24) {
126
            } else if (pcints[pcint_id].pcintBit < 24) {
127
                pcints[pcint_id].lastStatus = ((PIND & (1 << pcints[pcint_id].pcintBit%8)) != 0);
127
                pcints[pcint_id].lastStatus = (PIND & (1 << pcints[pcint_id].pcintBit%8));
128
                PCMSK2 |= (1<<pcints[pcint_id].pcintBit%8);
128
                PCMSK2 |= (1<<pcints[pcint_id].pcintBit%8);
129
//printf("PCMSK2 %u\n", PCMSK2);
129
//printf("PCMSK2 %u\n", PCMSK2);
130
            }
130
            }
131
        } else { //turn off interupt
131
        } else { //turn off interupt
132
            if (pcints[pcint_id].pcintBit < 8) {
132
            if (pcints[pcint_id].pcintBit < 8) {