Rev 1534 | Rev 1537 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1534 | Rev 1535 | ||
|---|---|---|---|
| Line 243... | Line 243... | ||
| 243 | Pcint_SetCallbackPin(act_protectedOutput_DIAG_PIN_PCINT, DIAG_PIN, &pcIntCallback); |
243 | Pcint_SetCallbackPin(act_protectedOutput_DIAG_PIN_PCINT, DIAG_PIN, &pcIntCallback); |
| 244 | 244 | ||
| 245 | /* |
245 | /* |
| 246 | * Read EEPROM data |
246 | * Read EEPROM data |
| 247 | */ |
247 | */ |
| 248 | |
248 | #if act_protectedOutput_EEPROM_ENABLED == 1 |
| 249 | if (EEDATA_OK) { |
249 | if (EEDATA_OK) { |
| 250 | #if act_protectedOutput_CH_COUNT >= 1 |
250 | #if act_protectedOutput_CH_COUNT >= 1 |
| 251 | outputStateTarget[0] = eeprom_read_byte(EEDATA.ch0); |
251 | outputStateTarget[0] = eeprom_read_byte(EEDATA.ch0); |
| 252 | #endif |
252 | #endif |
| 253 | #if act_protectedOutput_CH_COUNT >= 2 |
253 | #if act_protectedOutput_CH_COUNT >= 2 |
| Line 305... | Line 305... | ||
| 305 | } |
305 | } |
| 306 | 306 | ||
| 307 | 307 | ||
| 308 | void act_protectedOutput_Process() { |
308 | void act_protectedOutput_Process() { |
| 309 | 309 | ||
| - | 310 | #if act_protectedOutput_EEPROM_ENABLED == 1 |
|
| 310 | if (Timer_Expired(act_protectedOutput_STORE_VALUE_TIMEOUT)) { |
311 | if (Timer_Expired(act_protectedOutput_STORE_VALUE_TIMEOUT)) { |
| 311 | #if act_protectedOutput_CH_COUNT >= 1 |
312 | #if act_protectedOutput_CH_COUNT >= 1 |
| 312 | eeprom_write_byte_crc(EEDATA.ch0, outputStateTarget[0], WITHOUT_CRC); |
313 | eeprom_write_byte_crc(EEDATA.ch0, outputStateTarget[0], WITHOUT_CRC); |
| 313 | #endif |
314 | #endif |
| 314 | #if act_protectedOutput_CH_COUNT >= 2 |
315 | #if act_protectedOutput_CH_COUNT >= 2 |
| Line 320... | Line 321... | ||
| 320 | #if act_protectedOutput_CH_COUNT >= 4 |
321 | #if act_protectedOutput_CH_COUNT >= 4 |
| 321 | eeprom_write_byte_crc(EEDATA.ch3, outputStateTarget[3], WITHOUT_CRC); |
322 | eeprom_write_byte_crc(EEDATA.ch3, outputStateTarget[3], WITHOUT_CRC); |
| 322 | #endif |
323 | #endif |
| 323 | EEDATA_UPDATE_CRC; |
324 | EEDATA_UPDATE_CRC; |
| 324 | } |
325 | } |
| - | 326 | #endif |
|
| 325 | 327 | ||
| 326 | // shall we retry to set target output state? |
328 | // shall we retry to set target output state? |
| 327 | if (Timer_Expired(act_protectedOutput_RETRY_TIMER)) { |
329 | if (Timer_Expired(act_protectedOutput_RETRY_TIMER)) { |
| 328 | // read DIAG pin again and update outputs accordingly |
330 | // read DIAG pin again and update outputs accordingly |
| 329 | readDiagPin(); |
331 | readDiagPin(); |
| Line 333... | Line 335... | ||
| 333 | Timer_SetTimeout(act_protectedOutput_RETRY_TIMER, act_protectedOutput_RETRY_TIMER_TIME_S*1000, TimerTypeOneShot, 0); |
335 | Timer_SetTimeout(act_protectedOutput_RETRY_TIMER, act_protectedOutput_RETRY_TIMER_TIME_S*1000, TimerTypeOneShot, 0); |
| 334 | } |
336 | } |
| 335 | else { |
337 | else { |
| 336 | // things went back to normal. report this |
338 | // things went back to normal. report this |
| 337 | diagReportPending = 1; |
339 | diagReportPending = 1; |
| 338 | } |
340 | } |
| 339 | } |
341 | } |
| 340 | 342 | ||
| 341 | // shall we report diag status to CAN? |
343 | // shall we report diag status to CAN? |
| 342 | if (diagReportPending) { |
344 | if (diagReportPending) { |
| 343 | StdCan_Msg_t txMsg; |
345 | StdCan_Msg_t txMsg; |
| 344 | StdCan_Set_class(txMsg.Header, CAN_MODULE_CLASS_SNS); |
346 | StdCan_Set_class(txMsg.Header, CAN_MODULE_CLASS_SNS); |
| Line 355... | Line 357... | ||
| 355 | txMsg.Data[1] = 0; //not healthy, DIAG pin ASSERTED, not in target output state |
357 | txMsg.Data[1] = 0; //not healthy, DIAG pin ASSERTED, not in target output state |
| 356 | } |
358 | } |
| 357 | while (StdCan_Put(&txMsg) != StdCan_Ret_OK); |
359 | while (StdCan_Put(&txMsg) != StdCan_Ret_OK); |
| 358 | diagReportPending = 0; |
360 | diagReportPending = 0; |
| 359 | } |
361 | } |
| 360 | } |
362 | } |
| 361 | 363 | ||
| 362 | 364 | ||
| 363 | void act_protectedOutput_HandleMessage(StdCan_Msg_t *rxMsg) { |
365 | void act_protectedOutput_HandleMessage(StdCan_Msg_t *rxMsg) { |
| 364 | if ( StdCan_Ret_class(rxMsg->Header) == CAN_MODULE_CLASS_ACT && |
366 | if ( StdCan_Ret_class(rxMsg->Header) == CAN_MODULE_CLASS_ACT && |
| 365 | StdCan_Ret_direction(rxMsg->Header) == DIRECTIONFLAG_TO_OWNER && |
367 | StdCan_Ret_direction(rxMsg->Header) == DIRECTIONFLAG_TO_OWNER && |
| 366 | rxMsg->Header.ModuleType == CAN_MODULE_TYPE_SNS_PROTECTEDOUTPUT && |
368 | rxMsg->Header.ModuleType == CAN_MODULE_TYPE_SNS_PROTECTEDOUTPUT && |
| Line 377... | Line 379... | ||
| 377 | uint8_t channel = rxMsg->Data[0]; |
379 | uint8_t channel = rxMsg->Data[0]; |
| 378 | if (channel >= 0 && channel < act_protectedOutput_CH_COUNT) { |
380 | if (channel >= 0 && channel < act_protectedOutput_CH_COUNT) { |
| 379 | outputStateTarget[channel] = rxMsg->Data[1]; |
381 | outputStateTarget[channel] = rxMsg->Data[1]; |
| 380 | readDiagPin(); |
382 | readDiagPin(); |
| 381 | updateOutput(); |
383 | updateOutput(); |
| - | 384 | #if act_protectedOutput_EEPROM_ENABLED == 1 |
|
| 382 | // output states changed, store to EE after thie timer delay |
385 | // 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); |
386 | Timer_SetTimeout(act_protectedOutput_STORE_VALUE_TIMEOUT, act_protectedOutput_STORE_VALUE_TIMEOUT_TIME_S*1000, TimerTypeOneShot, 0); |
| - | 387 | #endif |
|
| 384 | } |
388 | } |
| 385 | StdCan_Set_direction(rxMsg->Header, DIRECTIONFLAG_FROM_OWNER); |
389 | StdCan_Set_direction(rxMsg->Header, DIRECTIONFLAG_FROM_OWNER); |
| 386 | rxMsg->Length = 2; |
390 | rxMsg->Length = 2; |
| 387 | while (StdCan_Put(rxMsg) != StdCan_Ret_OK); |
391 | while (StdCan_Put(rxMsg) != StdCan_Ret_OK); |
| 388 | } |
392 | } |