src/states.c
changeset 284 24bf3d692993
parent 263 d221d387ad2f
child 291 6165554cbfe9
equal deleted inserted replaced
283:e0b3096230e5 284:24bf3d692993
    31 
    31 
    32 #include "states.h"
    32 #include "states.h"
    33 #include "def.h"
    33 #include "def.h"
    34 #include "dcf.h"
    34 #include "dcf.h"
    35 #include "nmtSlave.h"
    35 #include "nmtSlave.h"
       
    36 #include "emcy.h"
    36 
    37 
    37 /** Prototypes for internals functions */
    38 /** Prototypes for internals functions */
    38 /*!                                                                                                
    39 /*!                                                                                                
    39 **                                                                                                 
    40 **                                                                                                 
    40 **                                                                                                 
    41 **                                                                                                 
    64 **/  
    65 **/  
    65 void canDispatch(CO_Data* d, Message *m)
    66 void canDispatch(CO_Data* d, Message *m)
    66 {
    67 {
    67 	 switch(m->cob_id.w >> 7)
    68 	 switch(m->cob_id.w >> 7)
    68 	{
    69 	{
    69 		case SYNC:
    70 		case SYNC:		/* can be a SYNC or a EMCY message */
    70 			if(d->CurrentCommunicationState.csSYNC)
    71 			if(m->cob_id.w == 0x080)	/* SYNC */
    71 				proceedSYNC(d);
    72 			{
       
    73 				if(d->CurrentCommunicationState.csSYNC)
       
    74 					proceedSYNC(d);
       
    75 			} else 		/* EMCY */
       
    76 				if(d->CurrentCommunicationState.csEmergency)
       
    77 					proceedEMCY(d,m);
    72 			break;
    78 			break;
    73 		/* case TIME_STAMP: */
    79 		/* case TIME_STAMP: */
    74 		case PDO1tx:
    80 		case PDO1tx:
    75 		case PDO1rx:
    81 		case PDO1rx:
    76 		case PDO2tx:
    82 		case PDO2tx:
   120 void switchCommunicationState(CO_Data* d, s_state_communication *newCommunicationState)
   126 void switchCommunicationState(CO_Data* d, s_state_communication *newCommunicationState)
   121 {
   127 {
   122 	StartOrStop(csSDO,	None,		resetSDO(d))
   128 	StartOrStop(csSDO,	None,		resetSDO(d))
   123 	StartOrStop(csSYNC,	startSYNC(d),		stopSYNC(d))
   129 	StartOrStop(csSYNC,	startSYNC(d),		stopSYNC(d))
   124 	StartOrStop(csHeartbeat,	heartbeatInit(d),	heartbeatStop(d))
   130 	StartOrStop(csHeartbeat,	heartbeatInit(d),	heartbeatStop(d))
   125 /*	StartOrStop(Emergency,,) */
   131 	StartOrStop(csEmergency,	emergencyInit(d),	emergencyStop(d)) 
   126 	StartOrStop(csPDO,	PDOInit(d),	PDOStop(d))
   132 	StartOrStop(csPDO,	PDOInit(d),	PDOStop(d))
   127 	StartOrStop(csBoot_Up,	None,	slaveSendBootUp(d))
   133 	StartOrStop(csBoot_Up,	None,	slaveSendBootUp(d))
   128 }
   134 }
   129 
   135 
   130 /*!                                                                                                
   136 /*!