src/states.c
changeset 381 854c43cdc24a
parent 378 d2abf6c8c27b
child 438 39ea9e1b8354
equal deleted inserted replaced
380:fe47568b8281 381:854c43cdc24a
   134 ** @param d                                                                                        
   134 ** @param d                                                                                        
   135 ** @param newCommunicationState                                                                    
   135 ** @param newCommunicationState                                                                    
   136 **/  	
   136 **/  	
   137 void switchCommunicationState(CO_Data* d, s_state_communication *newCommunicationState)
   137 void switchCommunicationState(CO_Data* d, s_state_communication *newCommunicationState)
   138 {
   138 {
       
   139 #ifdef CO_ENABLE_LSS
       
   140 	StartOrStop(csLSS,	startLSS(d),	stopLSS(d))
       
   141 #endif
   139 	StartOrStop(csSDO,	None,		resetSDO(d))
   142 	StartOrStop(csSDO,	None,		resetSDO(d))
   140 	StartOrStop(csSYNC,	startSYNC(d),		stopSYNC(d))
   143 	StartOrStop(csSYNC,	startSYNC(d),		stopSYNC(d))
   141 	StartOrStop(csHeartbeat,	heartbeatInit(d),	heartbeatStop(d))
   144 	StartOrStop(csHeartbeat,	heartbeatInit(d),	heartbeatStop(d))
   142 	StartOrStop(csEmergency,	emergencyInit(d),	emergencyStop(d)) 
   145 	StartOrStop(csEmergency,	emergencyInit(d),	emergencyStop(d)) 
   143 	StartOrStop(csPDO,	PDOInit(d),	PDOStop(d))
   146 	StartOrStop(csPDO,	PDOInit(d),	PDOStop(d))
   144 	StartOrStop(csBoot_Up,	None,	slaveSendBootUp(d))
   147 	StartOrStop(csBoot_Up,	None,	slaveSendBootUp(d))
   145 #ifdef CO_ENABLE_LSS
       
   146 	StartOrStop(csLSS,	startLSS(d),	stopLSS(d))
       
   147 #endif
       
   148 }
   148 }
   149 
   149 
   150 /*!                                                                                                
   150 /*!                                                                                                
   151 **                                                                                                 
   151 **                                                                                                 
   152 **                                                                                                 
   152 **                                                                                                 
   207 				newState = Stopped;
   207 				newState = Stopped;
   208 				switchCommunicationState(d, &newCommunicationState);
   208 				switchCommunicationState(d, &newCommunicationState);
   209 				(*d->stopped)(d);
   209 				(*d->stopped)(d);
   210 			}
   210 			}
   211 			break;
   211 			break;
   212 #ifdef CO_ENABLE_LSS
   212 			default:
   213 			case LssTimingDelay:
   213 				return 0xFF;
   214 			{
   214 
   215 				s_state_communication newCommunicationState = {0, 0, 0, 0, 0, 0, 0};
       
   216 				d->nodeState = LssTimingDelay;
       
   217 				newState = LssTimingDelay;
       
   218 				switchCommunicationState(d, &newCommunicationState);
       
   219 			}
       
   220 			break;
       
   221 #endif
       
   222 		}/* end switch case */
   215 		}/* end switch case */
   223 	
   216 	
   224 	}
   217 	}
   225 	/* d->nodeState contains the final state */
   218 	/* d->nodeState contains the final state */
   226 	/* may not be the requested state */
   219 	/* may not be the requested state */
   248 void setNodeId(CO_Data* d, UNS8 nodeId)
   241 void setNodeId(CO_Data* d, UNS8 nodeId)
   249 {
   242 {
   250   UNS16 offset = d->firstIndex->SDO_SVR;
   243   UNS16 offset = d->firstIndex->SDO_SVR;
   251   
   244   
   252 #ifdef CO_ENABLE_LSS
   245 #ifdef CO_ENABLE_LSS
       
   246   d->lss_transfer.nodeID=nodeId;
   253   if(nodeId==0xFF)
   247   if(nodeId==0xFF)
   254   {
   248   {
   255   	*d->bDeviceNodeId = nodeId;
   249   	*d->bDeviceNodeId = nodeId;
   256   	return;
   250   	return;
   257   }
   251   }