examples/TestMasterSlaveLSS/Master.c
author Laurent Bessard
Thu, 06 Dec 2012 16:07:46 +0100
changeset 765 90b738e4ede5
parent 718 0b33d9cdbdeb
permissions -rw-r--r--
Fixed warnings when compiling generated Object Dictionary
381
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
     1
/*
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
     2
This file is part of CanFestival, a library implementing CanOpen Stack. 
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
     3
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
     4
Copyright (C): Edouard TISSERANT , Francis DUPIN and Jorge BERZOSA
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
     5
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
     6
See COPYING file for copyrights details.
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
     7
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
     8
This library is free software; you can redistribute it and/or
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
     9
modify it under the terms of the GNU Lesser General Public
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    10
License as published by the Free Software Foundation; either
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    11
version 2.1 of the License, or (at your option) any later version.
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    12
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    13
This library is distributed in the hope that it will be useful,
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    14
but WITHOUT ANY WARRANTY; without even the implied warranty of
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    16
Lesser General Public License for more details.
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    17
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    18
You should have received a copy of the GNU Lesser General Public
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    19
License along with this library; if not, write to the Free Software
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    20
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    21
*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    22
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    23
#include "Master.h"
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    24
#include "SlaveA.h"
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    25
#include "SlaveB.h"
384
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 381
diff changeset
    26
#include "TestMasterSlaveLSS.h" 
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 381
diff changeset
    27
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 381
diff changeset
    28
extern s_BOARD MasterBoard;
381
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    29
/*****************************************************************************/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    30
void TestMaster_heartbeatError(CO_Data* d, UNS8 heartbeatID)
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    31
{
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    32
	eprintf("TestMaster_heartbeatError %d\n", heartbeatID);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    33
}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    34
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    35
/********************************************************
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    36
 * TestMaster_initialisation is responsible to
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    37
 *  - setup master RPDO 1 to receive TPDO 1 from id 2
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    38
 *  - setup master RPDO 2 to receive TPDO 1 from id 3
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    39
 ********************************************************/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    40
