Subversion Repositories HomeAutomation

Rev

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

Rev 1369 Rev 1370
Line 23... Line 23...
23
};
23
};
24
#endif
24
#endif
25
 
25
 
26
uint16_t pwmValue[NUMBEROFCHANNELS];
26
uint16_t pwmValue[NUMBEROFCHANNELS];
27
float pwmValueFloat[NUMBEROFCHANNELS];
27
float pwmValueFloat[NUMBEROFCHANNELS];
-
 
28
#if act_softPWM_ACTIVATE_AUTOOFF != 0
-
 
29
uint8_t offCounter[NUMBEROFCHANNELS];
28
 
30
#endif
29
void act_softPWM_Init(void)
31
void act_softPWM_Init(void)
30
{
32
{
31
#ifdef act_softPWM_USEEEPROM
33
#ifdef act_softPWM_USEEEPROM
32
    if (EEDATA_OK)
34
    if (EEDATA_OK)
33
    {
35
    {
Line 73... Line 75...
73
    gpio_set_out(PIN_5);
75
    gpio_set_out(PIN_5);
74
    gpio_clr_pin(PIN_5);
76
    gpio_clr_pin(PIN_5);
75
#endif
77
#endif
76
#ifdef PIN_6
78
#ifdef PIN_6
77
    gpio_set_out(PIN_6);
79
    gpio_set_out(PIN_6);
78
    gpio_clr_pin(PIN_6);
80
    gpio_clr_pin(PIN_6);
79
#endif
81
#endif
80
#ifdef PIN_7
82
#ifdef PIN_7
81
    gpio_set_out(PIN_7);
83
    gpio_set_out(PIN_7);
82
    gpio_clr_pin(PIN_7);
84
    gpio_clr_pin(PIN_7);
83
#endif
85
#endif
84
   
86
   
85
    Timer_SetTimeout(act_softPWM_TIMER, resolution, TimerTypeFreeRunning, NULL);
87
    Timer_SetTimeout(act_softPWM_TIMER, resolution, TimerTypeFreeRunning, NULL);
86
}
88
}
87
 
89
 
88
void act_softPWM_Process(void)
90
void act_softPWM_Process(void)
Line 90... Line 92...
90
    if (Timer_Expired(act_softPWM_TIMER)) {
92
    if (Timer_Expired(act_softPWM_TIMER)) {
91
        currentTimer++;
93
        currentTimer++;
92
        if (currentTimer == maxTimer) {
94
        if (currentTimer == maxTimer) {
93
            currentTimer=0;
95
            currentTimer=0;
94
            #ifdef PIN_0 
96
            #ifdef PIN_0
-
 
97
                if (pwmValue[0]!=0)
95
                gpio_set_pin(PIN_0);
98
                    gpio_set_pin(PIN_0);
96
            #endif
99
            #endif
97
            #ifdef PIN_1 
100
            #ifdef PIN_1 
-
 
101
                if (pwmValue[1]!=0)
98
                gpio_set_pin(PIN_1);
102
                    gpio_set_pin(PIN_1);
99
            #endif
103
            #endif
100
            #ifdef PIN_2 
104
            #ifdef PIN_2 
-
 
105
                if (pwmValue[2]!=0)
101
                gpio_set_pin(PIN_2);
106
                    gpio_set_pin(PIN_2);
102
            #endif
107
            #endif
103
            #ifdef PIN_3 
108
            #ifdef PIN_3 
-
 
109
                if (pwmValue[3]!=0)
104
                gpio_set_pin(PIN_3);
110
                    gpio_set_pin(PIN_3);
105
            #endif
111
            #endif
106
            #ifdef PIN_4 
112
            #ifdef PIN_4 
-
 
113
                if (pwmValue[4]!=0)
107
                gpio_set_pin(PIN_4);
114
                    gpio_set_pin(PIN_4);
108
            #endif
115
            #endif
109
            #ifdef PIN_5 
116
            #ifdef PIN_5 
-
 
117
                if (pwmValue[5]!=0)
110
                gpio_set_pin(PIN_5);
118
                    gpio_set_pin(PIN_5);
111
            #endif
119
            #endif
112
            #ifdef PIN_6 
120
            #ifdef PIN_6 
-
 
121
                if (pwmValue[6]!=0)
113
                gpio_set_pin(PIN_6);
122
                    gpio_set_pin(PIN_6);
114
            #endif
123
            #endif
115
            #ifdef PIN_7 
124
            #ifdef PIN_7 
-
 
125
                if (pwmValue[7]!=0)
116
                gpio_set_pin(PIN_7);
126
                    gpio_set_pin(PIN_7);
117
            #endif
127
            #endif
118
        }
128
        }
119
        #ifdef PIN_0
129
        #ifdef PIN_0
120
        if (currentTimer >= pwmValue[0]) {
130
        if (currentTimer >= pwmValue[0]) {
Line 201... Line 211...
201
        txMsg.Length = 3;
211
        txMsg.Length = 3;
202
        txMsg.Data[0] = currentSendChannelId;
212
        txMsg.Data[0] = currentSendChannelId;
203
        txMsg.Data[1] = (pwmValue[currentSendChannelId]>>8)&0xff;
213
        txMsg.Data[1] = (pwmValue[currentSendChannelId]>>8)&0xff;
204
        txMsg.Data[2] = (pwmValue[currentSendChannelId])&0xff;
214
        txMsg.Data[2] = (pwmValue[currentSendChannelId])&0xff;
205
        while (StdCan_Put(&txMsg) != StdCan_Ret_OK);
215
        while (StdCan_Put(&txMsg) != StdCan_Ret_OK);
-
 
216
#if act_softPWM_ACTIVATE_AUTOOFF != 0
-
 
217
        offCounter[currentSendChannelId]--;
-
 
218
        if (offCounter[currentSendChannelId] == 0) {
-
 
219
            pwmValue[currentSendChannelId] = 0;
-
 
220
            pwmValueFloat[currentSendChannelId] = 0;
-
 
221
            offCounter[currentSendChannelId] = 1;
-
 
222
        }
-
 
223
#endif
206
        currentSendChannelId++;
224
        currentSendChannelId++;
207
        if (currentSendChannelId >= NUMBEROFCHANNELS)
225
        if (currentSendChannelId >= NUMBEROFCHANNELS)
208
            currentSendChannelId=0;
226
            currentSendChannelId=0;
209
    }
227
    }
210
}
228
}
Line 229... Line 247...
229
                    rxMsg->Data[1] = (uint8_t)0x00ff & (((uint32_t)(pwmValueFloat[rxMsg->Data[0]]*64))>>8);
247
                    rxMsg->Data[1] = (uint8_t)0x00ff & (((uint32_t)(pwmValueFloat[rxMsg->Data[0]]*64))>>8);
230
                    rxMsg->Data[2] = (uint8_t)0x00ff & ((uint32_t)pwmValueFloat[rxMsg->Data[0]]*64);
248
                    rxMsg->Data[2] = (uint8_t)0x00ff & ((uint32_t)pwmValueFloat[rxMsg->Data[0]]*64);
231
                    StdCan_Set_direction(rxMsg->Header, DIRECTIONFLAG_FROM_OWNER);
249
                    StdCan_Set_direction(rxMsg->Header, DIRECTIONFLAG_FROM_OWNER);
232
                    rxMsg->Length = 3;
250
                    rxMsg->Length = 3;
233
                    while (StdCan_Put(rxMsg) != StdCan_Ret_OK);
251
                    while (StdCan_Put(rxMsg) != StdCan_Ret_OK);
-
 
252
                    #if act_softPWM_ACTIVATE_AUTOOFF != 0
-
 
253
                    offCounter[rxMsg->Data[0]] = act_softPWM_ACTIVATE_AUTOOFF;
-
 
254
                    #endif
234
                }
255
                }
235
            } else if (rxMsg->Length == 1) {
256
            } else if (rxMsg->Length == 1) {
236
                rxMsg->Data[1] = (uint8_t)0x00ff & (((uint32_t)(pwmValueFloat[rxMsg->Data[0]]*64))>>8);
257
                rxMsg->Data[1] = (uint8_t)0x00ff & (((uint32_t)(pwmValueFloat[rxMsg->Data[0]]*64))>>8);
237
                rxMsg->Data[2] = (uint8_t)0x00ff & ((uint32_t)pwmValueFloat[rxMsg->Data[0]]*64);
258
                rxMsg->Data[2] = (uint8_t)0x00ff & ((uint32_t)pwmValueFloat[rxMsg->Data[0]]*64);
238
                StdCan_Set_direction(rxMsg->Header, DIRECTIONFLAG_FROM_OWNER);
259
                StdCan_Set_direction(rxMsg->Header, DIRECTIONFLAG_FROM_OWNER);