?? objdict.c
字號:
/*************************************************************************** objdict.c - description ------------------- begin : Fri May 17 2002 copyright : (C) 2002 by Raphael Zulliger email : zulli@hsr.ch ***************************************************************************//*************************************************************************** * * * This library is Copyright (c) Raphael Zulliger <zulli@gmx.net>. * * It is licensed under the GNU Library General Public License (LGPL). * * * ***************************************************************************/#include <objdict.h>/** index 1000h: device type. You have to change the value below, so * it fits your canopen-slave-module */const CODE UNSIGNED32 devicetype = 0xFFFF;const CODE subindex Index1000[] ={ { RO, uint32, sizeof(UNSIGNED32), (void*)&devicetype }};/** index 1001: error register. Change the entries to fit your application */const CODE UNSIGNED8 errorRegister;const CODE subindex CODE Index1001[] ={ { RO, uint8, sizeof(UNSIGNED8), (void*)&errorRegister }};/** consumer heartbeat time [ms]. The time within a new heartbeat message * has to be received fCODE an other node (the node's id must be defined * of course. Maybe your device does not consume heartbeat, so you can * delete this object dictionary entry. *//** heartbeat consumer time array adjust the count of entries by * the COUNT_OF_HEARTBEAT_CONSUMER define (see objdict.h file) */static RAM UNSIGNED32 HBConsumerTimeArray[COUNT_OF_HEARTBEAT_CONSUMER];static RAM BYTE HBConsumerCount;RAM subindex Index1016[] ={ { RO, uint8, sizeof(UNSIGNED8), (void*)&HBConsumerCount }, { RW, uint32, sizeof(UNSIGNED32), (void*)&HBConsumerTimeArray[0] }};/** If this CANope node produces heartbeats, then this entry is needed. * you have to define the time in [ms] within this node has to send * a heartbeat-message */static RAM UNSIGNED16 HBProducerTime;RAM subindex Index1017[] ={ { RW, uint16, sizeof(UNSIGNED16), &HBProducerTime }};/** index 1018: identify object. Adjust the entries for your node/company */const CODE s_identity theIdentity ={ 4, // number of supported entries 0x1234, // Vendor-ID (given by the can-cia) 0x5678, // Product Code 0x1364, // Revision number 0x7964, // serial number} ;const CODE subindex Index1018[] ={ { RO, uint8, sizeof(UNSIGNED8), (void*)&theIdentity.count }, { RO, uint32, sizeof(UNSIGNED32), (void*)&theIdentity.vendor_id}, { RO, uint32, sizeof(UNSIGNED32), (void*)&theIdentity.product_code}, { RO, uint32, sizeof(UNSIGNED32), (void*)&theIdentity.revision_number}, { RO, uint32, sizeof(UNSIGNED32), (void*)&theIdentity.serial_number}};/** now the communication profile entries are grouped together, so they * can be accessed in a standardised manner. This could be memory-optimized * if the empty entries wouldn't be added, but then the communictaionprofile * area must be accessed different (see objacces.c file) */const CODE indextable FAR CommunicationProfileArea[] ={ DeclareIndexTableEntry(Index1000), // creates a line like: { Index1000, 1 }, DeclareIndexTableEntry(Index1001), { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, DeclareIndexTableEntry(Index1016), DeclareIndexTableEntry(Index1017), DeclareIndexTableEntry(Index1018),};/************************************************************************** This is the part of the object directory which contains the* Receive PDO parameters...*************************************************************************//** Usually the ID of a PDO is 0x200 + device_node_id, but the node_id is not * known during compilation... so what to do?! the correct values have * to be setted up during bootup of the device... *//** the following count of defined variables has to be the same as defined * in the objdict.h file with the define: RECEIVE_PDO_LAST * and the define: TRANSMIT_PDO_LAST */static RAM s_pdo_communication_parameter RxPDO1 = { 2, 0x200, 255 };static RAM subindex Index1400[] ={ { RO, uint8, sizeof( UNSIGNED8 ), (void*)&RxPDO1.count }, { RO, uint32, sizeof( UNSIGNED32), (void*)&RxPDO1.cob_id }, { RO, uint32, sizeof( UNSIGNED32), (void*)&RxPDO1.type }};/** if your device supports more than one receiving-PDO, you have * to create more variables below. *///s_pdo_communication_parameter CODE RxPDO2 = { 2, 0x300, 255 };//subindex CODE Index1401[] =//{// { RO, uint8, sizeof( UNSIGNED8 ), &RxPDO2.count },// { RO, uint32, sizeof( UNSIGNED32), &RxPDO2.cob_id },// { RO, uint32, sizeof( UNSIGNED32), &RxPDO2.type }//};////s_pdo_communication_parameter CODE RxPDO3 = { 2, 0x400, 255 };//subindex CODE Index1402[] =//{// { RO, uint8, sizeof( UNSIGNED8 ), &RxPDO3.count },// { RO, uint32, sizeof( UNSIGNED32), &RxPDO3.cob_id },// { RO, uint32, sizeof( UNSIGNED32), &RxPDO3.type }//};////s_pdo_communication_parameter CODE RxPDO4 = { 2, 0x500, 255 };//subindex CODE Index1403[] =//{// { RO, uint8, sizeof( UNSIGNED8 ), &RxPDO4.count },// { RO, uint32, sizeof( UNSIGNED32), &RxPDO4.cob_id },// { RO, uint32, sizeof( UNSIGNED32), &RxPDO4.type }//};///** Create the Receive PDO Parameter area. */const CODE indextable FAR receivePDOParameter[] ={ DeclareIndexTableEntry(Index1400) //,// DeclareIndexTableEntry(Index1401),// DeclareIndexTableEntry(Index1402),// DeclareIndexTableEntry(Index1403)};/************************************************************************** This is the part of the object directory which contains the* Transmit PDO parameters...*************************************************************************//** Usually the ID of a transmitting PDO is 0x180 + device_node_id, * but the node_id is not known during compilation... so what to do?! * the correct values have to be setted up during bootup of the device... */static RAM s_pdo_communication_parameter TxPDO1 = { 2, 0x180, 255 };static RAM subindex Index1800[] ={ { RO, uint8, sizeof( UNSIGNED8 ), (void*)&TxPDO1.count }, { RO, uint32, sizeof( UNSIGNED32), (void*)&TxPDO1.cob_id }, { RO, uint32, sizeof( UNSIGNED32), (void*)&TxPDO1.type }};/** if your device supports more than one receiving-PDO, you have * to create more variables below. *///s_pdo_communication_parameter CODE TxPDO2 = { 2, 0x280, 255 };//subindex CODE Index1801[] =//{// { RO, uint8, sizeof( UNSIGNED8 ), &TxPDO2.count },// { RO, uint32, sizeof( UNSIGNED32), &TxPDO2.cob_id },// { RO, uint32, sizeof( UNSIGNED32), &TxPDO2.type }//};////s_pdo_communication_parameter CODE TxPDO3 = { 2, 0x380, 255 };//subindex CODE Index1802[] =//{// { RO, uint8, sizeof( UNSIGNED8 ), &TxPDO3.count },// { RO, uint32, sizeof( UNSIGNED32), &TxPDO3.cob_id },// { RO, uint32, sizeof( UNSIGNED32), &TxPDO3.type }//};////s_pdo_communication_parameter CODE TxPDO4 = { 2, 0x480, 255 };//subindex CODE Index1803[] =//{// { RO, uint8, sizeof( UNSIGNED8 ), &TxPDO4.count },// { RO, uint32, sizeof( UNSIGNED32), &TxPDO4.cob_id },// { RO, uint32, sizeof( UNSIGNED32), &TxPDO4.type }//};///** Create the Transmitting PDO Parameter area. */const CODE indextable FAR transmitPDOParameter[] ={ DeclareIndexTableEntry(Index1800) //,// DeclareIndexTableEntry(Index1801),// DeclareIndexTableEntry(Index1802),// DeclareIndexTableEntry(Index1803)};/************************************************************************** This is the part of the object directory which contains the* Receive PDO Mapping parameters...*************************************************************************//** GNU C-compiler accepts empty initialization of arrays like this one: * s_pdo_mapping_parameter RxMap1 = { 0, { } }; * but Microchip C18 doesn't... therefore create this define... *//** the following count of defined variables has to be the same as defined * in the objdict.h file with the define: RECEIVE_PDO_MAPPING_LAST * and the define: TRANSMIT_PDO_MAPPING_LAST */#define FILL_DATA_S_PDO_MAPPING 0, 0, 0, 0static RAM s_pdo_mapping_parameter RxMap1 = { 0, { FILL_DATA_S_PDO_MAPPING } };//static s_pdo_mapping_parameter CODE RxMap2 = { 0, { FILL_DATA_S_PDO_MAPPING } };//static s_pdo_mapping_parameter CODE RxMap3 = { 0, { FILL_DATA_S_PDO_MAPPING } };//static s_pdo_mapping_parameter CODE RxMap4 = { 0, { FILL_DATA_S_PDO_MAPPING } };#undef FILL_DATA_S_PDO_MAPPINGRAM subindex Index1600[] ={ { RW, uint8, sizeof( UNSIGNED8 ), (void*)&RxMap1.count }, { RW, uint32, sizeof( UNSIGNED32 ), (void*)&RxMap1.object[0] }, { RW, uint32, sizeof( UNSIGNED32 ), (void*)&RxMap1.object[1] }, { RW, uint32, sizeof( UNSIGNED32 ), (void*)&RxMap1.object[2] }, { RW, uint32, sizeof( UNSIGNED32 ), (void*)&RxMap1.object[3] }};//subindex CODE Index1601[] =//{// { RW, uint8, sizeof( UNSIGNED8 ), &RxMap2.count },// { RW, uint32, sizeof( UNSIGNED32 ), &RxMap2.object[0] },// { RW, uint32, sizeof( UNSIGNED32 ), &RxMap2.object[1] },// { RW, uint32, sizeof( UNSIGNED32 ), &RxMap2.object[2] },// { RW, uint32, sizeof( UNSIGNED32 ), &RxMap2.object[3] }//};////subindex CODE Index1602[] =//{// { RW, uint8, sizeof( UNSIGNED8 ), &RxMap3.count },// { RW, uint32, sizeof( UNSIGNED32 ), &RxMap3.object[0] },// { RW, uint32, sizeof( UNSIGNED32 ), &RxMap3.object[1] },// { RW, uint32, sizeof( UNSIGNED32 ), &RxMap3.object[2] },// { RW, uint32, sizeof( UNSIGNED32 ), &RxMap3.object[3] }//};////subindex CODE Index1603[] =//{// { RW, uint8, sizeof( UNSIGNED8 ), &RxMap4.count },// { RW, uint32, sizeof( UNSIGNED32 ), &RxMap4.object[0] },// { RW, uint32, sizeof( UNSIGNED32 ), &RxMap4.object[1] },// { RW, uint32, sizeof( UNSIGNED32 ), &RxMap4.object[2] },// { RW, uint32, sizeof( UNSIGNED32 ), &RxMap4.object[3] }//};//const CODE indextable FAR RxPDOMappingTable[ ] ={ DeclareIndexTableEntry(Index1600) //,// DeclareIndexTableEntry(Index1601),// DeclareIndexTableEntry(Index1602),// DeclareIndexTableEntry(Index1603)};/************************************************************************** This is the part of the object directory which contains the* Transmit PDO Mapping parameters...*************************************************************************//** All the same thing as described above (see Receiving PDO-Mapping */#define FILL_DATA_S_PDO_MAPPING 0, 0, 0, 0static RAM s_pdo_mapping_parameter TxMap1 = { 0, { FILL_DATA_S_PDO_MAPPING } };//static RAM s_pdo_mapping_parameter TxMap2 = { 0, { FILL_DATA_S_PDO_MAPPING } };//static RAM s_pdo_mapping_parameter TxMap3 = { 0, { FILL_DATA_S_PDO_MAPPING } };//static RAM s_pdo_mapping_parameter TxMap4 = { 0, { FILL_DATA_S_PDO_MAPPING } };#undef FILL_DATA_S_PDO_MAPPINGRAM subindex Index1A00[] ={ { RW, uint8, sizeof( UNSIGNED8 ), (void*)&TxMap1.count }, { RW, uint32, sizeof( UNSIGNED32 ), (void*)&TxMap1.object[0] }, { RW, uint32, sizeof( UNSIGNED32 ), (void*)&TxMap1.object[1] }, { RW, uint32, sizeof( UNSIGNED32 ), (void*)&TxMap1.object[2] }, { RW, uint32, sizeof( UNSIGNED32 ), (void*)&TxMap1.object[3] }};//subindex CODE Index1A01[] =//{// { RW, uint8, sizeof( UNSIGNED8 ), (void*)&TxMap2.count },// { RW, uint32, sizeof( UNSIGNED32 ), (void*)&TxMap2.object[0] },// { RW, uint32, sizeof( UNSIGNED32 ), (void*)&TxMap2.object[1] },// { RW, uint32, sizeof( UNSIGNED32 ), (void*)&TxMap2.object[2] },// { RW, uint32, sizeof( UNSIGNED32 ), (void*)&TxMap2.object[3] }//};//subindex CODE Index1A02[] =//{// { RW, uint8, sizeof( UNSIGNED8 ), (void*)&TxMap3.count },// { RW, uint32, sizeof( UNSIGNED32 ), (void*)&TxMap3.object[0] },// { RW, uint32, sizeof( UNSIGNED32 ), (void*)&TxMap3.object[1] },// { RW, uint32, sizeof( UNSIGNED32 ), (void*)&TxMap3.object[2] },// { RW, uint32, sizeof( UNSIGNED32 ), (void*)&TxMap3.object[3] }//};//subindex CODE Index1A03[] =//{// { RW, uint8, sizeof( UNSIGNED8 ), &TxMap4.count },// { RW, uint32, sizeof( UNSIGNED32 ), &TxMap4.object[0] },// { RW, uint32, sizeof( UNSIGNED32 ), &TxMap4.object[1] },// { RW, uint32, sizeof( UNSIGNED32 ), &TxMap4.object[2] },// { RW, uint32, sizeof( UNSIGNED32 ), &TxMap4.object[3] }//};//const CODE indextable FAR TxPDOMappingTable[ ] ={ DeclareIndexTableEntry(Index1A00)//,// DeclareIndexTableEntry(Index1A01),// DeclareIndexTableEntry(Index1A02),// DeclareIndexTableEntry(Index1A03)};/*********************************************************************** ** PROFILES begins here *********************************************** ***********************************************************************//** As described in the CANopen standard, there are seperated profile- * definitions. e.g. there are definition for digital I/O device, * analog I/O-devices, ... * At the moment this object dictionary can only be used for digital * I/O devices (DS-401). * In future, it maybe would be useful if we define such profiles in * seperate files... *//** DS-401 *//** digital inputs. Inputs of this node (e.g. port a). this value * will be sent to an other node */static RAM UNSIGNED8 digitalInputCount = (BYTE)COUNT_OF_DIGITAL_INPUT;/** At the moment we use 3 digital input vars (3 * 8Bit Variables) */static RAM UNSIGNED8 digitalInputVar1;static RAM UNSIGNED8 digitalInputVar2;static RAM UNSIGNED8 digitalInputVar3;RAM subindex Index6000[] ={ { RO, uint8, sizeof( UNSIGNED8 ), (void*)&digitalInputCount }, { RW, uint8, sizeof( UNSIGNED8 ), (void*)&digitalInputVar1 }, { RW, uint8, sizeof( UNSIGNED8 ), (void*)&digitalInputVar2 }, { RW, uint8, sizeof( UNSIGNED8 ), (void*)&digitalInputVar3 }};const CODE indextable FAR digitalInputTable[] ={ DeclareIndexTableEntry(Index6000)};/** Digital outputs. This means, this node receives a value of an other node * and sets this value to the variable... */static RAM UNSIGNED8 digitalOutputCount = (BYTE)COUNT_OF_DIGITAL_OUTPUT;static RAM UNSIGNED8 digitalOutputVar1;RAM subindex Index6200[] ={ { RO, uint8, sizeof( UNSIGNED8 ), (void*)&digitalOutputCount }, { RW, uint8, sizeof( UNSIGNED8 ), (void*)&digitalOutputVar1 }};const CODE indextable FAR digitalOutputTable[] ={ DeclareIndexTableEntry(Index6200)};
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -