examples/TestMasterSlaveLSS/Master.c
changeset 738 396839c5d70f
parent 718 0b33d9cdbdeb
equal deleted inserted replaced
716:a28fc90dc23e 738:396839c5d70f
    39  ********************************************************/
    39  ********************************************************/
    40 void TestMaster_initialisation(CO_Data* d)
    40 void TestMaster_initialisation(CO_Data* d)
    41 {
    41 {
    42 	UNS32 PDO1_COBID = 0x0182; 
    42 	UNS32 PDO1_COBID = 0x0182; 
    43 	UNS32 PDO2_COBID = 0x0183;
    43 	UNS32 PDO2_COBID = 0x0183;
    44 	UNS8 size = sizeof(UNS32); 
    44 	UNS32 size = sizeof(UNS32); 
    45 	
    45 	
    46 	eprintf("TestMaster_initialisation\n");
    46 	eprintf("TestMaster_initialisation\n");
    47 
    47 
    48 	/*****************************************
    48 	/*****************************************
    49 	 * Define RPDO to match slave ID=2 TPDO1*
    49 	 * Define RPDO to match slave ID=2 TPDO1*
    76 
    76 
    77 static void CheckSDOAndContinue(CO_Data* d, UNS8 nodeId)
    77 static void CheckSDOAndContinue(CO_Data* d, UNS8 nodeId)
    78 {
    78 {
    79 	UNS32 abortCode;	
    79 	UNS32 abortCode;	
    80 	if(getWriteResultNetworkDict (d, nodeId, &abortCode) != SDO_FINISHED)
    80 	if(getWriteResultNetworkDict (d, nodeId, &abortCode) != SDO_FINISHED)
    81 		eprintf("Master : Failed in initializing slave %2.2x, step %d, AbortCode :%4.4x \n", nodeId, init_step, abortCode);
    81 		eprintf("Master : Failed in initializing slave %2.2x, AbortCode :%4.4x \n", nodeId, abortCode);
    82 
    82 
    83 	/* Finalise last SDO transfer with this node */
    83 	/* Finalise last SDO transfer with this node */
    84 	closeSDOtransfer(&TestMaster_Data, nodeId, SDO_CLIENT);
    84 	closeSDOtransfer(&TestMaster_Data, nodeId, SDO_CLIENT);
    85 
    85 
    86 	ConfigureSlaveNode(d, nodeId);
    86 	ConfigureSlaveNode(d, nodeId);
   124 					0x1800, /*UNS16 index*/
   124 					0x1800, /*UNS16 index*/
   125 					0x02, /*UNS8 subindex*/
   125 					0x02, /*UNS8 subindex*/
   126 					1, /*UNS8 count*/
   126 					1, /*UNS8 count*/
   127 					0, /*UNS8 dataType*/
   127 					0, /*UNS8 dataType*/
   128 					&Transmission_Type,/*void *data*/
   128 					&Transmission_Type,/*void *data*/
   129 					CheckSDOAndContinue); /*SDOCallback_t Callback*/
   129 					CheckSDOAndContinue, /*SDOCallback_t Callback*/
       
   130                     0); /*UNS8 useBlockMode*/
   130 					break;
   131 					break;
   131 		case 2: /* Second step : Set the new heartbeat producer time in the slave */
   132 		case 2: /* Second step : Set the new heartbeat producer time in the slave */
   132 		{
   133 		{
   133 			UNS32 Master_Cons_Heartbeat_T=Master_Cons_Heartbeat_Base + (nodeId * 0x10000);
   134 			UNS32 Master_Cons_Heartbeat_T=Master_Cons_Heartbeat_Base + (nodeId * 0x10000);
   134 			UNS8 size = sizeof(UNS32); 
   135 			UNS32 size = sizeof(UNS32); 
   135 			
   136 			
   136 			eprintf("Master : set slave %2.2x Producer Heartbeat Time = %d\n", nodeId,Slave_Prod_Heartbeat_T);
   137 			eprintf("Master : set slave %2.2x Producer Heartbeat Time = %d\n", nodeId,Slave_Prod_Heartbeat_T);
   137 			res = writeNetworkDictCallBack (d, /*CO_Data* d*/
   138 			res = writeNetworkDictCallBack (d, /*CO_Data* d*/
   138 					nodeId, /*UNS8 nodeId*/
   139 					nodeId, /*UNS8 nodeId*/
   139 					0x1017, /*UNS16 index*/
   140 					0x1017, /*UNS16 index*/
   140 					0x00, /*UNS8 subindex*/
   141 					0x00, /*UNS8 subindex*/
   141 					2, /*UNS8 count*/
   142 					2, /*UNS8 count*/
   142 					0, /*UNS8 dataType*/
   143 					0, /*UNS8 dataType*/
   143 					&Slave_Prod_Heartbeat_T,/*void *data*/
   144 					&Slave_Prod_Heartbeat_T,/*void *data*/
   144 					CheckSDOAndContinue); /*SDOCallback_t Callback*/
   145 					CheckSDOAndContinue, /*SDOCallback_t Callback*/
       
   146                     0); /*UNS8 useBlockMode*/
   145 					break;
   147 					break;
   146 					
   148 					
   147 			/* Set the new heartbeat consumer time in the master*/
   149 			/* Set the new heartbeat consumer time in the master*/
   148 			eprintf("Master : set Consumer Heartbeat Time for slave %2.2x = %d\n", nodeId,Master_Cons_Heartbeat_T);
   150 			eprintf("Master : set Consumer Heartbeat Time for slave %2.2x = %d\n", nodeId,Master_Cons_Heartbeat_T);
   149 			writeLocalDict( &TestMaster_Data, /*CO_Data* d*/
   151 			writeLocalDict( &TestMaster_Data, /*CO_Data* d*/
   210    			break;
   212    			break;
   211    		case LSS_CONF_ACT_BIT_TIMING:
   213    		case LSS_CONF_ACT_BIT_TIMING:
   212    			if(dat1==0){
   214    			if(dat1==0){
   213    				UNS8 LSS_mode=LSS_WAITING_MODE;
   215    				UNS8 LSS_mode=LSS_WAITING_MODE;
   214 				UNS32 SINC_cicle=50000;// us
   216 				UNS32 SINC_cicle=50000;// us
   215 				UNS8 size = sizeof(UNS32); 
   217 				UNS32 size = sizeof(UNS32); 
   216 	
   218 	
   217 				/* The slaves are now configured (nodeId and Baudrate) via the LSS services.
   219 				/* The slaves are now configured (nodeId and Baudrate) via the LSS services.
   218    			 	* Switch the LSS state to WAITING and restart the slaves. */
   220    			 	* Switch the LSS state to WAITING and restart the slaves. */
   219 				
   221 				
   220 				/*TODO: change the baud rate of the master!!*/
   222 				/*TODO: change the baud rate of the master!!*/