CANopen Master Documentation
Version 6.08.00
Loading...
Searching...
No Matches
com_demo_pdo.c

//====================================================================================================================//
// File: com_demo_pdo.c //
// Description: Examples for PDO service in CANopen Master stack //
// //
// Copyright (C) MicroControl GmbH & Co. KG //
// 53844 Troisdorf - Germany //
// www.microcontrol.net //
// //
//--------------------------------------------------------------------------------------------------------------------//
// The copyright to the computer program(s) herein is the property of MicroControl GmbH & Co. KG, Germany. The //
// program(s) may be used and/or copied only with the written permission of MicroControl GmbH & Co. KG or in //
// accordance with the terms and conditions stipulated in the agreement/contract under which the program(s) have //
// been supplied. //
// //
//====================================================================================================================//
/*--------------------------------------------------------------------------------------------------------------------*\
** Include files **
** **
\*--------------------------------------------------------------------------------------------------------------------*/
#include "com_pdo.h" // CANopen Master PDO service
#include "com_mgr.h" // CANopen Master management
//--------------------------------------------------------------------------------------------------------------------//
// ComDemoPdoTrmInit() //
// initialise Transmit PDOs //
//--------------------------------------------------------------------------------------------------------------------//
#if COM_PDO_TRM_MAX == 0
{
}
#else
{
uint16_t uwIdOffsetT;
//---------------------------------------------------------------------------------------------------
// calculate ID offset
//
uwIdOffsetT = ComMgrNodeId(ubNetV);
//---------------------------------------------------------------------------------------------------
// initialise TPDOs
//
ComPdoConfig(ubNetV, 0,
ePDO_DIR_TRM, // direction
0x0180 + uwIdOffsetT, // identifier
3, // DLC
ePDO_TYPE_SYNC_1, // transmissions type
0); // event timer
ComPdoEnable(ubNetV, 0, ePDO_DIR_TRM, 1);
ComPdoConfig(ubNetV, 1,
ePDO_DIR_TRM, // direction
0x0280 + uwIdOffsetT, // identifier
8, // DLC
ePDO_TYPE_EVENT_PROFILE, // transmissions type
0); // event timer
ComPdoEnable(ubNetV, 1, ePDO_DIR_TRM, 1);
ComPdoConfig(ubNetV, 2,
ePDO_DIR_TRM, // direction
0x0380 + uwIdOffsetT, // identifier
8, // DLC
ePDO_TYPE_EVENT_PROFILE, // transmissions type
0); // event timer
ComPdoEnable(ubNetV, 3, ePDO_DIR_TRM, 1);
return(eCOM_ERR_NONE);
}
#endif
//--------------------------------------------------------------------------------------------------------------------//
// ComDemoPdoRcvInit() //
// initialise Receive PDOs //
//--------------------------------------------------------------------------------------------------------------------//
#if COM_PDO_RCV_MAX == 0
{
}
#else
{
uint16_t uwIdOffsetT;
//---------------------------------------------------------------------------------------------------
// calculate ID offset
//
uwIdOffsetT = ComMgrNodeId(ubNetV);
//---------------------------------------------------------------------------------------------------
// initialise RPDOs
//
ComPdoConfig(ubNetV, 0,
ePDO_DIR_RCV, // direction
0x0200 + uwIdOffsetT, // identifier
8, // DLC
ePDO_TYPE_EVENT_PROFILE, // transmissions type
0); // event timer
ComPdoEnable(ubNetV, 0, ePDO_DIR_RCV, 1);
ComPdoConfig(ubNetV, 1,
ePDO_DIR_RCV, // direction
0x0300 + uwIdOffsetT, // identifier
8, // DLC
ePDO_TYPE_EVENT_PROFILE, // transmissions type
0); // event timer
ComPdoEnable(ubNetV, 1, ePDO_DIR_RCV, 1);
ComPdoConfig(ubNetV, 2,
ePDO_DIR_RCV, // direction
0x0400 + uwIdOffsetT, // identifier
8, // DLC
ePDO_TYPE_EVENT_PROFILE, // transmissions type
0); // event timer
ComPdoEnable(ubNetV, 2, ePDO_DIR_RCV, 1);
return(eCOM_ERR_NONE);
} // ComDemoPdoRcvInit
#endif
int32_t ComStatus_tv
Definition com_defs.h:116
@ eCOM_ERR_SERVICE_MODE
Definition com_defs.h:245
@ eCOM_ERR_NONE
Definition com_defs.h:155
ComStatus_tv ComDemoPdoTrmInit(uint8_t ubNetV)
ComStatus_tv ComDemoPdoRcvInit(uint8_t ubNetV)
CANopen Master management functions .
uint8_t ComMgrNodeId(uint8_t ubNetV)
CANopen Master PDO service .
@ ePDO_DIR_RCV
Definition com_pdo.h:91
@ ePDO_DIR_TRM
Definition com_pdo.h:96
@ ePDO_TYPE_SYNC_1
Definition com_pdo.h:117
@ 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)
#define CPP_PARM_UNUSED(x)
Definition mc_compiler.h:261




*/