]> rtime.felk.cvut.cz Git - CanFestival-3.git/blobdiff - examples/TestMasterSlave/Master.c
*** empty log message ***
[CanFestival-3.git] / examples / TestMasterSlave / Master.c
index dac02b6362a045be946fe2d12c9704e49c0d0847..6967a622bee2e8514b7c65814b4285143a1b875f 100644 (file)
@@ -24,8 +24,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #include "Slave.h"
 #include "TestMasterSlave.h"
 
+extern s_BOARD MasterBoard;
 /*****************************************************************************/
-void TestMaster_heartbeatError(UNS8 heartbeatID)
+void TestMaster_heartbeatError(CO_Data* d, UNS8 heartbeatID)
 {
        eprintf("TestMaster_heartbeatError %d\n", heartbeatID);
 }
@@ -35,11 +36,13 @@ void TestMaster_heartbeatError(UNS8 heartbeatID)
  *  - setup master RPDO 1 to receive TPDO 1 from id 2
  *  - setup master RPDO 2 to receive TPDO 2 from id 2
  ********************************************************/
-void TestMaster_initialisation()
+void TestMaster_initialisation(CO_Data* d)
 {
        UNS32 PDO1_COBID = 0x0182; 
        UNS32 PDO2_COBID = 0x0282;
        UNS8 size = sizeof(UNS32); 
+       UNS32 SINC_cicle=0;
+       UNS8 data_type = 0;
        
        eprintf("TestMaster_initialisation\n");
 
@@ -59,10 +62,11 @@ void TestMaster_initialisation()
                        &PDO2_COBID, /*void * pSourceData,*/ 
                        &size, /* UNS8 * pExpectedSize*/
                        RW);  /* UNS8 checkAccess */
+                                       
 }
 
 // Step counts number of times ConfigureSlaveNode is called
-static init_step = 0;
+static int init_step = 0;
 
 /*Froward declaration*/
 static void ConfigureSlaveNode(CO_Data* d, UNS8 nodeId);
@@ -82,8 +86,8 @@ static void CheckSDOAndContinue(CO_Data* d, UNS8 nodeId)
 
 /********************************************************
  * ConfigureSlaveNode is responsible to
- *  - setup slave TPDO 1 transmit time
- *  - setup slave TPDO 2 transmit time
+ *  - setup slave TPDO 1 transmit type
+ *  - setup slave TPDO 2 transmit type
  *  - switch to operational mode
  *  - send NMT to slave
  ********************************************************
@@ -91,7 +95,7 @@ static void CheckSDOAndContinue(CO_Data* d, UNS8 nodeId)
  * Network Dictionary Access (SDO) with Callback 
  * Slave node state change request (NMT) 
  ********************************************************
- * This is called first by TestMaster_preOperational
+ * This is called first by TestMaster_post_SlaveBootup
  * then it called again each time a SDO exchange is
  * finished.
  ********************************************************/
@@ -143,25 +147,23 @@ static void ConfigureSlaveNode(CO_Data* d, UNS8 nodeId)
        }
 }
 
-void TestMaster_preOperational()
-{
 
+void TestMaster_preOperational(CO_Data* d)
+{
        eprintf("TestMaster_preOperational\n");
-       ConfigureSlaveNode(&TestMaster_Data, 0x02);
-       
 }
 
-void TestMaster_operational()
+void TestMaster_operational(CO_Data* d)
 {
        eprintf("TestMaster_operational\n");
 }
 
-void TestMaster_stopped()
+void TestMaster_stopped(CO_Data* d)
 {
        eprintf("TestMaster_stopped\n");
 }
 
-void TestMaster_post_sync()
+void TestMaster_post_sync(CO_Data* d)
 {
        eprintf("TestMaster_post_sync\n");
        eprintf("Master: %d %d %d %d %d %d %d %d %d %x %x %d %d\n",
@@ -180,7 +182,7 @@ void TestMaster_post_sync()
                MasterMap13);
 }
 
-void TestMaster_post_emcy(UNS8 nodeID, UNS16 errCode, UNS8 errReg)
+void TestMaster_post_emcy(CO_Data* d, UNS8 nodeID, UNS16 errCode, UNS8 errReg)
 {
        eprintf("Master received EMCY message. Node: %2.2x  ErrorCode: %4.4x  ErrorRegister: %2.2x\n", nodeID, errCode, errReg);
 }
@@ -200,7 +202,7 @@ static void CheckSDO(CO_Data* d, UNS8 nodeId)
 
 
 static int MasterSyncCount = 0;
-void TestMaster_post_TPDO()
+void TestMaster_post_TPDO(CO_Data* d)
 {
        eprintf("TestMaster_post_TPDO MasterSyncCount = %d \n", MasterSyncCount);
 //
@@ -221,7 +223,7 @@ void TestMaster_post_TPDO()
 #if 0
        if(waiting_answer){
                UNS32 abortCode;                        
-               UNS8 size;                      
+               UNS8 size = 1;                  
                switch(getReadResultNetworkDict (
                        &TestMaster_Data, 
                        0x02,
@@ -286,3 +288,10 @@ void TestMaster_post_TPDO()
        }
        MasterSyncCount++;
 }
+
+void TestMaster_post_SlaveBootup(CO_Data* d, UNS8 nodeid)
+{
+       eprintf("TestMaster_post_SlaveBootup %x\n", nodeid);
+       
+       ConfigureSlaveNode(d, nodeid);
+}