Subversion Repositories HomeAutomation

Rev

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

Rev 1532 Rev 1534
Line 244... Line 244...
244
   
244
   
245
    /*
245
    /*
246
     * Read EEPROM data
246
     * Read EEPROM data
247
     */
247
     */
248
#ifdef act_protectedOutput_EEPROM_ENABLED
248
#ifdef act_protectedOutput_EEPROM_ENABLED
249
    if (EEDATA_OK)
249
    if (EEDATA_OK) {
250
    {
-
 
251
      ///TODO: Use stored data to set initial values for the module
-
 
252
      uint8_t index = 0;
-
 
253
#if act_protectedOutput_CH_COUNT >= 1
250
#if act_protectedOutput_CH_COUNT >= 1
254
      outputStateTarget[0] = eeprom_read_byte(EEDATA.ch0);
251
      outputStateTarget[0] = eeprom_read_byte(EEDATA.ch0);
255
#endif
252
#endif
256
#if act_protectedOutput_CH_COUNT >= 2
253
#if act_protectedOutput_CH_COUNT >= 2
257
      outputStateTarget[1] = eeprom_read_byte(EEDATA.ch1);
254
      outputStateTarget[1] = eeprom_read_byte(EEDATA.ch1);
258
#endif
255
#endif
259
#if act_protectedOutput_CH_COUNT >= 3
256
#if act_protectedOutput_CH_COUNT >= 3
260
      outputStateTarget[2] = eeprom_read_byte(EEDATA.ch2);
257
      outputStateTarget[2] = eeprom_read_byte(EEDATA.ch2);
261
#endif
258
#endif
262
#if act_protectedOutput_CH_COUNT >= 4
259
#if act_protectedOutput_CH_COUNT >= 4
263
      outputStateTarget[3] = eeprom_read_byte(EEDATA.ch3);
260
      outputStateTarget[3] = eeprom_read_byte(EEDATA.ch3);
264
#endif
261
#endif
Line 268... Line 265...
268
#if act_protectedOutput_CH_COUNT >= 1
265
#if act_protectedOutput_CH_COUNT >= 1
269
        eeprom_write_byte_crc(EEDATA.ch0, 0x00, WITHOUT_CRC);
266
        eeprom_write_byte_crc(EEDATA.ch0, 0x00, WITHOUT_CRC);
270
#endif
267
#endif
271
#if act_protectedOutput_CH_COUNT >= 2
268
#if act_protectedOutput_CH_COUNT >= 2
272
        eeprom_write_byte_crc(EEDATA.ch1, 0x00, WITHOUT_CRC);
269
        eeprom_write_byte_crc(EEDATA.ch1, 0x00, WITHOUT_CRC);
273
#endif
270
#endif
274
#if act_protectedOutput_CH_COUNT >= 3
271
#if act_protectedOutput_CH_COUNT >= 3
275
        eeprom_write_byte_crc(EEDATA.ch2, 0x00, WITHOUT_CRC);
272
        eeprom_write_byte_crc(EEDATA.ch2, 0x00, WITHOUT_CRC);
276
#endif
273
#endif
277
#if act_protectedOutput_CH_COUNT >= 4
274
#if act_protectedOutput_CH_COUNT >= 4
278
        eeprom_write_byte_crc(EEDATA.ch3, 0x00, WITHOUT_CRC);
275
        eeprom_write_byte_crc(EEDATA.ch3, 0x00, WITHOUT_CRC);
279
#endif
276
#endif
280
        EEDATA_UPDATE_CRC;
277
        EEDATA_UPDATE_CRC;
281
    }
278
    }
282
#endif
279
#endif
283
 
280
 
284
    /*
281
    /*
285
     * Configure OUTPUT pins
282
     * Configure OUTPUT pins
286
     */
283
     */
287
    #if act_protectedOutput_CH_COUNT >= 1
284
    #if act_protectedOutput_CH_COUNT >= 1
Line 290... Line 287...
290
    #endif
287
    #endif
291
   
288
   
292
    #if act_protectedOutput_CH_COUNT >= 2
289
    #if act_protectedOutput_CH_COUNT >= 2
