CANopen Slave Documentation
Version 6.16.04
|
The structure CosPdoMapping_s describes the mappable objects of a device with dynamic PDO mapping. Dynamic PDO mapping is selected by setting the symbol COS_PDO_MAPPING to a value greater than 0.
The element ulMapEntry describes a mapping entry (see CiA 301). The void pointer pvdData links the mapping entry to application data. The function pointer pfnHandler links to a handler that is called after reception of a RPDO or before transmission of a TPDO.
If dynamic PDO mapping is used, the possible mapping entries of the application are defined in several *.inc files. The file cos_user_rpdo.inc contains a list with valid mapping entries for
RPDOs and the cos_user_tpdo.inc a list with mapping entries for the TrPDOs. In addition to the mapping entries, callback handlers can be added as an option. For a RPDO the handler is called after reception, for a Transmit-PDO the handler is called before transmission.
On reception of a PDO data will be distributed to all mapped values defined by pvdData before the corresponding handler (pfnHandler) is called. On transmission of a PDO the data will be collected from all mapped values defined by pvdData after the corresponding handler (pfnHandler) has been called.
As an example, the available mapping entries for a RPDO defined in cos_user_rpdo.inc are:
Starting from this list you can use the function CosPdoRcvMapAdd() to map the entries to the desired position inside the PDO. Upon PDO reception, the variables ubCosMob_Var2002G and/or uwCosMob_Var2003G are updated and the handler CosMob_PdoRcvHandler() is called.
The file cos_user_tpdo.inc contains an example for TPDO mapping entries:
Starting from this list you can use the function CosPdoTrmMapAdd() to map the entries to the desired position in the PDO. Upon transmission, the function CosMob_PdoTrmHandler() will be called and the content of the variables ulCosMob_Var2004G and/or uqCosMob_Var2005G will be copied into the PDO payload.
Data Fields | |
uint32_t | ulMapEntry |
void * | pvdData |
CosPdoMapHandler_fn | pfnHandler |
CosPdoMapping_s::pfnHandler |
Function Handler of corresponding mapping entry.
CosPdoMapping_s::pvdData |
Pointer to corresponding value
uint32_t CosPdoMapping_s::ulMapEntry |
Mapping entry, according to CiA 301
Bit 31 .. Bit 16 | Bit 15 .. Bit 8 | Bit 7 .. Bit 0 |
---|---|---|
Index | Sub-Index | Length |
The functions CosPdoGetMapIndex(), CosPdoGetMapSubIndex() and CosPdoGetMapLength() can be used to access the individual values.