void TestMaster_initialisation(CO_Data* d)
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    41
{
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    42
	UNS32 PDO1_COBID = 0x0182; 
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    43
	UNS32 PDO2_COBID = 0x0183;
717
cfb4f62f35af Fixed example TestMasterSlaveLSS in Master.c missing argument in writeNetworkDictCallBack
Mongo
parents: 517
diff changeset
    44
	UNS32 size = sizeof(UNS32); 
381
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    45
	
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    46
	eprintf("TestMaster_initialisation\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    47
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    48
	/*****************************************
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    49
	 * Define RPDO to match slave ID=2 TPDO1*
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    50
	 *****************************************/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    51
	writeLocalDict( &TestMaster_Data, /*CO_Data* d*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    52
			0x1400, /*UNS16 index*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    53
			0x01, /*UNS8 subind*/ 
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    54
			&PDO1_COBID, /*void * pSourceData,*/ 
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    55
			&size, /* UNS8 * pExpectedSize*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    56
			RW);  /* UNS8 checkAccess */
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    57
			
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    58
	/*****************************************
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    59
	 * Define RPDO to match slave ID=3 TPDO1*
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    60
	 *****************************************/		
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    61
	writeLocalDict( &TestMaster_Data, /*CO_Data* d*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    62
			0x1401, /*UNS16 index*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    63
			0x01, /*UNS8 subind*/ 
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    64
			&PDO2_COBID, /*void * pSourceData,*/ 
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    65
			&size, /* UNS8 * pExpectedSize*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    66
			RW);  /* UNS8 checkAccess */
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    67
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    68
}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    69
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    70
// Step counts number of times ConfigureSlaveNode is called
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    71
// There is one per each slave
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    72
static init_step[] ={0,0};
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    73
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    74
/*Forward declaration*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    75
static void ConfigureSlaveNode(CO_Data* d, UNS8 nodeId);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    76
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    77
static void CheckSDOAndContinue(CO_Data* d, UNS8 nodeId)
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    78
{
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    79
	UNS32 abortCode;	
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    80
	if(getWriteResultNetworkDict (d, nodeId, &abortCode) != SDO_FINISHED)
717
cfb4f62f35af Fixed example TestMasterSlaveLSS in Master.c missing argument in writeNetworkDictCallBack
Mongo
parents: 517
diff changeset
    81
		eprintf("Master : Failed in initializing slave %2.2x, AbortCode :%4.4x \n", nodeId, abortCode);
381
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    82
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    83
	/* Finalise last SDO transfer with this node */
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    84
	closeSDOtransfer(&TestMaster_Data, nodeId, SDO_CLIENT);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    85
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    86
	ConfigureSlaveNode(d, nodeId);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    87
}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    88
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    89
/********************************************************
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    90
 * ConfigureSlaveNode is responsible to
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    91
 *  - setup slave 'n' TPDO 1 transmit type
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    92
 *  - setup slave 'n' Producer Hertbeat Time
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    93
 *  - setup the Consumer Heartbeat Time for slave 'n'
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    94
 *  - switch to operational mode
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    95
 *  - send NMT to slave
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    96
 ********************************************************
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    97
 * This an example of :
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    98
 * Network Dictionary Access (SDO) with Callback 
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    99
 * Slave node state change request (NMT) 
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   100
 ********************************************************
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   101
 * This is called first by TestMaster_post_SlaveBootup
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   102
 * after the LSS configuration has been done
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   103
 * then it called again each time a SDO exchange is
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   104
 * finished.
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   105
 ********************************************************/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   106
 
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   107
static void ConfigureSlaveNode(CO_Data* d, UNS8 nodeId)
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   108
{
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   109
	/* Master configure heartbeat producer time at 0 ms 
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   110
	 * for slaves node-id 0x02 and 0x03 by DCF concise */
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   111
	 
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   112
	UNS8 Transmission_Type = 0x01;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   113
	UNS16 Slave_Prod_Heartbeat_T=1000;//ms
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   114
	UNS32 Master_Cons_Heartbeat_Base=0x05DC; //1500ms
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   115
	UNS32 abortCode;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   116
	UNS8 res;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   117
	eprintf("Master : ConfigureSlaveNode %2.2x\n", nodeId);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   118
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   119
	switch(++init_step[nodeId-2]){
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   120
		case 1: /*First step : setup Slave's TPDO 1 to be transmitted on SYNC*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   121
			eprintf("Master : set slave %2.2x TPDO 1 transmit type\n", nodeId);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   122
			res = writeNetworkDictCallBack (d, /*CO_Data* d*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   123
					nodeId, /*UNS8 nodeId*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   124
					0x1800, /*UNS16 index*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   125
					0x02, /*UNS8 subindex*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   126
					1, /*UNS8 count*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   127
					0, /*UNS8 dataType*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   128
					&Transmission_Type,/*void *data*/
717
cfb4f62f35af Fixed example TestMasterSlaveLSS in Master.c missing argument in writeNetworkDictCallBack
Mongo
parents: 517
diff changeset
   129
					CheckSDOAndContinue, /*SDOCallback_t Callback*/
cfb4f62f35af Fixed example TestMasterSlaveLSS in Master.c missing argument in writeNetworkDictCallBack
Mongo
parents: 517
diff changeset
   130
                    0); /*UNS8 useBlockMode*/
381
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   131
					break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   132
		case 2: /* Second step : Set the new heartbeat producer time in the slave */
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   133
		{
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   134
			UNS32 Master_Cons_Heartbeat_T=Master_Cons_Heartbeat_Base + (nodeId * 0x10000);
718
0b33d9cdbdeb Fixed : wrong parameter size
Mongo
parents: 717
diff changeset
   135
			UNS32 size = sizeof(UNS32); 
381
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   136
			
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   137
			eprintf("Master : set slave %2.2x Producer Heartbeat Time = %d\n", nodeId,Slave_Prod_Heartbeat_T);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   138
			res = writeNetworkDictCallBack (d, /*CO_Data* d*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   139
					nodeId, /*UNS8 nodeId*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   140
					0x1017, /*UNS16 index*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   141
					0x00, /*UNS8 subindex*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   142
					2, /*UNS8 count*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   143
					0, /*UNS8 dataType*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   144
					&Slave_Prod_Heartbeat_T,/*void *data*/
717
cfb4f62f35af Fixed example TestMasterSlaveLSS in Master.c missing argument in writeNetworkDictCallBack
Mongo
parents: 517
diff changeset
   145
					CheckSDOAndContinue, /*SDOCallback_t Callback*/
cfb4f62f35af Fixed example TestMasterSlaveLSS in Master.c missing argument in writeNetworkDictCallBack
Mongo
parents: 517
diff changeset
   146
                    0); /*UNS8 useBlockMode*/
381
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   147
					break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   148
					
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   149
			/* Set the new heartbeat consumer time in the master*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   150
			eprintf("Master : set Consumer Heartbeat Time for slave %2.2x = %d\n", nodeId,Master_Cons_Heartbeat_T);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   151
			writeLocalDict( &TestMaster_Data, /*CO_Data* d*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   152
				0x1016, /*UNS16 index*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   153
				nodeId-1, /*UNS8 subind*/ 
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   154
				&Master_Cons_Heartbeat_T, /*void * pSourceData,*/ 
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   155
				&size, /* UNS8 * pExpectedSize*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   156
				RW);  /* UNS8 checkAccess */
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   157
		}		
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   158
		break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   159
		case 3: 
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   160
		
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   161
		/****************************** START *******************************/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   162
		
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   163
			/* Put the master in operational mode */
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   164
			setState(d, Operational);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   165
		 
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   166
			/* Ask slave node to go in operational mode */
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   167
			masterSendNMTstateChange (d, nodeId, NMT_Start_Node);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   168
	}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   169
}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   170
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   171
static void ConfigureLSSNode(CO_Data* d);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   172
// Step counts number of times ConfigureLSSNode is called
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   173
UNS8 init_step_LSS=1;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   174
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   175
static void CheckLSSAndContinue(CO_Data* d, UNS8 command)
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   176
{
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   177
	UNS32 dat1;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   178
	UNS8 dat2;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   179
	
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   180
	printf("CheckLSS->");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   181
	if(getConfigResultNetworkNode (d, command, &dat1, &dat2) != LSS_FINISHED){
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   182
			eprintf("Master : Failed in LSS comand %d.  Trying again\n", command);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   183
	}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   184
	else
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   185
	{
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   186
		init_step_LSS++;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   187
	
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   188
		switch(command){
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   189
		case LSS_CONF_NODE_ID:
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   190
   			switch(dat1){
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   191
   				case 0: printf("Node ID change succesful\n");break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   192
   				case 1: printf("Node ID change error:out of range\n");break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   193
   				case 0xFF:printf("Node ID change error:specific error\n");break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   194
   				default:break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   195
   			}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   196
   			break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   197
   		case LSS_CONF_BIT_TIMING:
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   198
   			switch(dat1){
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   199
   				case 0: printf("Baud rate change succesful\n");break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   200
   				case 1: printf("Baud rate change error: change baud rate not supported\n");break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   201
   				case 0xFF:printf("Baud rate change error:specific error\n");break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   202
   				default:break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   203
   			}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   204
   			break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   205
   		case LSS_CONF_STORE:
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   206
   			switch(dat1){
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   207
   				case 0: printf("Store configuration succesful\n");break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   208
   				case 1: printf("Store configuration error:not supported\n");break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   209
   				case 0xFF:printf("Store configuration error:specific error\n");break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   210
   				default:break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   211
   			}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   212
   			break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   213
   		case LSS_CONF_ACT_BIT_TIMING:
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   214
   			if(dat1==0){
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   215
   				UNS8 LSS_mode=LSS_WAITING_MODE;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   216
				UNS32 SINC_cicle=50000;// us
718
0b33d9cdbdeb Fixed : wrong parameter size
Mongo
parents: 717
diff changeset
   217
				UNS32 size = sizeof(UNS32); 
381
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   218
	
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   219
				/* The slaves are now configured (nodeId and Baudrate) via the LSS services.
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   220
   			 	* Switch the LSS state to WAITING and restart the slaves. */
517
003679edc437 FastScan review
groke6
parents: 384
diff changeset
   221
				
003679edc437 FastScan review
groke6
parents: 384
diff changeset
   222
				/*TODO: change the baud rate of the master!!*/
384
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 381
diff changeset
   223
   			 	MasterBoard.baudrate="250K";
517
003679edc437 FastScan review
groke6
parents: 384
diff changeset
   224
   			 	
003679edc437 FastScan review
groke6
parents: 384
diff changeset
   225
   			 	
381
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   226
	   			printf("Master : Switch Delay period finished. Switching to LSS WAITING state\n");
384
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 381
diff changeset
   227
   				configNetworkNode(d,LSS_SM_GLOBAL,&LSS_mode,0,NULL);
381
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   228
	   			
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   229
   				printf("Master : Restarting all the slaves\n");
517
003679edc437 FastScan review
groke6
parents: 384
diff changeset
   230
   				masterSendNMTstateChange (d, 0x00, NMT_Reset_Comunication);
381
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   231
	   			
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   232
   				printf("Master : Starting the SYNC producer\n");
384
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 381
diff changeset
   233
   				writeLocalDict( d, /*CO_Data* d*/
381
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   234
					0x1006, /*UNS16 index*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   235
					0x00, /*UNS8 subind*/ 
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   236
					&SINC_cicle, /*void * pSourceData,*/ 
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   237
					&size, /* UNS8 * pExpectedSize*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   238
					RW);  /* UNS8 checkAccess */
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   239
					
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   240
				return;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   241
			}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   242
   			else{
384
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 381
diff changeset
   243
   				UNS16 Switch_delay=1;
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 381
diff changeset
   244
				UNS8 LSS_mode=LSS_CONFIGURATION_MODE;
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 381
diff changeset
   245
				
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 381
diff changeset
   246
	   			eprintf("Master : unable to activate bit timing. trying again\n");
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 381
diff changeset
   247
				configNetworkNode(d,LSS_CONF_ACT_BIT_TIMING,&Switch_delay,0,CheckLSSAndContinue);
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 381
diff changeset
   248
				return;
381
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   249
   			}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   250
   			break;	
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   251
		case LSS_SM_SELECTIVE_SERIAL:
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   252
   			printf("Slave in LSS CONFIGURATION state\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   253
   			break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   254
   		case LSS_IDENT_REMOTE_SERIAL_HIGH:
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   255
   			printf("node identified\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   256
   			break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   257
   		case LSS_IDENT_REMOTE_NON_CONF:
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   258
   			if(dat1==0)
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   259
   				eprintf("There are no-configured remote slave(s) in the net\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   260
   			else
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   261
   			{
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   262
   				UNS16 Switch_delay=1;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   263
				UNS8 LSS_mode=LSS_CONFIGURATION_MODE;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   264
			
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   265
				/*The configuration of the slaves' nodeId ended.
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   266
				 * Start the configuration of the baud rate. */
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   267
				eprintf("Master : There are not no-configured slaves in the net\n", command);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   268
				eprintf("Switching all the nodes to LSS CONFIGURATION state\n");
384
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 381
diff changeset
   269
				configNetworkNode(d,LSS_SM_GLOBAL,&LSS_mode,0,NULL);
381
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   270
				eprintf("LSS=>Activate Bit Timing\n");
384
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 381
diff changeset
   271
				configNetworkNode(d,LSS_CONF_ACT_BIT_TIMING,&Switch_delay,0,CheckLSSAndContinue);
381
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   272
				return;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   273
   			}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   274
   			break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   275
   		case LSS_INQ_VENDOR_ID:
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   276
   			printf("Slave VendorID %x\n", dat1);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   277
   			break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   278
   		case LSS_INQ_PRODUCT_CODE:
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   279
   			printf("Slave Product Code %x\n", dat1);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   280
   			break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   281
   		case LSS_INQ_REV_NUMBER:
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   282
   			printf("Slave Revision Number %x\n", dat1);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   283
   			break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   284
   		case LSS_INQ_SERIAL_NUMBER:
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   285
   			printf("Slave Serial Number %x\n", dat1);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   286
   			break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   287
   		case LSS_INQ_NODE_ID:
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   288
   			printf("Slave nodeid %x\n", dat1);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   289
   			break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   290
#ifdef CO_ENABLE_LSS_FS
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   291
   		case LSS_IDENT_FASTSCAN:
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   292
   			if(dat1==0)
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   293
   				printf("Slave node identified with FastScan\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   294
   			else
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   295
   			{
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   296
   				printf("There is not unconfigured node in the net\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   297
   				return;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   298
   			}	
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   299
   			init_step_LSS++;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   300
   			break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   301
#endif	
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   302
	
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   303
		}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   304
	}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   305
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   306
	printf("\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   307
	ConfigureLSSNode(d);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   308
}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   309
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   310
/* Initial nodeID and VendorID. They are incremented by one for each slave*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   311
UNS8 NodeID=0x02;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   312
UNS32 Vendor_ID=0x12345678;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   313
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   314
/* Configuration of the nodeID and baudrate with LSS services:
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   315
 * --First ask if there is a node with an invalid nodeID.
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   316
 * --If FastScan is activated it is used to put the slave in the state “configuration”.
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   317
 * --If FastScan is not activated, identification services are used to identify the slave. Then 
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   318
 * 	 switch mode service is used to put it in configuration state.
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   319
 * --Next, all the inquire services are used (only for example) and a valid nodeId and a
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   320
 * 	 new baudrate are assigned to the slave.
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   321
 * --Finally, the slave's LSS state is restored to “waiting” and all the process is repeated 
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   322
 * 	 again until there isn't any node with an invalid nodeID.
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   323
 * --After the configuration of all the slaves finished the LSS state of all of them is switched 
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   324
 * 	 again to "configuration" and the Activate Bit Timing service is requested. On sucessfull, the 
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   325
 * 	 LSS state is restored to "waiting" and NMT state is changed to reset (by means of the NMT services).
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   326
 * */
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   327
static void ConfigureLSSNode(CO_Data* d)
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   328
{
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   329
	UNS32 Product_Code=0x90123456;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   330
	UNS32 Revision_Number=0x78901234;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   331
	UNS32 Serial_Number=0x56789012;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   332
	UNS32 Revision_Number_high=0x78901240;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   333
	UNS32 Revision_Number_low=0x78901230;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   334
	UNS32 Serial_Number_high=0x56789020;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   335
	UNS32 Serial_Number_low=0x56789010;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   336
	UNS8 LSS_mode=LSS_WAITING_MODE;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   337
	UNS8 Baud_Table=0;
384
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 381
diff changeset
   338
	//UNS8 Baud_BitTiming=3;
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 381
diff changeset
   339
	char* Baud_BitTiming="250K";
381
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   340
	UNS8 res;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   341
	eprintf("ConfigureLSSNode step %d -> ",init_step_LSS);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   342
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   343
	switch(init_step_LSS){
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   344
		case 1:	/* LSS=>identify non-configured remote slave */
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   345
			eprintf("LSS=>identify no-configured remote slave(s)\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   346
			res=configNetworkNode(&TestMaster_Data,LSS_IDENT_REMOTE_NON_CONF,0,0,CheckLSSAndContinue);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   347
			break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   348
#ifdef CO_ENABLE_LSS_FS
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   349
		case 2:	/* LSS=>FastScan */
517
003679edc437 FastScan review
groke6
parents: 384
diff changeset
   350
		{
003679edc437 FastScan review
groke6
parents: 384
diff changeset
   351
			lss_fs_transfer_t lss_fs;
381
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   352
			eprintf("LSS=>FastScan\n");
517
003679edc437 FastScan review
groke6
parents: 384
diff changeset
   353
			/* The VendorID and ProductCode are partialy known, except the last two digits (8 bits). */
003679edc437 FastScan review
groke6
parents: 384
diff changeset
   354
			lss_fs.FS_LSS_ID[0]=Vendor_ID;
003679edc437 FastScan review
groke6
parents: 384
diff changeset
   355
			lss_fs.FS_BitChecked[0]=8;
003679edc437 FastScan review
groke6
parents: 384
diff changeset
   356
			lss_fs.FS_LSS_ID[1]=Product_Code;
003679edc437 FastScan review
groke6
parents: 384
diff changeset
   357
			lss_fs.FS_BitChecked[1]=8;
003679edc437 FastScan review
groke6
parents: 384
diff changeset
   358
			/* serialNumber and RevisionNumber are unknown, i.e. the 8 digits (32bits) are unknown. */
003679edc437 FastScan review
groke6
parents: 384
diff changeset
   359
			lss_fs.FS_BitChecked[2]=32;
003679edc437 FastScan review
groke6
parents: 384
diff changeset
   360
			lss_fs.FS_BitChecked[3]=32;
003679edc437 FastScan review
groke6
parents: 384
diff changeset
   361
			res=configNetworkNode(&TestMaster_Data,LSS_IDENT_FASTSCAN,&lss_fs,0,CheckLSSAndContinue);
003679edc437 FastScan review
groke6
parents: 384
diff changeset
   362
		}
003679edc437 FastScan review
groke6
parents: 384
diff changeset
   363
		break;
381
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   364
#else
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   365
		case 2:	/* LSS=>identify node */
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   366
			eprintf("LSS=>identify node\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   367
			res=configNetworkNode(&TestMaster_Data,LSS_IDENT_REMOTE_VENDOR,&Vendor_ID,0,NULL);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   368
			res=configNetworkNode(&TestMaster_Data,LSS_IDENT_REMOTE_PRODUCT,&Product_Code,0,NULL);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   369
			res=configNetworkNode(&TestMaster_Data,LSS_IDENT_REMOTE_REV_LOW,&Revision_Number_low,0,NULL);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   370
			res=configNetworkNode(&TestMaster_Data,LSS_IDENT_REMOTE_REV_HIGH,&Revision_Number_high,0,NULL);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   371
			res=configNetworkNode(&TestMaster_Data,LSS_IDENT_REMOTE_SERIAL_LOW,&Serial_Number_low,0,NULL);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   372
			res=configNetworkNode(&TestMaster_Data,LSS_IDENT_REMOTE_SERIAL_HIGH,&Serial_Number_high,0,CheckLSSAndContinue);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   373
			break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   374
		case 3: /*LSS=>put in configuration mode*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   375
			eprintf("LSS=>put in configuration mode\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   376
			res=configNetworkNode(&TestMaster_Data,LSS_SM_SELECTIVE_VENDOR,&Vendor_ID,0,NULL);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   377
			res=configNetworkNode(&TestMaster_Data,LSS_SM_SELECTIVE_PRODUCT,&Product_Code,0,NULL);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   378
			res=configNetworkNode(&TestMaster_Data,LSS_SM_SELECTIVE_REVISION,&Revision_Number,0,NULL);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   379
			res=configNetworkNode(&TestMaster_Data,LSS_SM_SELECTIVE_SERIAL,&Serial_Number,0,CheckLSSAndContinue);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   380
			Vendor_ID++;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   381
			break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   382
#endif
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   383
		case 4:	/* LSS=>inquire nodeID */
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   384
			eprintf("LSS=>inquire nodeID\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   385
			res=configNetworkNode(&TestMaster_Data,LSS_INQ_NODE_ID,0,0,CheckLSSAndContinue);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   386
			break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   387
		case 5:	/* LSS=>inquire VendorID */
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   388
			eprintf("LSS=>inquire VendorID\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   389
			res=configNetworkNode(&TestMaster_Data,LSS_INQ_VENDOR_ID,0,0,CheckLSSAndContinue);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   390
			break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   391
		case 6:	/* LSS=>inquire Product code */
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   392
			eprintf("LSS=>inquire Product code\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   393
			res=configNetworkNode(&TestMaster_Data,LSS_INQ_PRODUCT_CODE,0,0,CheckLSSAndContinue);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   394
			break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   395
		case 7:	/* LSS=>inquire Revision Number */
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   396
			eprintf("LSS=>inquire Revision Number\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   397
			res=configNetworkNode(&TestMaster_Data,LSS_INQ_REV_NUMBER,0,0,CheckLSSAndContinue);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   398
			break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   399
		case 8:	/* LSS=>inquire Serial Number */
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   400
			eprintf("LSS=>inquire Serial Number\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   401
			res=configNetworkNode(&TestMaster_Data,LSS_INQ_SERIAL_NUMBER,0,0,CheckLSSAndContinue);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   402
			break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   403
		case 9:	/* LSS=>change the nodeID */
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   404
			eprintf("LSS=>change the nodeId\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   405
			res=configNetworkNode(&TestMaster_Data,LSS_CONF_NODE_ID,&NodeID,0,CheckLSSAndContinue);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   406
			NodeID++;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   407
			break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   408
		case 10:	/* LSS=>change the Baud rate */
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   409
			eprintf("LSS=>change the Baud rate\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   410
			res=configNetworkNode(&TestMaster_Data,LSS_CONF_BIT_TIMING,&Baud_Table,&Baud_BitTiming,CheckLSSAndContinue);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   411
			break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   412
		case 11:
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   413
			/*LSS=>store configuration*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   414
			eprintf("LSS=>store configuration\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   415
			res=configNetworkNode(&TestMaster_Data,LSS_CONF_STORE,0,0,CheckLSSAndContinue);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   416
			break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   417
		case 12: /* LSS=>put in waiting mode */
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   418
			eprintf("LSS=>put in waiting mode\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   419
			res=configNetworkNode(&TestMaster_Data,LSS_SM_GLOBAL,&LSS_mode,0,NULL);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   420
			/* Search again for no-configured slaves*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   421
			eprintf("LSS=>identify no-configured remote slave(s)\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   422
			res=configNetworkNode(&TestMaster_Data,LSS_IDENT_REMOTE_NON_CONF,0,0,CheckLSSAndContinue);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   423
			init_step_LSS=1;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   424
			break;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   425
	}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   426
}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   427
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   428
void TestMaster_preOperational(CO_Data* d)
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   429
{
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   430
	eprintf("TestMaster_preOperational\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   431
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   432
	/* Ask slaves to go in stop mode */
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   433
	masterSendNMTstateChange (d, 0, NMT_Stop_Node);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   434
	ConfigureLSSNode(&TestMaster_Data);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   435
}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   436
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   437
void TestMaster_operational(CO_Data* d)
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   438
{
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   439
	eprintf("TestMaster_operational\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   440
}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   441
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   442
void TestMaster_stopped(CO_Data* d)
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   443
{
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   444
	eprintf("TestMaster_stopped\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   445
}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   446
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   447
void TestMaster_post_sync(CO_Data* d)
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   448
{
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   449
	eprintf("TestMaster_post_sync\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   450
	eprintf("Master: %d %d %d\n",
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   451
		MasterMap1,
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   452
		MasterMap2,
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   453
		MasterMap3);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   454
}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   455
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   456
void TestMaster_post_emcy(CO_Data* d, UNS8 nodeID, UNS16 errCode, UNS8 errReg)
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   457
{
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   458
	eprintf("Master received EMCY message. Node: %2.2x  ErrorCode: %4.4x  ErrorRegister: %2.2x\n", nodeID, errCode, errReg);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   459
}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   460
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   461
void TestMaster_post_TPDO(CO_Data* d)
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   462
{
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   463
	eprintf("TestMaster_post_TPDO\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   464
}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   465
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   466
void TestMaster_post_SlaveBootup(CO_Data* d, UNS8 nodeid)
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   467
{
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   468
	eprintf("TestMaster_post_SlaveBootup %x\n", nodeid);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   469
	/* Wait until the new baud rate is stored before configure the slaves*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   470
	if(MasterBoard.baudrate=="250K")
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   471
		ConfigureSlaveNode(d, nodeid);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   472
}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
   473