Commit ebc1cbf6 authored by Peter Zumbruch's avatar Peter Zumbruch
Browse files

replaced commented out ISR by still commented can.c's ISR

to show changes:
	- commented out any debug output
	- added comments
	- RXOK:
		- acknowledge/clear RXOK after data readout added 0xFF mask
		- enable any previous communication (receive) mode instead of only setting bit CONMOB1
	- general error:
		- request communication abort 
		- disable communication
 

git-svn-id: https://subversion.gsi.de/epics/trunk/hadcon/API-Slave@381 50339f28-a4cd-11e1-ab1f-8360dde1fe65
parent 9d98178b
......@@ -1368,109 +1368,140 @@ ISR (SIG_UART0_RECV)
}
}//END of ISR (SIG_UART0_RECV)
///* interrupt for receive data via CAN communication
// * with defined interrupt vector CANIT_vect */
//
//ISR(CANIT_vect)
//{
// uint8_t save_canpage = CANPAGE;
//
// static uint16_t ctr = 0;
// ctr++;
// printDebug_p(debugLevelEventDebugVerbose, debugSystemCAN, __LINE__, PSTR(__FILE__), PSTR("ISR (%i): CANIT_vect occurred, canReady: %i --- BEGIN of ISR SREG=%x"), ctr, canReady,SREG);
// static uint16_t ctr = 0;
// ctr++;
// /* printDebug_p(debugLevelEventDebugVerbose, debugSystemCAN, __LINE__, PSTR(__FILE__),
// PSTR("ISR (%i): CANIT_vect occurred, canReady: %i --- BEGIN of ISR SREG=%x"), ctr, canReady, SREG ); */
//
// // --- interrupt generated by a MOb
// // --- interrupt generated by a MOb
// // i.e. there is a least one MOb,
// // if more than one choose the highest priority CANHPMOB
// if ( (CANHPMOB & 0xF0) != 0xF0 )
// if ((CANHPMOB & 0xF0) != 0xF0)
// {
// // set current canMob to the 'winner' in CANHPMOB
// // set current canMob to the 'winner' in CANHPMOB
// canMob = (CANHPMOB & 0xf0) >> HPMOB0;
// // set CANPAGE to current canMob
// CANPAGE = ((canMob << MOBNB0 ) & 0xf0);
// CANPAGE = ((canMob << MOBNB0) & 0xf0);
//
// // check all interrupt bits of CANSTMOB Bit 6:0
//
// // check whether MOb has an error Bit 4:0
// if (0 != canIsMObErrorAndAcknowledge())
// { // check if MOb has an error
// printDebug_p(debugLevelEventDebugVerbose, debugSystemCAN, __LINE__, PSTR(__FILE__),
// PSTR("ISR (%i): CANIT_vect occurred, MOb (%i) error occurred, CANSTMOB before/after acknowledge: 0x%x/0x%x,"), ctr, canMob, canCurrentMObStatus, CANSTMOB);
// {
// /* printDebug_p(debugLevelEventDebugVerbose, debugSystemCAN, __LINE__, PSTR(__FILE__),
// PSTR("ISR (%i): CANIT_vect occurred, MOb (%i) error occurred, CANSTMOB before/after acknowledge: 0x%x/0x%x,"),
// ctr, canMob, canCurrentMObStatus, CANSTMOB ); */
//
// printDebug_p(debugLevelEventDebugVerbose, debugSystemCAN, __LINE__, PSTR(__FILE__),
// PSTR("ISR (%i): CANIT_vect occurred, canReady: %i, MOb (%i) error occurred, setting canReady to 2"), ctr, canReady, canMob);
// /* printDebug_p(debugLevelEventDebugVerbose, debugSystemCAN, __LINE__, PSTR(__FILE__),
// PSTR("ISR (%i): CANIT_vect occurred, canReady: %i, MOb (%i) error occurred, setting canReady to %i"),
// ctr, canReady, canMob, canState_MOB_ERROR); */
//
// canReady = canState_MOB_ERROR;
//
// printDebug_p(debugLevelEventDebugVerbose, debugSystemCAN, __LINE__, PSTR(__FILE__),
// PSTR("ISR (%i): CANIT_vect occurred, canReady: %i"), ctr, canReady);
//
// printDebug_p(debugLevelEventDebugVerbose, debugSystemCAN, __LINE__, PSTR(__FILE__),
// PSTR("ISR (%i): CANIT_vect occurred, MOb (%i), CANCDMOB: 0x%x"), ctr, canMob, CANCDMOB);
// /* printDebug_p(debugLevelEventDebugVerbose, debugSystemCAN, __LINE__, PSTR(__FILE__),
// PSTR("ISR (%i): CANIT_vect occurred, canReady: %i"), ctr, canReady); */
//
//#warning TODO: CAN on error, reset correct behaviour?
// /* printDebug_p(debugLevelEventDebugVerbose, debugSystemCAN, __LINE__, PSTR(__FILE__),
// PSTR("ISR (%i): CANIT_vect occurred, MOb (%i), CANCDMOB: 0x%x"), ctr, canMob, CANCDMOB ); */
//
// /*on error disable communication ?? or restart ?*/
// CANCDMOB &= ~( 1 << CONMOB1 | 1 << CONMOB0 ); /* reset receive mode*/
// // disable communication
// CANCDMOB &= ~(1 << CONMOB1 | 1 << CONMOB0);
//
// printDebug_p(debugLevelEventDebugVerbose, debugSystemCAN, __LINE__, PSTR(__FILE__),
// PSTR("ISR (%i): CANIT_vect occurred, MOb (%i), CANCDMOB: 0x%x"), ctr, canMob, CANCDMOB);
// /* printDebug_p(debugLevelEventDebugVerbose, debugSystemCAN, __LINE__, PSTR(__FILE__),
// PSTR("ISR (%i): CANIT_vect occurred, MOb (%i), CANCDMOB: 0x%x"), ctr, canMob, CANCDMOB ); */
// }
// else if ( CANSTMOB & ( 1 << TXOK ) )
// else if (CANSTMOB & (1 << TXOK)) // Bit 5
// {
// // MOb finished transmission
// /* clear transmit OK flag */
// CANSTMOB &= ~( 1 << TXOK );
// /* disable communication */
// CANCDMOB &= ~( 1 << CONMOB1 | 1 << CONMOB0);
// printDebug_p(debugLevelEventDebugVerbose, debugSystemCAN, __LINE__, PSTR(__FILE__), PSTR("ISR (%i): CANIT_vect occurred, canReady: %i, TXOK received"), ctr, canReady);
//
// // clear transmit OK flag
// CANSTMOB &= ~(1 << TXOK);
// // disable communication
// CANCDMOB &= ~(1 << CONMOB1 | 1 << CONMOB0);
//
// /* printDebug_p(debugLevelEventDebugVerbose, debugSystemCAN, __LINE__, PSTR(__FILE__),
// PSTR("ISR (%i): CANIT_vect occurred, canReady: %i, TXOK received"), ctr, canReady); */
// }
// else if ( CANSTMOB & ( 1 << RXOK ) )
// else if (CANSTMOB & (1 << RXOK)) // Bit 6
// {
// // MOb received message
// ptr_canStruct->length = CANCDMOB & 0xF ;
// for ( uint8_t i = 0 ; i < ptr_canStruct->length ; i++ )
// {
// /* get data of selected MOb */
// ptr_canStruct->data[i] = CANMSG;
// }
// /*get identifier */
//
// // get mailbox number
// ptr_canStruct->mob = canMob;
// ptr_canStruct->length = CANCDMOB & 0xF;
//
// // get identifier
// ptr_canStruct->id = 0;
// ptr_canStruct->id = CANIDT2 >> 5;
// ptr_canStruct->id |= CANIDT1 << 3;
// ptr_canStruct->mob = canMob; /*get mailbox */
// CANSTMOB &= ~( 1 << RXOK ); /* acknowledge/clear interrupt */
// CANCDMOB = ( 1 << CONMOB1 ); /* reset receive mode*/
// canReady = canState_RXOK; /* mark, that we got an CAN_interrupt, to be handled by main */
//
// printDebug_p(debugLevelEventDebugVerbose, debugSystemCAN, __LINE__, PSTR(__FILE__), PSTR("ISR (%i): CANIT_vect occurred, canReady: %i, RXOK"), ctr, canReady);
// // get data of selected MOb
// for (uint8_t i = 0; i < ptr_canStruct->length; i++)
// {
// ptr_canStruct->data[i] = CANMSG;
// }
//
// // acknowledge/clear interrupt
// CANSTMOB &= (0xFF & ~(1 << RXOK));
//
// // enable any previous communication (receive) mode
// CANCDMOB &= ( 1 << CONMOB1 | 1 << CONMOB0 | 1 << IDE );
// // mark, that we got an CAN_interrupt, to be handled by main
// canReady = canState_RXOK;
//
// /* printDebug_p(debugLevelEventDebugVerbose, debugSystemCAN, __LINE__, PSTR(__FILE__),
// PSTR("ISR (%i): CANIT_vect occurred, canReady: %i, RXOK"), ctr, canReady); */
// }
// else
// {
//
//#warning CAN: this case is not covered or not possible?
// printDebug_p(debugLevelEventDebugVerbose, debugSystemCAN, __LINE__, PSTR(__FILE__), PSTR("ISR (%i): CANIT_vect occurred, canReady: %i"), ctr, canReady);
// /* printDebug_p(debugLevelEventDebugVerbose, debugSystemCAN, __LINE__, PSTR(__FILE__),
// PSTR("ISR (%i): CANIT_vect occurred, canReady: %i"), ctr, canReady); */
//
// }
//
//#warning CAN add detailed Interrupt handling
//
// CANPAGE = save_canpage; /* restore CANPAGE*/
// printDebug_p(debugLevelEventDebugVerbose, debugSystemCAN, __LINE__, PSTR(__FILE__), PSTR("ISR (%i): CANIT_vect occurred, canReady: %i"), ctr, canReady);
//
// /* printDebug_p(debugLevelEventDebugVerbose, debugSystemCAN, __LINE__, PSTR(__FILE__),
// PSTR("ISR (%i): CANIT_vect occurred, canReady: %i"), ctr, canReady); */
// }
// else /*general error*/
// {
//#warning CAN add detailed Interrupt handling
// // --- general interrupt was generated
// if ( 0 != canIsGeneralStatusError() )
// if (0 != canIsGeneralStatusError())
// {
// canReady = canState_GENERAL_ERROR;
// printDebug_p(debugLevelEventDebugVerbose, debugSystemCAN, __LINE__, PSTR(__FILE__), PSTR("ISR (%i): CANIT_vect occurred, canReady: %i, general error occurred"), ctr, canReady);
//
// // Abort Request
// CANGCON |= (1 << ABRQ);
// // disable communication
// CANCDMOB &= ~(1 << CONMOB1 | 1 << CONMOB0);
// // clear Abort Request bit
// CANGCON &= (0xFF & ~(1 << ABRQ));
//
//
// /* printDebug_p(debugLevelEventDebugVerbose, debugSystemCAN, __LINE__, PSTR(__FILE__),
// PSTR("ISR (%i): CANIT_vect occurred, canReady: %i, general error occurred"), ctr, canReady); */
// }
//
//#warning CAN TODO !!! wrong assignment CANGIT |= 0 does not work !!!
//
// CANGIT |= 0;
// }
//
// printDebug_p(debugLevelEventDebugVerbose, debugSystemCAN, __LINE__, PSTR(__FILE__), PSTR("ISR (%i): CANIT_vect occurred, canReady: %i --- END of ISR"), ctr, canReady);
// /* printDebug_p(debugLevelEventDebugVerbose, debugSystemCAN, __LINE__, PSTR(__FILE__),
// PSTR("ISR (%i): CANIT_vect occurred, canReady: %i --- END of ISR"), ctr, canReady); */
//
//}//END of ISR(CANIT_vect)
//} //END of ISR(CANIT_vect)
/*
*USART0 must be initialized before using this function
......
Markdown is supported
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