Subversion Repositories HomeAutomation

Rev

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

Rev 1125 Rev 1129
Line 36... Line 36...
36
Returns:  -
36
Returns:  -
37
**************************************************************************/
37
**************************************************************************/
38
ISR(PCINT0_vect) {
38
ISR(PCINT0_vect) {
39
    uint8_t p;
39
    uint8_t p;
40
    /* Check which pin that have had a change and call the callback.*/
40
    /* Check which pin that have had a change and call the callback.*/
-
 
41
    //printf("I\n");
41
    for (p = 0; p < PCINT_NUM_PCINTS; p++)
42
    for (p = 0; p < PCINT_NUM_PCINTS; p++)
42
    {
43
    {
43
        if (pcints[p].pcintBit < 8) {
44
        if (pcints[p].pcintBit < 8) {
44
            if (pcints[p].lastStatus != ((PINB & (1 << pcints[p].pcintBit)) != 0)) {
45
            if (pcints[p].lastStatus != ((PINB & (1 << pcints[p].pcintBit)) != 0)) {
45
                pcints[p].callback(p);
46
                pcints[p].callback(p);
Line 64... Line 65...
64
Function: ISR(PCINT1_vect)
65
Function: ISR(PCINT1_vect)
65
Purpose:  Executed when pin change on PCINT1.
66
Purpose:  Executed when pin change on PCINT1.
66
Input:    -
67
Input:    -
67
Returns:  -
68
Returns:  -
68
**************************************************************************/
69
**************************************************************************/
-
 
70
#if ((__GNUC__ == 4  && __GNUC_MINOR__ >= 2)||__GNUC__ > 4)
69
ISR(PCINT1_vect, ISR_ALIASOF(PCINT0_vect));
71
ISR(PCINT1_vect, ISR_ALIASOF(PCINT0_vect));
70
 
72
#else
-
 
73
ISR_ALIAS(PCINT1_vect, PCINT0_vect);
-
 
74
#endif
71
/*********************************************************************//**
75
/*********************************************************************//**
72
Function: ISR(PCINT0_vect)
76
Function: ISR(PCINT0_vect)
73
Purpose:  Executed when pin change on PCINT2.
77
Purpose:  Executed when pin change on PCINT2.
74
Input:    -
78
Input:    -
75
Returns:  -
79
Returns:  -
76
**************************************************************************/
80
**************************************************************************/
-
 
81
#if ((__GNUC__ == 4  && __GNUC_MINOR__ >= 2)||__GNUC__ > 4)
77
ISR(PCINT2_vect, ISR_ALIASOF(PCINT0_vect));
82
ISR(PCINT2_vect, ISR_ALIASOF(PCINT0_vect));
78
 
83
#else
-
 
84
ISR_ALIAS(PCINT2_vect, PCINT0_vect);
-
 
85
#endif
79
/*-----------------------------------------------------------------------------
86
/*-----------------------------------------------------------------------------
80
 * Public Functions
87
 * Public Functions
81
 *---------------------------------------------------------------------------*/
88
 *---------------------------------------------------------------------------*/
82
 
89
 
83
void Pcint_SetCallback(uint8_t pcint_id, uint8_t pcintBit, pcintCallback_t callback)
90
void Pcint_SetCallback(uint8_t pcint_id, uint8_t pcintBit, pcintCallback_t callback)
84
{
91
{
-
 
92
    //printf("Test\n");
85
    if (pcint_id<PCINT_NUM_PCINTS)
93
    if (pcint_id<PCINT_NUM_PCINTS)
86
    {
94
    {
87
        uint8_t sreg = SREG;
95
        uint8_t sreg = SREG;
88
        cli();
96
        cli();
89
 
97
 
Line 97... Line 105...
97
        pcints[pcint_id].lastStatus = 0;
105
        pcints[pcint_id].lastStatus = 0;
98
        if (callback != 0) {
106
        if (callback != 0) {
99
            if (pcints[pcint_id].pcintBit < 8) {
107
            if (pcints[pcint_id].pcintBit < 8) {
100
                pcints[pcint_id].lastStatus = ((PINB & (1 << pcints[pcint_id].pcintBit%8)) != 0);
108
                pcints[pcint_id].lastStatus = ((PINB & (1 << pcints[pcint_id].pcintBit%8)) != 0);
101
                PCMSK0 |= (1<<pcints[pcint_id].pcintBit%8);
109
                PCMSK0 |= (1<<pcints[pcint_id].pcintBit%8);
-
 
110
//printf("PCMSK %u\n", PCMSK0);
102
            } else if (pcints[pcint_id].pcintBit < 16) {
111
            } else if (pcints[pcint_id].pcintBit < 16) {
103
                pcints[pcint_id].lastStatus = ((PINC & (1 << pcints[pcint_id].pcintBit%8)) != 0);
112
                pcints[pcint_id].lastStatus = ((PINC & (1 << pcints[pcint_id].pcintBit%8)) != 0);
104
                PCMSK1 |= (1<<pcints[pcint_id].pcintBit%8);
113
                PCMSK1 |= (1<<pcints[pcint_id].pcintBit%8);
-
 
114
//printf("PCMSK1 %u\n", PCMSK1);
105
            } else if (pcints[pcint_id].pcintBit < 24) {
115
            } else if (pcints[pcint_id].pcintBit < 24) {
106
                pcints[pcint_id].lastStatus = ((PIND & (1 << pcints[pcint_id].pcintBit%8)) != 0);
116
                pcints[pcint_id].lastStatus = ((PIND & (1 << pcints[pcint_id].pcintBit%8)) != 0);
107
                PCMSK2 |= (1<<pcints[pcint_id].pcintBit%8);
117
                PCMSK2 |= (1<<pcints[pcint_id].pcintBit%8);
-
 
118
//printf("PCMSK2 %u\n", PCMSK2);
108
            }
119
            }
109
        } else { //turn off interupt
120
        } else { //turn off interupt
110
            if (pcints[pcint_id].pcintBit < 8) {
121
            if (pcints[pcint_id].pcintBit < 8) {
111
                PCMSK0 &= ~(1<<(pcints[pcint_id].pcintBit%8));
122
                PCMSK0 &= ~(1<<(pcints[pcint_id].pcintBit%8));
112
            } else if (pcints[pcint_id].pcintBit < 16) {
123
            } else if (pcints[pcint_id].pcintBit < 16) {