CANopen Slave Documentation
Version 6.16.04
Loading...
Searching...
No Matches
cos_time.h File Reference

Detailed Description

The are a number of CANopen services which require an internal timer (e.g. Heartbeat, timer-driven PDO). The timer values for these services are set in a multiple of 1 millisecond. The stack works internally with timer ticks. A timer tick has a resolution of 1 microsecond, the time span of a timer tick is set via the definition COS_TIMER_PERIOD inside the cos_conf.h file.

The requested time values are converted into timer ticks and vice versa with the functions CosTmrCalcTicks() and CosTmrCalcTime() respectively.

+ Include dependency graph for cos_time.h:

Data Structures

struct  CosTimeOfDay_s
 

Functions

uint16_t CosTmrCalcTicks (uint16_t uwReqTimingV)
 
uint16_t CosTmrCalcTime (uint16_t uwTicksV)
 
void CosTmrEvent (void)
 
void CosTmrTimeStampConsume (CosTimeOfDay_ts *ptsTimeStampV)
 
void CosTmrTimeStampProduce (CosTimeOfDay_ts *ptsTimeStampV)
 

Function Documentation

◆ CosTmrCalcTicks()

uint16_t CosTmrCalcTicks ( uint16_t  uwReqTimingV)
Parameters
[in]uwReqTimingVrequested time in milliseconds
Returns
number of required timer ticks
See also
CosTmrCalcTime()

The function calculates the number of required timer ticks (i.e. timer interrupts) based on the required time uwReqTimingV (in milliseconds) and the constant value COS_TIMER_PERIOD.

◆ CosTmrCalcTime()

uint16_t CosTmrCalcTime ( uint16_t  uwTicksV)
Parameters
[in]uwTicksVnumber of timer ticks
Returns
time in milliseconds
See also
CosTmrCalcTicks()

The function calculates the time (in milliseconds) based on the given number of timer ticks and the constant value COS_TIMER_PERIOD.

◆ CosTmrEvent()

void CosTmrEvent ( void  )

Execute Timer-based Services.

This routine must be called by a timer resource of the target system. It is responsible to call services that depend on a timer (e.g. Heartbeat). The period of the timer is defined via the COS_TIMER_PERIOD constant.

Example

//-------------------------------------------------------------//
// Timer interrupt service routine //
// //
//-------------------------------------------------------------//
void MyTimerInterrupt(void)
{
//... timer services of application ...
//--- call CANopen stack timer function -------------
//... retrigger the timer
}
void CosTmrEvent(void)
Execute Timer-based Services.

◆ CosTmrTimeStampConsume()

void CosTmrTimeStampConsume ( CosTimeOfDay_ts ptsTimeStampV)
Parameters
[in]ptsTimeStampVPointer to time-of-day structure
Note
Adopt this function to the application if required. The function implementation is located in the file cbl_user.c. The function is called by the protocol stack only if the symbol COS_DICT_OBJ_1012 is set to 1.

This function is called upon reception of a TIME message.

◆ CosTmrTimeStampProduce()

void CosTmrTimeStampProduce ( CosTimeOfDay_ts ptsTimeStampV)
Parameters
[in]ptsTimeStampVPointer to time-of-day structure

This function is used by the application in order to send a TIME message. Please note that the TIME object (1012h) must be configured for transmission. Otherwise the transmission request is dropped.