CANopen Slave Documentation
Version 6.16.04
|
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.
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) |
uint16_t CosTmrCalcTicks | ( | uint16_t | uwReqTimingV | ) |
[in] | uwReqTimingV | requested time in milliseconds |
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.
uint16_t CosTmrCalcTime | ( | uint16_t | uwTicksV | ) |
[in] | uwTicksV | number of timer ticks |
The function calculates the time (in milliseconds) based on the given number of timer ticks and the constant value COS_TIMER_PERIOD.
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
void CosTmrTimeStampConsume | ( | CosTimeOfDay_ts * | ptsTimeStampV | ) |
[in] | ptsTimeStampV | Pointer to time-of-day structure |
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.
void CosTmrTimeStampProduce | ( | CosTimeOfDay_ts * | ptsTimeStampV | ) |
[in] | ptsTimeStampV | Pointer 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.