Commit 8fe2d919 authored by Peter Zumbruch's avatar Peter Zumbruch
Browse files

- added if statement around CAN switch structure

- added canState_UNKNOWN case
- added ATOMIC_BLOCK(ATOMIC_RESTORESTATE) into timer0AScheduler to learn about ATOMIC_BLOCK
- cleaned up some obsolete commented commands
- removed/changed Debug statements


git-svn-id: https://subversion.gsi.de/epics/trunk/hadcon/API-Slave@386 50339f28-a4cd-11e1-ab1f-8360dde1fe65
parent c182bad2
...@@ -269,71 +269,71 @@ int main( void ) ...@@ -269,71 +269,71 @@ int main( void )
} }
// CANbus interface has received a message // CANbus interface has received a message
printDebug_p(debugLevelPeriodicDebug, debugSystemCAN, __LINE__, PSTR(__FILE__), PSTR("CAN %s"), ( 1 == canReady ) ? "--yes" : ""); printDebug_p(debugLevelPeriodicDebug, debugSystemCAN, __LINE__, PSTR(__FILE__), PSTR("CAN %s"), ( canState_IDLE != canReady ) ? "--yes" : "");
switch (canReady) if ( canState_IDLE != canReady)
{ {
case canState_IDLE: switch (canReady)
break; {
case canState_RXOK: case canState_IDLE:
/* received complete message */ break;
case canState_RXOK:
/* received complete message */
// disable interrupts // disable interrupts
cli(); cli();
printDebug_p(debugLevelEventDebugVerbose, debugSystemMain, __LINE__, PSTR(__FILE__), printDebug_p(debugLevelEventDebugVerbose, debugSystemMain, __LINE__, PSTR(__FILE__),
PSTR("interrupts disabled (cli)")); PSTR("interrupts disabled (cli)"));
canConvertCanFrameToUartFormat(ptr_canStruct); canConvertCanFrameToUartFormat(ptr_canStruct);
canReady = canState_IDLE; /* restore flag */
printDebug_p(debugLevelEventDebug, debugSystemCAN, __LINE__, PSTR(__FILE__), canReady = canState_IDLE; /* restore flag */
PSTR("CAN canReady %i received"), canReady);
// (re)enable interrupts printDebug_p(debugLevelEventDebug, debugSystemCAN, __LINE__, PSTR(__FILE__),
printDebug_p(debugLevelEventDebugVerbose, debugSystemMain, __LINE__, PSTR(__FILE__), PSTR("CAN canReady %i received"), canReady);
PSTR("enabling interrupts (sei)"));
sei();
printDebug_p(debugLevelEventDebugVerbose, debugSystemMain, __LINE__, PSTR(__FILE__),
PSTR("interrupts enabled (sei)"));
break;
case canState_MOB_ERROR:
case canState_GENERAL_ERROR:
default:
/* can error detected */
// disable interrupts // (re)enable interrupts
cli(); sei();
printDebug_p(debugLevelEventDebugVerbose, debugSystemMain, __LINE__, PSTR(__FILE__), printDebug_p(debugLevelEventDebugVerbose, debugSystemMain, __LINE__, PSTR(__FILE__),
PSTR("interrupts disabled (cli)")); PSTR("interrupts enabled (sei)"));
printDebug_p(debugLevelEventDebug, debugSystemCAN, __LINE__, PSTR(__FILE__), break;
PSTR("CAN canReady %i received -> ErrorHandling"), canReady); case canState_MOB_ERROR:
case canState_GENERAL_ERROR:
case canState_UNKNOWN:
default:
/* can error detected */
canErrorHandling(canReady); // disable interrupts
cli();
printDebug_p(debugLevelEventDebug, debugSystemCAN, __LINE__, PSTR(__FILE__), printDebug_p(debugLevelEventDebug, debugSystemCAN, __LINE__, PSTR(__FILE__),
PSTR("CAN canReady %i received -> resetting to 0"), canReady); PSTR("CAN canReady %i received -> ErrorHandling"), canReady);
printDebug_p(debugLevelEventDebugVerbose, debugSystemMain, __LINE__, PSTR(__FILE__),
PSTR("interrupts disabled (cli)"));
canReady = canState_IDLE; /* restore flag */ canErrorHandling(canReady);
printDebug_p(debugLevelEventDebug, debugSystemCAN, __LINE__, PSTR(__FILE__), printDebug_p(debugLevelEventDebug, debugSystemCAN, __LINE__, PSTR(__FILE__),
PSTR("CAN canReady %i reset to %i"), canReady, canState_IDLE); PSTR("CAN canReady %i received -> resetting to 0"), canReady);
// (re)enable interrupts canReady = canState_IDLE; /* restore flag */
printDebug_p(debugLevelEventDebugVerbose, debugSystemMain, __LINE__, PSTR(__FILE__),
PSTR("enabling interrupts (sei)")); printDebug_p(debugLevelEventDebug, debugSystemCAN, __LINE__, PSTR(__FILE__),
sei(); PSTR("CAN canReady %i reset to %i"), canReady, canState_IDLE);
printDebug_p(debugLevelEventDebugVerbose, debugSystemMain, __LINE__, PSTR(__FILE__),
PSTR("interrupts enabled (sei)"));
break;
}
// (re)enable interrupts
sei();
printDebug_p(debugLevelEventDebugVerbose, debugSystemMain, __LINE__, PSTR(__FILE__),
PSTR("interrupts enabled (sei)"));
break;
}
}
// timer 0 set by ISR // timer 0 set by ISR
printDebug_p(debugLevelPeriodicDebug, debugSystemTIMER0, __LINE__, PSTR(__FILE__), PSTR("timer 0%s"), ( 1 == timer0Ready ) ? "--yes" : ""); printDebug_p(debugLevelPeriodicDebug, debugSystemTIMER0, __LINE__, PSTR(__FILE__), PSTR("timer 0%s"), ( 1 == timer0Ready ) ? "--yes" : "");
if ( 1 == timer0Ready ) if ( 1 == timer0Ready )
{ {
cli(); cli();
/* canGetGeneralStatusError(); */
timer0Ready = 0; timer0Ready = 0;
sei(); sei();
} }
...@@ -361,7 +361,6 @@ int main( void ) ...@@ -361,7 +361,6 @@ int main( void )
if ( 1 == timer0AReady ) if ( 1 == timer0AReady )
{ {
cli(); cli();
/* canGetMObError(); */
timer0AReady = 0; /* restore flag */ timer0AReady = 0; /* restore flag */
sei(); sei();
} }
...@@ -371,14 +370,14 @@ int main( void ) ...@@ -371,14 +370,14 @@ int main( void )
if(1 == timer0ASchedulerReady ) if(1 == timer0ASchedulerReady )
{ {
// ATOMIC_BLOCK() ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
cli();
if (0 != owiTemperatureConversionGoingOnCountDown)
{ {
owiTemperatureConversionGoingOnCountDown--; if (0 != owiTemperatureConversionGoingOnCountDown)
{
owiTemperatureConversionGoingOnCountDown--;
}
timer0ASchedulerReady = 0; /* restore flag */
} }
timer0ASchedulerReady = 0; /* restore flag */
sei();
} }
/*relay block*/ /*relay block*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment