CANopen Master Documentation
Version 6.06.04
Loading...
Searching...
No Matches
com_pdo.h File Reference

Detailed Description

The real-time data transfer is performed by means of "Process Data Objects (PDO)". The transfer of PDOs is performed with no protocol overhead. The PDOs correspond to entries in the device Object Dictionary and provide the interface to the application objects. Data type and mapping of application objects into a PDO is determined by a corresponding default PDO mapping structure within the Device Object Dictionary. If variable PDO-mapping is supported the number of PDOs and the mapping of application objects into a PDO may be transmitted to a device during the device configuration process by applying the SDO services (see com_sdo_cln.h) to the corresponding entries of the Object Dictionary. Number and length of PDOs of a device is application specific and are specified within the device profile.

There are two kinds of use for PDOs. The first is data transmission and the second data reception. It is distinguished in Transmit-PDOs (TPDOs) and Receive-PDOs (RPDOs). Devices supporting TPDOs are PDO producer and devices which are able to receive PDOs are called PDO consumer.

In order to access the maximum number of PDOs, the API uses the parameter uwPdoNumV, which is called PDO number. The value for PDO number is 0 to COM_PDO_RCV_MAX - 1 for Receive PDOs and 0 to COM_PDO_TRM_MAX - 1 for Transmit PDOs.

The PDO communication section explains in detail the usage of the API and provides examples.

RPDO queue support

RPDO messages can be stored in a queue, the queue is disabled by default. The function ComPdoRcvQueueEnable() is used to enable a queue for RPDO messages. By means of the function ComPdoRcvQueueCount() the number of messages stored inside the queue can be retrieved. RPDO messages can be fetched from the queue by calling ComPdoRcvQueueFetch(). The example in RPDO Queue shows how to read messages.

+ Include dependency graph for com_pdo.h:

Data Structures

struct  ComPdoMapping_s
 

Typedefs

typedef void(* ComPdoMapHandler_fn) (uint32_t ulMapEntryV)
 

Enumerations

enum  PdoDir_e {
  ePDO_DIR_RCV = 0 ,
  ePDO_DIR_TRM
}
 
enum  PdoType_e {
  ePDO_TYPE_SYNC_0 = 0 ,
  ePDO_TYPE_SYNC_1 = 1 ,
  ePDO_TYPE_SYNC_2 = 2 ,
  ePDO_TYPE_SYNC_3 = 3 ,
  ePDO_TYPE_SYNC_4 = 4 ,
  ePDO_TYPE_SYNC_5 = 5 ,
  ePDO_TYPE_SYNC_6 = 6 ,
  ePDO_TYPE_SYNC_7 = 7 ,
  ePDO_TYPE_SYNC_8 = 8 ,
  ePDO_TYPE_SYNC_240 = 240 ,
  ePDO_TYPE_res241 = 241 ,
  ePDO_TYPE_res253 = 253 ,
  ePDO_TYPE_EVENT_MANUFACTURER = 254 ,
  ePDO_TYPE_EVENT_PROFILE = 255
}
 

Functions

ComStatus_tv ComPdoAddMappingList (uint8_t ubNetV, CPP_CONST ComPdoMapping_ts *ptsRcvMapListV, CPP_CONST ComPdoMapping_ts *ptsTrmMapListV)
 
ComStatus_tv ComPdoConfig (uint8_t ubNetV, uint16_t uwPdoNumV, uint8_t ubPdoDirV, uint32_t ulIdV, uint8_t ubDlcV, uint8_t ubTypeV, uint16_t uwTimeV)
 
ComStatus_tv ComPdoEnable (uint8_t ubNetV, uint16_t uwPdoNumV, uint8_t ubPdoDirV, uint8_t ubEnableV)
 
void ComPdoEventReceive (uint8_t ubNetV, uint16_t uwPdoNumV)
 
void ComPdoEventTimeout (uint8_t ubNetV, uint16_t uwPdoNumV)
 
ComStatus_tv ComPdoGetId (uint8_t ubNetV, uint16_t uwPdoNumV, uint8_t ubPdoDirV, uint32_t *pulIdV)
 
uint16_t ComPdoGetMapIndex (uint32_t ulMapEntryV)
 
uint8_t ComPdoGetMapLength (uint32_t ulMapEntryV)
 
uint8_t ComPdoGetMapSubIndex (uint32_t ulMapEntryV)
 
ComStatus_tv ComPdoGetTimer (uint8_t ubNetV, uint16_t uwPdoNumV, uint8_t ubPdoDirV, uint16_t *puwTimeV)
 
ComStatus_tv ComPdoGetType (uint8_t ubNetV, uint16_t uwPdoNumV, uint8_t ubPdoDirV, uint8_t *pubTypeV)
 
ComStatus_tv ComPdoIsEnabled (uint8_t ubNetV, uint16_t uwPdoNumV, uint8_t ubPdoDirV, uint8_t *pubPdoEnableV)
 
ComSdoStatus_tv ComPdoRcvMapAdd (uint8_t ubNetV, uint16_t uwPdoNumV, uint8_t ubMapIdxV, uint32_t ulMapEntryV)
 
ComSdoStatus_tv ComPdoRcvMapEnable (uint8_t ubNetV, uint16_t uwPdoNumV, uint8_t ubMapNumberV)
 
ComStatus_tv ComPdoRcvQueueClear (uint8_t ubNetV)
 
ComStatus_tv ComPdoRcvQueueCount (uint8_t ubNetV, uint16_t *puwCountV)
 
ComStatus_tv ComPdoRcvQueueDisable (uint8_t ubNetV)
 
ComStatus_tv ComPdoRcvQueueEnable (uint8_t ubNetV)
 
ComStatus_tv ComPdoRcvQueueFetch (uint8_t ubNetV, CpCanMsg_ts *ptsCanMsgV)
 
ComStatus_tv ComPdoRelease (uint8_t ubNetV, uint16_t uwPdoNumV, uint8_t ubPdoDirV)
 
ComStatus_tv ComPdoSetTimer (uint8_t ubNetV, uint16_t uwPdoNumV, uint8_t ubPdoDirV, uint16_t uwTimeV)
 
ComStatus_tv ComPdoSetType (uint8_t ubNetV, uint16_t uwPdoNumV, uint8_t ubPdoDirV, uint8_t ubTypeV)
 
ComSdoStatus_tv ComPdoTrmMapAdd (uint8_t ubNetV, uint16_t uwPdoNumV, uint8_t ubMapIdxV, uint32_t ulMapEntryV)
 
ComSdoStatus_tv ComPdoTrmMapEnable (uint8_t ubNetV, uint16_t uwPdoNumV, uint8_t ubMapNumberV)
 
ComStatus_tv ComPdoTrmMapEvent (uint8_t ubNetV, uint32_t ulMapEntryV)
 
ComStatus_tv ComPdoTrmPacket (uint8_t ubNetV, uint16_t uwPdoNumV, uint8_t ubSizeV, uint8_t *pubSrcDataV)
 

Typedef Documentation

◆ ComPdoMapHandler_fn

ComPdoMapHandler_fn
Parameters
ulMapEntryVMapping entry

Signature of handler in structure ComPdoMapping_s. The optional handler is called during the PDO mapping procedure for RPDOs and TPDOs. The parameter ulMapEntryV is the mapping entry assigned to the handler. This allows that one handler can support multiple mapping entries.

Enumeration Type Documentation

◆ PdoDir_e

enum PdoDir_e

PDO direction.

The following enumeration values define the direction of a PDO. The direction is seen from the device point of view, hence a RPDO is received by the CANopen Master, while a TPDO is sent by the CANopen Master.

Enumerator
ePDO_DIR_RCV 

Receive-PDO (RPDO)

ePDO_DIR_TRM 

Transmit-PDO (TPDO)

◆ PdoType_e

enum PdoType_e

PDO transmission types.

The common used PDO transmission types are defined in this enumeration.

Enumerator
ePDO_TYPE_SYNC_0 

Synchronous, acyclic PDO

ePDO_TYPE_SYNC_1 

Synchronous, cyclic every SYNC

ePDO_TYPE_SYNC_2 

Synchronous, cyclic every 2nd SYNC

ePDO_TYPE_SYNC_3 

Synchronous, cyclic every 3rd SYNC

ePDO_TYPE_SYNC_4 

Synchronous, cyclic every 4th SYNC

ePDO_TYPE_SYNC_5 

Synchronous, cyclic every 5th SYNC

ePDO_TYPE_SYNC_6 

Synchronous, cyclic every 6th SYNC

ePDO_TYPE_SYNC_7 

Synchronous, cyclic every 7th SYNC

ePDO_TYPE_SYNC_8 

Synchronous, cyclic every 8th SYNC

ePDO_TYPE_SYNC_240 

Synchronous, cyclic every 240th SYNC

ePDO_TYPE_res241 

reserved transmission type

ePDO_TYPE_res253 

reserved transmission type

ePDO_TYPE_EVENT_MANUFACTURER 

Event-driven PDO, manufacturer specific

ePDO_TYPE_EVENT_PROFILE 

Event-driven PDO, profile specific

Function Documentation

◆ ComPdoAddMappingList()

ComStatus_tv ComPdoAddMappingList ( uint8_t  ubNetV,
CPP_CONST ComPdoMapping_ts ptsRcvMapListV,
CPP_CONST ComPdoMapping_ts ptsTrmMapListV 
)
Parameters
[in]ubNetVCANopen Network channel
[in]ptsRcvMapListVList of objects for RPDO mapping
[in]ptsTrmMapListVList of objects for TPDO mapping
Returns
Value of enumeration ComErr_e

This function adds individual PDO mapping lists for RPDO mapping defined by ptsRcvMapListV and TPDO mapping defined by ptsTrmMapListV. Each list defines which objects can be mapped into a PDO. As default a CANopen network has no mapping list. Setting the mapping list pointer to NULL disables the mapping list.

◆ ComPdoConfig()

ComStatus_tv ComPdoConfig ( uint8_t  ubNetV,
uint16_t  uwPdoNumV,
uint8_t  ubPdoDirV,
uint32_t  ulIdV,
uint8_t  ubDlcV,
uint8_t  ubTypeV,
uint16_t  uwTimeV 
)
Parameters
[in]ubNetVCANopen Network channel
[in]uwPdoNumVPDO number
[in]ubPdoDirVPDO direction
[in]ulIdVPDO identifier
[in]ubDlcVPDO DLC value (omitted)
[in]ubTypeVPDO transmission type
[in]uwTimeVPDO timer
Returns
Value of enumeration ComErr_e
See also
ComPdoRelease()

This function adds a new PDO to the CANopen Master. The PDO direction (RPDO or TPDO) is defined by the parameter ubPdoDirV. The parameter uwPdoNumV denotes the PDO number. The first PDO (TPDO1 or RPDO1) is located at PDO number 0.

The PDO identifier is configured by parameter ulIdV. Please note that the identifier value must meet the requirements for restricted CAN IDs of CiA 301 or CiA 1301.

The parameter ubDlcV is omitted by the function, it is kept for compatibility reasons to previous versions of the CANopen API. The DLC value of the PDO is calculated upon the PDO mapping entries.

Possible PDO transmission type values for parameter ubTypeV are listed inside the enumeration PdoType_e.

The function disables the transmission of TPDOs and reception of RPDOs as default. In order to enable a PDO use ComPdoEnable() afterwards.

Example

void MyPdoSetup(void)
{
//----------------------------------------------------------------------------------
// add first receive PDO, ID = 0x201, enable reception
//
//----------------------------------------------------------------------------------
// add two transmit PDOs, ID = 0x181 & 0x281, disabled by default
//
//----------------------------------------------------------------------------------
// this configuration fails because the identifier is restricted
//
{
// this is not allowed
}
}
@ eCOM_NET_1
Definition com_defs.h:723
@ eCOM_ERR_COB_ID_VALUE
Definition com_defs.h:213
@ ePDO_DIR_RCV
Definition com_pdo.h:91
@ ePDO_DIR_TRM
Definition com_pdo.h:96
@ ePDO_TYPE_EVENT_PROFILE
Definition com_pdo.h:177
ComStatus_tv ComPdoConfig(uint8_t ubNetV, uint16_t uwPdoNumV, uint8_t ubPdoDirV, uint32_t ulIdV, uint8_t ubDlcV, uint8_t ubTypeV, uint16_t uwTimeV)
ComStatus_tv ComPdoEnable(uint8_t ubNetV, uint16_t uwPdoNumV, uint8_t ubPdoDirV, uint8_t ubEnableV)

◆ ComPdoEnable()

ComStatus_tv ComPdoEnable ( uint8_t  ubNetV,
uint16_t  uwPdoNumV,
uint8_t  ubPdoDirV,
uint8_t  ubEnableV 
)
Parameters
[in]ubNetVCANopen Network channel
[in]uwPdoNumVPDO number
[in]ubPdoDirVPDO direction
[in]ubEnableVEnable/Disable PDO
Returns
Value of enumeration ComErr_e
See also
ComPdoConfig()

This function enables (ubEnableV = 1) or disables (ubEnableV = 0) a PDO. The PDO direction (RPDO or TPDO) is defined by the parameter ubPdoDirV. The parameter uwPdoNumV denotes the PDO number. The first PDO (TPDO1 or RPDO1) is located at PDO number 0. A PDO is disabled by default upon creation (refer to ComPdoConfig()).

◆ ComPdoEventReceive()

void ComPdoEventReceive ( uint8_t  ubNetV,
uint16_t  uwPdoNumV 
)
Parameters
[in]ubNetVCANopen Network channel
[in]uwPdoNumVPDO number

The function is called by the CANopen Master stack upon reception of a Receive-PDO (RPDO). The Receive PDO has to be configured by ComPdoConfig() in advance.

◆ ComPdoEventTimeout()

void ComPdoEventTimeout ( uint8_t  ubNetV,
uint16_t  uwPdoNumV 
)
Parameters
[in]ubNetVCANopen Network channel
[in]uwPdoNumVPDO number

The function is called by the CANopen Master stack when reception of a Receive-PDO (RPDO) times out. The RPDO has to be configured by ComPdoConfig() in advance. The transmission type of the RPDO must either ePDO_TYPE_EVENT_MANUFACTURER or ePDO_TYPE_EVENT_PROFILE. In addition the RPDO timer value must be set to a value greater than 0.

◆ ComPdoGetId()

ComStatus_tv ComPdoGetId ( uint8_t  ubNetV,
uint16_t  uwPdoNumV,
uint8_t  ubPdoDirV,
uint32_t *  pulIdV 
)
Parameters
[in]ubNetVCANopen Network channel
[in]uwPdoNumVPDO number
[in]ubPdoDirVPDO direction
[out]pulIdVPointer to buffer for PDO identifier
Returns
Value of enumeration ComErr_e
See also
ComPdoSetId()

The parameter uwPdoNumV denotes the PDO number, the PDO direction (TPDO or RPDO) is defined by parameter ubPdoDirV. The first PDO (TPDO1 or RPDO1) is located at PDO number 0. The function copies the identifier for the selected PDO into the variable pulIdV. In case the selected PDO is not configured the function returns eCOM_ERR_COB_ID_VALUE.

◆ ComPdoGetMapIndex()

uint16_t ComPdoGetMapIndex ( uint32_t  ulMapEntryV)
Parameters
[in]ulMapEntryVMapping entry
Returns
Index field of mapping entry

This helper function returns the index value of the mapping entry (see structure ComPdoMapping_s) defined by the parameter ulMapEntryV.

◆ ComPdoGetMapLength()

uint8_t ComPdoGetMapLength ( uint32_t  ulMapEntryV)
Parameters
[in]ulMapEntryVMapping entry
Returns
Length field of mapping entry

This helper function returns the length (in number of bits) of the mapping entry (see structure ComPdoMapping_s) defined by the parameter ulMapEntryV.

◆ ComPdoGetMapSubIndex()

uint8_t ComPdoGetMapSubIndex ( uint32_t  ulMapEntryV)
Parameters
[in]ulMapEntryVMapping entry
Returns
Sub-index field of mapping entry

This helper function returns the sub-index value of the mapping entry (see structure ComPdoMapping_s) defined by the parameter ulMapEntryV.

◆ ComPdoGetTimer()

ComStatus_tv ComPdoGetTimer ( uint8_t  ubNetV,
uint16_t  uwPdoNumV,
uint8_t  ubPdoDirV,
uint16_t *  puwTimeV 
)
Parameters
[in]ubNetVCANopen Network channel
[in]uwPdoNumVPDO number
[in]ubPdoDirVPDO direction
[out]puwTimeVPointer to buffer for PDO timer
Returns
Value of enumeration ComErr_e
See also
ComPdoSetTimer()

The parameter uwPdoNumV denotes the PDO number, the PDO direction (TPDO or RPDO) is defined by parameter ubPdoDirV. The first PDO (TPDO1 or RPDO1) is located at PDO number 0. The function copies the timer value for the selected PDO into the variable puwTimeV. In case the selected PDO is not configured the function returns eCOM_ERR_COB_TIMER.

◆ ComPdoGetType()

ComStatus_tv ComPdoGetType ( uint8_t  ubNetV,
uint16_t  uwPdoNumV,
uint8_t  ubPdoDirV,
uint8_t *  pubTypeV 
)
Parameters
[in]ubNetVCANopen Network channel
[in]uwPdoNumVPDO number
[in]ubPdoDirVPDO direction
[out]pubTypeVPointer to buffer for PDO transmission type
Returns
Value of enumeration ComErr_e
See also
ComPdoSetType()

The parameter uwPdoNumV denotes the PDO number, the PDO direction (TPDO or RPDO) is defined by parameter ubPdoDirV. The first PDO (TPDO1 or RPDO1) is located at PDO number 0. The function copies the transmission type for the selected PDO into the variable pubTypeV. In case the selected PDO is not configured the function returns eCOM_ERR_COB_TYPE.

◆ ComPdoIsEnabled()

ComStatus_tv ComPdoIsEnabled ( uint8_t  ubNetV,
uint16_t  uwPdoNumV,
uint8_t  ubPdoDirV,
uint8_t *  pubPdoEnableV 
)
Parameters
[in]ubNetVCANopen Network channel
[in]uwPdoNumVPDO number
[in]ubPdoDirVPDO direction
[out]pubPdoEnableVPointer to PDO enable/disable status
Returns
Value of enumeration ComErr_e

◆ ComPdoRcvMapAdd()

ComSdoStatus_tv ComPdoRcvMapAdd ( uint8_t  ubNetV,
uint16_t  uwPdoNumV,
uint8_t  ubMapIdxV,
uint32_t  ulMapEntryV 
)
Parameters
[in]ubNetVCANopen Network channel
[in]uwPdoNumVPDO number
[in]ubMapIdxVIndex for mapping entry
[in]ulMapEntryVMapping entry, according to CiA 301 / CiA 1301
Returns
Value of enumeration ComSdo_e
See also
ComPdoRcvMapEnable()

The function allows to add or modify PDO mapping entries for a RPDO defined by the parameter uwPdoNumV. The mappings entry is defined by the value of ubMapIdxV, the first entry starts with a value of 0. The last possible entry is located at COM_PDO_MAPPING_ENTRIES - 1.

Adding or modifying a mapping entry is only possible if the current mapping is not valid (disabled). Refer to ComPdoRcvMapEnable() for enabling or disabling of a mapping entry.

The following code snippet depicts how to add object 2001:01h as first mapping entry for RPDO1:

if (eCOM_SDO_WRITE_OK == ComPdoRcvMapAdd(eCOM_NET_1, 0, 0, 0x20010108))
{
// successfully added first mapping entry to first RPDO
}
@ eCOM_SDO_WRITE_OK
Definition com_defs.h:535
ComSdoStatus_tv ComPdoRcvMapAdd(uint8_t ubNetV, uint16_t uwPdoNumV, uint8_t ubMapIdxV, uint32_t ulMapEntryV)

For a more detailed explanation please refer to the RPDO mapping example.

◆ ComPdoRcvMapEnable()

ComSdoStatus_tv ComPdoRcvMapEnable ( uint8_t  ubNetV,
uint16_t  uwPdoNumV,
uint8_t  ubMapNumberV 
)
Parameters
[in]ubNetVCANopen Network channel
[in]uwPdoNumVPDO number
[in]ubMapNumberVNumber of mapping entries
Returns
Value of enumeration ComSdo_e
See also
ComPdoRcvMapAdd()

The function enables or disables a mapping for a RPDO defined by the parameter uwPdoNumV. The PDO mapping is disables when parameter ubMapNumberV is set to 0. A value > 0 for a ubMapNumberV enables the mapping, the value defines how many mapping entries are valid.

The following code snippet depicts how to enable one mapping entry for RPDO1:

