J1939 Documentation
Version 4.16.00
Loading...
Searching...
No Matches
j1939_tmr.h File Reference

Detailed Description

The timer values for J1939 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 J1939_TIMER_PERIOD inside the j1939_conf.h file.

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

+ Include dependency graph for j1939_tmr.h:

Functions

uint16_t J1939_TmrCalcTicks (uint16_t uwReqTimingV)
 
uint16_t J1939_TmrCalcTime (uint16_t uwTicksV)
 
void J1939_TmrEvent (void)
 

Function Documentation

◆ J1939_TmrCalcTicks()

uint16_t J1939_TmrCalcTicks ( uint16_t uwReqTimingV)

Calculate number of timer ticks.

Parameters
uwReqTimingV- requested time in milliseconds
Returns
number of required timer ticks
See also
J1939_TmrCalcTime()

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 J1939_TIMER_PERIOD.

◆ J1939_TmrCalcTime()

uint16_t J1939_TmrCalcTime ( uint16_t uwTicksV)

Calculate time based on timer ticks.

Parameters
uwTicksV- number of timer ticks
Returns
time in milliseconds
See also
J1939_TmrCalcTicks()

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

◆ J1939_TmrEvent()

void J1939_TmrEvent ( 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. BAM). The period of the timer is defined via the J1939_TIMER_PERIOD constant.

Example

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