examples/TestMasterSlave/TestMaster.c
changeset 0 4472ee7c6c3e
child 23 6a5cdca4de01
equal deleted inserted replaced
-1:000000000000 0:4472ee7c6c3e
       
     1 /*
       
     2 This file is part of CanFestival, a library implementing CanOpen Stack. 
       
     3 
       
     4 Copyright (C): Edouard TISSERANT and Francis DUPIN
       
     5 
       
     6 See COPYING file for copyrights details.
       
     7 
       
     8 This library is free software; you can redistribute it and/or
       
     9 modify it under the terms of the GNU Lesser General Public
       
    10 License as published by the Free Software Foundation; either
       
    11 version 2.1 of the License, or (at your option) any later version.
       
    12 
       
    13 This library is distributed in the hope that it will be useful,
       
    14 but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    16 Lesser General Public License for more details.
       
    17 
       
    18 You should have received a copy of the GNU Lesser General Public
       
    19 License along with this library; if not, write to the Free Software
       
    20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
       
    21 */
       
    22 
       
    23 /* File generated by gen_cfile.py. Should not be modified. */
       
    24 
       
    25 #include "TestMaster.h"
       
    26 
       
    27 /**************************************************************************/
       
    28 /* Declaration of the mapped variables                                    */
       
    29 /**************************************************************************/
       
    30 UNS8 MasterMap1 = 0x0;		// Mapped at index 0x2000, subindex 0x00
       
    31 UNS8 MasterMap2 = 0x0;		// Mapped at index 0x2001, subindex 0x00
       
    32 UNS8 MasterMap3 = 0x0;		// Mapped at index 0x2002, subindex 0x00
       
    33 UNS8 MasterMap4 = 0x0;		// Mapped at index 0x2003, subindex 0x00
       
    34 
       
    35 /**************************************************************************/
       
    36 /* Declaration of the value range types                                   */
       
    37 /**************************************************************************/
       
    38 
       
    39 UNS32 TestMaster_valueRangeTest (UNS8 typeValue, void * value)
       
    40 {
       
    41   switch (typeValue) {
       
    42   }
       
    43   return 0;
       
    44 }
       
    45 
       
    46 /**************************************************************************/
       
    47 /* The node id                                                            */
       
    48 /**************************************************************************/
       
    49 /* node_id default value.*/
       
    50 UNS8 TestMaster_bDeviceNodeId = 0x00;
       
    51 
       
    52 //*****************************************************************************/
       
    53 /* Array of message processing information */
       
    54 
       
    55 const UNS8 TestMaster_iam_a_slave = 0;
       
    56 
       
    57 TIMER_HANDLE TestMaster_heartBeatTimers[1] = {TIMER_NONE,};
       
    58 
       
    59 //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       
    60 //
       
    61 //                       OBJECT DICTIONARY
       
    62 //                   
       
    63 //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       
    64 
       
    65 /* index 0x1000 :   Device Type. */
       
    66                     UNS32 TestMaster_obj1000 = 0x12D;
       
    67                     subindex TestMaster_Index1000[] = 
       
    68                      {
       
    69                        { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1000 }
       
    70                      };
       
    71 
       
    72 /* index 0x1001 :   Error Register. */
       
    73                     UNS8 TestMaster_obj1001 = 0x0;
       
    74                     subindex TestMaster_Index1001[] = 
       
    75                      {
       
    76                        { RO, uint8, sizeof (UNS8), (void*)&TestMaster_obj1001 }
       
    77                      };
       
    78 
       
    79 /* index 0x1005 :   SYNC COB ID. */
       
    80                     UNS32 TestMaster_obj1005 = 0x40000080;
       
    81                     ODCallback_t TestMaster_Index1005_callbacks[] = 
       
    82                      {
       
    83                        NULL,
       
    84                      };
       
    85                     subindex TestMaster_Index1005[] = 
       
    86                      {
       
    87                        { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1005 }
       
    88                      };
       
    89 
       
    90 /* index 0x1006 :   Communication / Cycle Period. */
       
    91                     UNS32 TestMaster_obj1006 = 0xC350;
       
    92                     ODCallback_t TestMaster_Index1006_callbacks[] = 
       
    93                      {
       
    94                        NULL,
       
    95                      };
       
    96                     subindex TestMaster_Index1006[] = 
       
    97                      {
       
    98                        { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1006 }
       
    99                      };
       
   100 
       
   101 /* index 0x1016 :   Consumer Heartbeat Time. */
       
   102                     UNS8 TestMaster_highestSubIndex_obj1016 = 1; // number of subindex - 1
       
   103                     UNS32 TestMaster_obj1016[] = 
       
   104                     {
       
   105                       133122
       
   106                     };
       
   107                     subindex TestMaster_Index1016[] = 
       
   108                      {
       
   109                        { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1016 },
       
   110                        { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1016[0] }
       
   111                      };
       
   112 
       
   113 /* index 0x1017 :   Producer Heartbeat Time */ 
       
   114                     UNS16 TestMaster_obj1017 = 0;
       
   115 
       
   116 /* index 0x1018 :   Identity. */
       
   117                     UNS8 TestMaster_highestSubIndex_obj1018 = 4; // number of subindex - 1
       
   118                     UNS32 TestMaster_obj1018_Vendor_ID = 0x0;
       
   119                     UNS32 TestMaster_obj1018_Product_Code = 0x0;
       
   120                     UNS32 TestMaster_obj1018_Revision_Number = 0x0;
       
   121                     UNS32 TestMaster_obj1018_Serial_Number = 0x0;
       
   122                     subindex TestMaster_Index1018[] = 
       
   123                      {
       
   124                        { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1018 },
       
   125                        { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1018_Vendor_ID },
       
   126                        { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1018_Product_Code },
       
   127                        { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1018_Revision_Number },
       
   128                        { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1018_Serial_Number }
       
   129                      };
       
   130 
       
   131 /* index 0x1280 :   Client SDO 1 Parameter. */
       
   132                     UNS8 TestMaster_highestSubIndex_obj1280 = 3; // number of subindex - 1
       
   133                     UNS32 TestMaster_obj1280_COB_ID_Client_to_Server_Transmit_SDO = 0x602;
       
   134                     UNS32 TestMaster_obj1280_COB_ID_Server_to_Client_Receive_SDO = 0x582;
       
   135                     UNS32 TestMaster_obj1280_Node_ID_of_the_SDO_Server = 0x2;
       
   136                     subindex TestMaster_Index1280[] = 
       
   137                      {
       
   138                        { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1280 },
       
   139                        { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1280_COB_ID_Client_to_Server_Transmit_SDO },
       
   140                        { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1280_COB_ID_Server_to_Client_Receive_SDO },
       
   141                        { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1280_Node_ID_of_the_SDO_Server }
       
   142                      };
       
   143 
       
   144 /* index 0x1400 :   Receive PDO 1 Parameter. */
       
   145                     UNS8 TestMaster_highestSubIndex_obj1400 = 5; // number of subindex - 1
       
   146                     UNS32 TestMaster_obj1400_COB_ID_used_by_PDO = 0x182;
       
   147                     UNS8 TestMaster_obj1400_Transmission_Type = 0x1;
       
   148                     UNS16 TestMaster_obj1400_Inhibit_Time = 0x0;
       
   149                     UNS16 TestMaster_obj1400_Compatibility_Entry = 0x0;
       
   150                     UNS16 TestMaster_obj1400_Event_Timer = 0x0;
       
   151                     subindex TestMaster_Index1400[] = 
       
   152                      {
       
   153                        { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1400 },
       
   154                        { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1400_COB_ID_used_by_PDO },
       
   155                        { RW, uint8, sizeof (UNS8), (void*)&TestMaster_obj1400_Transmission_Type },
       
   156                        { RW, uint16, sizeof (UNS16), (void*)&TestMaster_obj1400_Inhibit_Time },
       
   157                        { RW, uint16, sizeof (UNS16), (void*)&TestMaster_obj1400_Compatibility_Entry },
       
   158                        { RW, uint16, sizeof (UNS16), (void*)&TestMaster_obj1400_Event_Timer }
       
   159                      };
       
   160 
       
   161 /* index 0x1401 :   Receive PDO 2 Parameter. */
       
   162                     UNS8 TestMaster_highestSubIndex_obj1401 = 5; // number of subindex - 1
       
   163                     UNS32 TestMaster_obj1401_COB_ID_used_by_PDO = 0x282;
       
   164                     UNS8 TestMaster_obj1401_Transmission_Type = 0x1;
       
   165                     UNS16 TestMaster_obj1401_Inhibit_Time = 0x0;
       
   166                     UNS16 TestMaster_obj1401_Compatibility_Entry = 0x0;
       
   167                     UNS16 TestMaster_obj1401_Event_Timer = 0x0;
       
   168                     subindex TestMaster_Index1401[] = 
       
   169                      {
       
   170                        { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1401 },
       
   171                        { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1401_COB_ID_used_by_PDO },
       
   172                        { RW, uint8, sizeof (UNS8), (void*)&TestMaster_obj1401_Transmission_Type },
       
   173                        { RW, uint16, sizeof (UNS16), (void*)&TestMaster_obj1401_Inhibit_Time },
       
   174                        { RW, uint16, sizeof (UNS16), (void*)&TestMaster_obj1401_Compatibility_Entry },
       
   175                        { RW, uint16, sizeof (UNS16), (void*)&TestMaster_obj1401_Event_Timer }
       
   176                      };
       
   177 
       
   178 /* index 0x1600 :   Receive PDO 1 Mapping. */
       
   179                     UNS8 TestMaster_highestSubIndex_obj1600 = 2; // number of subindex - 1
       
   180                     UNS32 TestMaster_obj1600[] = 
       
   181                     {
       
   182                       536870920,
       
   183                       536936456
       
   184                     };
       
   185                     subindex TestMaster_Index1600[] = 
       
   186                      {
       
   187                        { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1600 },
       
   188                        { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[0] },
       
   189                        { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[1] }
       
   190                      };
       
   191 
       
   192 /* index 0x1601 :   Receive PDO 2 Mapping. */
       
   193                     UNS8 TestMaster_highestSubIndex_obj1601 = 2; // number of subindex - 1
       
   194                     UNS32 TestMaster_obj1601[] = 
       
   195                     {
       
   196                       537001992,
       
   197                       537067528
       
   198                     };
       
   199                     subindex TestMaster_Index1601[] = 
       
   200                      {
       
   201                        { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1601 },
       
   202                        { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1601[0] },
       
   203                        { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1601[1] }
       
   204                      };
       
   205 
       
   206 /* index 0x2000 :   Mapped variable MasterMap1 */
       
   207                     ODCallback_t MasterMap1_callbacks[] = 
       
   208                      {
       
   209                        NULL,
       
   210                      };
       
   211                     subindex TestMaster_Index2000[] = 
       
   212                      {
       
   213                        { RW, uint8, sizeof (UNS8), (void*)&MasterMap1 }
       
   214                      };
       
   215 
       
   216 /* index 0x2001 :   Mapped variable MasterMap2 */
       
   217                     subindex TestMaster_Index2001[] = 
       
   218                      {
       
   219                        { RW, uint8, sizeof (UNS8), (void*)&MasterMap2 }
       
   220                      };
       
   221 
       
   222 /* index 0x2002 :   Mapped variable MasterMap3 */
       
   223                     subindex TestMaster_Index2002[] = 
       
   224                      {
       
   225                        { RW, uint8, sizeof (UNS8), (void*)&MasterMap3 }
       
   226                      };
       
   227 
       
   228 /* index 0x2003 :   Mapped variable MasterMap4 */
       
   229                     subindex TestMaster_Index2003[] = 
       
   230                      {
       
   231                        { RW, uint8, sizeof (UNS8), (void*)&MasterMap4 }
       
   232                      };
       
   233 
       
   234 const indextable TestMaster_objdict[] = 
       
   235 {
       
   236   { (subindex*)TestMaster_Index1000,sizeof(TestMaster_Index1000)/sizeof(TestMaster_Index1000[0]), 0x1000},
       
   237   { (subindex*)TestMaster_Index1001,sizeof(TestMaster_Index1001)/sizeof(TestMaster_Index1001[0]), 0x1001},
       
   238   { (subindex*)TestMaster_Index1005,sizeof(TestMaster_Index1005)/sizeof(TestMaster_Index1005[0]), 0x1005},
       
   239   { (subindex*)TestMaster_Index1006,sizeof(TestMaster_Index1006)/sizeof(TestMaster_Index1006[0]), 0x1006},
       
   240   { (subindex*)TestMaster_Index1016,sizeof(TestMaster_Index1016)/sizeof(TestMaster_Index1016[0]), 0x1016},
       
   241   { (subindex*)TestMaster_Index1018,sizeof(TestMaster_Index1018)/sizeof(TestMaster_Index1018[0]), 0x1018},
       
   242   { (subindex*)TestMaster_Index1280,sizeof(TestMaster_Index1280)/sizeof(TestMaster_Index1280[0]), 0x1280},
       
   243   { (subindex*)TestMaster_Index1400,sizeof(TestMaster_Index1400)/sizeof(TestMaster_Index1400[0]), 0x1400},
       
   244   { (subindex*)TestMaster_Index1401,sizeof(TestMaster_Index1401)/sizeof(TestMaster_Index1401[0]), 0x1401},
       
   245   { (subindex*)TestMaster_Index1600,sizeof(TestMaster_Index1600)/sizeof(TestMaster_Index1600[0]), 0x1600},
       
   246   { (subindex*)TestMaster_Index1601,sizeof(TestMaster_Index1601)/sizeof(TestMaster_Index1601[0]), 0x1601},
       
   247   { (subindex*)TestMaster_Index2000,sizeof(TestMaster_Index2000)/sizeof(TestMaster_Index2000[0]), 0x2000},
       
   248   { (subindex*)TestMaster_Index2001,sizeof(TestMaster_Index2001)/sizeof(TestMaster_Index2001[0]), 0x2001},
       
   249   { (subindex*)TestMaster_Index2002,sizeof(TestMaster_Index2002)/sizeof(TestMaster_Index2002[0]), 0x2002},
       
   250   { (subindex*)TestMaster_Index2003,sizeof(TestMaster_Index2003)/sizeof(TestMaster_Index2003[0]), 0x2003},
       
   251 };
       
   252 
       
   253 const indextable * TestMaster_scanIndexOD (UNS16 wIndex, UNS32 * errorCode, ODCallback_t **callbacks)
       
   254 {
       
   255 	int i;
       
   256 	switch(wIndex){
       
   257 		case 0x1000: i = 0; *callbacks = NULL; break;
       
   258 		case 0x1001: i = 1; *callbacks = NULL; break;
       
   259 		case 0x1005: i = 2; *callbacks = TestMaster_Index1005_callbacks; break;
       
   260 		case 0x1006: i = 3; *callbacks = TestMaster_Index1006_callbacks; break;
       
   261 		case 0x1016: i = 4; *callbacks = NULL; break;
       
   262 		case 0x1018: i = 5; *callbacks = NULL; break;
       
   263 		case 0x1280: i = 6; *callbacks = NULL; break;
       
   264 		case 0x1400: i = 7; *callbacks = NULL; break;
       
   265 		case 0x1401: i = 8; *callbacks = NULL; break;
       
   266 		case 0x1600: i = 9; *callbacks = NULL; break;
       
   267 		case 0x1601: i = 10; *callbacks = NULL; break;
       
   268 		case 0x2000: i = 11; *callbacks = MasterMap1_callbacks; break;
       
   269 		case 0x2001: i = 12; *callbacks = NULL; break;
       
   270 		case 0x2002: i = 13; *callbacks = NULL; break;
       
   271 		case 0x2003: i = 14; *callbacks = NULL; break;
       
   272 		default:
       
   273 			*errorCode = OD_NO_SUCH_OBJECT;
       
   274 			return NULL;
       
   275 	}
       
   276 	*errorCode = OD_SUCCESSFUL;
       
   277 	return &TestMaster_objdict[i];
       
   278 }
       
   279 
       
   280 // To count at which received SYNC a PDO must be sent.
       
   281 // Even if no pdoTransmit are defined, at least one entry is computed
       
   282 // for compilations issues.
       
   283 UNS8 TestMaster_count_sync[1] = {0,};
       
   284 
       
   285 quick_index TestMaster_firstIndex = {
       
   286   SDO_SVR : 0,
       
   287   SDO_CLT : 6,
       
   288   PDO_RCV : 7,
       
   289   PDO_RCV_MAP : 9,
       
   290   PDO_TRS : 0,
       
   291   PDO_TRS_MAP : 0
       
   292 };
       
   293 
       
   294 quick_index TestMaster_lastIndex = {
       
   295   SDO_SVR : 0,
       
   296   SDO_CLT : 6,
       
   297   PDO_RCV : 8,
       
   298   PDO_RCV_MAP : 10,
       
   299   PDO_TRS : 0,
       
   300   PDO_TRS_MAP : 0
       
   301 };
       
   302 
       
   303 UNS16 TestMaster_ObjdictSize = sizeof(TestMaster_objdict)/sizeof(TestMaster_objdict[0]); 
       
   304 
       
   305 CO_Data TestMaster_Data = CANOPEN_NODE_DATA_INITIALIZER(TestMaster);
       
   306