{
// successfully enabled one mapping entry for RPDO1
}
ComSdoStatus_tv ComPdoRcvMapEnable(uint8_t ubNetV, uint16_t uwPdoNumV, uint8_t ubMapNumberV)

Mapping entries can be added or modified by usage of ComPdoRcvMapAdd().

◆ ComPdoRcvQueueClear()

ComStatus_tv ComPdoRcvQueueClear ( uint8_t  ubNetV)
Parameters
[in]ubNetVCANopen Network channel
Returns
Value of enumeration ComErr_e

The function removes all messages inside the PDO receive queue.

◆ ComPdoRcvQueueCount()

ComStatus_tv ComPdoRcvQueueCount ( uint8_t  ubNetV,
uint16_t *  puwCountV 
)
Parameters
[in]ubNetVCANopen Network channel
[out]puwCountVNumber of messages present in the queue
Returns
Value of enumeration ComErr_e

The function retrieves the number of pending elements inside a PDO receive queue.

◆ ComPdoRcvQueueDisable()

ComStatus_tv ComPdoRcvQueueDisable ( uint8_t  ubNetV)
Parameters
[in]ubNetVCANopen Network channel
Returns
Value of enumeration ComErr_e
See also
ComPdoQueueEnable()

The function disables the PDO receive queue on the selected CANopen network channel.

◆ ComPdoRcvQueueEnable()

ComStatus_tv ComPdoRcvQueueEnable ( uint8_t  ubNetV)
Parameters
[in]ubNetVCANopen Network channel
Returns
Value of enumeration ComErr_e
See also
ComPdoQueueDisable()

The function enables the PDO receive queue on the selected CANopen network channel.

◆ ComPdoRcvQueueFetch()

ComStatus_tv ComPdoRcvQueueFetch ( uint8_t  ubNetV,
CpCanMsg_ts ptsCanMsgV 
)
Parameters
[in]ubNetVCANopen Network channel
[out]ptsCanMsgVPointer to CAN message structure
Returns
Value of enumeration ComErr_e

The function fetches one CAN message from the PDO receive queue.

◆ ComPdoRelease()

ComStatus_tv ComPdoRelease ( uint8_t  ubNetV,
uint16_t  uwPdoNumV,
uint8_t  ubPdoDirV 
)
Parameters
[in]ubNetV- CANopen Network channel
[in]uwPdoNumV- PDO number
[in]ubPdoDirV- PDO direction
Returns
Value of enumeration ComErr_e
See also
ComPdoConfig()

This function releases a PDO from the CANopen Master. The PDO direction (RPDO or TPDO) is defined by the parameter ubPdoDirV. The parameter uwPdoNumV denotes the PDO number. The first PDO (TPDO1 or RPDO1) is located at PDO number 0.

◆ ComPdoSetTimer()

ComStatus_tv ComPdoSetTimer ( uint8_t  ubNetV,
uint16_t  uwPdoNumV,
uint8_t  ubPdoDirV,
uint16_t  uwTimeV 
)
Parameters
[in]ubNetVCANopen Network channel
[in]uwPdoNumVPDO number
[in]ubPdoDirVPDO direction
[in]uwTimeVPDO timer
Returns
Value of enumeration ComErr_e
See also
ComPdoGetTimer()

The parameter uwPdoNumV denotes the PDO number, the PDO direction (TPDO or RPDO) is defined by parameter ubPdoDirV. The first PDO (TPDO1 or RPDO1) is located at PDO number 0. The function sets the timer value for the selected PDO defined by uwTimeV. In case the selected PDO is not configured the function returns eCOM_ERR_COB_TIMER.

◆ ComPdoSetType()

ComStatus_tv ComPdoSetType ( uint8_t  ubNetV,
uint16_t  uwPdoNumV,
uint8_t  ubPdoDirV,
uint8_t  ubTypeV 
)
Parameters
[in]ubNetVCANopen Network channel
[in]uwPdoNumVPDO number
[in]ubPdoDirVPDO direction
[out]ubTypeVPDO transmission type
Returns
Value of enumeration ComErr_e
See also
ComPdoGetType()

The parameter uwPdoNumV denotes the PDO number, the PDO direction (TPDO or RPDO) is defined by parameter ubPdoDirV. The first PDO (TPDO1 or RPDO1) is located at PDO number 0. The function sets the transmission type for the selected PDO defined by ubTypeV. In case the selected PDO is not configured the function returns eCOM_ERR_COB_TYPE.

