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

//====================================================================================================================//
// File: com_demo_sync.c //
// Description: Examples for SYNC 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 **
** **
\*--------------------------------------------------------------------------------------------------------------------*/
//------------------------------------------------------------------------------------------------------
// CANopen Master demo header
//
#include "com_demo.h"
#if COM_SYNC_SUPPORT > 0
//--------------------------------------------------------------------------------------------------------------------//
// ComDemoSyncCounter() //
// Start SYNC with identifier 201h and SYNC counter, cycle time 20 ms //
//--------------------------------------------------------------------------------------------------------------------//
{
ComStatus_tv tvStatusT;
//---------------------------------------------------------------------------------------------------
// disable the SYNC service, otherwise we can't change the identifier value
//
tvStatusT = ComSyncEnable(ubNetV, 0);
if(tvStatusT != eCOM_ERR_NONE)
{
return(tvStatusT);
}
//---------------------------------------------------------------------------------------------------
// now set the identifier to 201h
//
tvStatusT = ComSyncSetId(ubNetV, 0x0201);
if(tvStatusT != eCOM_ERR_NONE)
{
return (tvStatusT);
}
//---------------------------------------------------------------------------------------------------
// the SYNC counter shall run from 1 .. 32
//
tvStatusT = ComSyncSetCounter(ubNetV, 32);
if(tvStatusT != eCOM_ERR_NONE)
{
return (tvStatusT);
}
//---------------------------------------------------------------------------------------------------
// set the cycle time to 20 ms
// we don't check the return value here because nothing bad can happen at this stage
//
ComSyncSetCycleTime(ubNetV, 20000);
//---------------------------------------------------------------------------------------------------
// enable the SYNC service again
//
ComSyncEnable(ubNetV, 1);
return(tvStatusT);
}
//--------------------------------------------------------------------------------------------------------------------//
// ComDemoSyncStart() //
// Start SYNC with default identifier and 500 milliseconds cycle time //
//--------------------------------------------------------------------------------------------------------------------//
{
ComStatus_tv tvStatusT;
//---------------------------------------------------------------------------------------------------
// set the cycle time to 500 ms
//
#if COM_SYNC_SUPPORT == 1
tvStatusT = ComSyncSetCycleTime(ubNetV, 500000);
if(tvStatusT != eCOM_ERR_NONE)
{
return(tvStatusT);
}
#endif
//---------------------------------------------------------------------------------------------------
// enable the SYNC service
//
tvStatusT = ComSyncEnable(ubNetV, 1);
return(tvStatusT);
}
#endif
int32_t ComStatus_tv
Definition com_defs.h:116
@ eCOM_ERR_NONE
Definition com_defs.h:155
Demo functions for CANopen Master protocol stack services .
ComStatus_tv ComDemoSyncStart(uint8_t ubNetV)
ComStatus_tv ComDemoSyncCounter(uint8_t ubNetV)
ComStatus_tv ComSyncSetCycleTime(uint8_t ubNetV, uint32_t ulTimeV)
ComStatus_tv ComSyncSetId(uint8_t ubNetV, uint32_t ulIdV)
ComStatus_tv ComSyncEnable(uint8_t ubNetV, uint8_t ubEnableV)
ComStatus_tv ComSyncSetCounter(uint8_t ubNetV, uint8_t ubCounterV)




*/