src/lss.c
changeset 361 2220813498f2
parent 343 118c1cabd0b0
child 365 9b76e0881beb
equal deleted inserted replaced
360:09af3515dd42 361:2220813498f2
    40 
    40 
    41 #include "data.h"
    41 #include "data.h"
    42 #include "lss.h"
    42 #include "lss.h"
    43 #include "canfestival.h"
    43 #include "canfestival.h"
    44 
    44 
    45 #define LSS_TIMEOUT_MS	(TIMEVAL)1000  /* ms */
    45 //#define LSS_TIMEOUT_MS	(TIMEVAL)1000  /* ms */
       
    46 //#define LSS_FS_TIMEOUT_MS	(TIMEVAL)100  /* ms */
    46 
    47 
    47 /* Returns the LSS ident field from a Message struct */
    48 /* Returns the LSS ident field from a Message struct */
    48 #define getLSSIdent(msg) ((msg->data[4] << 24) | (msg->data[3] << 16) | (msg->data[2] << 8) | (msg->data[1]))
    49 #define getLSSIdent(msg) ((msg->data[4] << 24) | (msg->data[3] << 16) | (msg->data[2] << 8) | (msg->data[1]))
    49 
    50 
    50 /* Returns the LSS switch delay field from a Message struct */
    51 /* Returns the LSS switch delay field from a Message struct */
    72 
    73 
    73 #define StartLSS_SDELAY_TIMER(){\
    74 #define StartLSS_SDELAY_TIMER(){\
    74  MSG_WAR(0x3D03, "StartLSS_TIMER for SDELAY_TIMER",0);\
    75  MSG_WAR(0x3D03, "StartLSS_TIMER for SDELAY_TIMER",0);\
    75  d->lss_transfer.timers[LSS_SWITCH_DELAY_TIMER] = SetAlarm(d,LSS_SWITCH_DELAY_TIMER,&LssAlarm,MS_TO_TIMEVAL(d->lss_transfer.switchDelay),MS_TO_TIMEVAL(d->lss_transfer.switchDelay));}
    76  d->lss_transfer.timers[LSS_SWITCH_DELAY_TIMER] = SetAlarm(d,LSS_SWITCH_DELAY_TIMER,&LssAlarm,MS_TO_TIMEVAL(d->lss_transfer.switchDelay),MS_TO_TIMEVAL(d->lss_transfer.switchDelay));}
    76 
    77 
       
    78 #define StartLSS_FS_TIMER(){\
       
    79  MSG_WAR(0x3D04, "StartLSS_TIMER for FS_TIMER",0);\
       
    80  d->lss_transfer.timers[LSS_FS_TIMER] = SetAlarm(d,LSS_FS_TIMER,&LssAlarm,MS_TO_TIMEVAL(LSS_FS_TIMEOUT_MS),0);}
       
    81 
       
    82 UNS8 sendMasterLSSMessage(CO_Data* d, UNS8 command,void *dat1,void *dat2);
    77 
    83 
    78 /*!                                                                                                
    84 /*!                                                                                                
    79 **                                                                                                 
    85 **                                                                                                 
    80 **                                                                                                 
    86 **                                                                                                 
    81 ** @param d                                                                                        
    87 ** @param d                                                                                        
    90  	time_period=(current_time.tv_sec - init_time.tv_sec)* 1000000 + current_time.tv_usec - init_time.tv_usec;
    96  	time_period=(current_time.tv_sec - init_time.tv_sec)* 1000000 + current_time.tv_usec - init_time.tv_usec;
    91  	printf("%3ld.%3ld.%3ld --",time_period/1000000,(time_period%1000000)/1000,time_period%1000);*/
    97  	printf("%3ld.%3ld.%3ld --",time_period/1000000,(time_period%1000000)/1000,time_period%1000);*/
    92  
    98  
    93 	switch(id){
    99 	switch(id){
    94 	case LSS_MSG_TIMER:
   100 	case LSS_MSG_TIMER:
    95 	 	MSG_ERR(0x1D04, "LSS timeout. LSS response not received.", 0);
   101 	 	StopLSS_TIMER(LSS_MSG_TIMER);
    96     	MSG_WAR(0x2D05, "LSS timeout command specifier : ", d->lss_transfer.command);
   102 #ifdef CO_ENABLE_LSS_FS
    97     
   103 		if(d->lss_transfer.command==LSS_IDENT_FASTSCAN){
    98 		StopLSS_TIMER(LSS_MSG_TIMER);
   104 			if(d->lss_transfer.FastScan_SM==LSS_FS_RESET){
    99     	/* Set aborted state */
   105    				/* if at least one node had answered before the timer expired, start the FastScan protocol*/
   100     	d->lss_transfer.state = LSS_ABORTED_INTERNAL;
   106    				if(d->lss_transfer.LSSanswer!=0){
       
   107    					d->lss_transfer.LSSanswer=0;
       
   108    					d->lss_transfer.BitChecked=31;
       
   109    					d->lss_transfer.IDNumber=0;
       
   110    					d->lss_transfer.FastScan_SM=LSS_FS_PROCESSING;
       
   111    					StartLSS_FS_TIMER();
       
   112    					sendMasterLSSMessage(d,LSS_IDENT_FASTSCAN,0,0);
       
   113    					return;
       
   114    				}
       
   115    				else{ 
       
   116    				
       
   117     				d->lss_transfer.state = LSS_FINISHED;
       
   118     				/* Inform the application that there aren't not configured nodes in the net  */
       
   119     				d->lss_transfer.dat1=1;
       
   120    				}
       
   121    			}
       
   122    			else{
       
   123 				/* This should not happen, an error ocurred*/
       
   124 				MSG_ERR(0x1D05, "LSS FastScan timeout. FastScan_SM inconsisten state.", d->lss_transfer.FastScan_SM);
       
   125    			}
       
   126 		}
       
   127 		else
       
   128 #endif
       
   129 		{
       
   130 			MSG_ERR(0x1D06, "LSS timeout. LSS response not received.", 0);
       
   131     		MSG_WAR(0x2D07, "LSS timeout command specifier : ", d->lss_transfer.command);
       
   132     		/* Set aborted state */
       
   133     		d->lss_transfer.state = LSS_ABORTED_INTERNAL;
       
   134     	}
       
   135     	
   101     	/* Call the user function to inform of the problem.*/
   136     	/* Call the user function to inform of the problem.*/
   102     	if(d->lss_transfer.Callback){
   137     	if(d->lss_transfer.Callback){
   103     		/*If there is a callback, it is responsible of the error*/
   138 	    	/*If there is a callback, it is responsible of the error*/
   104     		(*d->lss_transfer.Callback)(d,d->lss_transfer.command);
   139     		(*d->lss_transfer.Callback)(d,d->lss_transfer.command);
   105     	}
   140     	}
   106     break;
   141     break;
   107     case LSS_SWITCH_DELAY_TIMER:
   142     case LSS_SWITCH_DELAY_TIMER:
   108   		/* The first switch_delay period has expired. Store the node state, change it 
   143   		/* The first switch_delay period expired. Store the node state, change it 
   109  		 * so no CAN messages will be sent or received, call the ChangeBaudRate function*/
   144  		 * so no CAN messages will be sent or received, call the ChangeBaudRate function*/
   110    		if(d->lss_transfer.switchDelayState==SDELAY_FIRST){
   145    		if(d->lss_transfer.switchDelayState==SDELAY_FIRST){
   111    			MSG_WAR(0x3D06, "LSS switch delay first period expired",0);
   146    			MSG_WAR(0x3D08, "LSS switch delay first period expired",0);
   112     		d->lss_transfer.switchDelayState=SDELAY_SECOND;
   147     		d->lss_transfer.switchDelayState=SDELAY_SECOND;
   113     		//d->lss_transfer.currentState=getState(d);
       
   114     		//setState(d, LssTimingDelay);
       
   115     		(*d->lss_ChangeBaudRate)(d->lss_transfer.baudRate);
   148     		(*d->lss_ChangeBaudRate)(d->lss_transfer.baudRate);
   116     	}
   149     	}
   117     	else{ /* d->lss_transfer.switchDelayState==SDELAY_SECOND */
   150     	else{ /* d->lss_transfer.switchDelayState==SDELAY_SECOND */
   118     		MSG_WAR(0x3D07, "LSS switch delay second period expired",0);
   151     		MSG_WAR(0x3D09, "LSS switch delay second period expired",0);
   119     		d->lss_transfer.switchDelayState=SDELAY_OFF;
   152     		d->lss_transfer.switchDelayState=SDELAY_OFF;
   120     		StopLSS_TIMER(LSS_SWITCH_DELAY_TIMER);
   153     		StopLSS_TIMER(LSS_SWITCH_DELAY_TIMER);
   121     		
   154     		
   122     		setState(d, d->lss_transfer.currentState);
   155     		setState(d, d->lss_transfer.currentState);
   123     	}
   156     	}
   124      break;
   157      break;
       
   158 #ifdef CO_ENABLE_LSS_FS
       
   159      case LSS_FS_TIMER:
       
   160 	 	StopLSS_TIMER(LSS_FS_TIMER);
       
   161 		
       
   162 		switch(d->lss_transfer.FastScan_SM){
       
   163    		case LSS_FS_RESET:
       
   164    		{
       
   165    		   	/* This should not happen, an error ocurred*/
       
   166 			MSG_ERR(0x1D0A, "LSS FastScan timeout. FastScan_SM inconsisten state.", d->lss_transfer.FastScan_SM);
       
   167    		}
       
   168    		break;
       
   169 		case LSS_FS_PROCESSING:
       
   170 		{
       
   171 			/* If there isn't any answer, set the bit */
       
   172 			if(d->lss_transfer.LSSanswer==0){
       
   173 				UNS32 Mask=0x1;
       
   174 				Mask<<=d->lss_transfer.BitChecked;
       
   175 				d->lss_transfer.IDNumber|=Mask;
       
   176 			}
       
   177 			
       
   178 			if(d->lss_transfer.BitChecked==0){
       
   179 				/* We finished with the current LSS-ID[sub], confirm it */
       
   180 				d->lss_transfer.FastScan_SM=LSS_FS_CONFIRMATION;
       
   181 				if(d->lss_transfer.LSSNext<3)d->lss_transfer.LSSNext++;
       
   182 			}
       
   183 			else{
       
   184 				d->lss_transfer.BitChecked--;
       
   185 			}
       
   186    			
       
   187    			d->lss_transfer.LSSanswer=0;
       
   188   			StartLSS_FS_TIMER();
       
   189    			sendMasterLSSMessage(d,LSS_IDENT_FASTSCAN,0,0);
       
   190    			return;
       
   191    		}
       
   192 		break;
       
   193 		case LSS_FS_CONFIRMATION:
       
   194 		{
       
   195 			if(d->lss_transfer.LSSanswer!=0){
       
   196 				d->lss_transfer.LSSanswer=0;
       
   197 				
       
   198 				if(d->lss_transfer.LSSSub==3){
       
   199 					/* The LSS FastScan protocol finished correctly. Restore the parameters */
       
   200 					d->lss_transfer.BitChecked=128;
       
   201 					d->lss_transfer.FastScan_SM=LSS_FS_RESET;
       
   202 					d->lss_transfer.LSSSub=0;
       
   203 					d->lss_transfer.LSSNext=0;
       
   204    					d->lss_transfer.IDNumber=0;
       
   205 					
       
   206 					/* Inform the application that the FastScan finished correctly */
       
   207 					d->lss_transfer.state = LSS_FINISHED;
       
   208 					d->lss_transfer.dat1=0;
       
   209 				}
       
   210 				else{
       
   211 					/* Start with the next LSS-ID[sub] */
       
   212 					d->lss_transfer.LSSSub++;
       
   213 					d->lss_transfer.BitChecked=31;
       
   214    					d->lss_transfer.IDNumber=0;
       
   215    					d->lss_transfer.FastScan_SM=LSS_FS_PROCESSING;
       
   216    					StartLSS_FS_TIMER();
       
   217    					sendMasterLSSMessage(d,LSS_IDENT_FASTSCAN,0,0);
       
   218    					return;
       
   219 				}
       
   220 			}
       
   221 			else{
       
   222 				/* This should not happen, an error ocurred*/
       
   223 				MSG_ERR(0x1D0B, "LSS FastScan timeout. FastScan response not received.", 0);
       
   224 				/* Set aborted state */
       
   225     			d->lss_transfer.state = LSS_ABORTED_INTERNAL;
       
   226 			}
       
   227 		}
       
   228 		break;
       
   229    		}
       
   230 
       
   231     	/* Call the user function to inform of the problem.*/
       
   232     	if(d->lss_transfer.Callback){
       
   233 	    	/*If there is a callback, it is responsible of the error*/
       
   234     		(*d->lss_transfer.Callback)(d,d->lss_transfer.command);
       
   235     	}
       
   236     break;
       
   237 #endif
   125 	}
   238 	}
   126 }
   239 }
   127 
   240 
   128 /*!                                                                                                
   241 /*!                                                                                                
   129 **                                                                                                 
   242 **                                                                                                 
   157 {
   270 {
   158   Message m;
   271   Message m;
   159   UNS8 i;
   272   UNS8 i;
   160   
   273   
   161   if (!d->CurrentCommunicationState.csLSS){
   274   if (!d->CurrentCommunicationState.csLSS){
   162   	MSG_WAR(0x2D0A, "unable to send the LSS message (not in stop or pre-op mode", d->nodeState);
   275   	MSG_WAR(0x2D0C, "unable to send the LSS message, not in the proper state =>", d->nodeState);
   163   	return 0;
   276   	return 0xFF;
   164   }
   277   }
   165    
   278    
   166   for(i=1;i<8;i++)m.data[i]=0;
   279   for(i=1;i<8;i++)m.data[i]=0;
   167   m.len = 8;
   280   m.len = 8;
   168   m.rtr = NOT_A_REQUEST;
   281   m.rtr = NOT_A_REQUEST;
   192   case LSS_SM_SELECTIVE_RESP: /* Switch Mode Selective response*/
   305   case LSS_SM_SELECTIVE_RESP: /* Switch Mode Selective response*/
   193   case LSS_IDENT_SLAVE: /* LSS Identify Slave */
   306   case LSS_IDENT_SLAVE: /* LSS Identify Slave */
   194   case LSS_IDENT_NON_CONF_SLAVE: /* LSS identify non-configured remote slave */
   307   case LSS_IDENT_NON_CONF_SLAVE: /* LSS identify non-configured remote slave */
   195   	break;
   308   	break;
   196   default:
   309   default:
   197   	MSG_ERR(0x1D0B, "send Slave LSS command not implemented", command);
   310   	MSG_ERR(0x1D0D, "send Slave LSS command not implemented", command);
   198   	return 0xFF;
   311   	return 0xFF;
   199   break;
       
   200   }
   312   }
   201   
   313   
   202   return canSend(d->canHandle,&m);
   314   return canSend(d->canHandle,&m);
   203 }
   315 }
   204 
   316 
   257   case LSS_INQ_PRODUCT_CODE: /* Inquire Identity Product-Code */
   369   case LSS_INQ_PRODUCT_CODE: /* Inquire Identity Product-Code */
   258   case LSS_INQ_REV_NUMBER: /* Inquire Identity Revision-Number */
   370   case LSS_INQ_REV_NUMBER: /* Inquire Identity Revision-Number */
   259   case LSS_INQ_SERIAL_NUMBER: /* Inquire Identity Serial-Number */
   371   case LSS_INQ_SERIAL_NUMBER: /* Inquire Identity Serial-Number */
   260   case LSS_INQ_NODE_ID: /* Inquire Node-ID */
   372   case LSS_INQ_NODE_ID: /* Inquire Node-ID */
   261   	break;
   373   	break;
       
   374 #ifdef CO_ENABLE_LSS_FS
   262   case LSS_IDENT_FASTSCAN:
   375   case LSS_IDENT_FASTSCAN:
   263 		m.data[1]=(UNS8)(d->lss_transfer.IDNumber & 0xFF);
   376 		m.data[1]=(UNS8)(d->lss_transfer.IDNumber & 0xFF);
   264 		m.data[2]=(UNS8)(d->lss_transfer.IDNumber>>8 & 0xFF);
   377 		m.data[2]=(UNS8)(d->lss_transfer.IDNumber>>8 & 0xFF);
   265 		m.data[3]=(UNS8)(d->lss_transfer.IDNumber>>16 & 0xFF);
   378 		m.data[3]=(UNS8)(d->lss_transfer.IDNumber>>16 & 0xFF);
   266 		m.data[4]=(UNS8)(d->lss_transfer.IDNumber>>24 & 0xFF);
   379 		m.data[4]=(UNS8)(d->lss_transfer.IDNumber>>24 & 0xFF);
   267 		m.data[5]=d->lss_transfer.BitChecked;
   380 		m.data[5]=d->lss_transfer.BitChecked;
   268 		m.data[6]=d->lss_transfer.LSSSub;
   381 		m.data[6]=d->lss_transfer.LSSSub;
   269 		m.data[7]=d->lss_transfer.LSSNext;
   382 		m.data[7]=d->lss_transfer.LSSNext;
   270 	break;
   383 	break;
       
   384 #endif
   271   default:
   385   default:
   272    	MSG_ERR(0x1D0C, "send Master LSS command not implemented", command);
   386    	MSG_ERR(0x1D0E, "send Master LSS command not implemented", command);
   273   	return 0xFF;
   387   	return 0xFF;
   274   break;
       
   275   }
   388   }
   276 	
   389 	
   277   return canSend(d->canHandle,&m);
   390   return canSend(d->canHandle,&m);
   278 }
   391 }
   279 
   392 
   312 { 
   425 { 
   313 	UNS8 msg_cs;
   426 	UNS8 msg_cs;
   314 	UNS32 Dat1=0;
   427 	UNS32 Dat1=0;
   315 	UNS8 Dat2=0;
   428 	UNS8 Dat2=0;
   316 	
   429 	
   317  	MSG_WAR(0x3D0D, "MasterLSS proceedLSS; command ", m->data[0]);
   430 	if(d->lss_transfer.state!=LSS_TRANS_IN_PROGRESS)
   318 	StopLSS_TIMER(LSS_MSG_TIMER);
   431 	{
   319     /* Set state */
   432 		//MSG_WAR(0x3D0D, "MasterLSS proceedLSS; unexpected message arrived;command ", m->data[0]);
   320     d->lss_transfer.state = LSS_FINISHED;
   433 		//return 0;
       
   434 		goto ErrorProcessMaster;
       
   435 	}
       
   436 	
       
   437 	//#ifdef CO_ENABLE_LSS_FS
       
   438 	/* The FastScan protocol doesn't stops the timers when a message has been received */
       
   439 	/*if(d->lss_transfer.command!=LSS_IDENT_FASTSCAN)
       
   440 #endif
       
   441 	{
       
   442 		StopLSS_TIMER(LSS_MSG_TIMER);
       
   443     	d->lss_transfer.state = LSS_FINISHED;
       
   444 	}*/
       
   445 	
       
   446  	MSG_WAR(0x3D0F, "MasterLSS proceedLSS; command ", m->data[0]);
   321 	
   447 	
   322    	switch(msg_cs=m->data[0]){
   448    	switch(msg_cs=m->data[0]){
   323    		case LSS_INQ_NODE_ID: /* Inquire Node-ID */
   449    		case LSS_INQ_NODE_ID: /* Inquire Node-ID */
       
   450    			if(d->lss_transfer.command!=LSS_INQ_NODE_ID)goto ErrorProcessMaster;
   324    			Dat1=m->data[1];
   451    			Dat1=m->data[1];
   325    			break;
   452    			break;
   326    		case LSS_CONF_NODE_ID: /* Configure Node-ID */
   453    		case LSS_CONF_NODE_ID: /* Configure Node-ID */
   327    		case LSS_CONF_BIT_TIMING: /* Configure Bit Timing Parameters */
   454    		case LSS_CONF_BIT_TIMING: /* Configure Bit Timing Parameters */
   328    		case LSS_CONF_STORE: /* Store Configured Parameters */
   455    		case LSS_CONF_STORE: /* Store Configured Parameters */
       
   456    			if(d->lss_transfer.command!=msg_cs)goto ErrorProcessMaster;
   329    			Dat1=m->data[1];
   457    			Dat1=m->data[1];
   330    			Dat2=m->data[2];
   458    			Dat2=m->data[2];
   331    			break;
   459    			break;
   332    		case LSS_INQ_VENDOR_ID: /* Inquire Identity Vendor-ID */
   460    		case LSS_INQ_VENDOR_ID: /* Inquire Identity Vendor-ID */
   333    		case LSS_INQ_PRODUCT_CODE: /* Inquire Identity Product-Code */
   461    		case LSS_INQ_PRODUCT_CODE: /* Inquire Identity Product-Code */
   334    		case LSS_INQ_REV_NUMBER: /* Inquire Identity Revision-Number */
   462    		case LSS_INQ_REV_NUMBER: /* Inquire Identity Revision-Number */
   335    		case LSS_INQ_SERIAL_NUMBER: /* Inquire Identity Serial-Number */
   463    		case LSS_INQ_SERIAL_NUMBER: /* Inquire Identity Serial-Number */
       
   464    			if(d->lss_transfer.command!=msg_cs)goto ErrorProcessMaster;
   336    			Dat1=getLSSIdent(m);
   465    			Dat1=getLSSIdent(m);
   337  			break;
   466  			break;
   338  		case LSS_IDENT_SLAVE: /* LSS Identify Slave */
   467  		case LSS_IDENT_SLAVE: /* LSS Identify Slave */
   339    			/*if(d->lss_transfer.command==LSS_IDENT_FASTSCAN){
   468 #ifdef CO_ENABLE_LSS_FS
   340    			 * ************ TODO *******************
   469    			if(d->lss_transfer.command==LSS_IDENT_FASTSCAN){
   341   			}*/
   470    				/* A message arrived during the timer period */
       
   471    				d->lss_transfer.LSSanswer=1;
       
   472    				return 0;
       
   473   			}
       
   474   			else
       
   475 #endif
       
   476 			if(d->lss_transfer.command!=LSS_IDENT_REMOTE_VENDOR && \
       
   477  				d->lss_transfer.command!=LSS_IDENT_REMOTE_PRODUCT && \
       
   478  				d->lss_transfer.command!=LSS_IDENT_REMOTE_REV_LOW && \
       
   479  				d->lss_transfer.command!=LSS_IDENT_REMOTE_REV_HIGH && \
       
   480  				d->lss_transfer.command!=LSS_IDENT_REMOTE_SERIAL_LOW && \
       
   481  				d->lss_transfer.command!=LSS_IDENT_REMOTE_SERIAL_HIGH )
       
   482  					goto ErrorProcessMaster;
   342   		break;
   483   		break;
   343  		case LSS_SM_SELECTIVE_RESP: /* Switch Mode Selective response */
   484  		case LSS_SM_SELECTIVE_RESP: /* Switch Mode Selective response */
       
   485  			if(d->lss_transfer.command!=LSS_SM_SELECTIVE_VENDOR && \
       
   486  				d->lss_transfer.command!=LSS_SM_SELECTIVE_PRODUCT && \
       
   487  				d->lss_transfer.command!=LSS_SM_SELECTIVE_REVISION && \
       
   488  				d->lss_transfer.command!=LSS_SM_SELECTIVE_SERIAL )
       
   489  					goto ErrorProcessMaster;
       
   490  			break;
   344    		case LSS_IDENT_NON_CONF_SLAVE: /* LSS identify non-configured remote slave */
   491    		case LSS_IDENT_NON_CONF_SLAVE: /* LSS identify non-configured remote slave */
       
   492    			if(d->lss_transfer.command!=LSS_IDENT_REMOTE_NON_CONF)goto ErrorProcessMaster;
   345    			break;
   493    			break;
   346    		default:
   494    		default:
   347    			MSG_ERR(0x1D0E, "Master LSS command not implemented", msg_cs);
   495    			MSG_ERR(0x1D10, "Master LSS command not implemented", msg_cs);
   348   			return 0xFF;
   496   			return 0xFF;
   349    		break;
       
   350    	}
   497    	}
   351 
   498 	
       
   499 	StopLSS_TIMER(LSS_MSG_TIMER);
       
   500     d->lss_transfer.state = LSS_FINISHED;
       
   501     	
   352 	d->lss_transfer.dat1=Dat1;
   502 	d->lss_transfer.dat1=Dat1;
   353 	d->lss_transfer.dat2=Dat2;
   503 	d->lss_transfer.dat2=Dat2;
   354  	/* If there is a callback, it is responsible of the received response */
   504  	/* If there is a callback, it is responsible of the received response */
   355 	if(d->lss_transfer.Callback)
   505 	if(d->lss_transfer.Callback)
   356     	(*d->lss_transfer.Callback)(d,msg_cs);
   506     	(*d->lss_transfer.Callback)(d,d->lss_transfer.command);
   357     			
   507     			
   358    return 0;
   508    return 0;
       
   509    
       
   510 ErrorProcessMaster:
       
   511     MSG_WAR(0x3D11, "MasterLSS proceedLSS; unexpected message arrived;command ", m->data[0]);
       
   512 	return 0xFF;
       
   513 		
   359 }
   514 }
   360 
   515 
   361 /*!                                                                                                
   516 /*!                                                                                                
   362 **                                                                                                 
   517 **                                                                                                 
   363 **                                                                                                 
   518 **                                                                                                 
   368 **/ 
   523 **/ 
   369 UNS8 proceedLSS_Slave(CO_Data* d, Message* m )
   524 UNS8 proceedLSS_Slave(CO_Data* d, Message* m )
   370 {  
   525 {  
   371 	UNS8 msg_cs;
   526 	UNS8 msg_cs;
   372 	
   527 	
   373   	MSG_WAR(0x3D0F, "SlaveLSS proceedLSS; command ", m->data[0]);
   528   	MSG_WAR(0x3D12, "SlaveLSS proceedLSS; command ", m->data[0]);
   374   	
   529   	
   375    	switch(msg_cs=m->data[0]){
   530    	switch(msg_cs=m->data[0]){
   376    	case LSS_SM_GLOBAL:		/* Switch Mode Global */
   531    	case LSS_SM_GLOBAL:		/* Switch Mode Global */
   377    		/* if there is not a mode change break*/
   532    		/* if there is not a mode change break*/
   378    		if(m->data[1] == d->lss_transfer.mode){
   533    		if(m->data[1] == d->lss_transfer.mode){
   379    			MSG_WAR(0x3D10, "SlaveLSS already in the mode ", m->data[1]);
   534    			MSG_WAR(0x3D13, "SlaveLSS already in the mode ", m->data[1]);
   380    			break;
   535    			break;
   381    		}
   536    		}
   382    		
   537    		
   383 		if(m->data[1]==LSS_CONFIGURATION_MODE)	{
   538 		if(m->data[1]==LSS_CONFIGURATION_MODE)	{
   384 			MSG_WAR(0x3D11, "SlaveLSS switching to configuration mode ", 0);
   539 			MSG_WAR(0x3D14, "SlaveLSS switching to configuration mode ", 0);
   385 			/* Store the NodeId in case it will be changed */
   540 			/* Store the NodeId in case it will be changed */
   386 			d->lss_transfer.nodeID=getNodeId(d);
   541 			d->lss_transfer.nodeID=getNodeId(d);
   387 			d->lss_transfer.mode=LSS_CONFIGURATION_MODE;
   542 			d->lss_transfer.mode=LSS_CONFIGURATION_MODE;
   388 		}
   543 		}
   389 		else if(m->data[1]==LSS_WAITING_MODE){
   544 		else if(m->data[1]==LSS_WAITING_MODE){
   390 			MSG_WAR(0x3D12, "SlaveLSS switching to operational mode ", 0);
   545 			MSG_WAR(0x3D15, "SlaveLSS switching to operational mode ", 0);
   391 			
   546 			
   392 			if(d->lss_transfer.switchDelayState==SDELAY_OFF){
   547 			if(d->lss_transfer.switchDelayState==SDELAY_OFF){
   393 				/* If the nodeID has changed update it and put the node state to Initialisation. */
   548 				/* If the nodeID has changed update it and put the node state to Initialisation. */
   394 				if(d->lss_transfer.nodeID!=getNodeId(d)){
   549 				if(d->lss_transfer.nodeID!=getNodeId(d)){
   395 					MSG_WAR(0x3D13, "The node Id has changed. Reseting to Initialisation state",0);
   550 					MSG_WAR(0x3D16, "The node Id has changed. Reseting to Initialisation state",0);
   396 					setNodeId(d, d->lss_transfer.nodeID);
   551 					setNodeId(d, d->lss_transfer.nodeID);
   397 					setState(d, Initialisation);
   552 					setState(d, Initialisation);
   398 				}
   553 				}
   399 			}
   554 			}
   400 			d->lss_transfer.mode=LSS_WAITING_MODE;
   555 			d->lss_transfer.mode=LSS_WAITING_MODE;
   405 		UNS8 error_code=0;
   560 		UNS8 error_code=0;
   406 		UNS8 spec_error=0;
   561 		UNS8 spec_error=0;
   407 			
   562 			
   408 		if(d->lss_transfer.mode==LSS_CONFIGURATION_MODE){
   563 		if(d->lss_transfer.mode==LSS_CONFIGURATION_MODE){
   409 			if(m->data[1]>127 && m->data[1]!=0xFF){
   564 			if(m->data[1]>127 && m->data[1]!=0xFF){
   410 				MSG_ERR(0x1D14, "NodeID out of range",0);
   565 				MSG_ERR(0x1D17, "NodeID out of range",0);
   411 				error_code=1; /* NodeID out of range */
   566 				error_code=1; /* NodeID out of range */
   412 			}
   567 			}
   413 			else{
   568 			else{
   414 				d->lss_transfer.nodeID=m->data[1];
   569 				d->lss_transfer.nodeID=m->data[1];
   415 			}
   570 			}
   416 		}
   571 		}
   417 		else{
   572 		else{
   418 			MSG_ERR(0x1D15, "SlaveLSS not in configuration mode",0);
   573 			MSG_WAR(0x3D18, "SlaveLSS not in configuration mode",0);
   419 			error_code=0xFF;
   574 			//error_code=0xFF;
       
   575 			break;
   420 		}
   576 		}
   421 		sendSlaveLSSMessage(d,msg_cs,&error_code,&spec_error);
   577 		sendSlaveLSSMessage(d,msg_cs,&error_code,&spec_error);
   422 	}	
   578 	}	
   423 	break;
   579 	break;
   424 	case LSS_CONF_BIT_TIMING: /* Configure Bit Timing Parameters */
   580 	case LSS_CONF_BIT_TIMING: /* Configure Bit Timing Parameters */
   441 				case 0x05:d->lss_transfer.baudRate="100K";break;
   597 				case 0x05:d->lss_transfer.baudRate="100K";break;
   442 				case 0x06:d->lss_transfer.baudRate="50K";break;
   598 				case 0x06:d->lss_transfer.baudRate="50K";break;
   443 				case 0x07:d->lss_transfer.baudRate="20K";break;
   599 				case 0x07:d->lss_transfer.baudRate="20K";break;
   444 				case 0x08:d->lss_transfer.baudRate="10K";break;
   600 				case 0x08:d->lss_transfer.baudRate="10K";break;
   445 				default:
   601 				default:
   446 					MSG_ERR(0x1D16, "Baud rate not supported",0);
   602 					MSG_ERR(0x1D19, "Baud rate not supported",0);
   447 					error_code=0xFF; /* Baud rate not supported*/
   603 					error_code=0xFF; /* Baud rate not supported*/
   448 					break; 
   604 					break; 
   449 				}		
   605 				}		
   450 			}
   606 			}
   451 			else
   607 			else
   452 			{
   608 			{
   453 				MSG_ERR(0x1D17, "Bit timing not supported",0);
   609 				MSG_ERR(0x1D1A, "Bit timing not supported",0);
   454 				error_code=0x01; /* bit timing not supported */
   610 				error_code=0x01; /* bit timing not supported */
   455 			}
   611 			}
   456 		}
   612 		}
   457 		else{
   613 		else{
   458 			MSG_ERR(0x1D18, "SlaveLSS not in configuration mode",0);
   614 			MSG_WAR(0x3D1B, "SlaveLSS not in configuration mode",0);
   459 			error_code=0xFF;
   615 			//error_code=0xFF;
       
   616 			break;
   460 		}
   617 		}
   461 		
   618 		
   462 		sendSlaveLSSMessage(d,msg_cs,&error_code,&spec_error);
   619 		sendSlaveLSSMessage(d,msg_cs,&error_code,&spec_error);
   463 	}
   620 	}
   464 	break;
   621 	break;
   465 	case LSS_CONF_ACT_BIT_TIMING: /* Activate Bit Timing Parameters */
   622 	case LSS_CONF_ACT_BIT_TIMING: /* Activate Bit Timing Parameters */
   466 		
   623 		
   467 		if(d->lss_transfer.mode!=LSS_CONFIGURATION_MODE){
   624 		if(d->lss_transfer.mode!=LSS_CONFIGURATION_MODE){
   468 			MSG_ERR(0x1D19, "SlaveLSS not in configuration mode",0);
   625 			MSG_ERR(0x3D1C, "SlaveLSS not in configuration mode",0);
   469 			break;
   626 			break;
   470 		}
   627 		}
   471 		
   628 		
   472 		if(d->lss_transfer.baudRate!="none"){
   629 		if(d->lss_transfer.baudRate!="none"){
   473 			d->lss_transfer.switchDelay=getLSSDelay(m);
   630 			d->lss_transfer.switchDelay=getLSSDelay(m);
   474 			MSG_WAR(0x3D1A, "Slave Switch Delay set to: ",d->lss_transfer.switchDelay);
   631 			MSG_WAR(0x3D1D, "Slave Switch Delay set to: ",d->lss_transfer.switchDelay);
   475 			d->lss_transfer.switchDelayState=SDELAY_FIRST;
   632 			d->lss_transfer.switchDelayState=SDELAY_FIRST;
   476 			d->lss_transfer.currentState=getState(d);
   633 			d->lss_transfer.currentState=getState(d);
   477 			setState(d, LssTimingDelay);
   634 			setState(d, LssTimingDelay);
   478 			StartLSS_SDELAY_TIMER();
   635 			StartLSS_SDELAY_TIMER();
   479 		}
   636 		}
   487 			if(d->lss_StoreConfiguration){
   644 			if(d->lss_StoreConfiguration){
   488 				 /* call lss_StoreConfiguration with NodeId */
   645 				 /* call lss_StoreConfiguration with NodeId */
   489 	  			(*d->lss_StoreConfiguration)(&error_code,&spec_error);
   646 	  			(*d->lss_StoreConfiguration)(&error_code,&spec_error);
   490 			}
   647 			}
   491 			else{
   648 			else{
   492 				MSG_ERR(0x1D1B, "Store configuration not supported",0);
   649 				MSG_ERR(0x1D1E, "Store configuration not supported",0);
   493 				error_code=1; /* store configuration is not supported */
   650 				error_code=1; /* store configuration is not supported */
   494 			}	
   651 			}	
   495 		}
   652 		}
   496 		else{
   653 		else{
   497 			MSG_ERR(0x1D1C, "SlaveLSS not in configuration mode",0);
   654 			MSG_WAR(0x3D1F, "SlaveLSS not in configuration mode",0);
   498 			error_code=0xFF;
   655 			//error_code=0xFF;
       
   656 			break;
   499 		}
   657 		}
   500 		sendSlaveLSSMessage(d,msg_cs,&error_code,&spec_error);
   658 		sendSlaveLSSMessage(d,msg_cs,&error_code,&spec_error);
   501 	}
   659 	}
   502 	break;
   660 	break;
   503 	case LSS_SM_SELECTIVE_VENDOR:	/* Switch Mode Selective */
   661 	case LSS_SM_SELECTIVE_VENDOR:	/* Switch Mode Selective */
   510   		ODCallback_t *Callback;
   668   		ODCallback_t *Callback;
   511   		UNS32 _SpecificNodeInfo;
   669   		UNS32 _SpecificNodeInfo;
   512   
   670   
   513   		if(d->lss_transfer.mode==LSS_CONFIGURATION_MODE)
   671   		if(d->lss_transfer.mode==LSS_CONFIGURATION_MODE)
   514   		{
   672   		{
   515   			MSG_ERR(0x1D1D, "Switch Mode Selective only supported in operational mode",0);
   673   			MSG_ERR(0x1D20, "Switch Mode Selective only supported in operational mode",0);
   516   			break;
   674   			break;
   517   		}
   675   		}
   518   			
   676   			
   519 		_SpecificNodeInfo=getLSSIdent(m);
   677 		_SpecificNodeInfo=getLSSIdent(m);
   520 				
   678 				
   523 			
   681 			
   524 			d->lss_transfer.addr_sel_match|=(0x01<<(msg_cs-LSS_SM_SELECTIVE_VENDOR));
   682 			d->lss_transfer.addr_sel_match|=(0x01<<(msg_cs-LSS_SM_SELECTIVE_VENDOR));
   525 			/* If all the fields has been set */
   683 			/* If all the fields has been set */
   526 			if(d->lss_transfer.addr_sel_match==0x0F){
   684 			if(d->lss_transfer.addr_sel_match==0x0F){
   527 				
   685 				
   528 				MSG_WAR(0x3D1E, "SlaveLSS switching to configuration mode ", 0);
   686 				MSG_WAR(0x3D21, "SlaveLSS switching to configuration mode ", 0);
   529 				d->lss_transfer.addr_sel_match=0;
   687 				d->lss_transfer.addr_sel_match=0;
   530 				d->lss_transfer.nodeID=getNodeId(d);
   688 				d->lss_transfer.nodeID=getNodeId(d);
   531 				d->lss_transfer.mode=LSS_CONFIGURATION_MODE;
   689 				d->lss_transfer.mode=LSS_CONFIGURATION_MODE;
   532 
   690 
   533 				sendSlaveLSSMessage(d,LSS_SM_SELECTIVE_RESP,0,0);
   691 				sendSlaveLSSMessage(d,LSS_SM_SELECTIVE_RESP,0,0);
   534 			}
   692 			}
   535 		}	
   693 		}	
   536 		else {
   694 		else {
   537 			MSG_WAR(0x3D1F, "LSS identity field doesn't match ", _SpecificNodeInfo);
   695 			MSG_WAR(0x3D22, "LSS identity field doesn't match ", _SpecificNodeInfo);
   538 			d->lss_transfer.addr_sel_match=0;
   696 			d->lss_transfer.addr_sel_match=0;
   539 		}	
   697 		}	
   540 	}	
   698 	}	
   541 	break;
   699 	break;
   542 	case LSS_IDENT_REMOTE_VENDOR: /* LSS Identify Remote Slaves */
   700 	case LSS_IDENT_REMOTE_VENDOR: /* LSS Identify Remote Slaves */
   564 		case LSS_IDENT_REMOTE_SERIAL_LOW:d->lss_transfer.addr_ident_match=(_SpecificNodeInfo <= *(UNS32*)ptrTable->pSubindex[4].pObject)? d->lss_transfer.addr_ident_match|0x10:0;	break;
   722 		case LSS_IDENT_REMOTE_SERIAL_LOW:d->lss_transfer.addr_ident_match=(_SpecificNodeInfo <= *(UNS32*)ptrTable->pSubindex[4].pObject)? d->lss_transfer.addr_ident_match|0x10:0;	break;
   565 		case LSS_IDENT_REMOTE_SERIAL_HIGH:d->lss_transfer.addr_ident_match=(_SpecificNodeInfo >= *(UNS32*)ptrTable->pSubindex[4].pObject)? d->lss_transfer.addr_ident_match|0x20:0;	break;
   723 		case LSS_IDENT_REMOTE_SERIAL_HIGH:d->lss_transfer.addr_ident_match=(_SpecificNodeInfo >= *(UNS32*)ptrTable->pSubindex[4].pObject)? d->lss_transfer.addr_ident_match|0x20:0;	break;
   566 		}
   724 		}
   567 		/* If all the fields has been set.. */
   725 		/* If all the fields has been set.. */
   568 		if(d->lss_transfer.addr_ident_match==0x3F){
   726 		if(d->lss_transfer.addr_ident_match==0x3F){
   569 			MSG_WAR(0x3D20, "SlaveLSS identified ", 0);
   727 			MSG_WAR(0x3D23, "SlaveLSS identified ", 0);
   570 			d->lss_transfer.addr_ident_match=0;
   728 			d->lss_transfer.addr_ident_match=0;
   571 			sendSlaveLSSMessage(d,LSS_IDENT_SLAVE,0,0);
   729 			sendSlaveLSSMessage(d,LSS_IDENT_SLAVE,0,0);
   572 		}
   730 		}
   573 		else if(d->lss_transfer.addr_ident_match==0){
   731 		else if(d->lss_transfer.addr_ident_match==0){
   574 			MSG_WAR(0x3D21, "LSS identify field doesn't match ", _SpecificNodeInfo);
   732 			MSG_WAR(0x3D24, "LSS identify field doesn't match ", _SpecificNodeInfo);
   575 		}
   733 		}
   576 	}
   734 	}
   577 	break;
   735 	break;
   578 	case LSS_IDENT_REMOTE_NON_CONF: /* LSS identify non-configured remote slave */
   736 	case LSS_IDENT_REMOTE_NON_CONF: /* LSS identify non-configured remote slave */
   579 	{
   737 	{
   580 		if(getNodeId(d)==0xFF){		
   738 		if(getNodeId(d)==0xFF){		
   581 			MSG_WAR(0x3D22, "SlaveLSS non-configured ", 0);
   739 			MSG_WAR(0x3D25, "SlaveLSS non-configured ", 0);
   582 			sendSlaveLSSMessage(d,LSS_IDENT_NON_CONF_SLAVE,0,0);
   740 			sendSlaveLSSMessage(d,LSS_IDENT_NON_CONF_SLAVE,0,0);
   583 		}
   741 		}
   584 		else{
   742 		else{
   585 			MSG_WAR(0x3D23, "SlaveLSS already configured ", 0);
   743 			MSG_WAR(0x3D26, "SlaveLSS already configured ", 0);
   586 		}
   744 		}
   587 	}
   745 	}
   588 	break;
   746 	break;
   589 	case LSS_INQ_VENDOR_ID: /* Inquire Identity Vendor-ID */
   747 	case LSS_INQ_VENDOR_ID: /* Inquire Identity Vendor-ID */
   590 	case LSS_INQ_PRODUCT_CODE: /* Inquire Identity Product-Code */
   748 	case LSS_INQ_PRODUCT_CODE: /* Inquire Identity Product-Code */
   598   		ODCallback_t *Callback;
   756   		ODCallback_t *Callback;
   599   		UNS32 _SpecificNodeInfo;
   757   		UNS32 _SpecificNodeInfo;
   600   
   758   
   601   		ptrTable = (*d->scanIndexOD)(0x1018, &errorCode, &Callback);
   759   		ptrTable = (*d->scanIndexOD)(0x1018, &errorCode, &Callback);
   602   		_SpecificNodeInfo=*(UNS32*)ptrTable->pSubindex[msg_cs-(LSS_INQ_VENDOR_ID-1)].pObject;
   760   		_SpecificNodeInfo=*(UNS32*)ptrTable->pSubindex[msg_cs-(LSS_INQ_VENDOR_ID-1)].pObject;
   603   		MSG_WAR(0x3D24, "SlaveLSS identity field inquired ", _SpecificNodeInfo);
   761   		MSG_WAR(0x3D27, "SlaveLSS identity field inquired ", _SpecificNodeInfo);
   604 			
   762 			
   605 		sendSlaveLSSMessage(d,msg_cs,&_SpecificNodeInfo,0);
   763 		sendSlaveLSSMessage(d,msg_cs,&_SpecificNodeInfo,0);
   606 	}
   764 	}
   607 	break;
   765 	break;
   608 	case LSS_INQ_NODE_ID: /* Inquire Node-ID */
   766 	case LSS_INQ_NODE_ID: /* Inquire Node-ID */
   609 		if(d->lss_transfer.mode==LSS_CONFIGURATION_MODE)
   767 		if(d->lss_transfer.mode==LSS_CONFIGURATION_MODE)
   610 		{
   768 		{
   611 			UNS8 NodeID;
   769 			UNS8 NodeID;
   612 	
   770 	
   613 			NodeID=getNodeId(d);
   771 			NodeID=getNodeId(d);
   614 			MSG_WAR(0x3D25, "SlaveLSS Node ID inquired ", NodeID);
   772 			MSG_WAR(0x3D28, "SlaveLSS Node ID inquired ", NodeID);
   615 			sendSlaveLSSMessage(d,msg_cs,&NodeID,0);
   773 			sendSlaveLSSMessage(d,msg_cs,&NodeID,0);
   616 		}
   774 		}
   617 		else{
   775 		else{
   618 			MSG_ERR(0x1D26, "SlaveLSS not in configuration mode",0);
   776 			MSG_WAR(0x3D29, "SlaveLSS not in configuration mode",0);
   619 		}
   777 		}
   620 	break;
   778 	break;
       
   779 #ifdef CO_ENABLE_LSS_FS
   621 	case LSS_IDENT_FASTSCAN:
   780 	case LSS_IDENT_FASTSCAN:
   622 	{
   781 	{
   623 		/******* TODO *******/
   782 		/* If the nodeID isn't 0xFF the slave shall not participate  */
       
   783 		if(getNodeId(d)!=0xFF)break;
       
   784 		if(getLSSBitCheck(m)==128)d->lss_transfer.FastScan_SM=LSS_FS_RESET;
       
   785 		
       
   786    		switch(d->lss_transfer.FastScan_SM){
       
   787    		case LSS_FS_RESET:
       
   788    		{
       
   789    			UNS32 errorCode;
       
   790   			const indextable *ptrTable;
       
   791   			ODCallback_t *Callback;
       
   792   				
       
   793 			MSG_WAR(0x3D2A, "SlaveLSS Reseting LSSPos", 0);
       
   794 			d->lss_transfer.LSSPos=0;
       
   795 			d->lss_transfer.FastScan_SM=LSS_FS_PROCESSING;
       
   796 			
       
   797   			ptrTable = (*d->scanIndexOD)(0x1018, &errorCode, &Callback);
       
   798   			d->lss_transfer.IDNumber=*(UNS32*)ptrTable->pSubindex[d->lss_transfer.LSSPos+1].pObject;
       
   799 			
       
   800 			sendSlaveLSSMessage(d,LSS_IDENT_SLAVE,0,0);
       
   801    		}
       
   802 		break;
       
   803 		case LSS_FS_PROCESSING:/*if(getLSSBitCheck(m)<32)*/
       
   804 			if(d->lss_transfer.LSSPos==getLSSSub(m))
       
   805 			{
       
   806 				UNS32 Mask=0xFFFFFFFF<<getLSSBitCheck(m);
       
   807 				
       
   808 				MSG_WAR(0x3D2B, "SlaveLSS FastScan IDNumber", getLSSIdent(m));
       
   809 				MSG_WAR(0x3D2C, "SlaveLSS FastScan BitMask ", Mask);
       
   810 				MSG_WAR(0x3D2D, "SlaveLSS FastScan LSS-ID  ", d->lss_transfer.IDNumber);
       
   811 				
       
   812 				if((getLSSIdent(m) & Mask)==(d->lss_transfer.IDNumber & Mask))
       
   813 				{
       
   814 					sendSlaveLSSMessage(d,LSS_IDENT_SLAVE,0,0);
       
   815 				}
       
   816 				
       
   817 				if(getLSSBitCheck(m)==0)
       
   818 				{
       
   819 					d->lss_transfer.FastScan_SM=LSS_FS_CONFIRMATION;
       
   820 				}
       
   821 			}
       
   822 			break;
       
   823 		case LSS_FS_CONFIRMATION:
       
   824 			if(d->lss_transfer.LSSPos==getLSSSub(m))
       
   825 			{
       
   826 				if(getLSSIdent(m)==d->lss_transfer.IDNumber)
       
   827 				{
       
   828 					/* Current LSS-ID[sub] confirmed correctly */
       
   829 					MSG_WAR(0x3D2E, "SlaveLSS FastScan IDNumber and LSS-ID match=>", d->lss_transfer.IDNumber);
       
   830 					if(d->lss_transfer.LSSPos==3)
       
   831 					{
       
   832 						/* All LSS-ID[sub] identified correctly, switching to configuration mode */
       
   833 						MSG_WAR(0x3D2F, "SlaveLSS switching to configuration mode ", 0);
       
   834 			   			d->lss_transfer.nodeID=getNodeId(d);
       
   835 			   			d->lss_transfer.mode=LSS_CONFIGURATION_MODE;
       
   836 			    		d->lss_transfer.FastScan_SM=LSS_FS_RESET;
       
   837 			    		d->lss_transfer.LSSPos=0xFF;
       
   838 					}		
       
   839 					else
       
   840 					{
       
   841 						/* Switch to the next LSS-ID[sub] */
       
   842 						UNS32 errorCode;
       
   843   						const indextable *ptrTable;
       
   844   						ODCallback_t *Callback;
       
   845 		
       
   846 						d->lss_transfer.LSSPos=getLSSNext(m);
       
   847 						ptrTable = (*d->scanIndexOD)(0x1018, &errorCode, &Callback);
       
   848   						d->lss_transfer.IDNumber=*(UNS32*)ptrTable->pSubindex[d->lss_transfer.LSSPos+1].pObject;
       
   849 						d->lss_transfer.FastScan_SM=LSS_FS_PROCESSING;						
       
   850 					}
       
   851 					sendSlaveLSSMessage(d,LSS_IDENT_SLAVE,0,0);
       
   852 				}
       
   853 			}
       
   854 			break;
       
   855 		}
   624 	}	
   856 	}	
   625 	break;
   857 	break;
       
   858 #endif
   626    	default:
   859    	default:
   627    		MSG_ERR(0x1D27, "SlaveLSS command not implemented", msg_cs);
   860    		MSG_ERR(0x1D30, "SlaveLSS command not implemented", msg_cs);
   628   		return 0xFF;
   861   		return 0xFF;
   629   		break;
       
   630    	}
   862    	}
   631    
   863    
   632     return 0;
   864     return 0;
   633 }
   865 }
   634 
   866