beautypg.com

1 mapistm_init(), 2 mapistm_fn_start(), 3 mapistm_run() – Maxim Integrated 78M6612 M-API Library User Manual

Page 34: 4 mapistm_wait(), Soft-timers, Mapistm_init(), Mapistm_fn_start(), Mapistm_run(), Mapistm_wait()

background image

78M6612 M-API Library User Guide

UG_6612_036

34

Rev. 1.00

4.6 Soft-Timers

There are eight soft-timers in the 8051 Timer 0. Only six of these timers are available to application level
as two are used internally by the library. The timer is a fixed 10-milisecond time increment. When
TSC_Init()

is called, the timer will be started and setup. It also calls MAPIstm_init() so the

application layer does NOT need to call MAPIstm_init().

4.6.1 MAPIstm_init()

Purpose

Initialize soft-timers variables and structures.

Synopsis

void MAPIstm_init ( void );

Parameters

None.

Return Codes None.

4.6.2 MAPIstm_fn_start()

Purpose

Start a soft-timer with a call-back function pointer. Upon expiration of the timer,
execute the function then remove/free the timer.

Synopsis

unsigned integer *MAPIstm_fn_start (unsigned integer tenms_count,

void (code *fn_ptr) (void))

Parameters

tenms _count

Input parameter.

Number of counts (in 10ms units) passed to execute the call
back function fn_ptr.

*fn_ptr

Input parameter.

Pointer to the call-back function to execute when the
tenms_count

has expired. The function should be a reentrant.

Return Codes NULL_PTR: if there is no more soft-timer available. Or,

The address of where tenms_count value is stored, and counted down, is returned.
This is useful when the application needs to stop the timer at any time before it is expired.

4.6.3 MAPIstm_run()

Purpose

Keep the soft-timers updated and current. This API shall be called in the
application’s main loop after MAPIstm_fn_start() is used. This is where
fn_ptr (in MAPIstm_fn_start()

above) is processed.

Synopsis

void MAPIstm_run ( void );

Parameters

None.

Return Codes None.

4.6.4 MAPIstm_wait()

Purpose

Delay processing for a fixed time (in 10ms increment). Typically use when it is
necessary to wait for something to stabilize.

Synopsis

void MAPIstm_wait ( IN unsigned integer DelayTime );

Parameters

DelayTime

Input parameter

Wait (hold up CPU processing) for DelayTime * 10ms.

Return Codes None.