◆ ComPdoTrmMapAdd()

ComSdoStatus_tv ComPdoTrmMapAdd ( uint8_t  ubNetV,
uint16_t  uwPdoNumV,
uint8_t  ubMapIdxV,
uint32_t  ulMapEntryV 
)
Parameters
[in]ubNetVCANopen Network channel
[in]uwPdoNumVPDO number
[in]ubMapIdxVIndex for mapping entry
[in]ulMapEntryVMapping entry, according to CiA 301
Returns
Value of enumeration ComSdo_e

The function allows to add or modify PDO mapping entries for a TPDO defined by the parameter uwPdoNumV. The mappings entry is defined by the value of ubMapIdxV, the first entry starts with a value of 0.

Adding or modifying a mapping entry is only possible if the current mapping is not valid (disabled). Refer to ComPdoTrmMapEnable() for enabling or disabling of a mapping entry.

The following code snippet depicts how to add object 2011:01h as first mapping entry for TPDO1:

if (eCOM_SDO_WRITE_OK == ComPdoTrmMapAdd(eCOM_NET_1, 0, 0, 0x20110108))
{
// successfully added first mapping entry to first TPDO
}
ComSdoStatus_tv ComPdoTrmMapAdd(uint8_t ubNetV, uint16_t uwPdoNumV, uint8_t ubMapIdxV, uint32_t ulMapEntryV)

For a more detailed explanation please refer to the TPDO mapping example.

◆ ComPdoTrmMapEnable()

ComSdoStatus_tv ComPdoTrmMapEnable ( uint8_t  ubNetV,
uint16_t  uwPdoNumV,
uint8_t  ubMapNumberV 
)
Parameters
[in]ubNetVCANopen Network channel
[in]uwPdoNumVPDO number
[in]ubMapNumberVNumber of mapping entries
Returns
Value of enumeration ComSdo_e
See also
ComPdoTrmMapAdd()

The function enables or disables a mapping for a RPDO defined by the parameter uwPdoNumV. The PDO mapping is disables when parameter ubMapNumberV is set to 0. A value > 0 for a ubMapNumberV enables the mapping, the value defines how many mapping entries are valid.

The following code snippet depicts how to enable one mapping entry for RPDO1:

{
// successfully enabled one mapping entry for RPDO1
}

Mapping entries can be added or modified by usage of ComPdoRcvMapAdd().

◆ ComPdoTrmMapEvent()

ComStatus_tv ComPdoTrmMapEvent ( uint8_t  ubNetV,
uint32_t  ulMapEntryV 
)
Parameters
[in]ubNetVCANopen Network channel
[in]ulMapEntryVMapping entry, according to CiA 301
Returns
Value of enumeration ComErr_e

This function triggers transmission of a TPDO which contains the mapping entry defined by parameter ulMapEntryV. The function checks if the PDO is enabled and if the correct transmission type (ie. ePDO_TYPE_EVENT_MANUFACTURER or ePDO_TYPE_EVENT_PROFILE) is configured for the TPDO.

Transmission of a PDO is only possible in NMT Operational state (eCOM_NMT_STATE_OPERATIONAL).

The function returns a negative value from ComErr_e in case of an error. A positive value denotes how many times the entry ulMapEntryV has been mapped into a PDO.

◆ ComPdoTrmPacket()

ComStatus_tv ComPdoTrmPacket ( uint8_t  ubNetV,
uint16_t  uwPdoNumV,
uint8_t  ubSizeV,
uint8_t *  pubSrcDataV 
)
Parameters
[in]ubNetVCANopen Network channel
[in]uwPdoNumVPDO number
[in]ubSizeVSize of source data
[out]pubSrcDataVPointer to source data
Returns
Value of enumeration ComErr_e

This function triggers transmission of a TPDO defined by parameter uwPdoNumV. The first TPDO is located at PDO number 0.

The functions copies the the number of bytes defined by ubSizeV from pubSrcDataV to the PDO data field and pushes the CAN frame into an internal FIFO. A TPDO will only be transmitted under the following conditions:

Transmission of a PDO is only possible in NMT Operational state (eCOM_NMT_STATE_OPERATIONAL).