CANopen Master Protocol Stack 
Version 7.00.02
Loading...
Searching...
No Matches
com_tmr.h File Reference

Detailed Description

There 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 microsecond or 1 millisecond (depends on the service).

The stack works internally with timer ticks. The duration of one timer tick equals the configured timer period, which is expressed in microseconds and defined by COM_TIMER_PERIOD inside the com_conf.h file. The default value is 1000 microseconds (1 millisecond). This default is applied during ComMgrInit().

The timer period can be read at run-time with ComTmrGetPeriod() and changed with ComTmrSetPeriod(). The requested time values are converted into timer ticks and vice versa with the functions ComTmrCalcTicks() and ComTmrCalcTime() respectively.

Include dependency graph for com_tmr.h:

Functions

uint32_t ComTmrCalcTicks (uint32_t ulReqTimingV)
uint32_t ComTmrCalcTime (uint32_t ulTicksV)
uint32_t ComTmrGetPeriod (void)
void ComTmrSetPeriod (uint32_t ulPeriodV)

Function Documentation

◆ ComTmrCalcTicks()

uint32_t ComTmrCalcTicks ( uint32_t ulReqTimingV)
Parameters
[in]ulReqTimingVrequested time in microseconds
Returns
number of required timer ticks
See also
ComTmrCalcTime()

The function calculates the number of required timer ticks based on the required time ulReqTimingV (in microseconds) and the current timer period (see ComTmrGetPeriod()). The result is rounded to the nearest tick.

◆ ComTmrCalcTime()

uint32_t ComTmrCalcTime ( uint32_t ulTicksV)
Parameters
[in]ulTicksVnumber of timer ticks
Returns
time in microseconds
See also
ComTmrCalcTicks()

The function calculates the time (in microseconds) based on the given number of timer ticks and the currently configured timer period (see ComTmrGetPeriod()).

◆ ComTmrGetPeriod()

uint32_t ComTmrGetPeriod ( void )
Returns
current timer period in microseconds

The function returns the current configured timer period in microseconds.

◆ ComTmrSetPeriod()

void ComTmrSetPeriod ( uint32_t ulPeriodV)
Parameters
[in]ulPeriodVtimer period in microseconds

The function sets the timer period which is used to call the function ComMgrTimerEvent(). The parameter ulPeriodV is a multiple of 1 microsecond. The default value of the timer period is defined by the constant value COM_TIMER_PERIOD, which is applied by ComMgrInit(). This function can be used to override the default value at run-time.

If ulPeriodV is 0, the function has no effect and the current period is retained.