RKH

Files

file  rkhtmr.h
 Specifies the interface of software timer services.
 

Data Structures

struct  RKH_TMR_T
 Defines the data structure used to maintain information that allows the timer-handling facility to update and expire software timers. More...
 

Macros

#define RKH_TMR_INIT(t_, e_, th_)   rkh_tmr_init_((t_), (e_), (th_))
 Initializes the previously allocated timer structure RKH_TMR_T. More...
 
#define RKH_TMR_ONESHOT(t, sma, itick)
 Start a timer as one-shot timer. More...
 
#define RKH_TMR_PERIODIC(t, sma, itick, per)
 Start a timer as periodic timer. More...
 

Functions

void rkh_tmr_start (RKH_TMR_T *t, const struct RKH_SMA_T *sma, RKH_TNT_T itick)
 Start a timer. More...
 
void rkh_tmr_stop (RKH_TMR_T *t)
 Stops a running timer. More...
 
void rkh_tmr_get_info (RKH_TMR_T *t, RKH_TINFO_T *info)
 Retrieves performance information for a particular software timer. More...
 
void rkh_tmr_clear_info (RKH_TMR_T *t)
 Clear performance information for a particular software timer. More...
 

Detailed Description

Macro Definition Documentation

#define RKH_TMR_INIT (   t_,
  e_,
  th_ 
)    rkh_tmr_init_((t_), (e_), (th_))

Initializes the previously allocated timer structure RKH_TMR_T.

A timer is declared with the RKH_TMR_T data type and is defined with the RKH_TMR_INIT() service. The timer is initialized in a non-active state (stopped). In this case, a subsequent start service call is necessary to get the timer actually started. The following listing creates an application timer that executes "my_timer_hook" and send the event signal "TOUT" to "pwr" SMA after 100 timer-ticks.

Parameters
[in]t_pointer to previously allocated timer structure. Any software module intending to install a software timer must first allocate a timer structure RKH_TMR_T.
[in]e_event to be directly posted (using the FIFO policy) into the event queue of the target agreed state machine application at the timer expiration.
[in]th_hook function to be called at the timer expiration. This argument is optional, thus it could be declared as NULL or eliminated in compile-time with RKH_CFG_TMR_HOOK_EN.
Note
See RKH_TMR_T structure for more information.
Usage
1 #define MY_TICK 100
2 
3 static RKH_TMR_T my_timer;
4 static RKH_ROM_STATIC_EVENT( e_timer, TOUT );
5 
6 ...
7 RKH_TMR_INIT( &my_timer, &e_timer, my_timer_hook );
8 RKH_TMR_ONESHOT( &my_timer, pwr, MY_TICK );

Definition at line 134 of file rkhtmr.h.

#define RKH_TMR_ONESHOT (   t,
  sma,
  itick 
)
Value:
(t)->period = 0; \
rkh_tmr_start(t, sma, itick)

Start a timer as one-shot timer.

This operation installs a previously created timer into the timer-handling facility. The timer begins running at the completion of this operation. The timer won't be re-started automatically. The following listing creates an application timer that executes "my_timer_hook" and send the event signal "TOUT" to "pwr" SMA after 100 timer-ticks.

Parameters
[in]tpointer to previously created timer structure.
[in]smastate machine application (SMA) that receives the timer event.
[in]iticknumber of ticks for timer expiration.
Usage
1 #define MY_TICK 100
2 
3 static RKH_TMR_T my_timer;
4 static RKH_ROM_STATIC_EVENT( e_timer, TOUT );
5 
6 ...
7 RKH_TMR_INIT( &my_timer, e_timer, my_timer_hook );
8 RKH_TMR_ONESHOT( &my_timer, pwr, MY_TICK );

Definition at line 171 of file rkhtmr.h.

#define RKH_TMR_PERIODIC (   t,
  sma,
  itick,
  per 
)
Value:
(t)->period = (per); \
rkh_tmr_start((t), (sma), (itick))

Start a timer as periodic timer.

This operation installs a previously created timer into the timer-handling facility. The timer begins running at the completion of this operation. Once the timeout will expire the timer will be re-started (re-triggered) again automatically. The following listing creates an application timer that executes "my_timer_hook" and send the event signal "TOUT" to "pwr" SMA after 100 timer-ticks initially and then after every 25 timer-ticks.

Parameters
[in]tpointer to previously created timer structure.
[in]smastate machine application (SMA) that receives the timer event.
[in]iticknumber initial of ticks for timer expiration.
[in]pernumber of ticks for all timer expirations after the first (expiration period). A zero for this parameter makes the timer a one-shot timer, otherwise, for periodic timers, any value in range.
Usage
1 #define MY_TICK 100
2 
3 static RKH_TMR_T my_timer;
4 static RKH_ROM_STATIC_EVENT( e_timer, TOUT );
5 
6 ...
7 RKH_TMR_INIT( &my_timer, &e_timer, my_timer_hook );
8 RKH_TMR_PERIODIC( &my_timer, pwr, MY_TICK, MY_TICK/4 );

Definition at line 210 of file rkhtmr.h.

Function Documentation

void rkh_tmr_start ( RKH_TMR_T t,
const struct RKH_SMA_T sma,
RKH_TNT_T  itick 
)

Start a timer.

This operation installs a previously created timer into the timer-handling facility. The timer begins running at the completion of this operation.

Parameters
[in]tpointer to previously created timer structure.
[in]smastate machine application (SMA) that receives the timer event.
[in]iticknumber of ticks for timer expiration.
void rkh_tmr_stop ( RKH_TMR_T t)

Stops a running timer.

This operation stops a timer by removing the currently running timer from the timer-handling facility. If the timer is already stopped, this service has no effect.

Parameters
[in]tpointer to previously created timer structure.
void rkh_tmr_get_info ( RKH_TMR_T t,
RKH_TINFO_T info 
)

Retrieves performance information for a particular software timer.

The user application must allocate an RKH_TINFO_T data structure used to receive data. The performance information is available during run-time for each of the RKH services. This can be useful in determining whether the application is performing properly, as well as helping to optimize the application. This information provides a "snapshot" a particular instant in time, i.e., when the service is invoked.

Parameters
[in]tpointer to previously created timer structure.
[in]infopointer to the buffer into which the performance information will be copied by reference.
Note
See RKH_TINFO_T structure for more information. This function is optional, thus it could be eliminated in compile-time with RKH_CFG_TMR_GET_INFO_EN.
void rkh_tmr_clear_info ( RKH_TMR_T t)

Clear performance information for a particular software timer.

Parameters
[in]tpointer to previously created timer structure.
Note
See RKH_TINFO_T structure for more information. This function is optional, thus it could be eliminated in compile-time with RKH_CFG_TMR_GET_INFO_EN.