293
    gpio_set_statement(CH1_OFF, CH1_PIN);
290
    gpio_set_statement(CH1_OFF, CH1_PIN);
294
    gpio_set_out(act_protectedOutput_CH1);
291
    gpio_set_out(act_protectedOutput_CH1);
295
    #endif
292
    #endif
296
 
293
 
297
    #if act_protectedOutput_CH_COUNT >= 3
294
    #if act_protectedOutput_CH_COUNT >= 3
298
    gpio_set_statement(CH2_OFF, CH2_PIN);
295
    gpio_set_statement(CH2_OFF, CH2_PIN);
299
    gpio_set_out(act_protectedOutput_CH2);
296
    gpio_set_out(act_protectedOutput_CH2);
300
    #endif
297
    #endif
301
 
298
 
Line 307... Line 304...
307
    diagState = DIAG_NORMAL;
304
    diagState = DIAG_NORMAL;
308
}
305
}
309
 
306
 
310
 
307
 
311
void act_protectedOutput_Process() {
308
void act_protectedOutput_Process() {
-
 
309
 
-
 
310
    if (Timer_Expired(act_protectedOutput_STORE_VALUE_TIMEOUT)) {
-
 
311
#if act_protectedOutput_CH_COUNT >= 1
-
 
312
        eeprom_write_byte_crc(EEDATA.ch0, outputStateTarget[0], WITHOUT_CRC);
-
 
313
#endif
-
 
314
#if act_protectedOutput_CH_COUNT >= 2
-
 
315
        eeprom_write_byte_crc(EEDATA.ch1, outputStateTarget[1], WITHOUT_CRC);
-
 
316
#endif
-
 
317
#if act_protectedOutput_CH_COUNT >= 3
-
 
318
        eeprom_write_byte_crc(EEDATA.ch2, outputStateTarget[2], WITHOUT_CRC);
-
 
319
#endif
-
 
320
#if act_protectedOutput_CH_COUNT >= 4
-
 
321
        eeprom_write_byte_crc(EEDATA.ch3, outputStateTarget[3], WITHOUT_CRC);
-
 
322
#endif
-
 
323
        EEDATA_UPDATE_CRC;
-
 
324
    }
312
 
325
 
313
    // shall we retry to set target output state?
326
    // shall we retry to set target output state?
314
    if (Timer_Expired(act_protectedOutput_RETRY_TIMER)) {
327
    if (Timer_Expired(act_protectedOutput_RETRY_TIMER)) {
315
        // read DIAG pin again and update outputs accordingly
328
        // read DIAG pin again and update outputs accordingly
316
        readDiagPin();
329
        readDiagPin();
Line 364... Line 377...
364
                    uint8_t channel = rxMsg->Data[0];
377
                    uint8_t channel = rxMsg->Data[0];
365
                    if (channel >= 0 && channel < act_protectedOutput_CH_COUNT) {
378
                    if (channel >= 0 && channel < act_protectedOutput_CH_COUNT) {
366
                        outputStateTarget[channel] = rxMsg->Data[1];
379
                        outputStateTarget[channel] = rxMsg->Data[1];
367
                        readDiagPin();
380
                        readDiagPin();
368
                        updateOutput();
381
                        updateOutput();
-
 
382
                        // output states changed, store to EE after thie timer delay
-
 
383
                        Timer_SetTimeout(act_protectedOutput_STORE_VALUE_TIMEOUT, act_protectedOutput_STORE_VALUE_TIMEOUT_TIME_S*1000, TimerTypeOneShot, 0);
369
                    }              
384
                    }              
370
                    StdCan_Set_direction(rxMsg->Header, DIRECTIONFLAG_FROM_OWNER);
385
                    StdCan_Set_direction(rxMsg->Header, DIRECTIONFLAG_FROM_OWNER);
371
                    rxMsg->Length = 2;
386
                    rxMsg->Length = 2;
372
                    while (StdCan_Put(rxMsg) != StdCan_Ret_OK);
387
                    while (StdCan_Put(rxMsg) != StdCan_Ret_OK);
373
                }
388
                }