etisserant@0: /* etisserant@0: This file is part of CanFestival, a library implementing CanOpen Stack. etisserant@0: etisserant@0: Copyright (C): Edouard TISSERANT and Francis DUPIN etisserant@0: etisserant@0: See COPYING file for copyrights details. etisserant@0: etisserant@0: This library is free software; you can redistribute it and/or etisserant@0: modify it under the terms of the GNU Lesser General Public etisserant@0: License as published by the Free Software Foundation; either etisserant@0: version 2.1 of the License, or (at your option) any later version. etisserant@0: etisserant@0: This library is distributed in the hope that it will be useful, etisserant@0: but WITHOUT ANY WARRANTY; without even the implied warranty of etisserant@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU etisserant@0: Lesser General Public License for more details. etisserant@0: etisserant@0: You should have received a copy of the GNU Lesser General Public etisserant@0: License along with this library; if not, write to the Free Software etisserant@0: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA etisserant@0: */ etisserant@0: etisserant@0: #include "objdict.h" etisserant@0: etisserant@0: /**************************************************************************/ etisserant@0: /* Declaration of the mapped variables */ etisserant@0: /**************************************************************************/ etisserant@0: etisserant@0: /**************************************************************************/ etisserant@0: /* Declaration of the value range types */ etisserant@0: /**************************************************************************/ etisserant@0: etisserant@0: etisserant@0: etisserant@0: UNS32 gene_SYNC_valueRangeTest (UNS8 typeValue, UNS32 unsValue, REAL32 realValue) etisserant@0: { etisserant@0: switch (typeValue) { etisserant@0: } etisserant@0: return 0; etisserant@0: } etisserant@0: etisserant@0: etisserant@0: /**************************************************************************/ etisserant@0: /* The node id */ etisserant@0: /**************************************************************************/ etisserant@0: /* node_id default value. etisserant@0: This default value is deprecated. etisserant@0: You should always overwrite this by using the function setNodeId(UNS8 nodeId) in your C code. etisserant@0: */ etisserant@0: #define NODE_ID 0x03 etisserant@0: UNS8 gene_SYNC_bDeviceNodeId = NODE_ID; etisserant@0: etisserant@0: etisserant@0: //*****************************************************************************/ etisserant@0: /* Array of message processing information */ etisserant@0: /* Should not be modified */ etisserant@0: etisserant@0: const UNS8 gene_SYNC_iam_a_slave = 1; etisserant@0: etisserant@0: // Macros definition etisserant@0: etisserant@0: /* Beware : etisserant@0: index *must* be writen 4 numbers in hexa etisserant@0: sub_index *must* be writen 2 numbers in hexa etisserant@0: size_variable_in_UNS8 *must* be writen 2 numbers in hexa etisserant@0: */ etisserant@0: #define PDO_MAP(index, sub_index, size_variable_in_bits)\ etisserant@0: 0x ## index ## sub_index ## size_variable_in_bits etisserant@0: etisserant@0: /** This macro helps creating the object dictionary entries. etisserant@0: * by calling this macro etisserant@0: * it creates an entry in form of: 7 of entries, pointer to the entry. etisserant@0: */ etisserant@0: #define DeclareIndexTableEntry(entryname, index) { (subindex*)entryname,sizeof(entryname)/sizeof(entryname[0]), index} etisserant@0: etisserant@0: //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ etisserant@0: // etisserant@0: // OBJECT DICTIONARY etisserant@0: // etisserant@0: //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ etisserant@0: // Make your change, depending of your application etisserant@0: etisserant@0: etisserant@0: /* index 0x1000 : Device type. etisserant@0: You have to change the value below, so etisserant@0: it fits your canopen-slave-module */ etisserant@0: etisserant@0: /* Not used, so, should not be modified */ etisserant@0: etisserant@0: UNS32 gene_SYNC_obj1000 = 0; etisserant@0: subindex gene_SYNC_Index1000[] = etisserant@0: { etisserant@0: { RO, uint32, sizeof(UNS32), (void*)&gene_SYNC_obj1000 } etisserant@0: }; etisserant@0: etisserant@0: /* index 0x1001 : Error register. etisserant@0: Change the entries to fit your application etisserant@0: Not used, so, should not be modified */ etisserant@0: UNS8 gene_SYNC_obj1001 = 0x00000000; etisserant@0: subindex gene_SYNC_Index1001[] = etisserant@0: { etisserant@0: { RO, uint8, sizeof(UNS8), (void*)&gene_SYNC_obj1001 } etisserant@0: }; etisserant@0: etisserant@0: /* index 0x1005 : COB_ID SYNC */ etisserant@0: /* Should not be modified */ etisserant@0: UNS32 gene_SYNC_obj1005 = 0x40000080; // bit 30 = 1 : device can generate a SYNC message etisserant@0: // Beware, it is over written when the node etisserant@0: // enters in reset mode etisserant@0: // See initResetMode() in init.c etisserant@0: subindex gene_SYNC_Index1005[] = etisserant@0: { etisserant@0: { RW, uint32, sizeof(UNS32), (void*)&gene_SYNC_obj1005 } etisserant@0: }; etisserant@0: etisserant@0: /* index 0x1006 : SYNC period */ etisserant@0: // For producing the SYNC signal every n micro-seconds. etisserant@0: // Put 0 to not producing SYNC etisserant@0: UNS32 gene_SYNC_obj1006 = 0x000186A0; etisserant@0: // Default 0 to not produce SYNC // etisserant@0: // Beware, it is over written when the etisserant@0: // node enters in reset mode. etisserant@0: // See initResetMode() in init.c etisserant@0: subindex gene_SYNC_Index1006[] = etisserant@0: { etisserant@0: { RW, uint32, sizeof(UNS32), (void*)&gene_SYNC_obj1006 } etisserant@0: }; etisserant@0: etisserant@0: etisserant@0: TIMER_HANDLE gene_SYNC_heartBeatTimers[0]; etisserant@0: UNS32 gene_SYNC_obj1016[0]; etisserant@0: UNS8 gene_SYNC_obj1016_cnt = 0; etisserant@0: subindex gene_SYNC_Index1016[0]; etisserant@0: etisserant@0: UNS16 gene_SYNC_obj1017 = 0x0000; etisserant@0: /* index 0x1018 : Identity object */ etisserant@0: /** index 1018: identify object. Adjust the entries for your node/company etisserant@0: */ etisserant@0: /* Values can be modified */ etisserant@0: etisserant@0: s_identity gene_SYNC_obj1018 = etisserant@0: { etisserant@0: 4, // number of supported entries etisserant@0: 0, // Vendor-ID (given by the can-cia) etisserant@0: 0, // Product Code etisserant@0: 0, // Revision number etisserant@0: 0 // serial number etisserant@0: }; etisserant@0: etisserant@0: subindex gene_SYNC_Index1018[] = etisserant@0: { etisserant@0: { RO, uint8, sizeof(UNS8), (void*)&gene_SYNC_obj1018.count }, etisserant@0: { RO, uint32, sizeof(UNS32), (void*)&gene_SYNC_obj1018.vendor_id}, etisserant@0: { RO, uint32, sizeof(UNS32), (void*)&gene_SYNC_obj1018.product_code}, etisserant@0: { RO, uint32, sizeof(UNS32), (void*)&gene_SYNC_obj1018.revision_number}, etisserant@0: { RO, uint32, sizeof(UNS32), (void*)&gene_SYNC_obj1018.serial_number} etisserant@0: }; etisserant@0: etisserant@0: /* index 0x1200 : The SDO Server parameters */ etisserant@0: /* BEWARE You cannot define more than one SDO server */ etisserant@0: /* The values should not be modified here, etisserant@0: but can be changed at runtime */ etisserant@0: // Beware that the default values that you could put here etisserant@0: // will be over written at the initialisation of the node. etisserant@0: // See setNodeId() in init.c etisserant@0: s_sdo_parameter gene_SYNC_obj1200 = etisserant@0: { 3, // Number of entries. Always 3 for the SDO etisserant@0: 0x000, // The cob_id transmited in CAN msg to the server etisserant@0: 0x000, // The cob_id received in CAN msg from the server etisserant@0: 0x03 // The node id of the client. Should not be modified etisserant@0: }; etisserant@0: subindex gene_SYNC_Index1200[] = etisserant@0: { etisserant@0: { RO, uint8, sizeof( UNS8 ), (void*)&gene_SYNC_obj1200.count }, etisserant@0: { RO, uint32, sizeof( UNS32), (void*)&gene_SYNC_obj1200.cob_id_client }, etisserant@0: { RO, uint32, sizeof( UNS32), (void*)&gene_SYNC_obj1200.cob_id_server }, etisserant@0: { RW, uint8, sizeof( UNS8), (void*)&gene_SYNC_obj1200.node_id } etisserant@0: }; etisserant@0: etisserant@0: /* index 0x1280 : SDO client parameter */ etisserant@0: s_sdo_parameter gene_SYNC_obj1280 = etisserant@0: { 3, // Nb of entries etisserant@0: 0x000, // cobid transmited to the server. The good value should be 0x600 + server nodeId etisserant@0: 0x000, // cobid received from the server. The good value should be 0x580 + server nodeId etisserant@0: 0x00 // server NodeId etisserant@0: }; etisserant@0: subindex gene_SYNC_Index1280[] = etisserant@0: { etisserant@0: { RO, uint8, sizeof( UNS8 ), (void*)&gene_SYNC_obj1280.count }, etisserant@0: { RW, uint8, sizeof( UNS32 ), (void*)&gene_SYNC_obj1280.cob_id_client }, etisserant@0: { RW, uint8, sizeof( UNS32 ), (void*)&gene_SYNC_obj1280.cob_id_server }, etisserant@0: { RW, uint8, sizeof( UNS8 ), (void*)&gene_SYNC_obj1280.node_id } etisserant@0: }; etisserant@0: etisserant@0: etisserant@0: const indextable gene_SYNC_objdict[] = etisserant@0: { etisserant@0: DeclareIndexTableEntry(gene_SYNC_Index1000, 0x1000), etisserant@0: DeclareIndexTableEntry(gene_SYNC_Index1001, 0x1001), etisserant@0: DeclareIndexTableEntry(gene_SYNC_Index1005, 0x1005), etisserant@0: DeclareIndexTableEntry(gene_SYNC_Index1006, 0x1006), etisserant@0: DeclareIndexTableEntry(gene_SYNC_Index1018, 0x1018), etisserant@0: DeclareIndexTableEntry(gene_SYNC_Index1200, 0x1200), etisserant@0: DeclareIndexTableEntry(gene_SYNC_Index1280, 0x1280), etisserant@0: }; etisserant@0: etisserant@0: // To count at which received SYNC a PDO must be sent. etisserant@0: // Even if no pdoTransmit are defined, at least one entry is computed etisserant@0: // for compilations issues. etisserant@0: UNS8 gene_SYNC_count_sync[1] = {0, }; etisserant@0: etisserant@0: quick_index gene_SYNC_firstIndex = { etisserant@0: SDO_SVR : 5, etisserant@0: SDO_CLT : 6, etisserant@0: PDO_RCV : 0, etisserant@0: PDO_RCV_MAP : 0, etisserant@0: PDO_TRS : 0, etisserant@0: PDO_TRS_MAP : 0 etisserant@0: }; etisserant@0: etisserant@0: quick_index gene_SYNC_lastIndex = { etisserant@0: SDO_SVR : 5, etisserant@0: SDO_CLT : 6, etisserant@0: PDO_RCV : 0, etisserant@0: PDO_RCV_MAP : 0, etisserant@0: PDO_TRS : 0, etisserant@0: PDO_TRS_MAP : 0 etisserant@0: }; etisserant@0: etisserant@0: UNS16 gene_SYNC_ObjdictSize = sizeof(gene_SYNC_objdict)/sizeof(gene_SYNC_objdict[0]); etisserant@0: etisserant@0: CO_Data gene_SYNC_Data = CANOPEN_NODE_DATA_INITIALIZER(gene_SYNC); etisserant@0: